org.jurvis.swing.table
Class JvDefaultSortableTableModel
java.lang.Object
javax.swing.table.AbstractTableModel
org.jurvis.swing.table.JvTableMap
org.jurvis.swing.table.JvDefaultSortableTableModel
- All Implemented Interfaces:
- Serializable, EventListener, TableModelListener, TableModel, JvObjectTableModel, JvSortableTableModel
public class JvDefaultSortableTableModel
- extends JvTableMap
- implements JvSortableTableModel, JvObjectTableModel
- See Also:
- Serialized Form
|
Method Summary |
protected void |
checkModel()
|
protected int |
compare(int row1,
int row2)
|
protected int |
compareRowsByColumn(int row1,
int row2,
int column)
|
Collection |
getEmptyCollection()
Return an empty collection suitable for putting the selected items
within. |
Object |
getObjectAt(int row)
Return the domain object associated with the specified row. |
int |
getSortColumn()
Returns the table model index of the column the model is sorted on. |
Object |
getValueAt(int aRow,
int aColumn)
|
boolean |
isAscending()
Return whether the sort is ascending or descending. |
int |
mapRow(int aRow)
|
protected void |
n2sort()
|
protected void |
reallocateIndexes()
|
void |
setAscending(boolean ascending)
Set whether the sort is ascending or descending. |
void |
setModel(TableModel model)
|
void |
setSortColumn(int columnIndex)
Sort the rows by the column with the specified table model index. |
void |
setValueAt(Object aValue,
int aRow,
int aColumn)
|
protected void |
shuttlesort(int[] from,
int[] to,
int low,
int high)
|
void |
sort(Object sender)
|
void |
sortByColumn(int columnIndex,
boolean ascending)
Set the column to sort by and whether the sort is ascending or
descending in one swoop. |
protected void |
swap(int i,
int j)
|
void |
tableChanged(TableModelEvent e)
|
| 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 |
indexes
protected int[] indexes
sortColumn
protected int sortColumn
ascending
protected boolean ascending
compares
protected int compares
JvDefaultSortableTableModel
public JvDefaultSortableTableModel()
JvDefaultSortableTableModel
public JvDefaultSortableTableModel(TableModel model)
checkModel
protected final void checkModel()
compare
protected int compare(int row1,
int row2)
compareRowsByColumn
protected int compareRowsByColumn(int row1,
int row2,
int column)
getValueAt
public Object getValueAt(int aRow,
int aColumn)
- Specified by:
getValueAt in interface TableModel- Overrides:
getValueAt in class JvTableMap
mapRow
public int mapRow(int aRow)
n2sort
protected void n2sort()
reallocateIndexes
protected void reallocateIndexes()
setModel
public void setModel(TableModel model)
- Overrides:
setModel in class JvTableMap
setValueAt
public void setValueAt(Object aValue,
int aRow,
int aColumn)
- Specified by:
setValueAt in interface TableModel- Overrides:
setValueAt in class JvTableMap
shuttlesort
protected void shuttlesort(int[] from,
int[] to,
int low,
int high)
sort
public void sort(Object sender)
setSortColumn
public void setSortColumn(int columnIndex)
- Description copied from interface:
JvSortableTableModel
- Sort the rows by the column with the specified table model index.
- Specified by:
setSortColumn in interface JvSortableTableModel
- Parameters:
columnIndex - the index of the column, or -1 for no sorting
getSortColumn
public int getSortColumn()
- Description copied from interface:
JvSortableTableModel
- Returns the table model index of the column the model is sorted on.
- Specified by:
getSortColumn in interface JvSortableTableModel
- Returns:
- the index of the sort column, or -1 if not sorted
setAscending
public void setAscending(boolean ascending)
- Description copied from interface:
JvSortableTableModel
- Set whether the sort is ascending or descending.
- Specified by:
setAscending in interface JvSortableTableModel
- Parameters:
ascending - true if the sort is ascending, false otherwise
isAscending
public boolean isAscending()
- Description copied from interface:
JvSortableTableModel
- Return whether the sort is ascending or descending.
- Specified by:
isAscending in interface JvSortableTableModel
- Returns:
- true if the sort is ascending, false otherwise
sortByColumn
public void sortByColumn(int columnIndex,
boolean ascending)
- Description copied from interface:
JvSortableTableModel
- Set the column to sort by and whether the sort is ascending or
descending in one swoop. Using this method is equivalent to a call to
JvSortableTableModel.setSortColumn(int) and a call to JvSortableTableModel.setAscending(boolean) but only
causes a single sort of the data instead of two.
- Specified by:
sortByColumn in interface JvSortableTableModel
- Parameters:
columnIndex - the index of the column, or -1 for no sortingascending - true if the sort is ascending, false otherwise
swap
protected final void swap(int i,
int j)
tableChanged
public void tableChanged(TableModelEvent e)
- Specified by:
tableChanged in interface TableModelListener- Overrides:
tableChanged in class JvTableMap
getObjectAt
public Object getObjectAt(int row)
- Return the domain object associated with the specified row.
- Specified by:
getObjectAt in interface JvObjectTableModel
- Parameters:
row - the index of the desired row
- Returns:
- the domain object for the specified row
getEmptyCollection
public Collection getEmptyCollection()
- Return an empty collection suitable for putting the selected items
within.
- Specified by:
getEmptyCollection in interface JvObjectTableModel
- Returns:
- an empty collection
Copyright © 1999-2004 Neil W. Weber. All Rights Reserved.