JAC project
AOPSYS
CEDRIC & LIP6 labs

org.objectweb.jac.aspects.gui
Class TableModel

java.lang.Object
  |
  +--javax.swing.table.AbstractTableModel
        |
        +--org.objectweb.jac.aspects.gui.TableModel
All Implemented Interfaces:
CollectionModel, CollectionUpdate, ExtendedTableModel, Model, ObjectUpdate, Serializable, TableModel

public class TableModel
extends AbstractTableModel
implements ExtendedTableModel, ObjectUpdate, CollectionUpdate

The data model for tables.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
TableModel(CollectionItem collection, Object substance, String viewName, ViewFactory factory)
          Creates a new table model.
 
Method Summary
 void addRow(Object object, Object[] data)
           
 void close()
          Unregisters the model from the event it is currently listening to.
 Object getCellRenderer(View tableView, int column, ViewFactory factory, DisplayContext context)
          Build a cell render for a given column.
static Object getCellRenderer(View tableView, Object substance, MemberItem member, String header, ViewFactory factory, DisplayContext context)
           
 CollectionItem getCollection()
          Get the collection item represented by the model
 Class getColumnClass(int column)
           
 int getColumnCount()
           
 String getColumnName(int column)
           
 String[] getHeaders()
          Gets the headers' titles.
 MemberItem[] getMembers()
          Returns the members that are displayed in the table.
 Object getObject(int index)
          Returns the object at the row represented by the given index.
 Object getObject(int row, int col)
          Gets the value at a given row, column couple.
 Object[] getRow(int row)
           
 int getRowCount()
          Gets the number of rows of this collection.
 Object getValueAt(int row, int column)
           
 int indexOf(Object object)
          Returns the index of an object in the collection
 boolean isCellEditable(int row, int column)
           
 void objectUpdated(Object substance, Object param)
          The callback method.
 void onAdd(Object substance, CollectionItem collection, Object value, Object added, Object param)
          Upcalled when an item is added in a collection.
 void onChange(Object substance, CollectionItem collection, Object value, Object param)
          Upcalled when the collection is changed (with a set or other methods such as clear, removeAll, addAll, ...).
 void onRemove(Object substance, CollectionItem collection, Object value, Object removed, Object param)
          Upcalled when an item is removed from a collection.
protected  void registerViews()
          Register ourself as a view on all objects of the collection
protected  void unregisterViews()
          Unregister ourself as a view on all objects of the collection
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, 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
addTableModelListener, removeTableModelListener, setValueAt
 

Constructor Detail

TableModel

public TableModel(CollectionItem collection,
                  Object substance,
                  String viewName,
                  ViewFactory factory)
Creates a new table model.

Parameters:
collection - the substance collection
substance - the object that holds the collection
factory - the used view factory
Method Detail

getCollection

public CollectionItem getCollection()
Description copied from interface: CollectionModel
Get the collection item represented by the model

Specified by:
getCollection in interface CollectionModel
Returns:
a collection item

getCellRenderer

public Object getCellRenderer(View tableView,
                              int column,
                              ViewFactory factory,
                              DisplayContext context)
Description copied from interface: ExtendedTableModel
Build a cell render for a given column.

Specified by:
getCellRenderer in interface ExtendedTableModel
Parameters:
tableView - the actual table view
column - the column for which to build the viewer
factory - the factory to use
context - the display context

getCellRenderer

public static Object getCellRenderer(View tableView,
                                     Object substance,
                                     MemberItem member,
                                     String header,
                                     ViewFactory factory,
                                     DisplayContext context)

getMembers

public MemberItem[] getMembers()
Description copied from interface: ExtendedTableModel
Returns the members that are displayed in the table.

Specified by:
getMembers in interface ExtendedTableModel
Returns:
one member per column

getHeaders

public String[] getHeaders()
Description copied from interface: ExtendedTableModel
Gets the headers' titles.

Specified by:
getHeaders in interface ExtendedTableModel
Returns:
one title per column

getRowCount

public int getRowCount()
Description copied from interface: CollectionModel
Gets the number of rows of this collection.

Specified by:
getRowCount in interface TableModel
Returns:
the number of rows

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface TableModel

getColumnName

public String getColumnName(int column)
Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel

getColumnClass

public Class getColumnClass(int column)
Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel

getValueAt

public Object getValueAt(int row,
                         int column)
Specified by:
getValueAt in interface TableModel

getObject

public Object getObject(int index)
Description copied from interface: CollectionModel
Returns the object at the row represented by the given index.

Specified by:
getObject in interface CollectionModel
Parameters:
index - a row index

indexOf

public int indexOf(Object object)
Description copied from interface: CollectionModel
Returns the index of an object in the collection

Specified by:
indexOf in interface CollectionModel
Parameters:
object - the object whose index to find
Returns:
the index of object, or -1 if the object is not in the collection

getObject

public Object getObject(int row,
                        int col)
Description copied from interface: ExtendedTableModel
Gets the value at a given row, column couple.

Specified by:
getObject in interface ExtendedTableModel

getRow

public Object[] getRow(int row)

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class AbstractTableModel

addRow

public void addRow(Object object,
                   Object[] data)

objectUpdated

public void objectUpdated(Object substance,
                          Object param)
Description copied from interface: ObjectUpdate
The callback method.

Specified by:
objectUpdated in interface ObjectUpdate
Parameters:
substance - the updated object
param - extra data
See Also:
ViewControlWrapper.registerObject(Wrappee,ObjectUpdate,Object)

onChange

public void onChange(Object substance,
                     CollectionItem collection,
                     Object value,
                     Object param)
Description copied from interface: CollectionUpdate
Upcalled when the collection is changed (with a set or other methods such as clear, removeAll, addAll, ...).

Specified by:
onChange in interface CollectionUpdate
Parameters:
substance - the object of which a field was updated
collection - the updated collection
value - the new collection
param - extra data
See Also:
ViewControlWrapper.registerCollection(Wrappee,CollectionItem,CollectionUpdate,Object)

onAdd

public void onAdd(Object substance,
                  CollectionItem collection,
                  Object value,
                  Object added,
                  Object param)
Description copied from interface: CollectionUpdate
Upcalled when an item is added in a collection.

Specified by:
onAdd in interface CollectionUpdate
Parameters:
substance - the object of which a collection was updated
collection - the updated collection
value - the collection's value
added - the value added to the collection
param - extra data (e.g. index)
See Also:
ViewControlWrapper.registerCollection(Wrappee,CollectionItem,CollectionUpdate,Object)

onRemove

public void onRemove(Object substance,
                     CollectionItem collection,
                     Object value,
                     Object removed,
                     Object param)
Description copied from interface: CollectionUpdate
Upcalled when an item is removed from a collection.

Specified by:
onRemove in interface CollectionUpdate
Parameters:
substance - the object of which a collection was updated
collection - the updated collection
value - the collection's value
removed - the removed item
param - extra data (e.g. index)
See Also:
ViewControlWrapper.registerCollection(Wrappee,CollectionItem,CollectionUpdate,Object)

registerViews

protected void registerViews()
Register ourself as a view on all objects of the collection


unregisterViews

protected void unregisterViews()
Unregister ourself as a view on all objects of the collection


close

public void close()
Description copied from interface: Model
Unregisters the model from the event it is currently listening to.

Specified by:
close in interface Model

Contact JAC development team:
Renaud Pawlak
Lionel Seinturier
Laurent Martelli