Class SortableTable

All Implemented Interfaces:
Serializable, EventListener, TableModelListener, TableModel

public class SortableTable extends AbstractTableModel implements TableModelListener
A class that proves a column-sorted view of a data table. The sorting of the table is strictly 'virtual'. The real data is unchanged, only the presentation order is altered.
See Also:
Serialized Form
  • Constructor Details

  • Method Details

    • getModel

      public AttributeStore getModel()
    • getListSelectionModel

      public SorterSelectionModel getListSelectionModel()
    • setListSelectionModel

      public void setListSelectionModel(SorterSelectionModel listSelectionModel)
    • close

      public void close()
    • getValueAt

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

      public Object getValueAt(int aRow, int aColumn, int aPeriod)
    • setValueAt

      public void setValueAt(Object aValue, int aRow, int aColumn)
      Specified by:
      setValueAt in interface TableModel
      Overrides:
      setValueAt in class AbstractTableModel
    • setValueAt

      public void setValueAt(Object aValue, int aRow, int aColumn, int aPeriod)
    • getRowCount

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

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

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

      public Class getColumnClass(int aColumn)
      Specified by:
      getColumnClass in interface TableModel
      Overrides:
      getColumnClass in class AbstractTableModel
    • isCellEditable

      public boolean isCellEditable(int row, int column)
      Specified by:
      isCellEditable in interface TableModel
      Overrides:
      isCellEditable in class AbstractTableModel
    • getPeriod

      public int getPeriod()
    • exportCSV

      public void exportCSV(Window w, String filename, String[] columns, int period, String reselect)
    • exportCSV

      public void exportCSV(Window w, String filename, ArrayList<DBFColumnSpec> defs, int period, String reselect)
    • exportDBF

      public void exportDBF(Window w, String filename, String[] columns, int period, String reselect)
      Export all columns of the selected rows to a DBF file.
    • exportDBF

      public void exportDBF(Window w, String filename, ArrayList<DBFColumnSpec> defs, int period, String reselect)
    • getModelRow

      public int getModelRow(int aRow)
      Return the row in the original model that corresponds to the given row in the sorted model.
      Parameters:
      aRow - the row in the sorted model to look up
    • getViewRow

      public int getViewRow(int aRow)
      Return the row in the view that corresponds to the given row in the original model.
      Parameters:
      aRow - the row in the original model to look up
    • setSortOrder

      public void setSortOrder(int[] indexes)
    • getSortOrder

      public int[] getSortOrder()
    • addSortOrderListener

      public void addSortOrderListener(SortOrderListener listener)
    • removeSortOrderListener

      public void removeSortOrderListener(SortOrderListener listener)
    • reallocateIndexes

      public void reallocateIndexes()
    • sortByExpression

      public void sortByExpression(String expression, boolean ascending, int period)
      Sort the table by an expression.
      Parameters:
      expression - the expression to sort on
      ascending - specifies the sort order. true = ascending, false = descending
      period - the period to sort the values on
    • sortByColumn

      public void sortByColumn(int column, boolean ascending, int period)
      Sort the table by the specified column.
      Parameters:
      column - the column number to sort on
      ascending - specifies the sort order. true = ascending, false = descending
      period - the period to sort the values on
    • sortByColumn

      public void sortByColumn(int column, boolean ascending)
      Sort the table by the specified column. This will sort on values from the default period, and is the same as
       sortByColumn(column, ascending, model.getPeriod());
       
      Parameters:
      column - the column number to sort on
      ascending - specifies the sort order. true = ascending, false = descending
    • addCellEditors

      public void addCellEditors(JTable t, int offset)
    • tableChanged

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