JIDE 3.5.15

com.jidesoft.pivot
Class SortableAggregateTableModel

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.SortableTableModel
                  extended by com.jidesoft.pivot.SortableAggregateTableModel
All Implemented Interfaces:
ColumnIdentifierTableModel, ContextSensitiveTableModel, EditorStyleTableModel, IndexChangeEventGenerator, IndexedRowTableModelWrapper, ISortableTableModel, MultiTableModel, NavigableModel, RowTableModelWrapper, SpanModel, StyleModel, TableModelWrapper, Serializable, EventListener, TableModelListener, TableModel

public class SortableAggregateTableModel
extends SortableTableModel

A sortable AggregateTableModel used by AggregateTable. If the AggregateTable is sortable, it will use this model by default.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.jidesoft.grid.SortableTableModel
SortableTableModel.ColumnComparatorContextProvider, SortableTableModel.SortOrderHandler
 
Nested classes/interfaces inherited from interface com.jidesoft.grid.ISortableTableModel
ISortableTableModel.SortItem
 
Field Summary
 
Fields inherited from class com.jidesoft.grid.SortableTableModel
_sortItemSupport
 
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.ISortableTableModel
SORT_PRIORITY_FIFO, SORT_PRIORITY_FILO
 
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
SortableAggregateTableModel(TableModel model)
           
 
Method Summary
 int compare(int row1, int row2, int column)
          Compares the two cell values at the two rows.
protected  void sort()
          Sorts the aggregate table model.
 
Methods inherited from class com.jidesoft.grid.SortableTableModel
addSortListener, append, cacheComparators, compare, compare, fireSortEvent, fireSortingEvent, fireTableChanged, fireTableStructureChanged, getColumnComparatorContext, getColumnComparatorContextProvider, getColumnSortRank, getComparator, getMasterSortColumnIndex, getMasterSortColumns, getMaximumSortColumns, getPopupMenuItems, getSortableModel, getSortedRowAt, getSortingColumns, getSortListeners, getSortOrderHandler, getSortPriority, getSortRanges, insert, isAlwaysUseComparators, isAutoResort, isColumnAscending, isColumnSortable, isColumnSorted, isInSortRanges, isMultiColumnSortable, isOptimized, isResetOnTableStructureChangeEvent, isSortable, isSortingPaused, removeSortListener, reset, resort, reverseColumnSortOrder, search, setAlwaysUseComparators, setAutoResort, setColumnComparatorContextProvider, setColumnSortable, setIndexes, setMasterSortColumns, setMaximumSortColumns, setMultiColumnSortable, setOptimized, setResetOnTableStructureChangeEvent, setSortable, setSortingColumns, setSortingPaused, setSortOrderHandler, setSortPriority, shouldOptimize, shouldReverseIndices, sort, sortColumn, sortColumn, sortColumn, tableChanged, toggleSortOrder, unsortColumn
 
Methods inherited from class com.jidesoft.grid.DefaultTableModelWrapper
fireIndexChanged, fireIndexChanging, getActualRowAt, getCellClassAt, getCellSpanAt, getConverterContextAt, getEditorContextAt, getEditorStyleAt, getIndexes, getRowCount, getValueAt, getVisualRowAt, isCacheEnabled, isCellEditable, isRowCountChanged, reallocateIndexes, setCacheEnabled, setValueAt, tableCellsUpdated, tableDataChanged, tableDataChanged, tableRowsDeleted, tableRowsInserted, tableRowsUpdated, tableStructureChanged
 
Methods inherited from class com.jidesoft.grid.TableModelWrapperImpl
addIndexChangeListener, createCompoundTableModelEvent, fireTableCellsUpdated, getActualModel, getCellStyleAt, getColumnClass, getColumnCount, getColumnIdentifier, getColumnName, getColumnType, getIndexChangeListeners, getTableIndex, isCellSpanOn, isCellStyleOn, isNavigableAt, isNavigationOn, removeIndexChangeListener
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, 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 com.jidesoft.grid.ISortableTableModel
getActualRowAt
 
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
 

Constructor Detail

SortableAggregateTableModel

public SortableAggregateTableModel(TableModel model)
Method Detail

sort

protected void sort()
Sorts the aggregate table model. Subclass can override to provide an optimized way to sort the table. You can get the grouping column information by using getMasterSortColumns() and get all sorting column information by using getSortingColumns().

Overrides:
sort in class SortableTableModel

compare

public int compare(int row1,
                   int row2,
                   int column)
Compares the two cell values at the two rows. Since we have to keep summary value on the bottom, so the return value has a little bit confusion here. if one of the two rows is a summary value and the column is not a grouping column, we use Integer.MIN_VALUE or Integer.MAX_VALUE so the value will not be changed by sorting direction. With this algorithm, we don't have to override SortableTableModel.compare(int,int). if two rows are both summary values with same prefix values, we now just keep the original order. You can choose to override this method if you want to sort summary values as well.

Overrides:
compare in class SortableTableModel
Parameters:
row1 - index of the first row to be compared
row2 - index of the second row to be compared
column - the column index of both rows.
Returns:
If it returns > 0, it means the first value is greater than the second value. If it returns -1, it means the second value is greater than the first value. If it returns 0, it means the two values are the same. If it returns Integer.MAX_VALUE, the first value is always appear after the second value, regarding of the order is ascending or descending. If it returns Integer.MIN_VALUE, the first value is always appear before the second value, regarding of the order is ascending or descending.

JIDE 3.5.15