Module jEdit

Class FilteredListModel<E extends ListModel<?>>

java.lang.Object
javax.swing.AbstractListModel
org.gjt.sp.jedit.gui.FilteredListModel<E>
All Implemented Interfaces:
Serializable, EventListener, ListDataListener, ListModel

public abstract class FilteredListModel<E extends ListModel<?>> extends AbstractListModel implements ListDataListener
This ListModel delegates another model to add some filtering features to any JList. To use it you must implement the abstract method passFilter(). This method is called for each row, and must return true if the row should be visible, and false otherwise. It is also possible to override the method prepareFilter() that allow you to transform the filter String. Usually you can return it as lowercase It is not mandatory but highly recommended to give the JList instance to the model in order to keep the selection after the filter has been updated
Since:
jEdit 4.3pre11
Version:
$Id: Buffer.java 8190 2006-12-07 07:58:34Z kpouer $
Author:
Matthieu Casanova
See Also:
  • Field Details

    • delegated

      protected E extends ListModel<?> delegated
      The delegated table model.
  • Constructor Details

    • FilteredListModel

      protected FilteredListModel(E delegated)
  • Method Details

    • setList

      public void setList(JList<?> list)
      Set the JList that uses this model. It is used to restore the selection after the filter has been applied If it is null,
      Parameters:
      list - the list that uses the model
    • getDelegated

      public E getDelegated()
    • setDelegated

      public void setDelegated(E delegated)
    • setFilter

      public void setFilter(@Nullable String filter)
    • prepareFilter

      @Nullable public String prepareFilter(@Nullable String filter)
    • passFilter

      public abstract boolean passFilter(int row, @Nullable String filter)
      This callback indicates if a row passes the filter.
      Parameters:
      row - the row number the delegate row count
      filter - the filter string
      Returns:
      true if the row must be visible
    • saveSelection

      protected Set<Integer> saveSelection()
    • restoreSelection

      protected void restoreSelection(Set<Integer> selectedIndices)
    • getTrueRow

      public int getTrueRow(int rowIndex)
      Converts a row index from the JTable to an internal row index from the delegated model.
      Parameters:
      rowIndex - the row index
      Returns:
      the row index in the delegated model
    • getInternal2ExternalRow

      public int getInternal2ExternalRow(int internalRowIndex)
      Converts a row index from the delegated table model into a row index of the JTable.
      Parameters:
      internalRowIndex - the internal row index
      Returns:
      the table row index or -1 if this row is not visible
    • getElementAt

      public Object getElementAt(int index)
      Specified by:
      getElementAt in interface ListModel<E extends ListModel<?>>
    • getSize

      public int getSize()
      Specified by:
      getSize in interface ListModel<E extends ListModel<?>>
    • contentsChanged

      public void contentsChanged(ListDataEvent e)
      Specified by:
      contentsChanged in interface ListDataListener
    • intervalAdded

      public void intervalAdded(ListDataEvent e)
      Specified by:
      intervalAdded in interface ListDataListener
    • intervalRemoved

      public void intervalRemoved(ListDataEvent e)
      Specified by:
      intervalRemoved in interface ListDataListener