nl.tudelft.simulation.introspection.gui
Class CollectionTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by nl.tudelft.simulation.introspection.gui.CollectionTableModel
All Implemented Interfaces:
Serializable, TableModel, IntrospectingTableModelInterface, DynamicTableModel

public class CollectionTableModel
extends AbstractTableModel
implements IntrospectingTableModelInterface, DynamicTableModel

A tablemodel used to manage and present the instances of a composite property.

(c) copyright 2002-2005-2004 Delft University of Technology , the Netherlands.
See for project information www.simulation.tudelft.nl
License of use: Lesser General Public License (LGPL) , no warranty.

Since:
1.4
Version:
1.1 Apr 15, 2004
Author:
Niels Lang Peter Jacobs
See Also:
Serialized Form

Field Summary
protected  Map instances
          the instances of the collection
protected  List keys
          the keys identifying specific instances
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
CollectionTableModel(Property parentProperty)
          constructs a new CollectionTableModel
CollectionTableModel(Property parentProperty, Introspector introspector)
          constructs a new CollectionTableModel
 
Method Summary
 void createRow()
          Creates a new row at the end of the TableModel.
 void createRows(int amount)
          Creates a number of new rows at the end of the TableModel
 void deleteRow(int index)
          Deletes a specific row from the TableModel.
 void deleteRows(int[] indices)
          Deletes a specific set of rows from the TableModel.
 Class getColumnClass(int columnIndex)
           
 int getColumnCount()
           
 String getColumnName(int columnIndex)
           
 Introspector getIntrospector()
           
 ModelManager getModelManager()
          By default, a {see DefaultModelManager}returned.
protected  Property getProperty(int index)
           
 Property getProperty(String propertyName)
          The collection table model labels all properties according to their rowIndex.
 int getRowCount()
           
 Class getTypeAt(int rowIndex, int columnIndex)
          gets the class of the the object at row,column.
 Object getValueAt(int rowIndex, int columnIndex)
           
 boolean isCellEditable(int rowIndex, int columnIndex)
           
 boolean isRowEditable()
           
 void setModelManager(ModelManager manager)
          Sets the modelmanager.
 void setValueAt(Object aValue, int rowIndex, int columnIndex)
           
 
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
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, removeTableModelListener
 

Field Detail

instances

protected Map instances
the instances of the collection


keys

protected List keys
the keys identifying specific instances

Constructor Detail

CollectionTableModel

public CollectionTableModel(Property parentProperty)
constructs a new CollectionTableModel

Parameters:
parentProperty - the parentPropert

CollectionTableModel

public CollectionTableModel(Property parentProperty,
                            Introspector introspector)
constructs a new CollectionTableModel

Parameters:
parentProperty - the parentProperty
introspector - the introspector to use
Method Detail

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface TableModel
See Also:
TableModel.getRowCount()

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface TableModel
See Also:
TableModel.getColumnCount()

getValueAt

public Object getValueAt(int rowIndex,
                         int columnIndex)
Specified by:
getValueAt in interface TableModel
See Also:
TableModel.getValueAt(int, int)

getColumnName

public String getColumnName(int columnIndex)
Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel
See Also:
TableModel.getColumnName(int)

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class AbstractTableModel
See Also:
TableModel.isCellEditable(int, int)

setValueAt

public void setValueAt(Object aValue,
                       int rowIndex,
                       int columnIndex)
Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel
See Also:
TableModel.setValueAt(Object, int, int)

getColumnClass

public Class getColumnClass(int columnIndex)
Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel
See Also:
TableModel.getColumnClass(int)

getProperty

public Property getProperty(String propertyName)
The collection table model labels all properties according to their rowIndex. Only these labels are expected to be requested here.

Specified by:
getProperty in interface IntrospectingTableModelInterface
Parameters:
propertyName - The name of the Property to be returned
Returns:
The Property corresponding to 'propertyName', null if the property could not be found.
See Also:
#getProperty(java.lang.String)

getProperty

protected Property getProperty(int index)
Parameters:
index - the index of the property
Returns:
the Property

createRow

public void createRow()
Description copied from interface: DynamicTableModel
Creates a new row at the end of the TableModel.

Specified by:
createRow in interface DynamicTableModel
See Also:
DynamicTableModel.createRow()

createRows

public void createRows(int amount)
Description copied from interface: DynamicTableModel
Creates a number of new rows at the end of the TableModel

Specified by:
createRows in interface DynamicTableModel
Parameters:
amount - The number of rows to be created.
See Also:
DynamicTableModel.createRows(int)

deleteRow

public void deleteRow(int index)
Description copied from interface: DynamicTableModel
Deletes a specific row from the TableModel.

Specified by:
deleteRow in interface DynamicTableModel
Parameters:
index - The (TableModel) index of the row to be deleted
See Also:
DynamicTableModel.deleteRow(int)

deleteRows

public void deleteRows(int[] indices)
Description copied from interface: DynamicTableModel
Deletes a specific set of rows from the TableModel.

Specified by:
deleteRows in interface DynamicTableModel
Parameters:
indices - The (TableModel) indices of the rows to be deleted
See Also:
DynamicTableModel.deleteRows(int[])

getIntrospector

public Introspector getIntrospector()
Specified by:
getIntrospector in interface IntrospectingTableModelInterface
Returns:
The introspector instance used by this introspecting TableModel.
See Also:
#getIntrospector()

getTypeAt

public Class getTypeAt(int rowIndex,
                       int columnIndex)
Description copied from interface: IntrospectingTableModelInterface
gets the class of the the object at row,column.

Specified by:
getTypeAt in interface IntrospectingTableModelInterface
Parameters:
rowIndex - the rowNumber
columnIndex - the columnNumber
Returns:
The type of the value in cell 'rowIndex', 'columnIndex'
See Also:
#getTypeAt(int,int)

setModelManager

public void setModelManager(ModelManager manager)
Sets the modelmanager. By default, a {see DefaultModelManager}is used.

Parameters:
manager - the manager

getModelManager

public ModelManager getModelManager()
By default, a {see DefaultModelManager}returned.

Specified by:
getModelManager in interface IntrospectingTableModelInterface
Returns:
the Manager
See Also:
#getModelManager()

isRowEditable

public boolean isRowEditable()
Specified by:
isRowEditable in interface DynamicTableModel
Returns:
whether or not the rows in this model can be edited. If false, calls to create and delete methods will have no final result.
See Also:
DynamicTableModel.isRowEditable()


Copyright © 2002-2011 Delft University of Technology, the Netherlands. All Rights Reserved.