JIDE 3.5.15

com.jidesoft.grid
Interface IFilterableTableModel

All Superinterfaces:
AutoFilterTableHeaderAdapter, AutoFilterTableModel, TableModel
All Known Implementing Classes:
AdvancePageTableModel, CrudDatabaseTableModel, DatabaseTableModel, FilterableAggregateTableModel, FilterableTableModel, FilterableTreeTableModel, HibernatePageTableModel, LuceneFilterableTableModel

public interface IFilterableTableModel
extends TableModel, AutoFilterTableModel

An interface to allow you to implement filtering feature on any table model.


Nested Class Summary
static class IFilterableTableModel.FilterItem
          FilterItem contains a column and a filter for that column.
 
Nested classes/interfaces inherited from interface com.jidesoft.grid.AutoFilterTableHeaderAdapter
AutoFilterTableHeaderAdapter.FilterTitleFormatter
 
Field Summary
static int ALL_COLUMNS
          Specifies all columns.
static int ANY_COLUMNS
          Specifies any columns.
static String IDENTIFIER_ALL_COLUMNS
           
static String IDENTIFIER_ANY_COLUMNS
           
 
Method Summary
 void addFilter(Filter filter)
          Adds a filter to all columns.
 void addFilter(IFilterableTableModel.FilterItem filterItem)
          Adds a FilterItem.
 void addFilter(int column, Filter filter)
          Adds a filter to the specified column.
 void addFilterableTableModelListener(FilterableTableModelListener l)
          Adds a listener to the list that's notified each time a change to the filter occurs.
 void clearFilters()
          Removes all filters from all columns.
 FilterableTableModelListener[] getFilterableTableModelListeners()
          Returns an array of all the FilterableTableModel listeners registered on this filter.
 Icon getFilterIcon(int column)
          Gets the filter icon for a particular column.
 List<IFilterableTableModel.FilterItem> getFilterItems()
          Gets all the FilterItems added to this FilterableTableModel.
 Filter[] getFilters(int column)
          Gets the filters for the specified column.
 Object[] getPossibleValues(int columnIndex, Comparator comparator)
          Gets all possible values of the table model.
 Object[] getPossibleValuesAndConverters(int columnIndex, Comparator comparator)
           
 boolean hasFilter()
          Checks if the FilterableTableModel has any filters.
 boolean hasFilter(int columnIndex)
          Checks if the FilterableTableModel has any filters on the specified column.
 boolean isAdjusting()
          Checks if the FilterableTableModel is adjusting.
 boolean isAndMode()
          Sets the logic of filters on the same column.
 boolean isColumnFilterable(int column)
          Checks if the column is filterable for the filters that are added to ALL_COLUMNS.
 boolean isColumnVisible(int column)
          Checks if the column is visible.
 boolean isFilteringPaused()
          Checks if the filtering is paused.
 boolean isFiltersApplied()
          Checks if the filters are in effect.
 boolean isSameConverterAt(int columnIndex)
          Check if each converter in this column for each row is the same.
 void refresh()
          Reapply all filters after they are changed.
 void removeAllFilters()
          Removes all filters that are added using addFilter(Filter).
 void removeAllFilters(int column)
          Removes all filters from the specified column.
 void removeFilter(Filter filter)
          Removes the filter from all columns.
 void removeFilter(IFilterableTableModel.FilterItem filterItem)
          Removes the filter item.
 void removeFilter(int column, Filter filter)
          Removes the filter from the specified column.
 void removeFilterableTableModelListener(FilterableTableModelListener l)
          Removes a listener from the list that's notified each time a change to the filter occurs.
 void setAdjusting(boolean adjusting)
          Sets the FilterableTableModel to adjusting mode.
 void setAndMode(boolean andMode)
          Sets the logic among the filters.
 void setFilteringPaused(boolean pause)
          If filtering is paused, keep rows in same relative positions Inserts/Deletes shift rows without re-ordering
 void setFiltersApplied(boolean apply)
          Applies or unapplies the filters.
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnClass, getColumnCount, getColumnName, getRowCount, getValueAt, isCellEditable, removeTableModelListener, setValueAt
 
Methods inherited from interface com.jidesoft.grid.AutoFilterTableHeaderAdapter
getDynamicTableFilters, getFilterTitleFormatter, getListCellRenderer, getTitleConverter, isAllowCustomFilter, isAllowMultipleValues, isColumnAutoFilterable, isUseTableCellRenderer, isValuePredetermined
 

Field Detail

ALL_COLUMNS

static final int ALL_COLUMNS
Specifies all columns. You can use this to apply a filter to all columns. All columns must satisfy the filter condition in order for the row not to be filtered away.

See Also:
Constant Field Values

ANY_COLUMNS

static final int ANY_COLUMNS
Specifies any columns. You can use this to apply a filter to any columns. As long as there is one column satisfies the filter condition, the row will not be filtered away.

