com.objectwave.persist.gui
Class PersistenceAttributeTableModel

java.lang.Object
  |
  +--javax.swing.table.AbstractTableModel
        |
        +--com.objectwave.persist.gui.PersistenceAttributeTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class PersistenceAttributeTableModel
extends javax.swing.table.AbstractTableModel

The TableModel interface ispecifies the methods the JTable will use to interrogate a tabular data model.

The JTable can be set up to display any data model which implements the TableModel interface with a couple of lines of code:

TableModel myData = new MyTableModel(); JTable table = new JTable(myData);

Version:
1.2
Author:
Dave Hoag
See Also:
JTable, AbstractTableModel, Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
PersistenceAttributeTableModel()
           
 
Method Summary
 java.lang.Class getColumnClass(int columnIndex)
          Returns the lowest common denominator Class in the column.
 int getColumnCount()
          Returns the number of columns managed by the data source object.
 java.lang.String getColumnName(int columnIndex)
          Returns the name of the column at columnIndex.
 int getRowCount()
          Returns the number of records managed by the data source object.
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
          Returns an attribute value for the cell at columnIndex and rowIndex.
 boolean isCellEditable(int rowIndex, int columnIndex)
          Returns true if the cell at rowIndex and columnIndex is editable.
 void setSubject(Persistence p)
           
 void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
          Sets an attribute value for the record in the cell at columnIndex and rowIndex.
 
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
 

Constructor Detail

PersistenceAttributeTableModel

public PersistenceAttributeTableModel()
Method Detail

getColumnClass

public java.lang.Class getColumnClass(int columnIndex)
Returns the lowest common denominator Class in the column. This is used by the table to set up a default renderer and editor for the column.

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel
Returns:
the common ancestor class of the object values in the model.

getColumnCount

public int getColumnCount()
Returns the number of columns managed by the data source object. A JTable uses this method to determine how many columns it should create and display on initialization.

Returns:
the number or columns in the model
See Also:
getRowCount()

getColumnName

public java.lang.String getColumnName(int columnIndex)
Returns the name of the column at columnIndex. This is used to initialize the table's column header name. Note, this name does not need to be unique. Two columns on a table can have the same name.

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Parameters:
columnIndex - the index of column
Returns:
the name of the column

getRowCount

public int getRowCount()
Returns the number of records managed by the data source object. A JTable uses this method to determine how many rows it should create and display. This method should be quick, as it is call by JTable quite frequently.

Returns:
the number or rows in the model
See Also:
getColumnCount()

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
Returns an attribute value for the cell at columnIndex and rowIndex.

Parameters:
rowIndex - the row whose value is to be looked up
columnIndex - the column whose value is to be looked up
Returns:
the value Object at the specified cell

isCellEditable

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

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel
Parameters:
rowIndex - the row whose value is to be looked up
columnIndex - the column whose value is to be looked up
Returns:
true if the cell is editable.
See Also:
#setValueAt()

setSubject

public void setSubject(Persistence p)

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int rowIndex,
                       int columnIndex)
Sets an attribute value for the record in the cell at columnIndex and rowIndex. aValue is the new value.

Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel
Parameters:
aValue - the new value
rowIndex - the row whose value is to be changed
columnIndex - the column whose value is to be changed
See Also:
#getValueAt(), #isCellEditable()