public class TableSorter extends TableMap
listenerList| Constructor and Description |
|---|
TableSorter(TableModel pModel)
Create new TableSorter for given table model.
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
compare(int pRow1,
int pRow2)
Compare two rows of tablemodel holding data.
|
protected int |
compareRowsByColumn(int pRow1,
int pRow2,
int pColumn)
Compare two rows of tablemodel holding data with respect to given column.
|
void |
dropSorting()
Drop the sorting criteria for this table model but keep the current row order.
|
int |
getModelRow(int pRow)
Map view-index of table row to model-index.
|
TableSortInfo |
getSortInfo()
Get current sorting info.
|
Object |
getValueAt(int pRow,
int pColumn)
Returns an attribute value for the cell at aRow and aColumn.
|
int |
getViewRow(int pRow)
Map model-index of table row to view-index.
|
boolean |
isSorted(int pColumn)
Check if given column is a sorted column.
|
void |
resetColumns()
Reset all previous set sorting info.
|
void |
setModel(TableModel pModel)
Set a new TableModel.
|
void |
setValueAt(Object pValue,
int pRow,
int pColumn)
Sets an attribute value for the record in the cell at
aRow and aColumn.
|
protected void |
sort()
Sort data in tablemodel according to columns set up via sortByColumn.
|
void |
sortByColumn(int pColumn)
Sort data according to specified column.
|
void |
sortByColumn(int pColumn,
boolean pAscending)
Sort data according to specified column.
|
void |
tableChanged(TableModelEvent pEvent)
Callback from TableModel.
|
getColumnClass, getColumnCount, getColumnName, getModel, getRowCount, isCellEditableaddTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListenerpublic TableSorter(TableModel pModel)
pModel - table model holding data to be displayedpublic void setModel(TableModel pModel)
public int getModelRow(int pRow)
pRow - row-index from viewpublic int getViewRow(int pRow)
pRow - row-index from modelpublic boolean isSorted(int pColumn)
pColumn - index of the column to checkpublic void tableChanged(TableModelEvent pEvent)
tableChanged in interface TableModelListenertableChanged in class TableMappEvent - tableModelEvent from tableModelpublic Object getValueAt(int pRow, int pColumn)
getValueAt in interface TableModelgetValueAt in class TableMappRow - the row whose value is to be looked uppColumn - the column whose value is to be looked uppublic void setValueAt(Object pValue, int pRow, int pColumn)
setValueAt in interface TableModelsetValueAt in class TableMappValue - the new valuepRow - the row whose value is to be changedpColumn - the column whose value is to be changedpublic void sortByColumn(int pColumn)
pColumn - the modelindex of the columnpublic void sortByColumn(int pColumn,
boolean pAscending)
To start a fresh sort call resetColumns() first.
pColumn - the modelindex of the columnpAscending - the sorting directionpublic void dropSorting()
public void resetColumns()
public TableSortInfo getSortInfo()
protected void sort()
This method is made protected as a hook for different sorting implementations.
protected int compareRowsByColumn(int pRow1,
int pRow2,
int pColumn)
This method is made protected as a hook for different sorting implementations.
pRow1 - first row of comparepRow2 - second row of comparepColumn - column to use for compareprotected int compare(int pRow1,
int pRow2)
This method is made protected as a hook for different sorting implementations.
pRow1 - first row of comparepRow2 - second row of compareCopyright © 2017 Jürgen Zeller (privat). All rights reserved.