|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.table.AbstractTableModel | +--org.objectweb.jac.aspects.gui.TableMap | +--org.objectweb.jac.aspects.gui.TableSorter
A sorter for TableModels. The sorter has a model (conforming to TableModel) and itself implements TableModel. TableSorter 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 TableSorter 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.
Field Summary | |
protected ExtendedTableModel |
model
|
Fields inherited from class javax.swing.table.AbstractTableModel |
listenerList |
Constructor Summary | |
TableSorter()
|
|
TableSorter(ExtendedTableModel model)
|
Method Summary | |
void |
checkModel()
|
void |
close()
Unregisters the model from the event it is currently listening to. |
int |
compare(int row1,
int row2)
|
int |
compareRowsByColumn(int row1,
int row2,
int column)
|
void |
defaultSortOrder()
Sets the sort column for the collection from the context or from RTTI configuration. |
int |
getActualIndex(int row)
|
Object |
getCellRenderer(View tableView,
int column,
ViewFactory factory,
DisplayContext context)
Build a cell render for a given column. |
CollectionItem |
getCollection()
Get the collection item represented by the model |
Class |
getColumnClass(int aColumn)
|
int |
getColumnCount()
|
int |
getColumnIndex(FieldItem field)
|
String |
getColumnName(int aColumn)
|
TableFilter |
getFilter()
|
String[] |
getHeaders()
Gets the headers' titles. |
MemberItem[] |
getMembers()
Returns the members that are displayed in the table. |
ExtendedTableModel |
getModel()
|
Object |
getObject(int row)
Returns the object at the row represented by the given index. |
Object |
getObject(int row,
int column)
Gets the value at a given row, column couple. |
int |
getRowCount()
Gets the number of rows of this collection. |
SortCriteria |
getSortCriteria(int column)
Gets the sort criteria for a column. |
TableSorter |
getSorter()
|
Object |
getValueAt(int aRow,
int aColumn)
|
int |
indexOf(Object object)
Returns the index of an object in the collection |
boolean |
isCellEditable(int row,
int column)
|
void |
n2sort()
|
void |
reallocateIndexes()
Reset to default unsorted order of the model. |
protected void |
saveSortCriteria(SortCriteria criteria)
Save the sort criteria in the context |
void |
setModel(ExtendedTableModel model)
|
void |
setValueAt(Object aValue,
int aRow,
int aColumn)
|
void |
shuttlesort(int[] from,
int[] to,
int low,
int high)
|
void |
sort(Object sender)
|
void |
sortByColumn(int column)
Sorts using values of a column |
void |
sortByColumn(int column,
boolean ascending)
|
void |
swap(int i,
int j)
|
void |
tableChanged(TableModelEvent e)
|
void |
toggleSortByColumn(int column)
Sorts using values of a column. |
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 |
Methods inherited from interface javax.swing.table.TableModel |
addTableModelListener, removeTableModelListener |
Field Detail |
protected ExtendedTableModel model
Constructor Detail |
public TableSorter()
public TableSorter(ExtendedTableModel model)
Method Detail |
public SortCriteria getSortCriteria(int column)
public void setModel(ExtendedTableModel model)
setModel
in class org.objectweb.jac.aspects.gui.TableMap
public void defaultSortOrder()
public int compareRowsByColumn(int row1, int row2, int column)
public int compare(int row1, int row2)
public void reallocateIndexes()
public int getActualIndex(int row)
public void tableChanged(TableModelEvent e)
tableChanged
in interface TableModelListener
tableChanged
in class org.objectweb.jac.aspects.gui.TableMap
public void checkModel()
public void sort(Object sender)
public void n2sort()
public void shuttlesort(int[] from, int[] to, int low, int high)
public void swap(int i, int j)
public Object getValueAt(int aRow, int aColumn)
getValueAt
in interface TableModel
getValueAt
in class org.objectweb.jac.aspects.gui.TableMap
public Object getObject(int row)
CollectionModel
getObject
in interface CollectionModel
getObject
in class org.objectweb.jac.aspects.gui.TableMap
row
- a row indexpublic int indexOf(Object object)
CollectionModel
indexOf
in interface CollectionModel
indexOf
in class org.objectweb.jac.aspects.gui.TableMap
object
- the object whose index to find
public Object getObject(int row, int column)
ExtendedTableModel
getObject
in interface ExtendedTableModel
getObject
in class org.objectweb.jac.aspects.gui.TableMap
public void setValueAt(Object aValue, int aRow, int aColumn)
setValueAt
in interface TableModel
setValueAt
in class org.objectweb.jac.aspects.gui.TableMap
public void sortByColumn(int column)
column
- index of column to sort bypublic void toggleSortByColumn(int column)
column
- index of column to sort bypublic void sortByColumn(int column, boolean ascending)
protected void saveSortCriteria(SortCriteria criteria)
criteria
- the sort criteria to savepublic ExtendedTableModel getModel()
public CollectionItem getCollection()
CollectionModel
getCollection
in interface CollectionModel
public int getRowCount()
CollectionModel
getRowCount
in interface TableModel
public int getColumnCount()
getColumnCount
in interface TableModel
public String getColumnName(int aColumn)
getColumnName
in interface TableModel
getColumnName
in class AbstractTableModel
public Class getColumnClass(int aColumn)
getColumnClass
in interface TableModel
getColumnClass
in class AbstractTableModel
public boolean isCellEditable(int row, int column)
isCellEditable
in interface TableModel
isCellEditable
in class AbstractTableModel
public Object getCellRenderer(View tableView, int column, ViewFactory factory, DisplayContext context)
ExtendedTableModel
getCellRenderer
in interface ExtendedTableModel
tableView
- the actual table viewcolumn
- the column for which to build the viewerfactory
- the factory to usecontext
- the display contextpublic MemberItem[] getMembers()
ExtendedTableModel
getMembers
in interface ExtendedTableModel
public String[] getHeaders()
ExtendedTableModel
getHeaders
in interface ExtendedTableModel
public int getColumnIndex(FieldItem field)
getColumnIndex
in interface ExtendedTableModel
public void close()
Model
close
in interface Model
public TableFilter getFilter()
getFilter
in interface ExtendedTableModel
public TableSorter getSorter()
getSorter
in interface ExtendedTableModel
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |