JIDE 3.5.15

com.jidesoft.pivot
Class FilterableAggregateTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.jidesoft.grid.TableModelWrapperImpl
          extended by com.jidesoft.grid.DefaultTableModelWrapper
              extended by com.jidesoft.grid.FilterableTableModel
                  extended by 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

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
static int FILTER_TARGET_ON_STANDARD_ROWS
          Only filter on standard rows.
static int FILTER_TARGET_ON_SUMMARY_ROWS
          Only filter on summary rows.
 
Fields inherited from class com.jidesoft.grid.FilterableTableModel
_allColumnFilters, _anyColumnFilters, _columnIncluded, _eachColumnFilters, _filterItemSupport, _valueProvider, FILTER_ALGORITHM_BY_FILTER, FILTER_ALGORITHM_BY_ROW
 
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
FilterableAggregateTableModel(TableModel model)
           
 
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
 
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

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
Constructor Detail

FilterableAggregateTableModel

public FilterableAggregateTableModel(TableModel model)
Method Detail

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 value
rowIndex - 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 value
rowIndex - The row index to be decided
remainingRows - 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

JIDE 3.5.15