|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjavax.swing.table.AbstractTableModel
uic.widgets.TableSorter
uic.model.TableRowSorter
A sorter for TableModels. The sorter has a model (conforming to TableModel) and itself implements TableModel. TableRowSorter 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. 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 TableRowSorter 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 around rows when its comparison function returns 0 to denote that they are equivalent. Various bugfixes and make-faster patches by Roy van der Kuil and Thomas Zander
| Field Summary |
| Fields inherited from class uic.widgets.TableSorter |
model |
| Fields inherited from class javax.swing.table.AbstractTableModel |
listenerList |
| Constructor Summary | |
TableRowSorter()
Empty constructor, be sure to do a 'setModel' afterwards. |
|
TableRowSorter(TableModel model)
Main constructor; creates a new table sorter wrapping your data model to pass to that table. |
|
| Method Summary | |
void |
addKeyListenerToTable(JTable table)
Add a key listener to the table for making it possible to browse with key events |
void |
addMouseListenerToHeaderInTable(JTable table)
Adds functionality so that clicking on the table header of the given JTable Changes the sorting of the corresponding column |
void |
addSortedColumn(int column,
boolean ascending)
Add a sorting column in a given direction |
Class |
getColumnClass(int column)
Return the column class of the specified column index |
int |
getColumnCount()
Return number of columns that this model has |
String |
getColumnName(int column)
Return the column name of the specified column index |
TableModel |
getModel()
Returns the (data) model |
int |
getOriginalIndex(int localIndex)
Return the original index of the view index |
int |
getRowCount()
Return number of rows that this model has |
int[] |
getSortedColumns()
Returns all sorted columns or an empty array if no columns are being sorted |
Object |
getValueAt(int row,
int column)
Deprectated class since the original has been moved to uic.model. |
boolean |
isAscending()
Is current sort ascending? |
boolean |
isCellEditable(int row,
int column)
Returns true if cell is editable Per default ONLY booleans are editable |
void |
setModel(TableModel model)
set the (data)model this sorter wraps. |
void |
setValueAt(Object value,
int row,
int column)
Update cell value |
void |
sort()
This is the general, please sort me, method. |
void |
sortByColumn(int column)
Sort column |
void |
sortByColumn(int column,
boolean ascending)
Sort column in a given direction |
void |
tableChanged(TableModelEvent e)
React on table change events. |
| Methods inherited from class uic.widgets.TableSorter |
getOrgIndex, n2sort |
| 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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public TableRowSorter()
public TableRowSorter(TableModel model)
UICDefaultTableModel tableTableModel = new UICDefaultTableModel();
tableTableModel.addColumn(translate().i18n("Name"));
tableTableModel.addColumn(translate().i18n("Address"));
tableTableModel.addColumn(translate().i18n("City"));
TableRowSorter sorter = new TableRowSorter(tableTableModel);
table = new UICTable(sorter);
| Method Detail |
public void tableChanged(TableModelEvent e)
tableChanged in interface TableModelListenertableChanged in class TableSorterTableRowSorterpublic void sort()
sort in class TableSorterTableRowSorter
public Object getValueAt(int row,
int column)
TableSorter
getValueAt in interface TableModelgetValueAt in class TableSorterTableRowSorter
public void setValueAt(Object value,
int row,
int column)
setValueAt in interface TableModelsetValueAt in class TableSorterTableRowSorterpublic void sortByColumn(int column)
sortByColumn in class TableSorterTableRowSorter
public void sortByColumn(int column,
boolean ascending)
sortByColumn in class TableSorterTableRowSorter
public void addSortedColumn(int column,
boolean ascending)
addSortedColumn in class TableSorterTableRowSorterpublic int[] getSortedColumns()
getSortedColumns in class TableSorterTableRowSorterpublic boolean isAscending()
isAscending in class TableSorterTableRowSorterpublic void addMouseListenerToHeaderInTable(JTable table)
addMouseListenerToHeaderInTable in class TableSortertable - the table which header should react on mouse eventsTableRowSorterpublic void addKeyListenerToTable(JTable table)
addKeyListenerToTable in class TableSortertable - the table to add the keylistener toTableRowSorterpublic int getRowCount()
getRowCount in interface TableModelgetRowCount in class TableSorterTableRowSorterpublic int getColumnCount()
getColumnCount in interface TableModelgetColumnCount in class TableSorterTableRowSorterpublic String getColumnName(int column)
getColumnName in interface TableModelgetColumnName in class TableSorterTableRowSorterpublic Class getColumnClass(int column)
getColumnClass in interface TableModelgetColumnClass in class TableSorterTableRowSorter
public boolean isCellEditable(int row,
int column)
isCellEditable in interface TableModelisCellEditable in class TableSorterTableRowSorterpublic TableModel getModel()
getModel in interface TableViewInterfacegetModel in class TableSorterTableRowSorterpublic int getOriginalIndex(int localIndex)
getOriginalIndex in interface TableViewInterfacegetOriginalIndex in class TableSorterlocalIndex - the visible index
TableRowSorterpublic void setModel(TableModel model)
setModel in interface TableViewInterfacesetModel in class TableSorterTableRowSorter
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||