|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.table.AbstractTableModel com.jidesoft.grid.TableModelWrapperImpl com.jidesoft.grid.DefaultTableModelWrapper com.jidesoft.grid.FilterableTableModel
public class FilterableTableModel
FilterableTableModel
is a table model which wraps another table model so that user can apply filters on
it.
addFilter(Filter)
. Or you can add filter to a particular column using addFilter(int, Filter)
.
By default, filters won't take effect immediately. You need to call setFiltersApplied(true)
to apply
those filters. If filtersApplied
flag is true already, you just need to call refresh(). We don't refresh
automatically because you might have several filters to add. You can add all of them, then only call refresh once.
setFiltersApplied(int)
will control all the filters. Each filter has its own enabled flag which will
control each individual filter.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.jidesoft.grid.IFilterableTableModel |
---|
IFilterableTableModel.FilterItem |
Nested classes/interfaces inherited from interface com.jidesoft.grid.AutoFilterTableHeaderAdapter |
---|
AutoFilterTableHeaderAdapter.FilterTitleFormatter |
Field Summary | |
---|---|
protected List<Filter> |
_allColumnFilters
|
protected List<Filter> |
_anyColumnFilters
|
protected boolean[] |
_columnIncluded
|
protected List<Filter>[] |
_eachColumnFilters
|
protected FilterItemSupport |
_filterItemSupport
|
protected ValueProvider |
_valueProvider
|
static int |
FILTER_ALGORITHM_BY_FILTER
This is one of the filter algorithms. |
static int |
FILTER_ALGORITHM_BY_ROW
This is one of the filter algorithms. |
Fields inherited from class com.jidesoft.grid.DefaultTableModelWrapper |
---|
_indexes |
Fields inherited from class com.jidesoft.grid.TableModelWrapperImpl |
---|
_model |
Fields inherited from class javax.swing.table.AbstractTableModel |
---|
listenerList |
Fields inherited from interface com.jidesoft.grid.IFilterableTableModel |
---|
ALL_COLUMNS, ANY_COLUMNS, IDENTIFIER_ALL_COLUMNS, IDENTIFIER_ANY_COLUMNS |
Fields inherited from interface com.jidesoft.grid.MultiTableModel |
---|
FOOTER_COLUMN, HEADER_COLUMN, REGULAR_COLUMN |
Fields inherited from interface com.jidesoft.grid.EditorStyleTableModel |
---|
EDITOR_STYLE_EDITABLE, EDITOR_STYLE_NORMAL, EDITOR_STYLE_READ_ONLY, EDITOR_STYLE_SELECT_ONLY |
Constructor Summary | |
---|---|
FilterableTableModel(TableModel model)
Creates a FilterableTableModel from any table model. |
Method Summary | |
---|---|
void |
addDynamicTableFilter(int modelIndex,
DynamicTableFilter filter)
Add a DynamicTableFilter . |
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. |
protected static int[] |
deleteIndexes(int[] indexes,
int firstRowActual,
int lastRowActual,
int firstRowVisual,
int lastRowVisual)
Delete a continuous set of rows |
protected void |
filter(boolean filterAllData)
Applies filters and generates a new array of indices. |
void |
fireFilterAdded(int column,
Filter filter)
|
void |
fireFilterChanged(FilterableTableModelEvent e)
Forwards the given notification event to all FilterableTableModelListeners that registered
themselves as listeners for this table model. |
void |
fireFilterRemoved(int column,
Filter filter)
|
protected void |
fireIndexChanged(int eventSerialNumber)
Tells the TableModeWrapper that indexes is changed. |
protected int |
fireIndexChanging()
Tells the TableModeWrapper that indexes is going to be changed. |
DynamicTableFilter[] |
getDynamicTableFilters(int modelIndex)
Gets all the DynamicTableFilter s. |
FilterableTableModelListener[] |
getFilterableTableModelListeners()
Returns an array of all the FilterableTableModel listeners registered on this filter. |
int |
getFilterAlgorithm()
Get current filter algorithm. |
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. |
AutoFilterTableHeaderAdapter.FilterTitleFormatter |
getFilterTitleFormatter(int column)
Gets the formatter that will format the title for the AutoFilterTableHeader. |
ListCellRenderer |
getListCellRenderer(int column)
Gets the list cell renderer for the drop down filter list. |
protected static int |
getNearestRow(int[] indexes,
int indexActual,
boolean exists)
|
JMenuItem[] |
getPopupMenuItems(int column)
Gets a list of menu items for the specified column. |
Object[] |
getPossibleValues(int columnIndex,
Comparator comparator)
Gets all possible values of the table model. |
Object[] |
getPossibleValuesAndConverters(int columnIndex,
Comparator comparator)
|
protected List<Integer> |
getReservedRows(int firstRow,
int lastRow)
Get reserved rows after applying filters on rows from firstRow to lastRow. |
StringConverter |
getTitleConverter(int column)
Gets the title converter to convert the column name. |
boolean |
hasFilter()
Checks if the FilterableTableModel has any filters. |
boolean |
hasFilter(int columnIndex)
Checks if the FilterableTableModel has any filters on the specified column. |
protected static int[] |
insertIndexes(int[] indices,
int rowCount,
int firstRow,
int lastRow,
boolean exists)
Insert a continuous set of rows View Actual 0 0 1 10 2 20 3 30 4 40 5 50 Pick view row 3 Insert into Base Model @ row 30 Add +1 to all rows >= 30 |
protected void |
invalidateFilterCache()
|
boolean |
isAdjusting()
Checks if the FilterableTableModel is adjusting. |
boolean |
isAllowCustomFilter(int column)
Checks if the AutoFilterTableHeader allows custom filter. |
boolean |
isAllowMultipleValues(int column)
Checks if the AutoFilterTableHeader allows multiple values as the filter for the column index. |
boolean |
isAndMode()
Sets the logic of filters on the same column. |
boolean |
isClearFiltersOnStructureChanged()
Gets the flag indicating that if the existing filter should be cleared if table structure changed event is received. |
boolean |
isColumnAutoFilterable(int column)
Checks if the column is auto-filterable. |
boolean |
isColumnFilterable(int column)
Checks if the column is filterable for the filters that are added to IFilterableTableModel.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. |
protected boolean |
isNeedFilterAllData()
Get the flag if we need filter all datum in the table while applying new filter comparing to the old filter. |
boolean |
isSameConverterAt(int columnIndex)
Check if each converter in this column for each row is the same. |
boolean |
isUseTableCellRenderer(int column)
Checks if the table cell renderer will be used for the list. |
boolean |
isValuePredetermined(int column)
Checks if the column is type-filterable. |
protected void |
prepareFilters()
Prepares the filters. |
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 |
removeDynamicTableFilter(int modelIndex,
DynamicTableFilter filter)
Removes a DynamicTableFilter which was added earlier. |
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. |
int |
retrieveFilterApplyRecords()
Deprecated. not an accurate data from customer point of view. Please use FilterableTableModel#getActualModel()#getRowCount() instead. |
void |
setAdjusting(boolean adjusting)
Sets the FilterableTableModel to adjusting mode. |
void |
setAndMode(boolean andMode)
Sets the logic among the filters. |
void |
setClearFiltersOnStructureChanged(boolean clearFiltersOnStructureChanged)
Sets the flag indicating that if the existing filter should be cleared if table structure changed event is received. |
void |
setFilterAlgorithm(int filterAlgorithm)
Sets the filter algorithm. |
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. |
protected void |
setNeedFilterAllData(boolean needFilterAllData)
Set the flag if we need filter all datum in the table while applying new filter comparing to the old filter. |
protected boolean |
shouldBeFiltered(int rowIndex)
Checks if the row should be filtered. |
protected boolean |
shouldBeFiltered(int row,
List<Filter> allColumnFilters,
List<Filter> anyColumnFilters,
List<Filter>[] eachColumnFilters)
The method contains the algorithm to filter the specified row. |
protected boolean |
shouldBeFiltered(ValueProvider valueProvider,
int rowIndex)
Checks if the row should be filtered. |
protected boolean |
shouldBeFiltered(ValueProvider valueProvider,
int row,
List<Filter> allColumnFilters,
List<Filter> anyColumnFilters,
List<Filter>[] eachColumnFilters)
The method contains the algorithm to filter the specified row. |
protected boolean |
shouldBeIgnored(ValueProvider valueProvider,
int rowIndex)
The method is for you to override if you want certain rows to be ignored the filtering process. |
protected boolean |
shouldBeKept(ValueProvider valueProvider,
int rowIndex,
List<Integer> remainingRows)
The method is for you to decide if the rowIndex should be kept based on the rows remained in the remainingRows. |
protected List<Integer> |
shouldNotBeFiltered(ValueProvider valueProvider,
List<Integer> filteringRowList,
Filter filter,
int filteringColumn)
The method contains the algorithm to filter the specified row list with specified filter. |
protected boolean |
shouldOptimize(int firstRow,
int lastRow)
Should we optimize the filtering by doing incremental filtering. |
protected boolean |
shouldPossibleValueBeIncluded(Object value,
int columnIndex)
Checks if a value should be included in the possible value array. |
protected void |
tableCellsUpdated(int column,
int firstRow,
int lastRow)
Called each time the cells in column in the range [firstRow , lastRow ] are
updated. |
protected void |
tableDataChanged()
Called each time all of the data (i.e. |
protected void |
tableDataChanged(CompoundTableModelEvent event)
Called if it receives a table data changed event however the event is an instance of CompoundTableModelEvent . |
protected void |
tableRowsDeleted(int firstRow,
int lastRow)
Called each time one or more contiguous rows are deleted from the underlying TableModel . |
protected void |
tableRowsInserted(int firstRow,
int lastRow)
Called each time one or more contiguous rows are inserted into the underlying TableModel . |
protected void |
tableRowsUpdated(int firstRow,
int lastRow)
Called each time one or more contiguous rows are updated in the underlying TableModel . |
protected void |
tableStructureChanged()
Called each time the structure ( TableColumn s, etc) of the underlying TableModel
changes. |
Methods inherited from class com.jidesoft.grid.DefaultTableModelWrapper |
---|
getActualRowAt, getCellClassAt, getCellSpanAt, getConverterContextAt, getEditorContextAt, getEditorStyleAt, getIndexes, getRowCount, getValueAt, getVisualRowAt, isCacheEnabled, isCellEditable, isRowCountChanged, reallocateIndexes, setCacheEnabled, setIndexes, setValueAt |
Methods inherited from class com.jidesoft.grid.TableModelWrapperImpl |
---|
addIndexChangeListener, createCompoundTableModelEvent, fireTableCellsUpdated, fireTableChanged, getActualModel, getCellStyleAt, getColumnClass, getColumnCount, getColumnIdentifier, getColumnName, getColumnType, getIndexChangeListeners, getTableIndex, isCellSpanOn, isCellStyleOn, isNavigableAt, isNavigationOn, removeIndexChangeListener, tableChanged |
Methods inherited from class javax.swing.table.AbstractTableModel |
---|
addTableModelListener, findColumn, fireTableCellUpdated, 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 |
Methods inherited from interface javax.swing.table.TableModel |
---|
addTableModelListener, getColumnClass, getColumnCount, getColumnName, getRowCount, getValueAt, isCellEditable, removeTableModelListener, setValueAt |
Methods inherited from interface com.jidesoft.grid.TableModelWrapper |
---|
getActualModel |
Field Detail |
---|
protected FilterItemSupport _filterItemSupport
protected ValueProvider _valueProvider
protected transient List<Filter> _allColumnFilters
protected transient List<Filter> _anyColumnFilters
protected transient List<Filter>[] _eachColumnFilters
protected transient boolean[] _columnIncluded
public static final int FILTER_ALGORITHM_BY_ROW
shouldBeFiltered(int)
,
shouldBeFiltered(ValueProvider, int)
,
shouldBeFiltered(int, java.util.List, java.util.List, java.util.List[])
,
shouldBeFiltered(ValueProvider, int, java.util.List, java.util.List, java.util.List[])
,
Constant Field Valuespublic static final int FILTER_ALGORITHM_BY_FILTER
shrinkRowsBeforeFilter(ValueProvider, java.util.List)
,
shouldBeIgnored(ValueProvider, int)
,
shouldBeKept(ValueProvider, int, java.util.List)
,
Constant Field ValuesConstructor Detail |
---|
public FilterableTableModel(TableModel model)
model
- the table model that has the data before filtering.Method Detail |
---|
protected void tableDataChanged(CompoundTableModelEvent event)
TableModelWrapperImpl
CompoundTableModelEvent
.
tableDataChanged
in class DefaultTableModelWrapper
event
- the received CompoundTableModelEventprotected void tableDataChanged()
DefaultTableModelWrapper
TableModel
. This
default implementation simply fires a corresponding TableModelEvent
to the listeners on this model.
tableDataChanged
in class DefaultTableModelWrapper
protected void tableStructureChanged()
DefaultTableModelWrapper
TableColumn
s, etc) of the underlying TableModel
changes. This default implementation simply fires a corresponding TableModelEvent
to the listeners
on this model.
tableStructureChanged
in class DefaultTableModelWrapper
protected static int getNearestRow(int[] indexes, int indexActual, boolean exists)
protected static int[] insertIndexes(int[] indices, int rowCount, int firstRow, int lastRow, boolean exists)
indices
- the indicesrowCount
- the row countfirstRow
- the first rowlastRow
- the last row.exists
- true means the inserted rows exist in the VIEW index (so, find exact nearest row); false means
the inserted rows may not exist, so find the first row greater than firstRow
protected static int[] deleteIndexes(int[] indexes, int firstRowActual, int lastRowActual, int firstRowVisual, int lastRowVisual)
indexes
- Array of indexesfirstRowActual
- Actual Index of First RowlastRowActual
- Actual Index of Last RowfirstRowVisual
- Visual Index of First RowlastRowVisual
- Visual Index of Last Row
protected void tableRowsInserted(int firstRow, int lastRow)
DefaultTableModelWrapper
TableModel
. This
default implementation simply fires a corresponding TableModelEvent
to the listeners on this model.
tableRowsInserted
in class DefaultTableModelWrapper
firstRow
- the index of the first row that was insertedlastRow
- the index of the last row that was insertedprotected void tableRowsDeleted(int firstRow, int lastRow)
DefaultTableModelWrapper
TableModel
. This
default implementation simply fires a corresponding TableModelEvent
to the listeners on this model.
tableRowsDeleted
in class DefaultTableModelWrapper
firstRow
- the index of the first row that was deletedlastRow
- the index of the last row that was deletedprotected void tableRowsUpdated(int firstRow, int lastRow)
DefaultTableModelWrapper
TableModel
. simply fires
a corresponding TableModelEvent
to the listeners on this model.
tableRowsUpdated
in class DefaultTableModelWrapper
firstRow
- the index of the first row that was updatedlastRow
- the index of the last row that was updatedprotected boolean shouldOptimize(int firstRow, int lastRow)
firstRow
- the first row which is updated.lastRow
- the last row which is updated
protected List<Integer> getReservedRows(int firstRow, int lastRow)
firstRow
- the first rowlastRow
- the last row
protected void tableCellsUpdated(int column, int firstRow, int lastRow)
DefaultTableModelWrapper
column
in the range [firstRow
, lastRow
] are
updated. This default implementation simply fires a corresponding TableModelEvent
to the listeners
on this model.
tableCellsUpdated
in class DefaultTableModelWrapper
column
- the index of the column that was updatedfirstRow
- the index of the first row in the above column
that was updatedlastRow
- the index of the last row in the above column
that was updatedpublic void refresh()
refresh
in interface IFilterableTableModel
protected void fireIndexChanged(int eventSerialNumber)
fireIndexChanged
in class DefaultTableModelWrapper
eventSerialNumber
- the event serial numberprotected int fireIndexChanging()
fireIndexChanging
in class DefaultTableModelWrapper
protected boolean shouldBeFiltered(int rowIndex)
prepareFilters()
once before you call this
method one or multiple times. For example, you want to check if several rows should be filtered. Here is what you
should do.
Please be noted that if getFilterAlgorithm()
returns FILTER_ALGORITHM_BY_FILTER
, this method
will not take effect. So if you want to override this method, please make sure your filter algorithm is FILTER_ALGORITHM_BY_ROW
prepareFilters();
for (int row = firstRow; row <= lastRow; row++) {
boolean filtered = shouldBeFiltered(row);
if (!filtered) {
// do something
}
}
rowIndex
- the row index in the table model.
protected boolean shouldBeFiltered(ValueProvider valueProvider, int rowIndex)
shouldBeFiltered(int)
, this one takes a ValueProvider
as parameter in case the value of the row is not in the table model. For
example, in the case of TreeTableModel
, the value could be in the Row object which may or may not be
visible.
Please be noted that if getFilterAlgorithm()
returns FILTER_ALGORITHM_BY_FILTER
, this method
will not take effect. So if you want to override this method, please make sure your filter algorithm is FILTER_ALGORITHM_BY_ROW
valueProvider
- an interface where we can retrieve value.rowIndex
- the row index
protected void prepareFilters()
shouldBeFiltered(int)
or
shouldBeFiltered(ValueProvider, int)
.
protected void invalidateFilterCache()
protected void filter(boolean filterAllData)
filterAllData
- the flag that if we have to filter on all data or we could just filter the current datapublic boolean isColumnVisible(int column)
isColumnVisible
in interface IFilterableTableModel
column
- the column index.
public boolean isColumnFilterable(int column)
IFilterableTableModel.ALL_COLUMNS
. The column will be
excluded if it returns false (same as isColumnVisible(int)
in this case. There is also isColumnAutoFilterable(int)
which is used for AutoFilterHeader
to control if the filter button is
visible.
isColumnFilterable
in interface IFilterableTableModel
column
- the column index.
public boolean isColumnAutoFilterable(int column)
AutoFilterHeader
. If it
returns false, we will not show the filter button on the header for that column.
isColumnAutoFilterable
in interface AutoFilterTableHeaderAdapter
column
- the column index.
public boolean isValuePredetermined(int column)
AutoFilterHeader
on multi-line
mode. If it returns false, we will not show the filter field on the header for that column.
isValuePredetermined
in interface AutoFilterTableHeaderAdapter
column
- the column index.
protected boolean shouldBeFiltered(int row, List<Filter> allColumnFilters, List<Filter> anyColumnFilters, List<Filter>[] eachColumnFilters)
getFilterAlgorithm()
returns FILTER_ALGORITHM_BY_FILTER
, this method
will not take effect. So if you want to override this method, please make sure your filter algorithm is FILTER_ALGORITHM_BY_ROW
row
- the row indexallColumnFilters
- The list of filters on ALL_COLUMNanyColumnFilters
- The list of filters on ANY_COLUMNeachColumnFilters
- The array of list of filters on each column
protected boolean shouldBeFiltered(ValueProvider valueProvider, int row, List<Filter> allColumnFilters, List<Filter> anyColumnFilters, List<Filter>[] eachColumnFilters)
getFilterAlgorithm()
returns FILTER_ALGORITHM_BY_FILTER
, this method
will not take effect. So if you want to override this method, please make sure your filter algorithm is FILTER_ALGORITHM_BY_ROW
valueProvider
- an interface where we can retrieve value.row
- the row indexallColumnFilters
- The list of filters on ALL_COLUMNanyColumnFilters
- The list of filters on ANY_COLUMNeachColumnFilters
- The array of list of filters on each column
protected boolean shouldBeIgnored(ValueProvider valueProvider, int rowIndex)
TreeTableModel treeTableModel = (TreeTableModel) TableModelWrapperUtils.getActualTableModel(this,
TreeTableModel.class);
Row row = valueProvider instanceof RowValueProvider ? ((RowValueProvider) valueProvider).getRow() :
treeTableModel.getRowAt(TableModelWrapperUtils.getActualRowAt(_model, rowIndex, treeTableModel));
return row == null || !(row instanceof Expandable) || !((Expandable) row).hasChildren();
Please be noted that this method will take effect only if getFilterAlgorithm()
returns FILTER_ALGORITHM_BY_FILTER
. So if you try to override this method, please make sure your filter algorithm is
FILTER_ALGORITHM_BY_FILTER
valueProvider
- An interface where we can retrieve valuerowIndex
- The row index to be decided
protected List<Integer> shouldNotBeFiltered(ValueProvider valueProvider, List<Integer> filteringRowList, Filter filter, int filteringColumn)
shrinkRowsBeforeFilter(ValueProvider, java.util.List)
.
Please be noted that this method will take effect only if getFilterAlgorithm()
returns FILTER_ALGORITHM_BY_FILTER
. So if you try to override this method, please make sure your filter algorithm is
FILTER_ALGORITHM_BY_FILTER
valueProvider
- An interface where we can retrieve valuefilteringRowList
- The row index list to be checkedfilter
- Current filterfilteringColumn
- Current filtering column, its value could be either a real column index or IFilterableTableModel.ANY_COLUMNS
protected boolean shouldBeKept(ValueProvider valueProvider, int rowIndex, List<Integer> remainingRows)
getFilterAlgorithm()
returns FILTER_ALGORITHM_BY_FILTER
. So if you try to override this method, please make sure your filter algorithm is
FILTER_ALGORITHM_BY_FILTER
valueProvider
- An interface where we can retrieve valuerowIndex
- The row index to be decidedremainingRows
- The rows remained after major filter process
public void addFilter(int column, Filter filter)
addFilter
in interface IFilterableTableModel
column
- the column index. It could also be two special values - IFilterableTableModel.ALL_COLUMNS
or IFilterableTableModel.ANY_COLUMNS
. If the value is IFilterableTableModel.ANY_COLUMNS
, this method will be the same as addFilter(Filter)
.filter
- the filter to be added.public void addFilter(IFilterableTableModel.FilterItem filterItem)
addFilter
in interface IFilterableTableModel
filterItem
- the FilterItempublic void addFilter(Filter filter)
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.
addFilter
in interface IFilterableTableModel
filter
- the filter to be added.public void removeFilter(int column, Filter filter)
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.
removeFilter
in interface IFilterableTableModel
column
- the column index. It could also be two special values - IFilterableTableModel.ALL_COLUMNS
or IFilterableTableModel.ANY_COLUMNS
. If the value is IFilterableTableModel.ANY_COLUMNS
, this method will be the same as removeFilter(Filter)
.filter
- the filter to be removed.public void removeFilter(IFilterableTableModel.FilterItem filterItem)
removeFilter
in interface IFilterableTableModel
filterItem
- the FilterItem to be removed.public void removeFilter(Filter filter)
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.
removeFilter
in interface IFilterableTableModel
filter
- the filter to be removed.public void removeAllFilters(int column)
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.
removeAllFilters
in interface IFilterableTableModel
column
- the column index where all filters for that column should be removed.public void removeAllFilters()
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.
removeAllFilters
in interface IFilterableTableModel
public void clearFilters()
clearFilters
in interface IFilterableTableModel
public Filter[] getFilters(int column)
getFilters
in interface IFilterableTableModel
column
- the column index.
public List<IFilterableTableModel.FilterItem> getFilterItems()
getFilterItems
in interface IFilterableTableModel
public void setFiltersApplied(boolean apply)
setFiltersApplied
in interface IFilterableTableModel
apply
- true to apply the filters.public boolean isFiltersApplied()
isFiltersApplied
in interface IFilterableTableModel
public boolean hasFilter()
FilterableTableModel
has any filters.
hasFilter
in interface IFilterableTableModel
public boolean hasFilter(int columnIndex)
FilterableTableModel
has any filters on the specified column.
hasFilter
in interface IFilterableTableModel
columnIndex
- the column index to check if there is a filter on it.
public JMenuItem[] getPopupMenuItems(int column)
column
- the column
public boolean isAndMode()
IFilterableTableModel.ALL_COLUMNS
and IFilterableTableModel.ANY_COLUMNS
.
isAndMode
in interface IFilterableTableModel
public void setAndMode(boolean andMode)
FilterableTableModel
. 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
FilterableTableModel
s will always be AND logic.
setAndMode
in interface IFilterableTableModel
andMode
- true or false.public int getFilterAlgorithm()
setFilterAlgorithm(int)
public void setFilterAlgorithm(int filterAlgorithm)
FILTER_ALGORITHM_BY_ROW
by default for performance consideration. In FilterableTreeTableModel
,
it is automatically set to FILTER_ALGORITHM_BY_FILTER
.
filterAlgorithm
- the filter algorithmpublic boolean isAdjusting()
isAdjusting
in interface IFilterableTableModel
public void setAdjusting(boolean adjusting)
setAdjusting
in interface IFilterableTableModel
adjusting
- true or false.protected boolean shouldPossibleValueBeIncluded(Object value, int columnIndex)
value
- the value in the table model.columnIndex
- the column index where the value is from.
getPossibleValues(int, java.util.Comparator)
public Object[] getPossibleValues(int columnIndex, Comparator comparator)
shouldPossibleValueBeIncluded(Object, int)
method to decide if you want a particular value
appears in the possible value array.
The possible values are used by AutoFilterTableHeader
to populate the drop down filter list.
getPossibleValues
in interface IFilterableTableModel
columnIndex
- the column index.comparator
- the comparator. It is used to sort the values.
shouldPossibleValueBeIncluded(Object, int)
public Object[] getPossibleValuesAndConverters(int columnIndex, Comparator comparator)
getPossibleValuesAndConverters
in interface IFilterableTableModel
public void setFilteringPaused(boolean pause)
setFilteringPaused
in interface IFilterableTableModel
pause
- TRUE = Filtering is Paused; FALSE = Filtering is Activepublic boolean isFilteringPaused()
isFilteringPaused
in interface IFilterableTableModel
public void addFilterableTableModelListener(FilterableTableModelListener l)
addFilterableTableModelListener
in interface IFilterableTableModel
l
- the FilterableTableModelListenerpublic void removeFilterableTableModelListener(FilterableTableModelListener l)
removeFilterableTableModelListener
in interface IFilterableTableModel
l
- the FilterableTableModelListenerpublic FilterableTableModelListener[] getFilterableTableModelListeners()
getFilterableTableModelListeners
in interface IFilterableTableModel
FilterableTableModelListener
s or an empty array if no filter listeners
are currently registeredaddFilterableTableModelListener(com.jidesoft.grid.FilterableTableModelListener)
,
removeFilterableTableModelListener(com.jidesoft.grid.FilterableTableModelListener)
public void fireFilterChanged(FilterableTableModelEvent e)
FilterableTableModelListeners
that registered
themselves as listeners for this table model.
e
- the event to be forwardedaddFilterableTableModelListener(com.jidesoft.grid.FilterableTableModelListener)
,
FilterableTableModelEvent
,
EventListenerList
public void fireFilterAdded(int column, Filter filter)
public void fireFilterRemoved(int column, Filter filter)
public Icon getFilterIcon(int column)
getFilterIcon
in interface IFilterableTableModel
column
- the column index.
protected boolean isNeedFilterAllData()
protected void setNeedFilterAllData(boolean needFilterAllData)
needFilterAllData
- the flag@Deprecated public int retrieveFilterApplyRecords()
public boolean isSameConverterAt(int columnIndex)
isSameConverterAt
in interface IFilterableTableModel
columnIndex
- the column index
public void addDynamicTableFilter(int modelIndex, DynamicTableFilter filter)
DynamicTableFilter
.
DynamicTableFilter
allows to add your own customize filter to the drop down filter list. Any
DynamicTableFilter
will become an entry in the list. If user clicks on that entry, the filter will
be used to filter the column. What's special about DynamicTableFilter
is it allows to to create a
filter on fly. For example, in initializeFilter method of DynamicTableFilter, you can pop up a dialog to allow
user to select certain information and you return a filter based on user selection. If returning null, no filter
will be added. If not null, the filter you just created will be added to the IFilterableTableModel
.
modelIndex
- the column in the model to add the DynamicTableFilterfilter
- a DynamicTableFilter
.public void removeDynamicTableFilter(int modelIndex, DynamicTableFilter filter)
DynamicTableFilter
which was added earlier.
modelIndex
- the column in the model to remove the DynamicTableFilterfilter
- a DynamicTableFilter
.public DynamicTableFilter[] getDynamicTableFilters(int modelIndex)
DynamicTableFilter
s.
getDynamicTableFilters
in interface AutoFilterTableHeaderAdapter
modelIndex
- the column in the model to add the DynamicTableFilter
DynamicTableFilter
s.public boolean isAllowMultipleValues(int column)
AutoFilterTableHeaderAdapter
AutoFilterTableHeader
allows multiple values as the filter for the column index. The
difference will be to use a CheckBoxList or a regular JList as the popup panel when clicking on the filter button.
isAllowMultipleValues
in interface AutoFilterTableHeaderAdapter
column
- the column index.
public StringConverter getTitleConverter(int column)
AutoFilterTableHeaderAdapter
getTitleConverter
in interface AutoFilterTableHeaderAdapter
column
- the column index
public AutoFilterTableHeaderAdapter.FilterTitleFormatter getFilterTitleFormatter(int column)
AutoFilterTableHeaderAdapter
getFilterTitleFormatter
in interface AutoFilterTableHeaderAdapter
column
- the column index
public ListCellRenderer getListCellRenderer(int column)
AutoFilterTableHeaderAdapter
getListCellRenderer
in interface AutoFilterTableHeaderAdapter
column
- the column in the model to add the DynamicTableFilter
DynamicTableFilter
s.public boolean isUseTableCellRenderer(int column)
AutoFilterTableHeaderAdapter
isUseTableCellRenderer
in interface AutoFilterTableHeaderAdapter
column
- the column index.
public boolean isAllowCustomFilter(int column)
AutoFilterTableHeaderAdapter
AutoFilterTableHeader
allows custom filter. The difference is there will be a (Custom...)
item in the drop down list.when clicking on the filter button. The value is only considered when
AutoFilterTableHeader.isAllowMultipleValues()
returns false.
isAllowCustomFilter
in interface AutoFilterTableHeaderAdapter
column
- the column index.
public boolean isClearFiltersOnStructureChanged()
setClearFiltersOnStructureChanged(boolean)
public void setClearFiltersOnStructureChanged(boolean clearFiltersOnStructureChanged)
clearFiltersOnStructureChanged
- the flag
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |