|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.table.AbstractTableModel
com.antelmann.util.table.SortableTableModel
public class SortableTableModel
a wrapper around a TableModel allowing to sort the model.
| Field Summary | |
|---|---|
static int |
NO_COLUMN
|
| Fields inherited from class javax.swing.table.AbstractTableModel |
|---|
listenerList |
| 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 | |
|---|---|
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 the default would be used for sorting |
Comparator<Object> |
getDefaultComparator()
returns the Comparator in use if the column comparator is null; returns an instance of a UniversalComparator by default |
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()
|
Comparator<?> |
setComparatorForColumn(int column,
Comparator<?> comp)
sets the Comparator for the specified column (may be null, in which case the default comparator is used) |
void |
setDefaultComparator(Comparator<Object> defaultComparator)
allows to specify a general Comparator for columns that have no specific Comparator set |
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
and the second parameter is ignored |
void |
tableChanged(TableModelEvent ev)
public as an implementation side effect; resets the table to its updated model (table is sorted as before herafter) unless it's only a single row that has been updated. |
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). |
TableModel |
unwrap()
returns the embedded instance that this wrapper encloses |
| 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, 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<Object> getDefaultComparator()
UniversalComparatorpublic void setDefaultComparator(Comparator<Object> defaultComparator)
public Comparator<?> setComparatorForColumn(int column,
Comparator<?> comp)
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
NO_COLUMN, the table will be reset to be in an unsorted state
and the second parameter is ignored
IllegalArgumentExceptionpublic TableModel unwrap()
Wrapped
unwrap in interface Wrapped<TableModel>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 TableModelgetColumnName in class AbstractTableModelpublic Class<?> getColumnClass(int column)
getColumnClass in interface TableModelgetColumnClass in class AbstractTableModel
public boolean isCellEditable(int row,
int column)
isCellEditable in interface TableModelisCellEditable in class AbstractTableModel
public Object getValueAt(int row,
int column)
getValueAt in interface TableModel
public void setValueAt(Object value,
int row,
int column)
setValueAt in interface TableModelsetValueAt in class AbstractTableModel
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||