Package ca.spatial.table
Class SortableTable
java.lang.Object
javax.swing.table.AbstractTableModel
ca.spatial.table.SortableTable
- All Implemented Interfaces:
Serializable
,EventListener
,TableModelListener
,TableModel
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCellEditors(JTable t, int offset)
void
addSortOrderListener(SortOrderListener listener)
void
close()
void
void
void
Export all columns of the selected rows to a DBF file.void
getColumnClass(int aColumn)
int
getColumnName(int aColumn)
getModel()
int
getModelRow(int aRow)
Return the row in the original model that corresponds to the given row in the sorted model.int
int
int[]
getValueAt(int aRow, int aColumn)
getValueAt(int aRow, int aColumn, int aPeriod)
int
getViewRow(int aRow)
Return the row in the view that corresponds to the given row in the original model.boolean
isCellEditable(int row, int column)
void
void
removeSortOrderListener(SortOrderListener listener)
void
setListSelectionModel(SorterSelectionModel listSelectionModel)
void
setSortOrder(int[] indexes)
void
setValueAt(Object aValue, int aRow, int aColumn)
void
setValueAt(Object aValue, int aRow, int aColumn, int aPeriod)
void
sortByColumn(int column, boolean ascending)
Sort the table by the specified column.void
sortByColumn(int column, boolean ascending, int period)
Sort the table by the specified column.void
sortByExpression(String expression, boolean ascending, int period)
Sort the table by an expression.void
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
-
Constructor Details
-
SortableTable
-
-
Method Details
-
getModel
-
getListSelectionModel
-
setListSelectionModel
-
close
public void close() -
getValueAt
- Specified by:
getValueAt
in interfaceTableModel
-
getValueAt
-
setValueAt
- Specified by:
setValueAt
in interfaceTableModel
- Overrides:
setValueAt
in classAbstractTableModel
-
setValueAt
-
getRowCount
public int getRowCount()- Specified by:
getRowCount
in interfaceTableModel
-
getColumnCount
public int getColumnCount()- Specified by:
getColumnCount
in interfaceTableModel
-
getColumnName
- Specified by:
getColumnName
in interfaceTableModel
- Overrides:
getColumnName
in classAbstractTableModel
-
getColumnClass
- Specified by:
getColumnClass
in interfaceTableModel
- Overrides:
getColumnClass
in classAbstractTableModel
-
isCellEditable
public boolean isCellEditable(int row, int column)- Specified by:
isCellEditable
in interfaceTableModel
- Overrides:
isCellEditable
in classAbstractTableModel
-
getPeriod
public int getPeriod() -
exportCSV
-
exportCSV
public void exportCSV(Window w, String filename, ArrayList<DBFColumnSpec> defs, int period, String reselect) -
exportDBF
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
-
removeSortOrderListener
-
reallocateIndexes
public void reallocateIndexes() -
sortByExpression
Sort the table by an expression.- Parameters:
expression
- the expression to sort onascending
- specifies the sort order. true = ascending, false = descendingperiod
- 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 onascending
- specifies the sort order. true = ascending, false = descendingperiod
- 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 assortByColumn(column, ascending, model.getPeriod());
- Parameters:
column
- the column number to sort onascending
- specifies the sort order. true = ascending, false = descending
-
addCellEditors
-
tableChanged
- Specified by:
tableChanged
in interfaceTableModelListener
-