Class SortTableModel
java.lang.Object
javax.swing.table.AbstractTableModel
com.inductiveautomation.ignition.client.util.gui.table.SortTableModel
- All Implemented Interfaces:
Serializable,EventListener,TableModelListener,TableModel
A sorter for TableModels. The sorter has a model (conforming to TableModel)
and itself implements TableModel. TableSorter does not store or copy
the data in the TableModel, instead it maintains an array of
integers which it keeps the same size as the number of rows in its
model. When the model changes it notifies the sorter that something
has changed eg. "rowsAdded" so that its internal array of integers
can be reallocated. As requests are made of the sorter (like
getValueAt(row, col) it redirects them to its model via the mapping
array. That way the TableSorter appears to hold another copy of the table
with the rows in a different order. The sorting algorthm used is stable
which means that it does not move around rows when its comparison
function returns 0 to denote that they are equivalent.
- See Also:
-
Field Summary
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidRe-allocates the indexes array to be a straight sort: matching the original sort order of the tablevoidvoidintcompare(int row1, int row2) intcompareRowsByColumn(int row1, int row2, int column) intfindColumn(String columnName) Class<?>getColumnClass(int columnIndex) intgetColumnName(int column) int[]Returns an array of integers, which are the indexes of the actual data rows in the current sort orderintgetValueAt(int aRow, int aColumn) booleanisCellEditable(int rowIndex, int columnIndex) booleanvoidvoidsetRetainSortOnChange(boolean b) voidsetValueAt(Object aValue, int aRow, int aColumn) voidsortByColumn(int column, boolean ascending) voidvoidinttranslateIndexToRow(int row) Translates a row index as the underlying model knows it to a row as the JTable view sees it.inttranslateRowToIndex(int index) Translates a row as the JTable view reports it to a model index of the underlying modelMethods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
-
Constructor Details
-
SortTableModel
-
-
Method Details
-
compareRowsByColumn
public int compareRowsByColumn(int row1, int row2, int column) -
compare
public int compare(int row1, int row2) -
reallocateIndexes
public void reallocateIndexes() -
tableChanged
- Specified by:
tableChangedin interfaceTableModelListener
-
checkModel
public void checkModel() -
getValueAt
- Specified by:
getValueAtin interfaceTableModel
-
setValueAt
- Specified by:
setValueAtin interfaceTableModel- Overrides:
setValueAtin classAbstractTableModel
-
translateIndexToRow
public int translateIndexToRow(int row) Translates a row index as the underlying model knows it to a row as the JTable view sees it. -
translateRowToIndex
public int translateRowToIndex(int index) Translates a row as the JTable view reports it to a model index of the underlying model -
_sortOrig
public void _sortOrig()Re-allocates the indexes array to be a straight sort: matching the original sort order of the table -
getIndexes
public int[] getIndexes()Returns an array of integers, which are the indexes of the actual data rows in the current sort order -
sortOriginal
public void sortOriginal() -
sortByColumn
public void sortByColumn(int column, boolean ascending) -
addMouseListenerToHeaderInTable
-
getColumnCount
public int getColumnCount()- Specified by:
getColumnCountin interfaceTableModel
-
getRowCount
public int getRowCount()- Specified by:
getRowCountin interfaceTableModel
-
findColumn
- Overrides:
findColumnin classAbstractTableModel
-
getColumnClass
- Specified by:
getColumnClassin interfaceTableModel- Overrides:
getColumnClassin classAbstractTableModel
-
getColumnName
- Specified by:
getColumnNamein interfaceTableModel- Overrides:
getColumnNamein classAbstractTableModel
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex) - Specified by:
isCellEditablein interfaceTableModel- Overrides:
isCellEditablein classAbstractTableModel
-
isRetainSortOnChange
public boolean isRetainSortOnChange() -
setRetainSortOnChange
public void setRetainSortOnChange(boolean b)
-