ix.iface.ui.table
Class AbstractIXTableModel

java.lang.Object
  |
  +--javax.swing.table.AbstractTableModel
        |
        +--ix.iface.ui.table.AbstractIXTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel
Direct Known Subclasses:
AbstractTreeTableModel

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

An abstract class for table models. Keeps track of the base objects that are shown in the table. Implements most functions required by JTable and IXTable objects to work. Implement the following functions (see documentation below):

See Also:
Serialized Form

Field Summary
protected  java.util.ArrayList columnClasses
           
protected  java.util.ArrayList columnFields
           
protected  java.util.ArrayList columnNames
           
protected  java.lang.Class objectClass
           
protected  java.util.List rows
          a list of objects that appear in the table
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
AbstractIXTableModel()
          Makes an empty model.
AbstractIXTableModel(java.lang.Class theClass, java.lang.Object[] theRows)
          Makes a model that contains the given nodes and derives which fields to use.
AbstractIXTableModel(java.lang.Object[] theRows)
          Makes a model that contains the given nodes.
AbstractIXTableModel(java.lang.Object[] theRows, java.lang.String[] columns)
          Makes a model as above but with the given strings as column names.
 
Method Summary
 void addData(java.lang.Object data)
          Adds the given data object to the table's rows if it is not already there and notifies listeners.
 void clearData()
          Removes all data objects from the table's rows and notifies listeners.
protected  java.lang.Object defaultGetCellValueAt(java.lang.Object o, int columnIndex)
          Looks up the value in the columnField of the given index.
protected  void defaultSetColumnFields(java.lang.String[] fieldNames)
          Sets the fields to be used as table columns
protected  void deriveColumnFields()
          Collects usable fields from the objectClass
abstract  java.lang.Object getCellValueAt(java.lang.Object baseObject, int columnIndex)
          Gets the object's value for the given column index.
 java.lang.Class getColumnClass(int index)
          JTable required TableModel function (default is Object).
 int getColumnCount()
          JTable required TableModel function.
 java.lang.String getColumnName(int index)
          JTable required TableModel function.
protected  java.lang.String[] getColumnNames()
          Gets the strings to use as column names.
 int getObjectRow(java.lang.Object object)
          Gets the row index of the given object
 int getRowCount()
          JTable required TableModel function.
 java.lang.Object getRowObject(int rowIndex)
          Gets the object that is in the given row.
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
          Gets the value for a cell in the table defined by the given indices.
 void removeData(java.lang.Object data)
          Removes the given data object from the table's rows and notifies listeners if it worked.
 void setColumnClasses(java.lang.Class[] fieldClasses)
          Sets the column classes of the table
 void setColumnFields(java.lang.Class objectClass, java.lang.String[] fieldNames)
          Sets the fields to be used as columns in the table
 void setColumnNames(java.lang.String[] fieldNames)
          Sets the column titles to be used in the table
 void setData(java.lang.Object[] data)
          Sets the table's rows to the given data objects and notifies listeners.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, isCellEditable, removeTableModelListener, setValueAt
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

columnFields

protected java.util.ArrayList columnFields

columnNames

protected java.util.ArrayList columnNames

columnClasses

protected java.util.ArrayList columnClasses

objectClass

protected java.lang.Class objectClass

rows

protected java.util.List rows
a list of objects that appear in the table
Constructor Detail

AbstractIXTableModel

public AbstractIXTableModel()
Makes an empty model.

AbstractIXTableModel

public AbstractIXTableModel(java.lang.Object[] theRows)
Makes a model that contains the given nodes.

AbstractIXTableModel

public AbstractIXTableModel(java.lang.Object[] theRows,
                            java.lang.String[] columns)
Makes a model as above but with the given strings as column names.

AbstractIXTableModel

public AbstractIXTableModel(java.lang.Class theClass,
                            java.lang.Object[] theRows)
Makes a model that contains the given nodes and derives which fields to use.
Method Detail

setData

public void setData(java.lang.Object[] data)
Sets the table's rows to the given data objects and notifies listeners.

addData

public void addData(java.lang.Object data)
Adds the given data object to the table's rows if it is not already there and notifies listeners.

removeData

public void removeData(java.lang.Object data)
Removes the given data object from the table's rows and notifies listeners if it worked.

clearData

public void clearData()
Removes all data objects from the table's rows and notifies listeners.

getRowObject

public java.lang.Object getRowObject(int rowIndex)
Gets the object that is in the given row.
Returns:
the object or null if there is no such row.

getObjectRow

public int getObjectRow(java.lang.Object object)
Gets the row index of the given object
Returns:
the object's index or -1 if there is no such object.

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
Gets the value for a cell in the table defined by the given indices. Looks up the object and calls the abstract object-index method.
Overrides:
getValueAt in class javax.swing.table.AbstractTableModel

getRowCount

public int getRowCount()
JTable required TableModel function.
Overrides:
getRowCount in class javax.swing.table.AbstractTableModel

getColumnCount

public int getColumnCount()
JTable required TableModel function.
Overrides:
getColumnCount in class javax.swing.table.AbstractTableModel

getColumnName

public java.lang.String getColumnName(int index)
JTable required TableModel function.
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel

getColumnClass

public java.lang.Class getColumnClass(int index)
JTable required TableModel function (default is Object).
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel

getCellValueAt

public abstract java.lang.Object getCellValueAt(java.lang.Object baseObject,
                                                int columnIndex)
Gets the object's value for the given column index.
Returns:
an object that can be rendered by the table.

setColumnNames

public void setColumnNames(java.lang.String[] fieldNames)
Sets the column titles to be used in the table

setColumnClasses

public void setColumnClasses(java.lang.Class[] fieldClasses)
Sets the column classes of the table

getColumnNames

protected java.lang.String[] getColumnNames()
Gets the strings to use as column names.

setColumnFields

public void setColumnFields(java.lang.Class objectClass,
                            java.lang.String[] fieldNames)
Sets the fields to be used as columns in the table

deriveColumnFields

protected void deriveColumnFields()
Collects usable fields from the objectClass

defaultSetColumnFields

protected void defaultSetColumnFields(java.lang.String[] fieldNames)
Sets the fields to be used as table columns

defaultGetCellValueAt

protected java.lang.Object defaultGetCellValueAt(java.lang.Object o,
                                                 int columnIndex)
Looks up the value in the columnField of the given index.
Returns:
the value object or null if something goes wrong.