|
EchoPoint 2.1.0rc4 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnextapp.echo2.app.table.AbstractTableModel
echopointng.table.DefaultSortableTableModel
DefaultSortableTableModel is a decorator for
TableModel's; adding sorting functionality.
DefaultSortableTableModel does not store or copy the data in
its TableModel; instead it maintains a map from the row
indexes of the view to the row indexes of the model.
As requests are made of the sorter (like getValueAt(col, row)) they are passed to the underlying model after the row numbers have been translated via the internal mapping array.
This way, the DefaultSortableTableModel appears to hold
another copy of the table with the rows in a different order.
This also makes this decorator TableModel very light weight
and if no sorting is specified then no extra sorting information is kept.
This code has been adapted from
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#sorting http://java.sun.com/docs/books/tutorial/uiswing/components/examples/TableSorter.java
| Field Summary | |
static java.util.Comparator |
COMPARABLE_COMPARATOR
You can use this comparator if the column objects impment Comparable |
static java.util.Comparator |
LEXICAL_COMPARATOR
This comparator converts the objects into Strings first and then compares them based on lexical order. |
protected nextapp.echo2.app.table.TableModel |
underlyingTableModel
This is the underlying TableModel being decorated by this class |
| Fields inherited from interface echopointng.table.SortableTableModel |
ASCENDING, DESCENDING, NOT_SORTED |
| Constructor Summary | |
DefaultSortableTableModel(nextapp.echo2.app.table.TableColumnModel columnModel)
|
|
DefaultSortableTableModel(nextapp.echo2.app.table.TableModel underlyingTableModel)
Contructs a DefaultSortableTableModel based on the
underlying TableModel |
|
DefaultSortableTableModel(nextapp.echo2.app.table.TableModel underlyingTableModel,
nextapp.echo2.app.table.TableColumnModel columnModel)
Contructs a DefaultSortableTableModel based on the
underlying TableModel and the provided
TableColumnModel |
|
| Method Summary | |
java.lang.Class |
getColumnClass(int column)
|
int |
getColumnCount()
|
java.lang.String |
getColumnName(int column)
|
protected java.util.Comparator |
getComparator(int column)
Called to get a Comparator for a given column. |
int |
getCurrentSortColumn()
Returns the primarily sorted column number. |
int |
getRowCount()
|
int |
getSortDirective(int column)
Returns the sort directive for the specified column |
nextapp.echo2.app.table.TableModel |
getUnderlyingTableModel()
|
java.lang.Object |
getValueAt(int column,
int row)
|
void |
setColumnComparator(java.lang.Class type,
java.util.Comparator comparator)
Colums can be sorted by Class by setting this method. |
void |
setSortDirective(int column,
int sortDirective)
Sets th sort directive for the given TableModel column. |
void |
setUnderlyingTableModel(nextapp.echo2.app.table.TableModel newTableModel)
Sets the underlying TableModel to use for this DefaultSortableTableModel. |
void |
sortByColumn(int column,
int sortDirective)
Sorts the data backing this model based on the given column and sort directive |
int |
toSortedViewRowIndex(int modelRowIndex)
This converts the unsorted model row index into the equivalent sorted view row index. |
int |
toUnsortedModelRowIndex(int viewRowIndex)
This converts the sorted view row index into the equivalent unsorted model row index. |
| Methods inherited from class nextapp.echo2.app.table.AbstractTableModel |
addTableModelListener, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getEventListenerList, removeTableModelListener |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface nextapp.echo2.app.table.TableModel |
addTableModelListener, removeTableModelListener |
| Field Detail |
protected nextapp.echo2.app.table.TableModel underlyingTableModel
public static final java.util.Comparator COMPARABLE_COMPARATOR
public static final java.util.Comparator LEXICAL_COMPARATOR
| Constructor Detail |
public DefaultSortableTableModel(nextapp.echo2.app.table.TableModel underlyingTableModel)
DefaultSortableTableModel based on the
underlying TableModel
underlyingTableModel - -
the underlying and unsorted TableModel
public DefaultSortableTableModel(nextapp.echo2.app.table.TableModel underlyingTableModel,
nextapp.echo2.app.table.TableColumnModel columnModel)
DefaultSortableTableModel based on the
underlying TableModel and the provided
TableColumnModel
underlyingTableModel - -
the underlying and unsorted TableModelcolumnModel - -
the TableColumnModel to usepublic DefaultSortableTableModel(nextapp.echo2.app.table.TableColumnModel columnModel)
| Method Detail |
public nextapp.echo2.app.table.TableModel getUnderlyingTableModel()
TableModelpublic void setUnderlyingTableModel(nextapp.echo2.app.table.TableModel newTableModel)
DefaultSortableTableModel.
newTableModel - -
the new underlying TableModelpublic int getSortDirective(int column)
SortableTableModel
getSortDirective in interface SortableTableModelSortableTableModel.getSortDirective(int)
public void setSortDirective(int column,
int sortDirective)
SortableTableModel
setSortDirective in interface SortableTableModelcolumn - the column in questionsortDirective - must be one of :
SortableTableModel.setSortDirective(int, int)
public void setColumnComparator(java.lang.Class type,
java.util.Comparator comparator)
protected java.util.Comparator getComparator(int column)
column - -
the column in question
Comparator to use to sort the columnpublic int toUnsortedModelRowIndex(int viewRowIndex)
SortableTableModelTableModel row
indexes.
toUnsortedModelRowIndex in interface SortableTableModelviewRowIndex - -
a row index in terms of the sorted view that you want to convert to a
unsorted model row index
SortableTableModel.toUnsortedModelRowIndex(int)public int toSortedViewRowIndex(int modelRowIndex)
SortableTableModel
toSortedViewRowIndex in interface SortableTableModelmodelRowIndex - -
a row index in terms of the unsorted model that you want to convert to
a sorted view row index
SortableTableModel.toSortedViewRowIndex(int)public int getRowCount()
getRowCount in interface nextapp.echo2.app.table.TableModelpublic int getColumnCount()
getColumnCount in interface nextapp.echo2.app.table.TableModelpublic java.lang.String getColumnName(int column)
getColumnName in interface nextapp.echo2.app.table.TableModelpublic java.lang.Class getColumnClass(int column)
getColumnClass in interface nextapp.echo2.app.table.TableModel
public java.lang.Object getValueAt(int column,
int row)
getValueAt in interface nextapp.echo2.app.table.TableModel
public void sortByColumn(int column,
int sortDirective)
SortableTableModel
sortByColumn in interface SortableTableModelcolumn - the column to sort bysortDirective - must be one of :
SortableTableModel.sortByColumn(int, int)public int getCurrentSortColumn()
SortableTableModel
getCurrentSortColumn in interface SortableTableModelSortableTableModel.getCurrentSortColumn()
|
EchoPoint 2.1.0rc4 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||