public class FilterableAggregateTableModel extends FilterableTableModel
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.IFilterableTableModel.FilterItem
AutoFilterTableHeaderAdapter.FilterTitleFormatter
Modifier and Type | Field and Description |
---|---|
static int |
FILTER_TARGET_ON_STANDARD_ROWS
Only filter on standard rows.
|
static int |
FILTER_TARGET_ON_SUMMARY_ROWS
Only filter on summary rows.
|
_allColumnFilters, _anyColumnFilters, _columnIncluded, _eachColumnFilters, _filterItemSupport, _valueProvider, FILTER_ALGORITHM_BY_FILTER, FILTER_ALGORITHM_BY_ROW
_indexes
_model
listenerList
ALL_COLUMNS, ANY_COLUMNS, IDENTIFIER_ALL_COLUMNS, IDENTIFIER_ANY_COLUMNS
FOOTER_COLUMN, HEADER_COLUMN, REGULAR_COLUMN
EDITOR_STYLE_EDITABLE, EDITOR_STYLE_NORMAL, EDITOR_STYLE_READ_ONLY, EDITOR_STYLE_SELECT_ONLY
Constructor and Description |
---|
FilterableAggregateTableModel(TableModel model) |
Modifier and Type | Method and Description |
---|---|
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.
|
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
getActualRowAt, getCellClassAt, getCellSpanAt, getConverterContextAt, getEditorContextAt, getEditorStyleAt, getIndexes, getRowCount, getValueAt, getVisualRowAt, isCacheEnabled, isCellEditable, isRowCountChanged, reallocateIndexes, setCacheEnabled, setIndexes, setValueAt
addIndexChangeListener, createCompoundTableModelEvent, fireTableCellsUpdated, fireTableChanged, getActualModel, getCellStyleAt, getColumnClass, getColumnCount, getColumnIdentifier, getColumnName, getColumnType, getIndexChangeListeners, getTableIndex, isCellSpanOn, isCellStyleOn, isNavigableAt, isNavigationOn, removeIndexChangeListener, tableChanged
addTableModelListener, findColumn, fireTableCellUpdated, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addTableModelListener, getColumnClass, getColumnCount, getColumnName, getRowCount, getValueAt, isCellEditable, removeTableModelListener, setValueAt
getActualModel
public static final int FILTER_TARGET_ON_STANDARD_ROWS
public static final int FILTER_TARGET_ON_SUMMARY_ROWS
public FilterableAggregateTableModel(TableModel model)
protected boolean shouldBeFiltered(int rowIndex)
FilterableTableModel
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
}
}
shouldBeFiltered
in class FilterableTableModel
rowIndex
- the row index in the table model.protected boolean shouldBeIgnored(ValueProvider valueProvider, int rowIndex)
FilterableTableModel
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
shouldBeIgnored
in class FilterableTableModel
valueProvider
- An interface where we can retrieve valuerowIndex
- The row index to be decidedprotected boolean shouldBeKept(ValueProvider valueProvider, int rowIndex, List<Integer> remainingRows)
FilterableTableModel
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
shouldBeKept
in class FilterableTableModel
valueProvider
- An interface where we can retrieve valuerowIndex
- The row index to be decidedremainingRows
- The rows remained after major filter processpublic int getFilterTarget()
FILTER_TARGET_ON_STANDARD_ROWS
.public void setFilterTarget(int filterTarget)
filterTarget
- the configuration