com.jidesoft.pivot
Class FilterableAggregateTableModel
java.lang.Object
javax.swing.table.AbstractTableModel
com.jidesoft.grid.TableModelWrapperImpl
com.jidesoft.grid.DefaultTableModelWrapper
com.jidesoft.grid.FilterableTableModel
com.jidesoft.pivot.FilterableAggregateTableModel
- All Implemented Interfaces:
- AutoFilterTableHeaderAdapter, AutoFilterTableModel, ColumnIdentifierTableModel, ContextSensitiveTableModel, EditorStyleTableModel, IFilterableTableModel, IndexChangeEventGenerator, IndexedRowTableModelWrapper, MultiTableModel, NavigableModel, RowTableModelWrapper, SpanModel, StyleModel, TableModelWrapper, Serializable, EventListener, TableModelListener, TableModel
public class FilterableAggregateTableModel
- extends FilterableTableModel
This is a FilterableTableModel designed to wrap AggregateTableModel. This is a subclass of FilterableTableModel
. With this class, you can designate which level of values you want to keep
anyway. By default, your filter will just work on standard rows and keep grand total values and summary values. In
another scenario, you can change the configuration to filter on summary values only and keep all its "child" standard
rows.
- See Also:
setFilterTarget(int)
,
FILTER_TARGET_ON_STANDARD_ROWS
,
FILTER_TARGET_ON_SUMMARY_ROWS
,
Serialized Form
Method Summary |
int |
getFilterTarget()
Get the configuration indicating the filter should apply on summary rows or standard rows. |
void |
setFilterTarget(int filterTarget)
Set the configuration indicating the filter should apply on summary rows or standard rows. |
protected boolean |
shouldBeFiltered(int rowIndex)
Checks if the row should be filtered. |
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. |
Methods inherited from class com.jidesoft.grid.FilterableTableModel |
addDynamicTableFilter, addFilter, addFilter, addFilter, addFilterableTableModelListener, clearFilters, deleteIndexes, filter, fireFilterAdded, fireFilterChanged, fireFilterRemoved, fireIndexChanged, fireIndexChanging, getDynamicTableFilters, getFilterableTableModelListeners, getFilterAlgorithm, getFilterIcon, getFilterItems, getFilters, getFilterTitleFormatter, getListCellRenderer, getNearestRow, getPopupMenuItems, getPossibleValues, getPossibleValuesAndConverters, getReservedRows, getTitleConverter, hasFilter, hasFilter, insertIndexes, invalidateFilterCache, isAdjusting, isAllowCustomFilter, isAllowMultipleValues, isAndMode, isClearFiltersOnStructureChanged, isColumnAutoFilterable, isColumnFilterable, isColumnVisible, isFilteringPaused, isFiltersApplied, isNeedFilterAllData, isSameConverterAt, isUseTableCellRenderer, isValuePredetermined, prepareFilters, refresh, removeAllFilters, removeAllFilters, removeDynamicTableFilter, removeFilter, removeFilter, removeFilter, removeFilterableTableModelListener, retrieveFilterApplyRecords, setAdjusting, setAndMode, setClearFiltersOnStructureChanged, setFilterAlgorithm, setFilteringPaused, setFiltersApplied, setNeedFilterAllData, shouldBeFiltered, shouldBeFiltered, shouldBeFiltered, shouldNotBeFiltered, shouldOptimize, shouldPossibleValueBeIncluded, tableCellsUpdated, tableDataChanged, tableDataChanged, tableRowsDeleted, tableRowsInserted, tableRowsUpdated, tableStructureChanged |
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 |
FILTER_TARGET_ON_STANDARD_ROWS
public static final int FILTER_TARGET_ON_STANDARD_ROWS
- Only filter on standard rows. Keep summary rows and grand total rows anyway.
- See Also:
- Constant Field Values
FILTER_TARGET_ON_SUMMARY_ROWS
public static final int FILTER_TARGET_ON_SUMMARY_ROWS
- Only filter on summary rows. Keep grand total rows anyway. Only the "child" rows of the kept summary rows will be
kept.
- See Also:
- Constant Field Values
FilterableAggregateTableModel
public FilterableAggregateTableModel(TableModel model)
shouldBeFiltered
protected boolean shouldBeFiltered(int rowIndex)
- Description copied from class:
FilterableTableModel
- Checks if the row should be filtered. Make sure you call
FilterableTableModel.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 FilterableTableModel.getFilterAlgorithm()
returns FilterableTableModel.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 FilterableTableModel.FILTER_ALGORITHM_BY_ROW
prepareFilters();
for (int row = firstRow; row <= lastRow; row++) {
boolean filtered = shouldBeFiltered(row);
if (!filtered) {
// do something
}
}
- Overrides:
shouldBeFiltered
in class FilterableTableModel
- Parameters:
rowIndex
- the row index in the table model.
- Returns:
- true if the row should be filtered away. Otherwise false.
shouldBeIgnored
protected boolean shouldBeIgnored(ValueProvider valueProvider,
int rowIndex)
- Description copied from class:
FilterableTableModel
- The method is for you to override if you want certain rows to be ignored the filtering process. In some cases,
you can also improve the filter performance significantly based on the characteristics of your data. In this
implementation, we just return true.
The following sample code is going to make the filter only apply on the nodes which are not leaf nodes.
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 FilterableTableModel.getFilterAlgorithm()
returns FilterableTableModel.FILTER_ALGORITHM_BY_FILTER
. So if you try to override this method, please make sure your filter algorithm is
FilterableTableModel.FILTER_ALGORITHM_BY_FILTER
- Overrides:
shouldBeIgnored
in class FilterableTableModel
- Parameters:
valueProvider
- An interface where we can retrieve valuerowIndex
- The row index to be decided
- Returns:
- True if you do NOT want the row in the filter process. Otherwise false.
shouldBeKept
protected boolean shouldBeKept(ValueProvider valueProvider,
int rowIndex,
List<Integer> remainingRows)
- Description copied from class:
FilterableTableModel
- The method is for you to decide if the rowIndex should be kept based on the rows remained in the remainingRows.
The method is invoked row by row after the filtering process. In this implementation, we just return if the
remainingRows contains the rowIndex.
For example, in FilterableTreeTableModel, even the rowIndex is not in the remainingRows, we will still check if
one of its ancestors is in the remainingRows when ifKeepAllChildren() flag is true.
Please be noted that the method will take effect only if
FilterableTableModel.getFilterAlgorithm()
returns FilterableTableModel.FILTER_ALGORITHM_BY_FILTER
. So if you try to override this method, please make sure your filter algorithm is
FilterableTableModel.FILTER_ALGORITHM_BY_FILTER
- Overrides:
shouldBeKept
in class FilterableTableModel
- Parameters:
valueProvider
- An interface where we can retrieve valuerowIndex
- The row index to be decidedremainingRows
- The rows remained after major filter process
- Returns:
- True if the rowIndex should be kept given the rows in remainingRows are kept. Otherwise false.
getFilterTarget
public int getFilterTarget()
- Get the configuration indicating the filter should apply on summary rows or standard rows.
The default value is
FILTER_TARGET_ON_STANDARD_ROWS
.
- Returns:
- the configuration.
setFilterTarget
public void setFilterTarget(int filterTarget)
- Set the configuration indicating the filter should apply on summary rows or standard rows.
- Parameters:
filterTarget
- the configuration