celeboss.ui.util
Class SortedTableModel

java.lang.Object
  extended byjavax.swing.table.AbstractTableModel
      extended byceleboss.ui.util.SortedTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel
Direct Known Subclasses:
MonitorableTableModel

public abstract class SortedTableModel
extends javax.swing.table.AbstractTableModel

This table model holds a list of objects which are sorted to the columns defined.

Version:
1.0
Author:
bevans
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
SortedTableModel()
          Create a model that monitors a set of entities.
 
Method Summary
 int addObject(java.lang.Object newObject)
          Add a new object to this table model.
protected  void cellUpdated(int row, int column)
          Ths value of a cell has been updated in the remote data source.
protected abstract  java.lang.Object getCellValue(java.lang.Object item, int column)
          This method provides the cell vaue for the specified column.
abstract  java.lang.String getColumnDescription(int column)
          This returns a long description for what the data in the specified column represents.
 java.lang.Object getRow(int rowId)
          Return the contents of the specified row.
 int getRowCount()
          Returns the number of celebrities.
 int getRowId(java.lang.Object object)
          Retunr the row index of the specified object.
 java.lang.Object getValueAt(int row, int column)
          Return the object at a specific cell.
 void release()
          This method releases all references to the model and objects.
 int removeObject(java.lang.Object object)
          Remove the specifed object.
 void sortByColumn(int column, boolean ascending)
          Change the sorting parameters.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
 
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
getColumnCount
 

Constructor Detail

SortedTableModel

public SortedTableModel()
Create a model that monitors a set of entities.

Method Detail

addObject

public int addObject(java.lang.Object newObject)
Add a new object to this table model. It will be inserted according to the sorting parameters.

Parameters:
newObject - Object to add.
Returns:
Index of insertion

cellUpdated

protected void cellUpdated(int row,
                           int column)
Ths value of a cell has been updated in the remote data source. This action may trigger a re-sorting of the table.

Parameters:
row - Row id.
column - Column id of changed cell.

getCellValue

protected abstract java.lang.Object getCellValue(java.lang.Object item,
                                                 int column)
This method provides the cell vaue for the specified column.

Parameters:
item - Item for value source.
column - Column index.
Returns:
Object value.

getColumnDescription

public abstract java.lang.String getColumnDescription(int column)
This returns a long description for what the data in the specified column represents. This may be used in a help or tooltip context.

Parameters:
column - Index of target column
Returns:
Description of data

getRow

public java.lang.Object getRow(int rowId)
Return the contents of the specified row.

Parameters:
rowId - Id.
Returns:
Object at row.

getRowCount

public int getRowCount()
Returns the number of celebrities.

See Also:
TableModel.getRowCount()

getRowId

public int getRowId(java.lang.Object object)
Retunr the row index of the specified object.

Parameters:
object - Object to searhc for.
Returns:
Index or -1 if not found.

getValueAt

public java.lang.Object getValueAt(int row,
                                   int column)
Return the object at a specific cell.

Parameters:
row - Row index.
column - column index
Returns:
Object

release

public void release()
This method releases all references to the model and objects.


removeObject

public int removeObject(java.lang.Object object)
Remove the specifed object.

Parameters:
object - Object to remove
Returns:
Index where row was removed.

sortByColumn

public void sortByColumn(int column,
                         boolean ascending)
Change the sorting parameters.

Parameters:
column - Column index for sorting.
ascending - Sort ascending.