| java.lang.Object javax.swing.table.AbstractTableModel org.gjt.sp.jedit.gui.FilteredTableModel
FilteredTableModel | abstract public class FilteredTableModel extends AbstractTableModel implements TableModelListener(Code) | | 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
author: Shlomy Reinstein author: Matthieu Casanova version: $Id: Buffer.java 8190 2006-12-07 07:58:34Z kpouer $ since: jEdit 4.3pre11 |
Field Summary | |
protected E | delegated The delegated table model. |
delegated | protected E delegated(Code) | | The delegated table model.
|
FilteredTableModel | protected FilteredTableModel(E delegated)(Code) | | |
getColumnClass | public Class> getColumnClass(int columnIndex)(Code) | | |
getColumnCount | public int getColumnCount()(Code) | | |
getColumnName | public String getColumnName(int columnIndex)(Code) | | |
getDelegated | public E getDelegated()(Code) | | |
getInternal2ExternalRow | public int getInternal2ExternalRow(int internalRowIndex)(Code) | | Converts a row index from the delegated table model into a row index of the JTable.
Parameters: internalRowIndex - the internal row index the table row index or -1 if this row is not visible |
getRowCount | public int getRowCount()(Code) | | |
getTrueRow | public int getTrueRow(int rowIndex)(Code) | | Converts a row index from the JTable to an internal row index from the delegated model.
Parameters: rowIndex - the row index the row index in the delegated model |
getValueAt | public Object getValueAt(int rowIndex, int columnIndex)(Code) | | |
isCellEditable | public boolean isCellEditable(int rowIndex, int columnIndex)(Code) | | |
passFilter | abstract public boolean passFilter(int row, String filter)(Code) | | This callback indicates if a row passes the filter.
Parameters: row - the row number the delegate row count Parameters: filter - the filter string true if the row must be visible |
setDelegated | public void setDelegated(E delegated)(Code) | | |
setTable | public void setTable(JTable table)(Code) | | 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 |
setValueAt | public void setValueAt(Object aValue, int rowIndex, int columnIndex)(Code) | | |
tableChanged | public void tableChanged(TableModelEvent e)(Code) | | This fine grain notification tells listeners the exact range
of cells, rows, or columns that changed.
|
|
|