|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.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 TableModelListener
tableChanged
in class TableSorter
TableRowSorter
public void sort()
sort
in class TableSorter
TableRowSorter
public Object getValueAt(int row, int column)
TableSorter
getValueAt
in interface TableModel
getValueAt
in class TableSorter
TableRowSorter
public void setValueAt(Object value, int row, int column)
setValueAt
in interface TableModel
setValueAt
in class TableSorter
TableRowSorter
public void sortByColumn(int column)
sortByColumn
in class TableSorter
TableRowSorter
public void sortByColumn(int column, boolean ascending)
sortByColumn
in class TableSorter
TableRowSorter
public void addSortedColumn(int column, boolean ascending)
addSortedColumn
in class TableSorter
TableRowSorter
public int[] getSortedColumns()
getSortedColumns
in class TableSorter
TableRowSorter
public boolean isAscending()
isAscending
in class TableSorter
TableRowSorter
public void addMouseListenerToHeaderInTable(JTable table)
addMouseListenerToHeaderInTable
in class TableSorter
table
- the table which header should react on mouse eventsTableRowSorter
public void addKeyListenerToTable(JTable table)
addKeyListenerToTable
in class TableSorter
table
- the table to add the keylistener toTableRowSorter
public int getRowCount()
getRowCount
in interface TableModel
getRowCount
in class TableSorter
TableRowSorter
public int getColumnCount()
getColumnCount
in interface TableModel
getColumnCount
in class TableSorter
TableRowSorter
public String getColumnName(int column)
getColumnName
in interface TableModel
getColumnName
in class TableSorter
TableRowSorter
public Class getColumnClass(int column)
getColumnClass
in interface TableModel
getColumnClass
in class TableSorter
TableRowSorter
public boolean isCellEditable(int row, int column)
isCellEditable
in interface TableModel
isCellEditable
in class TableSorter
TableRowSorter
public TableModel getModel()
getModel
in interface TableViewInterface
getModel
in class TableSorter
TableRowSorter
public int getOriginalIndex(int localIndex)
getOriginalIndex
in interface TableViewInterface
getOriginalIndex
in class TableSorter
localIndex
- the visible index
TableRowSorter
public void setModel(TableModel model)
setModel
in interface TableViewInterface
setModel
in class TableSorter
TableRowSorter
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |