org.gjt.sp.jedit.gui

## Class FilteredTableModel<E extends javax.swing.table.TableModel>

- java.lang.Object
- - javax.swing.table.AbstractTableModel
  - - org.gjt.sp.jedit.gui.FilteredTableModel<E>

- All Implemented Interfaces:
    java.io.Serializable, java.util.EventListener, javax.swing.event.TableModelListener, javax.swing.table.TableModel

      public abstract class FilteredTableModel<E extends javax.swing.table.TableModel>
      extends javax.swing.table.AbstractTableModel
      implements javax.swing.event.TableModelListener

  This TableModel delegates another model to add some filtering features to any JTable. 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

  Here is an example of how to use it extracted from the InstallPanel `PluginTableModel tableModel = new PluginTableModel(); filteredTableModel = new FilteredTableModel(tableModel) { public String prepareFilter(String filter) { return filter.toLowerCase(); }

  public boolean passFilter(int row, String filter) { String pluginName = (String) delegated.getValueAt(row, 1); return pluginName.toLowerCase().contains(filter); } }; table = new JTable(filteredTableModel); filteredTableModel.setTable(table);` It is not mandatory but highly recommended to give the JTable instance to the model in order to keep the selection after the filter has been updated
  Since:
    jEdit 4.3pre11
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected E` | `delegated` The delegated table model.

    - ### Fields inherited from class javax.swing.table.AbstractTableModel

      `listenerList`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `FilteredTableModel()`
    `protected` | `FilteredTableModel(E delegated)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Class<?>` | `getColumnClass(int columnIndex)`
    `int` | `getColumnCount()`
    `java.lang.String` | `getColumnName(int columnIndex)`
    `E` | `getDelegated()`
    `int` | `getInternal2ExternalRow(int internalRowIndex)` Converts a row index from the delegated table model into a row index of the JTable.
    `int` | `getRowCount()`
    `int` | `getTrueRow(int rowIndex)` Converts a row index from the JTable to an internal row index from the delegated model.
    `java.lang.Object` | `getValueAt(int rowIndex, int columnIndex)`
    `boolean` | `isCellEditable(int rowIndex, int columnIndex)`
    `abstract boolean` | `passFilter(int row, java.lang.String filter)` This callback indicates if a row passes the filter.
    `java.lang.String` | `prepareFilter(java.lang.String filter)`
    `void` | `setDelegated(E delegated)`
    `void` | `setFilter(java.lang.String filter)`
    `void` | `setTable(javax.swing.JTable table)` Set the JTable that uses this model.
    `void` | `setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)`
    `void` | `tableChanged(javax.swing.event.TableModelEvent e)` This fine grain notification tells listeners the exact range of cells, rows, or columns that changed.

    - ### Methods inherited from class javax.swing.table.AbstractTableModel

      `addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### delegated

          protected E extends javax.swing.table.TableModel delegated

      The delegated table model.

  - ### Constructor Detail

    - #### FilteredTableModel

          protected FilteredTableModel(E delegated)

    - #### FilteredTableModel

          protected FilteredTableModel()

  - ### Method Detail

    - #### setTable

          public void setTable(javax.swing.JTable table)

      Set the JTable that uses this model. It is used to restore the selection after the filter has been applied If it is null,
      Parameters:
        `table` - the table that uses the model

    - #### getDelegated

          public E getDelegated()

    - #### setDelegated

          public void setDelegated(E delegated)

    - #### setFilter

          public void setFilter(java.lang.String filter)

    - #### prepareFilter

          public java.lang.String prepareFilter(java.lang.String filter)

    - #### passFilter

          public abstract boolean passFilter(int row,
                           java.lang.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

    - #### getRowCount

          public int getRowCount()

      Specified by:
        `getRowCount` in interface `javax.swing.table.TableModel`

    - #### getColumnCount

          public int getColumnCount()

      Specified by:
        `getColumnCount` in interface `javax.swing.table.TableModel`

    - #### getColumnName

          public java.lang.String getColumnName(int columnIndex)

      Specified by:
        `getColumnName` in interface `javax.swing.table.TableModel`
      Overrides:
        `getColumnName` in class `javax.swing.table.AbstractTableModel`

    - #### getColumnClass

          public java.lang.Class<?> getColumnClass(int columnIndex)

      Specified by:
        `getColumnClass` in interface `javax.swing.table.TableModel`
      Overrides:
        `getColumnClass` in class `javax.swing.table.AbstractTableModel`

    - #### isCellEditable

          public boolean isCellEditable(int rowIndex,
                               int columnIndex)

      Specified by:
        `isCellEditable` in interface `javax.swing.table.TableModel`
      Overrides:
        `isCellEditable` in class `javax.swing.table.AbstractTableModel`

    - #### getValueAt

          public java.lang.Object getValueAt(int rowIndex,
                                    int columnIndex)

      Specified by:
        `getValueAt` in interface `javax.swing.table.TableModel`

    - #### setValueAt

          public void setValueAt(java.lang.Object aValue,
                        int rowIndex,
                        int columnIndex)

      Specified by:
        `setValueAt` in interface `javax.swing.table.TableModel`
      Overrides:
        `setValueAt` in class `javax.swing.table.AbstractTableModel`

    - #### 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

    - #### tableChanged

          public void tableChanged(javax.swing.event.TableModelEvent e)

      This fine grain notification tells listeners the exact range of cells, rows, or columns that changed.
      Specified by:
        `tableChanged` in interface `javax.swing.event.TableModelListener`