|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.table.AbstractTableModel
uic.model.TableRowSorter
public class 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 | |
|---|---|
protected TableModel |
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)
|
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. |
void |
updateModel()
|
| 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 |
| Field Detail |
|---|
protected TableModel model
| 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 TableModelListenerpublic void updateModel()
public void sort()
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 AbstractTableModelpublic void sortByColumn(int column)
public void sortByColumn(int column,
boolean ascending)
public void addSortedColumn(int column,
boolean ascending)
public int[] getSortedColumns()
public boolean isAscending()
public void addMouseListenerToHeaderInTable(JTable table)
table - the table which header should react on mouse eventspublic void addKeyListenerToTable(JTable table)
table - the table to add the keylistener topublic 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 AbstractTableModelpublic TableModel getModel()
getModel in interface TableViewInterfacepublic int getOriginalIndex(int localIndex)
getOriginalIndex in interface TableViewInterfacelocalIndex - the visible index
public void setModel(TableModel model)
setModel in interface TableViewInterfacemodel - the new child model this model will start using.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||