java.lang.Object
javax.swing.table.AbstractTableModel
com.inductiveautomation.ignition.client.util.gui.table.SortTableModel
All Implemented Interfaces:
Serializable, EventListener, TableModelListener, TableModel

public class SortTableModel extends AbstractTableModel implements TableModelListener
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:
  • Constructor Details

  • 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

      public void tableChanged(TableModelEvent e)
      Specified by:
      tableChanged in interface TableModelListener
    • checkModel

      public void checkModel()
    • getValueAt

      public Object getValueAt(int aRow, int aColumn)
      Specified by:
      getValueAt in interface TableModel
    • setValueAt

      public void setValueAt(Object aValue, int aRow, int aColumn)
      Specified by:
      setValueAt in interface TableModel
      Overrides:
      setValueAt in class 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(JTable table)
    • getColumnCount

      public int getColumnCount()
      Specified by:
      getColumnCount in interface TableModel
    • getRowCount

      public int getRowCount()
      Specified by:
      getRowCount in interface TableModel
    • findColumn

      public int findColumn(String columnName)
      Overrides:
      findColumn in class AbstractTableModel
    • getColumnClass

      public Class<?> getColumnClass(int columnIndex)
      Specified by:
      getColumnClass in interface TableModel
      Overrides:
      getColumnClass in class AbstractTableModel
    • getColumnName

      public String getColumnName(int column)
      Specified by:
      getColumnName in interface TableModel
      Overrides:
      getColumnName in class AbstractTableModel
    • isCellEditable

      public boolean isCellEditable(int rowIndex, int columnIndex)
      Specified by:
      isCellEditable in interface TableModel
      Overrides:
      isCellEditable in class AbstractTableModel
    • isRetainSortOnChange

      public boolean isRetainSortOnChange()
    • setRetainSortOnChange

      public void setRetainSortOnChange(boolean b)