See Also:
Constant Field Values

IDENTIFIER_ALL_COLUMNS

static final String IDENTIFIER_ALL_COLUMNS
See Also:
Constant Field Values

IDENTIFIER_ANY_COLUMNS

static final String IDENTIFIER_ANY_COLUMNS
See Also:
Constant Field Values
Method Detail

refresh

void refresh()
Reapply all filters after they are changed.


isColumnFilterable

boolean isColumnFilterable(int column)
Checks if the column is filterable for the filters that are added to ALL_COLUMNS. The column will be excluded if it returns false (same as isColumnVisible(int) in this case. There is also AutoFilterTableHeaderAdapter.isColumnAutoFilterable(int) which is used for AutoFilterHeader to control if the filter button is visible.

Parameters:
column - the column index.
Returns:
true if the column can be filtered.

isColumnVisible

boolean isColumnVisible(int column)
Checks if the column is visible. Since column visible information is on the JTable, FilterableTableModel has no idea whether a column is visible. So we added this protected method to give user a chance to tell FilterableTableModel whether a column is visible. If it is not visible, it will not be considered when filtering.

Parameters:
column - the column index.
Returns:
true if the column is visible. Otherwise false.

addFilter

void addFilter(int column,
               Filter filter)
Adds a filter to the specified column.

Parameters:
column - the column index. It could also be two special values - ALL_COLUMNS or ANY_COLUMNS. If the value is ANY_COLUMNS, this method will be the same as addFilter(Filter).
filter - the filter to be added.

addFilter

void addFilter(Filter filter)
Adds a filter to all columns. if one of the columns matches the filter, the row will be not be filtered.

You can use AbstractFilter to create new filter. If you need the row index or column index in order to decide if the value should be filtered, you can use AbstractTableFilter and use getRowIndex() and getColumnInde() to find out current row or column index.

Please note, addFilter will not change the FilterableTableModel data right away. You still need to call setFiltersApplied(true) to apply the filter. The reason is to give developers a chance to add/remove multiple filters and only updates the data once at the end.

Parameters:
filter - the filter to be added.

addFilter

void addFilter(IFilterableTableModel.FilterItem filterItem)
Adds a FilterItem.

Parameters:
filterItem - the FilterItem

removeFilter

void removeFilter(int column,
                  Filter filter)
Removes the filter from the specified column. The filter must be added using addFilter(int, Filter).

Please note, removeFilter will not change the FilterableTableModel data right away. You still need to call setFiltersApplied(true) to apply the filter. The reason is to give developers a chance to add/remove multiple filters and only updates the data once at the end.

Parameters:
column - the column index. It could also be two special values - ALL_COLUMNS or ANY_COLUMNS. If the value is ANY_COLUMNS, this method will be the same as removeFilter(Filter).
filter - the filter to be removed.

removeFilter

void removeFilter(Filter filter)
Removes the filter from all columns. The filter must be added using addFilter(Filter).

Please note, removeFilter will not change the FilterableTableModel data right away. You still need to call setFiltersApplied(true) to apply the filter. The reason is to give developers a chance to add/remove multiple filters and only updates the data once at the end.

Parameters:
filter - the filter to be removed.

removeFilter

void removeFilter(IFilterableTableModel.FilterItem filterItem)
Removes the filter item.

Please note, removeFilter will not change the FilterableTableModel data right away. You still need to call setFiltersApplied(true) to apply the filter. The reason is to give developers a chance to add/remove multiple filters and only updates the data once at the end.

Parameters:
filterItem - the FilterItem to be removed.

removeAllFilters

void removeAllFilters(int column)
Removes all filters from the specified column. Those filters are added using addFilter(int, Filter).

Please note, removeAllFilters will not change the FilterableTableModel data right away. You still need to call setFiltersApplied(true) to apply the filter. The reason is to give developers a chance to add/remove multiple filters and only updates the data once at the end.

Parameters:
column - the column index where all filters for that column should be removed.

removeAllFilters

void removeAllFilters()
Removes all filters that are added using addFilter(Filter). If you want to remove all filters that either added using addFilter(int, Filter) or addFilter(Filter), you should use clearFilters().

Please note, removeAllFilters will not change the FilterableTableModel data right away. You still need to call setFiltersApplied(true) to apply the filter. The reason is to give developers a chance to add/remove multiple filters and only updates the data once at the end.


clearFilters

void clearFilters()
Removes all filters from all columns.

Please note, clearFilters will not change the FilterableTableModel data right away. You still need to call setFiltersApplied(true) to apply the filter. The reason is to give developers a chance to add/remove multiple filters and only updates the data once at the end.


getFilters

Filter[] getFilters(int column)
Gets the filters for the specified column.

Parameters:
column - the column index.
Returns:
the filters for the specified column.

getFilterItems

List<IFilterableTableModel.FilterItem> getFilterItems()
Gets all the FilterItems added to this FilterableTableModel.

Returns:
all the FilterItems added to this FilterableTableModel.

setFiltersApplied

void setFiltersApplied(boolean apply)
Applies or unapplies the filters. By default, the filters are not applied. So after user adds several filters, this method should be called to make filters taking effect. When new filter is added or existing is removed, this method should be called as well.

Parameters:
apply - true to apply the filters.

isFiltersApplied

boolean isFiltersApplied()
Checks if the filters are in effect.

Returns:
true if filters are in effect.

hasFilter

boolean hasFilter()
Checks if the FilterableTableModel has any filters.

Returns:
true if there are any filters. Otherwise false.

hasFilter

boolean hasFilter(int columnIndex)
Checks if the FilterableTableModel has any filters on the specified column.

Parameters:
columnIndex - the column index to check if there is a filter on it.
Returns:
true if there are any filters on the specified column. Otherwise false.

isAndMode

boolean isAndMode()
Sets the logic of filters on the same column. If true, filters are in AND mode, meaning if one of the filters return true in isValueFiltered method, the value will be filtered. If false, filters are in OR mode, meaning if one of the filters return false, the value will NOT be filtered.

The mode only has effect on the filters of the same columns which includes each column of the table model as well as the two special column value ALL_COLUMNS and ANY_COLUMNS.

Returns:
the AND/OR mode. Default is true which means AND mode.

setAndMode

void setAndMode(boolean andMode)
Sets the logic among the filters. If AND is true, Please note, this logic mode will apply for all filters, no matter it's for a column or any column or all columns. You won't be able to do complex expression such as AND some filters and OR some other filters using one FitlerableTableModel. In order to do more complex expression, you would need multiple FilterableTableModel, one wraps the other. You make filters in each FilterableTableModel to be OR logic, then the logic among the pipe of FilterableTableModels will always be AND logic.

Parameters:
andMode - true or false.

isAdjusting

boolean isAdjusting()
Checks if the FilterableTableModel is adjusting. If it is adjusting, FilterableTableModel will not apply filter when the actual list model changes.

Returns:
true if adjusting. Otherwise false.

setAdjusting

void setAdjusting(boolean adjusting)
Sets the FilterableTableModel to adjusting mode. If it is adjusting, FilterableTableModel will not apply filter when the actual table model changes. After you set adjusting to false, FilterableListModel will re-apply the filter.

Parameters:
adjusting - true or false.

getPossibleValues

Object[] getPossibleValues(int columnIndex,
                           Comparator comparator)
Gets all possible values of the table model. If there is filter on this column, the possible values are collected from the actual table model. If there is no filter on this column, the possible values are collected from this filterable table model. After we collected all the values, we will use Arrays.sort method to sort the values.

The possible values are used by AutoFilterTableHeader to populate the drop down filter list.

Parameters:
columnIndex - the column index.
comparator - the comparator. It is used to sort the values.
Returns:
an array of all possible values of certain column in the table model.

getPossibleValuesAndConverters

Object[] getPossibleValuesAndConverters(int columnIndex,
                                        Comparator comparator)

getFilterIcon

Icon getFilterIcon(int column)
Gets the filter icon for a particular column.

Parameters:
column - the column index.
Returns:
the icon.

setFilteringPaused

void setFilteringPaused(boolean pause)
If filtering is paused, keep rows in same relative positions Inserts/Deletes shift rows without re-ordering

Parameters:
pause - TRUE = Filtering is Paused; FALSE = Filtering is Active

isFilteringPaused

boolean isFilteringPaused()
Checks if the filtering is paused.

Returns:
true if paused. Otherwise false.

addFilterableTableModelListener

void addFilterableTableModelListener(FilterableTableModelListener l)
Adds a listener to the list that's notified each time a change to the filter occurs.

Parameters:
l - the FilterableTableModelListener

removeFilterableTableModelListener

void removeFilterableTableModelListener(FilterableTableModelListener l)
Removes a listener from the list that's notified each time a change to the filter occurs.

Parameters:
l - the FilterableTableModelListener

getFilterableTableModelListeners

FilterableTableModelListener[] getFilterableTableModelListeners()
Returns an array of all the FilterableTableModel listeners registered on this filter.

Returns:
all of this filter's FilterableTableModelListeners or an empty array if no filter listeners are currently registered
See Also:
addFilterableTableModelListener(com.jidesoft.grid.FilterableTableModelListener), removeFilterableTableModelListener(com.jidesoft.grid.FilterableTableModelListener)

isSameConverterAt

boolean isSameConverterAt(int columnIndex)
Check if each converter in this column for each row is the same.

Parameters:
columnIndex - the column index
Returns:
true if all converters are the same in every row. Otherwise false.

JIDE 3.5.15