Class SortTableModel
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- com.inductiveautomation.ignition.client.util.gui.table.SortTableModel
-
- All Implemented Interfaces:
java.io.Serializable,java.util.EventListener,javax.swing.event.TableModelListener,javax.swing.table.TableModel
public class SortTableModel extends javax.swing.table.AbstractTableModel implements javax.swing.event.TableModelListenerA 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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SortTableModel(javax.swing.table.AbstractTableModel delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void_sortOrig()Re-allocates the indexes array to be a straight sort: matching the original sort order of the tablevoidaddMouseListenerToHeaderInTable(javax.swing.JTable table)voidcheckModel()intcompare(int row1, int row2)intcompareRowsByColumn(int row1, int row2, int column)intfindColumn(java.lang.String columnName)java.lang.Class<?>getColumnClass(int columnIndex)intgetColumnCount()java.lang.StringgetColumnName(int column)int[]getIndexes()Returns an array of integers, which are the indexes of the actual data rows in the current sort orderintgetRowCount()java.lang.ObjectgetValueAt(int aRow, int aColumn)booleanisCellEditable(int rowIndex, int columnIndex)booleanisRetainSortOnChange()voidreallocateIndexes()voidsetRetainSortOnChange(boolean b)voidsetValueAt(java.lang.Object aValue, int aRow, int aColumn)voidsortByColumn(int column, boolean ascending)voidsortOriginal()voidtableChanged(javax.swing.event.TableModelEvent e)inttranslateIndexToRow(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 model-
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
-
-
-
-
Method Detail
-
compareRowsByColumn
public int compareRowsByColumn(int row1, int row2, int column)
-
compare
public int compare(int row1, int row2)
-
reallocateIndexes
public void reallocateIndexes()
-
tableChanged
public void tableChanged(javax.swing.event.TableModelEvent e)
- Specified by:
tableChangedin interfacejavax.swing.event.TableModelListener
-
checkModel
public void checkModel()
-
getValueAt
public java.lang.Object getValueAt(int aRow, int aColumn)- Specified by:
getValueAtin interfacejavax.swing.table.TableModel
-
setValueAt
public void setValueAt(java.lang.Object aValue, int aRow, int aColumn)- Specified by:
setValueAtin interfacejavax.swing.table.TableModel- Overrides:
setValueAtin classjavax.swing.table.AbstractTableModel
-
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
public void addMouseListenerToHeaderInTable(javax.swing.JTable table)
-
getColumnCount
public int getColumnCount()
- Specified by:
getColumnCountin interfacejavax.swing.table.TableModel
-
getRowCount
public int getRowCount()
- Specified by:
getRowCountin interfacejavax.swing.table.TableModel
-
findColumn
public int findColumn(java.lang.String columnName)
- Overrides:
findColumnin classjavax.swing.table.AbstractTableModel
-
getColumnClass
public java.lang.Class<?> getColumnClass(int columnIndex)
- Specified by:
getColumnClassin interfacejavax.swing.table.TableModel- Overrides:
getColumnClassin classjavax.swing.table.AbstractTableModel
-
getColumnName
public java.lang.String getColumnName(int column)
- Specified by:
getColumnNamein interfacejavax.swing.table.TableModel- Overrides:
getColumnNamein classjavax.swing.table.AbstractTableModel
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex)- Specified by:
isCellEditablein interfacejavax.swing.table.TableModel- Overrides:
isCellEditablein classjavax.swing.table.AbstractTableModel
-
isRetainSortOnChange
public boolean isRetainSortOnChange()
-
setRetainSortOnChange
public void setRetainSortOnChange(boolean b)
-
-