|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnextapp.echo.table.AbstractTableModel
echopoint.table.TableModelAdapter
echopoint.table.SortableTableModel
public class SortableTableModel
A sorter of 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.
This class uses a Comparator to sort the data. The DefaultSortableTableModel comparator is used by default, which can sort Java basisc types as well as some Echo Components.
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 rows around when the Comparator returns 0 to denote that they are equivalent.
Field Summary | |
---|---|
static int |
COMPARATOR_STYLE_BEAN
|
static int |
COMPARATOR_STYLE_PROPERTYCOMPONENT
|
static int |
COMPARATOR_STYLE_VALUE
|
static int |
DOWN
|
static int |
NONE
allowable states for a column |
static int |
UP
|
Fields inherited from class echopoint.table.TableModelAdapter |
---|
model |
Fields inherited from class nextapp.echo.table.AbstractTableModel |
---|
listenerList |
Constructor Summary | |
---|---|
SortableTableModel()
SortableTableModel constructor |
|
SortableTableModel(TableModel model)
SortableTableModel constructor that wraps the given TableModel. |
Method Summary | |
---|---|
int |
getColumnSortingState(int col)
This method returns the state of a given column and whether it is being sorted UP, DOWN or NONE. |
java.util.Comparator |
getComparator(ColumnSortCriterion columnSortCriterion)
Returns the Comparator that will be used to sort the TableModel |
int |
getComparatorStyle()
|
int |
getModelRowIndex(int row)
This returns the "sorted" table model row index for a given "visual" table row index. |
int |
getSortableRowIndex(int modelIndex)
|
java.lang.Object |
getValueAt(int col,
int row)
Returns the "sorted" value at the given column and row. |
boolean |
isRowEditable(int row)
When a table model supports editing of data, this method will be called to query if a row is currently editable. |
void |
setComparator(java.util.Comparator newComparator)
Sets the Comparator that will be used to sort the TableModel |
void |
setComparatorStyle(int comparatorStyle)
|
void |
setModel(TableModel model)
Sets the model wrapped by this SortableTableModel. |
void |
sortByColumn(int column)
Sorts the model by the given column, in ascending order. |
void |
sortByColumn(int column,
boolean ascending)
Sorts the model by the given column, with the given ordering |
void |
sortByColumns(java.util.List columnSortCriteria)
Sorts the model by the given columns, with the given ordering |
void |
tableChanged(TableModelEvent e)
Implementation of TableModelListener |
Methods inherited from class echopoint.table.TableModelAdapter |
---|
deleteRow, getColumnClass, getColumnCount, getColumnName, getModel, getRowCount, insertRow |
Methods inherited from class nextapp.echo.table.AbstractTableModel |
---|
addTableModelListener, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, removeTableModelListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DOWN
public static final int NONE
public static final int UP
public static final int COMPARATOR_STYLE_PROPERTYCOMPONENT
public static final int COMPARATOR_STYLE_VALUE
public static final int COMPARATOR_STYLE_BEAN
Constructor Detail |
---|
public SortableTableModel()
public SortableTableModel(TableModel model)
Method Detail |
---|
public int getColumnSortingState(int col)
public java.util.Comparator getComparator(ColumnSortCriterion columnSortCriterion)
public int getModelRowIndex(int row)
public java.lang.Object getValueAt(int col, int row)
getValueAt
in interface TableModel
getValueAt
in class TableModelAdapter
col
- The column of the value to return.row
- The row of the value to return.TableModel
public void setComparator(java.util.Comparator newComparator)
newComparator
- java.util.Comparatorpublic void setModel(TableModel model)
setModel
in class TableModelAdapter
TableModel
public void sortByColumn(int column)
public void sortByColumn(int column, boolean ascending)
public void sortByColumns(java.util.List columnSortCriteria)
public void tableChanged(TableModelEvent e)
tableChanged
in interface TableModelListener
tableChanged
in class TableModelAdapter
e
- The event describing the action.TableModel
public boolean isRowEditable(int row)
TableModel
When a table model supports editing of data, this method will be called to query if a row is currently editable.
isRowEditable
in interface TableModel
isRowEditable
in class TableModelAdapter
public int getSortableRowIndex(int modelIndex)
public int getComparatorStyle()
public void setComparatorStyle(int comparatorStyle)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |