org.xnap.gui.table
Class AbstractSortableTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.xnap.gui.table.AbstractSortableTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel, SortableModel
Direct Known Subclasses:
AbstractColumnTableModel

public abstract class AbstractSortableTableModel
extends javax.swing.table.AbstractTableModel
implements SortableModel

See Also:
Serialized Form

Field Summary
protected  boolean ascending
           
protected  int compares
          Counts number of compares.
protected  int[] indexes
           
protected  int lastSortedColumn
           
protected  boolean maintainSortOrder
           
protected  int[] revIndexes
           
protected  java.util.Vector sortingColumns
          All columns to be sorted by.
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
AbstractSortableTableModel()
           
AbstractSortableTableModel(boolean maintainSortOrder)
           
 
Method Summary
protected  int compare(int row1, int row2)
          Compares two rows.
protected  int compareRowsByColumn(int row1, int row2, int column)
          Compares two rows by a column.
 void fireTableChanged(javax.swing.event.TableModelEvent e)
          We need to mangle these events to fire the right indicies.
abstract  java.lang.Object get(int aRow, int aColumn)
           
 int getSortedColumn()
          Returns the index of the column that was sorted last.
 java.lang.Object getValueAt(int aRow, int aColumn)
          The mapping only affects the contents of the data rows.
 boolean isCellEditable(int row, int column)
           
 boolean isSortedAscending()
          Returns true, if the table is sorted in ascending order.
 int mapToDtmIndex(int i)
          Deprecated.  
 int mapToIndex(int i)
          Returns the mapped row index.
 void n2sort()
           
protected  void reallocateIndexes()
           
protected  void reallocateIndexes(javax.swing.event.TableModelEvent e)
           
 void resort()
           
 void set(java.lang.Object aValue, int aRow, int aColumn)
           
 void setMaintainSortOrder(boolean newValue)
          Sets the maintain sort order flag.
 void setSortedAscending(boolean newValue)
           
 void setValueAt(java.lang.Object aValue, int aRow, int aColumn)
           
 boolean shuttlesort(int[] from, int[] to, int low, int high)
          Returns false if nothing has changed.
protected  boolean sort()
          Returns false if nothing has changed.
 boolean sortByColumn(int column, boolean ascending, boolean revert)
          Sorts the table.
protected  void swap(int i, int j)
           
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, 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 org.xnap.gui.table.SortableModel
getColumnClass
 
Methods inherited from interface javax.swing.table.TableModel
getColumnCount, getRowCount
 

Field Detail

indexes

protected int[] indexes

revIndexes

protected int[] revIndexes

sortingColumns

protected java.util.Vector sortingColumns
All columns to be sorted by.


ascending

protected boolean ascending

compares

protected int compares
Counts number of compares.


lastSortedColumn

protected int lastSortedColumn

maintainSortOrder

protected boolean maintainSortOrder
Constructor Detail

AbstractSortableTableModel

public AbstractSortableTableModel(boolean maintainSortOrder)

AbstractSortableTableModel

public AbstractSortableTableModel()
Method Detail

fireTableChanged

public void fireTableChanged(javax.swing.event.TableModelEvent e)
We need to mangle these events to fire the right indicies.

Overrides:
fireTableChanged in class javax.swing.table.AbstractTableModel

get

public abstract java.lang.Object get(int aRow,
                                     int aColumn)

getSortedColumn

public int getSortedColumn()
Description copied from interface: SortableModel
Returns the index of the column that was sorted last.

Specified by:
getSortedColumn in interface SortableModel

getValueAt

public java.lang.Object getValueAt(int aRow,
                                   int aColumn)
The mapping only affects the contents of the data rows. Pass all requests to these rows through the mapping array: "indexes".

Specified by:
getValueAt in interface javax.swing.table.TableModel

isSortedAscending

public boolean isSortedAscending()
Description copied from interface: SortableModel
Returns true, if the table is sorted in ascending order.

Specified by:
isSortedAscending in interface SortableModel

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel

mapToDtmIndex

public int mapToDtmIndex(int i)
Deprecated. 

Returns the mapped row index.


mapToIndex

public int mapToIndex(int i)
Returns the mapped row index.


set

public void set(java.lang.Object aValue,
                int aRow,
                int aColumn)

setMaintainSortOrder

public void setMaintainSortOrder(boolean newValue)
Description copied from interface: SortableModel
Sets the maintain sort order flag.

Specified by:
setMaintainSortOrder in interface SortableModel

setSortedAscending

public void setSortedAscending(boolean newValue)

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int aRow,
                       int aColumn)
Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel

sortByColumn

public boolean sortByColumn(int column,
                            boolean ascending,
                            boolean revert)
Sorts the table.

Specified by:
sortByColumn in interface SortableModel
Parameters:
column - the column to sort
ascending - true, if table needs to be sorted in ascending order; false, if in descending order
revert - automatically revert sort order
Returns:
true, if table is sorted ascending; false, if descending

resort

public void resort()

compare

protected int compare(int row1,
                      int row2)
Compares two rows.


compareRowsByColumn

protected int compareRowsByColumn(int row1,
                                  int row2,
                                  int column)
Compares two rows by a column.


reallocateIndexes

protected void reallocateIndexes(javax.swing.event.TableModelEvent e)

reallocateIndexes

protected void reallocateIndexes()

sort

protected boolean sort()
Returns false if nothing has changed.


shuttlesort

public boolean shuttlesort(int[] from,
                           int[] to,
                           int low,
                           int high)
Returns false if nothing has changed.


n2sort

public void n2sort()

swap

protected void swap(int i,
                    int j)


Copyright © 2001-2005 XNap Team. All Rights Reserved.