org.jurvis.swing.table
Class JvAbstractObjectTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.jurvis.swing.table.JvAbstractObjectTableModel
All Implemented Interfaces:
Serializable, TableModel, JvObjectTableModel
Direct Known Subclasses:
JvDefaultObjectTableModel

public abstract class JvAbstractObjectTableModel
extends AbstractTableModel
implements JvObjectTableModel

A JvObjectTableModel is a TableModel in which each row is actually a single object (which implements JvObjectTableRow. The columns of a row typically represent different fields of the row object.

Author:
Neil W. Weber
See Also:
JvObjectTableRow, Serialized Form

Field Summary
protected  List rowData
          The List of JvObjectTableRow objects.
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
JvAbstractObjectTableModel()
          Construct a JvObjectTableModel with the given row data.
 
Method Summary
 Class getColumnClass(int columnIndex)
          Return the class of object displayed in the specified column.
 int getColumnCount()
          Returns 0 for the number of columns in this data table.
 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.
protected abstract  JvObjectTableRow getRowAt(int row)
          Return the JvObjectTableRow for the specified row.
 Object getValueAt(int row, int column)
          Returns an attribute value for the cell at row and column.
 boolean isCellEditable(int row, int column)
          Returns true if the cell at row and column is editable.
 void setValueAt(Object value, int row, int column)
          Sets the object value for the cell at column and row.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, 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 javax.swing.table.TableModel
addTableModelListener, getColumnName, getRowCount, removeTableModelListener
 

Field Detail

rowData

protected List rowData
The List of JvObjectTableRow objects.

Constructor Detail

JvAbstractObjectTableModel

public JvAbstractObjectTableModel()
Construct a JvObjectTableModel with the given row data.

Method Detail

getRowAt

protected abstract JvObjectTableRow getRowAt(int row)
Return the JvObjectTableRow for the specified row.

Parameters:
row - the index of the desired row
Returns:
the JvObjectTableRow for the specified row

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 ArrayList

getColumnCount

public int getColumnCount()
Returns 0 for the number of columns in this data table. This method returns 0 because the TableColumnModel should not be created from this TableModel. Columns should be created using the JvSwingFactory.createTableColumn(javax.swing.JTable, java.lang.String, int) method.

Specified by:
getColumnCount in interface TableModel
Returns:
0

getColumnClass

public Class getColumnClass(int columnIndex)
Return the class of object displayed in the specified column. This method makes a guess at the class by querying the row data. If there is no row data, Object is returned.

Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel
Parameters:
columnIndex - the column being queried
Returns:
the class of the object of the specified column

getValueAt

public Object getValueAt(int row,
                         int column)
Returns an attribute value for the cell at row and column.

Specified by:
getValueAt in interface TableModel
Parameters:
row - the row whose value is to be queried
column - the column whose value is to be queried
Returns:
the value Object at the specified cell

setValueAt

public void setValueAt(Object value,
                       int row,
                       int column)
Sets the object value for the cell at column and row. value is the new value. This method will generate a tableChanged notification.

Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel
Parameters:
value - the new value; this can be null
row - the row whose value is to be changed
column - the column whose value is to be changed

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Returns true if the cell at row and column is editable. Otherwise, setValueAt on the cell will not change the value of that cell.

Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class AbstractTableModel
Parameters:
row - the row whose value to be queried
column - the column whose value to be queried
Returns:
true if the cell is editable


Copyright © 1999-2004 Neil W. Weber. All Rights Reserved.