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 TypeMethodDescriptionvoid
Re-allocates the indexes array to be a straight sort: matching the original sort order of the tablevoid
void
int
compare
(int row1, int row2) int
compareRowsByColumn
(int row1, int row2, int column) int
findColumn
(String columnName) Class<?>
getColumnClass
(int columnIndex) int
getColumnName
(int column) int[]
Returns an array of integers, which are the indexes of the actual data rows in the current sort orderint
getValueAt
(int aRow, int aColumn) boolean
isCellEditable
(int rowIndex, int columnIndex) boolean
void
void
setRetainSortOnChange
(boolean b) void
setValueAt
(Object aValue, int aRow, int aColumn) void
sortByColumn
(int column, boolean ascending) void
void
int
translateIndexToRow
(int row) Translates a row index as the underlying model knows it to a row as the JTable view sees it.int
translateRowToIndex
(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:
tableChanged
in interfaceTableModelListener
-
checkModel
public void checkModel() -
getValueAt
- Specified by:
getValueAt
in interfaceTableModel
-
setValueAt
- Specified by:
setValueAt
in interfaceTableModel
- Overrides:
setValueAt
in 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:
getColumnCount
in interfaceTableModel
-
getRowCount
public int getRowCount()- Specified by:
getRowCount
in interfaceTableModel
-
findColumn
- Overrides:
findColumn
in classAbstractTableModel
-
getColumnClass
- Specified by:
getColumnClass
in interfaceTableModel
- Overrides:
getColumnClass
in classAbstractTableModel
-
getColumnName
- Specified by:
getColumnName
in interfaceTableModel
- Overrides:
getColumnName
in classAbstractTableModel
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex) - Specified by:
isCellEditable
in interfaceTableModel
- Overrides:
isCellEditable
in classAbstractTableModel
-
isRetainSortOnChange
public boolean isRetainSortOnChange() -
setRetainSortOnChange
public void setRetainSortOnChange(boolean b)
-