|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.util.table.SortableTableModel
public class SortableTableModel
a wrapper around a TableModel allowing to sort the model. Note that this implementation is not synchronized.
| Field Summary | |
|---|---|
static int |
NO_COLUMN
|
| Constructor Summary | |
|---|---|
SortableTableModel(TableModel model,
Comparator<?>... comp)
constructs a SortableTableModel with an embedded model and Comparator objects for each column. |
|
SortableTableModel(TableModel model,
List<Comparator<?>> comp)
constructs a SortableTableModel with an embedded model and Comparator objects for each column. |
|
| Method Summary | |
|---|---|
void |
addTableModelListener(TableModelListener listener)
|
protected void |
finalize()
allows itself to be garbage collected by removing itself as a listener to the embedded model |
Class<?> |
getColumnClass(int column)
|
int |
getColumnCount()
|
String |
getColumnName(int column)
|
Comparator<?> |
getComparatorForColumn(int column)
return value may be null, in wich case a UniversalComparator would be used for sorting |
TableModel |
getModel()
returns the embedded model |
int |
getOriginalRow(int sortedRowPosition)
|
int |
getRowCount()
|
int |
getRowPosition(int originalRow)
|
List<Integer> |
getSortingView()
returns an unmodifiable view of the current sorting |
Object |
getValueAt(int row,
int column)
|
boolean |
isCellEditable(int row,
int column)
|
int |
lastRowSorted()
|
boolean |
lastSortAscending()
|
void |
removeTableModelListener(TableModelListener listener)
|
Comparator<?> |
setComparatorForColumn(Comparator<?> comp,
int column)
sets the Comparator for the specified column (may be null, in which case a UniversalComparator is used) |
void |
setValueAt(Object value,
int row,
int column)
|
void |
sortByColumn(int column)
calls sortByColumn(column, true) |
void |
sortByColumn(int column,
boolean ascending)
if column is NO_COLUMN, the table will be reset to be in an unsorted state |
void |
tableChanged(TableModelEvent ev)
public as an implementation side effect; resets the table to its updated model (table is unsorted herafter) unless it's only a single row that has been updated Note that - in case of structural changes - the Comparators set may not be adequate anymore. |
void |
toggleSorting(int column)
either sorts by the given solumn or - if that column is already sorted - reverses the current column sorting (from ascending to descending or vice versa). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int NO_COLUMN
| Constructor Detail |
|---|
public SortableTableModel(TableModel model,
Comparator<?>... comp)
UniversalComparator
public SortableTableModel(TableModel model,
List<Comparator<?>> comp)
UniversalComparator| Method Detail |
|---|
protected void finalize()
finalize in class Objectpublic Comparator<?> getComparatorForColumn(int column)
public Comparator<?> setComparatorForColumn(Comparator<?> comp,
int column)
public void tableChanged(TableModelEvent ev)
tableChanged in interface TableModelListenerpublic void toggleSorting(int column)
public void sortByColumn(int column)
public void sortByColumn(int column,
boolean ascending)
throws IllegalArgumentException
IllegalArgumentExceptionpublic TableModel getModel()
public int getOriginalRow(int sortedRowPosition)
public int getRowPosition(int originalRow)
public List<Integer> getSortingView()
public int lastRowSorted()
public boolean lastSortAscending()
public int getRowCount()
getRowCount in interface TableModelpublic int getColumnCount()
getColumnCount in interface TableModelpublic String getColumnName(int column)
getColumnName in interface TableModelpublic Class<?> getColumnClass(int column)
getColumnClass in interface TableModel
public boolean isCellEditable(int row,
int column)
isCellEditable in interface TableModel
public Object getValueAt(int row,
int column)
getValueAt in interface TableModel
public void setValueAt(Object value,
int row,
int column)
setValueAt in interface TableModelpublic void addTableModelListener(TableModelListener listener)
addTableModelListener in interface TableModelpublic void removeTableModelListener(TableModelListener listener)
removeTableModelListener in interface TableModel
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||