org.archiviststoolkit.mydomain
Class DomainTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.archiviststoolkit.mydomain.DomainTableModel
All Implemented Interfaces:
java.io.Serializable, java.util.EventListener, javax.swing.table.TableModel, DomainAccessListener
Direct Known Subclasses:
DomainRawTableModel, DomainRelatedTableModel

public class DomainTableModel
extends javax.swing.table.AbstractTableModel
implements DomainAccessListener

The model used to display lists of domain objects inside a JTable.

See Also:
Serialized Form

Field Summary
protected  java.lang.Class clazz
          The class of this domain table.
protected  java.util.ArrayList columnModel
          A list of column models.
protected  java.util.ArrayList<DomainObject> domainCollection
          The list of domainobjects to display.
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
DomainTableModel()
           
 
Method Summary
 void addDomainObject(DomainObject object)
           
 void addDomainObject(int index, DomainObject object)
           
 void domainChanged(DomainAccessEvent event)
          Notify this model that the domain has changed state.
 DomainObject get(int index)
          Get a domain object for a specific row in the list.
 java.lang.Class getColumnClass(int index)
          Get the class associated with a column.
 int getColumnCount()
          Get the number of columns.
 java.lang.String getColumnName(int index)
          Get the name of a specific column.
 java.lang.Object getColumnValue(java.lang.Object object, int column)
          Get the value for a specific column.
 java.lang.Class getDomainClass()
          Get the domain model class.
 java.util.ArrayList<DomainObject> getDomainCollection()
           
 int getIndex(DomainObject object)
          Get the row index of a specific domain object.
 int getRowCount()
          Get the number of rows in this domain.
 DomainTableModelColumn getTableModelColumn(int index)
          Get the table model for a specific column.
 java.lang.Object getValueAt(int row, int column)
          Get the value at a specific row or column.
 boolean isCellEditable(int row, int col)
          Get the domain model class.
 void removeDomainObject(int index)
           
 java.lang.Object setColumnValue(java.lang.Object object, int column, java.lang.Object value)
          Get the value for a specific column.
 void setDomainObject(int index, DomainObject object)
           
 void setValueAt(java.lang.Object value, int row, int col)
           
 void updateCollection(java.util.Collection newCollection)
           
 
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
 

Field Detail

clazz

protected java.lang.Class clazz
The class of this domain table.


domainCollection

protected java.util.ArrayList<DomainObject> domainCollection
The list of domainobjects to display.


columnModel

protected java.util.ArrayList columnModel
A list of column models.

Constructor Detail

DomainTableModel

public DomainTableModel()
Method Detail

getTableModelColumn

public DomainTableModelColumn getTableModelColumn(int index)
Get the table model for a specific column.

Parameters:
index - the index of the column
Returns:
the table model for that column

getColumnName

public java.lang.String getColumnName(int index)
Get the name of a specific column.

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

getColumnCount

public int getColumnCount()
Get the number of columns.

Specified by:
getColumnCount in interface javax.swing.table.TableModel
Returns:
the number of columns

getColumnClass

public java.lang.Class getColumnClass(int index)
Get the class associated with a column.

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel
Parameters:
index - the index of the column
Returns:
the class for that column

getColumnValue

public java.lang.Object getColumnValue(java.lang.Object object,
                                       int column)
Get the value for a specific column.

Parameters:
object - the domain object used for this row
column - the column to get
Returns:
the value

setColumnValue

public java.lang.Object setColumnValue(java.lang.Object object,
                                       int column,
                                       java.lang.Object value)
Get the value for a specific column.

Parameters:
object - the domain object used for this row
column - the column to get
Returns:
the value

isCellEditable

public boolean isCellEditable(int row,
                              int col)
Get the domain model class.

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel
Returns:
the domain model class

setValueAt

public void setValueAt(java.lang.Object value,
                       int row,
                       int col)
Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel

getDomainClass

public java.lang.Class getDomainClass()
Get the domain model class.

Returns:
the domain model class

domainChanged

public void domainChanged(DomainAccessEvent event)
Notify this model that the domain has changed state.

Specified by:
domainChanged in interface DomainAccessListener
Parameters:
event - the type of state change

getRowCount

public int getRowCount()
Get the number of rows in this domain.

Specified by:
getRowCount in interface javax.swing.table.TableModel
Returns:
the number of rows

getValueAt

public java.lang.Object getValueAt(int row,
                                   int column)
Get the value at a specific row or column.

Specified by:
getValueAt in interface javax.swing.table.TableModel
Parameters:
row - the row
column - the column
Returns:
the value at that location

get

public DomainObject get(int index)
Get a domain object for a specific row in the list.

Parameters:
index - the index within the row
Returns:
the domain object

getIndex

public int getIndex(DomainObject object)
Get the row index of a specific domain object.

Parameters:
object - the object in question
Returns:
the index within the row list

setDomainObject

public void setDomainObject(int index,
                            DomainObject object)

addDomainObject

public void addDomainObject(DomainObject object)

addDomainObject

public void addDomainObject(int index,
                            DomainObject object)

removeDomainObject

public void removeDomainObject(int index)

updateCollection

public void updateCollection(java.util.Collection newCollection)

getDomainCollection

public java.util.ArrayList<DomainObject> getDomainCollection()