|
SalesPoint Framework v3.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.table.AbstractTableModel util.swing.AbstractTableModel util.swing.TableMap util.swing.TableSorter
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.
Field Summary |
Fields inherited from class util.swing.TableMap |
model |
Fields inherited from class javax.swing.table.AbstractTableModel |
listenerList |
Constructor Summary | |
TableSorter()
Constructor. |
|
TableSorter(AbstractTableModel model)
Constructor. |
Method Summary | |
void |
addMouseListenerToHeaderInTable(JTable table,
Object[] ao)
Adds a mouse listener to the table header. |
int |
compare(int row1,
int row2)
Comparison of two rows. |
int |
compareRowsByColumn(int row1,
int row2,
int column)
Compares columns of two specific rows. |
Object |
getRecord(int row)
Gets the record. |
Object |
getValueAt(int aRow,
int aColumn)
Changes the value of a table cell. |
void |
setModel(AbstractTableModel model)
Sets the TableModel . |
void |
setValueAt(Object aValue,
int aRow,
int aColumn)
Changes the value of a table cell. |
void |
sortByColumn(int column)
Sorts the table ascending by a column. |
void |
sortByColumn(int column,
boolean ascending)
Sorts the table by a column. |
void |
tableChanged(TableModelEvent e)
Reacts on TableChangeEvents, either converts them as needed or passes them to the model. |
Methods inherited from class util.swing.TableMap |
getColumnClass, getColumnCount, getColumnName, getModel, getRowCount, isCellEditable, setData |
Methods inherited from class util.swing.AbstractTableModel |
getEntryDescriptor, orderByColumn, reOrderBy |
Methods inherited from class javax.swing.table.AbstractTableModel |
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TableSorter()
public TableSorter(AbstractTableModel model)
model
- the wrapped TableModel
Method Detail |
public void setModel(AbstractTableModel model)
TableModel
.
setModel
in class TableMap
model
- the model.public int compareRowsByColumn(int row1, int row2, int column)
row1
- first row.row2
- second row.column
- the column index.
public int compare(int row1, int row2)
row1
- first row.row2
- second row.
public void tableChanged(TableModelEvent e)
tableChanged
in interface TableModelListener
tableChanged
in class TableMap
e
- the event.public Object getValueAt(int aRow, int aColumn)
getValueAt
in interface TableModel
getValueAt
in class TableMap
aRow
- the row of the TableCell to be changed.aColumn
- the column of the table cell to be changed.
public Object getRecord(int row)
getRecord
in class TableMap
row
- the affected table row.
public void setValueAt(Object aValue, int aRow, int aColumn)
setValueAt
in interface TableModel
setValueAt
in class TableMap
aValue
- the value to set.aRow
- the row of the TableCell to be changed.aColumn
- the column of the table cell to be changed.public void sortByColumn(int column)
column
- the column by which the table should be sorted.public void sortByColumn(int column, boolean ascending)
column
- the column by which the table should be sorted.ascending
- if true
sort sequence is ascending, otherwise descending.public void addMouseListenerToHeaderInTable(JTable table, Object[] ao)
table
- the table to which header the listener is to be added
|
SalesPoint Framework v3.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |