ilog.views.sdm.model
Class IlvTableSDMModel

java.lang.Object
  extended by ilog.views.sdm.model.IlvBasicSDMModel
      extended by ilog.views.sdm.model.IlvAbstractSDMModel
          extended by ilog.views.sdm.model.IlvTableSDMModel
All Implemented Interfaces:
IlvSDMModel, IlvInterModelLinks, Serializable

public class IlvTableSDMModel
extends IlvAbstractSDMModel
implements IlvInterModelLinks

This class is an adapter between a Swing TableModel and an IlvSDMModel. It transforms a single TableModel into an SDM model.

The mapping between required properties of the SDM model and actual columns in the table is done through an IlvTableModelMapper.

The table mapper defines which columns of the table contain the SDM object's identifier, tag, link/node boolean, link source, and link destination. These properties must be registered in the mapper using the following names:

The table model mapper also defines which columns of the table model will be mapped to user-defined properties of the SDM model.

This class is most often used in conjunction with an IlvMultipleSDMModel to combine several tables. Note that the objects contained in this model implement the IlvMultipleSDMModel.OwnedObject interface to enhance performance when this model is used inside a multiple model.

Since:
JViews 6.0
See Also:
Serialized Form

Field Summary
static String FROM
          The name of the mapped property that defines the source node of a link.
static String ID
          The name of the mapped property that defines the object identifier.
static String IS_LINK
          The name of the mapped property that defines whether objects are links or nodes.
protected  ArrayList rows
           
static String TAG
          The name of the mapped property that defines the tag of the object.
static String TO
          The name of the mapped property that defines the destination node of a link.
 
Constructor Summary
IlvTableSDMModel(IlvTableModelMapper tableMapper, String defaultTag, boolean defaultIsLink)
          Creates a new Table-to-SDM-model adapter.
IlvTableSDMModel(IlvTableModelMapper tableMapper, String defaultTag, boolean defaultIsLink, boolean mapAllColumns)
          Creates a new Table-to-SDM-model adapter.
 
Method Summary
protected  void addObjectImpl(Object object, Object parent, Object before)
          This method adds a new row to the table if the Table model is an instance of DefaultTableModel or IlvTableModel.
 void clear()
          Removes all the objects from the model.
 Object createLink(String tag)
          This method creates a new row representing a link.
 Object createNode(String tag)
          This method creates a new row representing a node.
 boolean getDefaultIsLink()
          Returns true if this model contains links by default, or false if this model contains nodes by default.
 String getDefaultTag()
          Returns the tag of the objects.
 String getFromID(Object link)
          Returns the ID of the source node of a link.
 Enumeration getObjects()
          Returns the application objects that represent the SDM nodes and links.
 IlvTableModelMapper getTableMapper()
          Returns the Table model mapper that is the source of this SDM model.
 String getToID(Object link)
          Returns the ID of the destination node of a link.
 boolean isMapAllColumns()
          Returns the flag that specifies whether all the columns of the table model are automatically mapped to object properties in the SDM model.
 void removeObject(Object object)
          This method removes a row from the table if the Table model is an instance of DefaultTableModel or IlvTableModel.
 void setDefaultIsLink(boolean defaultIsLink)
          Specifies whether this model contains links or nodes by default.
 void setDefaultTag(String defaultTag)
          Changes the tag of the objects.
 void setFromID(Object link, String id)
          Sets the ID of the source node of a link.
 void setMapAllColumns(boolean mapAllColumns)
          Specifies whether all the columns of the table model are automatically mapped to object properties in the SDM model, even if the table model mapper does not define a mapping explicitely.
 void setTableMapper(IlvTableModelMapper tableMapper)
          Changes the Table model mapper that is the source of this SDM model.
 void setToID(Object link, String id)
          Sets the ID of the destination node of a link.
 
Methods inherited from class ilog.views.sdm.model.IlvAbstractSDMModel
getChildren, getFrom, getIDImpl, getObjectProperty, getObjectPropertyNames, getParent, getTag, getTo, isEditable, isLink, setEditable, setFrom, setIDImpl, setObjectProperty, setTo
 
Methods inherited from class ilog.views.sdm.model.IlvBasicSDMModel
addObject, addSDMModelListener, addSDMPropertyChangeListener, allocID, contains, fireAdjustmentFinished, fireDataChanged, fireIDChanged, fireLinkDestinationChanged, fireLinkSourceChanged, fireObjectAdded, fireObjectRemoved, firePropertyChanged, getID, getObject, isAdjusting, removeSDMModelListener, removeSDMPropertyChangeListener, setAdjusting, setID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rows

protected ArrayList rows
Internal method or field: do not use!

ID

public static final String ID
The name of the mapped property that defines the object identifier. This property must have the type String.

See Also:
Constant Field Values

IS_LINK

public static final String IS_LINK
The name of the mapped property that defines whether objects are links or nodes. This property must have the type Boolean.

See Also:
Constant Field Values

TAG

public static final String TAG
The name of the mapped property that defines the tag of the object. This property must have the type String.

See Also:
Constant Field Values

FROM

public static final String FROM
The name of the mapped property that defines the source node of a link. This property must have the type String and must correspond to the ID of an object in the same or in another table (if this model is used in an IlvMultipleSDMModel.

See Also:
Constant Field Values

TO

public static final String TO
The name of the mapped property that defines the destination node of a link. This property must have the type String and must correspond to the ID of an object in the same or in another table (if this model is used in an IlvMultipleSDMModel.

See Also:
Constant Field Values
Constructor Detail

IlvTableSDMModel

public IlvTableSDMModel(IlvTableModelMapper tableMapper,
                        String defaultTag,
                        boolean defaultIsLink)
Creates a new Table-to-SDM-model adapter.

Parameters:
tableMapper - The table model mapper that will be transformed into an SDM model. The table mapper contains the reference to the TableModel that defines the data. This parameter can be null, in which case the mapper must be specified later using setTableMapper(ilog.views.util.data.IlvTableModelMapper).
defaultTag - The default tag of the objects. All objects in this SDM model will have this tag, unless the mapper defines a mapping for the TAG property.
defaultIsLink - Specifies whether objects in this model are links or nodes by default. This default value is used if the mapper does not define a mapping for the IS_LINK property. If no mapping is defined for IS_LINK and if this parameter is true, the model will return true from its IlvAbstractSDMModel.isLink(java.lang.Object) method, to indicate that all the objects must be rendered as links; otherwise, all the objects will be rendered as nodes.

IlvTableSDMModel

public IlvTableSDMModel(IlvTableModelMapper tableMapper,
                        String defaultTag,
                        boolean defaultIsLink,
                        boolean mapAllColumns)
Creates a new Table-to-SDM-model adapter.

Parameters:
tableMapper - The table model mapper that will be transformed into an SDM model. The table mapper contains the reference to the TableModel that defines the data. This parameter can be null, in which case the mapper must be specified later using setTableMapper(ilog.views.util.data.IlvTableModelMapper).
defaultTag - The default tag of the objects. All objects in this SDM model will have this tag, unless the mapper defines a mapping for the TAG property.
defaultIsLink - Specifies whether objects in this model are links or nodes by default. This default value is used if the mapper does not define a mapping for the IS_LINK property. If no mapping is defined for IS_LINK and if this parameter is true, the model will return true from its IlvAbstractSDMModel.isLink(java.lang.Object) method, to indicate that all the objects must be rendered as links; otherwise, all the objects will be rendered as nodes.
mapAllColumns - Specifies whether all the columns of the table model are automatically mapped to object properties in the SDM model, even if the table model mapper does not define a mapping explicitely. (see setMapAllColumns(boolean)
Since:
JViews 6.5
Method Detail

getDefaultIsLink

public boolean getDefaultIsLink()
Returns true if this model contains links by default, or false if this model contains nodes by default.

If a mapping is defined for the IS_LINK property, then this default value is not used.

Returns:
true if this model contains links by default

setDefaultIsLink

public void setDefaultIsLink(boolean defaultIsLink)
Specifies whether this model contains links or nodes by default.

If a mapping is defined for the IS_LINK property, then this default value is not used.

Parameters:
defaultIsLink - If this parameter is true, this model will return true from its IlvAbstractSDMModel.isLink(java.lang.Object) method, to indicate that all the objects must be rendered as links. Otherwise, all the objects will be rendered as nodes.

getTableMapper

public IlvTableModelMapper getTableMapper()
Returns the Table model mapper that is the source of this SDM model.

Returns:
table model mapper

setTableMapper

public void setTableMapper(IlvTableModelMapper tableMapper)
Changes the Table model mapper that is the source of this SDM model.

Parameters:
tableMapper - the new table model mapper

getDefaultTag

public String getDefaultTag()
Returns the tag of the objects. All objects in this SDM model have this tag by default.

If a mapping is defined for the TAG property, then this default value is not used.

Returns:
default tag

setDefaultTag

public void setDefaultTag(String defaultTag)
Changes the tag of the objects. All objects in this SDM model will have this tag by default.

If a mapping is defined for the TAG property, then this default value is not used. Note: The tags of objects in an SDM model are normally immutable, so you may change the tag only at initialization time. Changing the tag when objects have already been returned by this model can have unspecified results.

Parameters:
defaultTag - The tag of the objects.

setMapAllColumns

public void setMapAllColumns(boolean mapAllColumns)
Specifies whether all the columns of the table model are automatically mapped to object properties in the SDM model, even if the table model mapper does not define a mapping explicitely.

The default value is true.

Parameters:
mapAllColumns - If true (the default), all columns of the table model are mapped to an object property in the SDM model, even if no explicit mapping has been defined in the table model mapper for these properties. If false, only the properties that are explicitely mapped in the table model mapper (using IlvTableModelMapper.addPropertyDescriptor(java.lang.String, ilog.views.util.data.IlvTableModelPropertyDescriptor, java.lang.Class) will define object properties in the SDM model.
Since:
JViews 6.5
See Also:
IlvTableModelMapper, IlvTableModelMapper.addPropertyDescriptor(java.lang.String, ilog.views.util.data.IlvTableModelPropertyDescriptor, java.lang.Class)

isMapAllColumns

public boolean isMapAllColumns()
Returns the flag that specifies whether all the columns of the table model are automatically mapped to object properties in the SDM model.

Returns:
true if all columns are mapped
Since:
JViews 6.5
See Also:
setMapAllColumns(boolean)

getObjects

public Enumeration getObjects()
Returns the application objects that represent the SDM nodes and links.

Specified by:
getObjects in interface IlvSDMModel
Returns:
An enumeration of objects that will be converted to IlvGraphics by the IlvSDMViewRenderer associated with the IlvSDMView. The returned enumeration can be null if the model has no objects.

createNode

public Object createNode(String tag)
This method creates a new row representing a node.

If the model is configured to contain links (that is, if getDefaultIsLink() returns true, this method returns null.

Specified by:
createNode in interface IlvSDMModel
Overrides:
createNode in class IlvAbstractSDMModel
Parameters:
tag - This parameter must be the same as the result of getDefaultTag(), otherwise this method returns null

createLink

public Object createLink(String tag)
This method creates a new row representing a link.

If the model is configured to contain nodes (that is, if getDefaultIsLink() returns false, this method returns null.

Specified by:
createLink in interface IlvSDMModel
Overrides:
createLink in class IlvAbstractSDMModel
Parameters:
tag - This parameter must be the same as the result of getDefaultTag(), otherwise this method returns null

addObjectImpl

protected void addObjectImpl(Object object,
                             Object parent,
                             Object before)
This method adds a new row to the table if the Table model is an instance of DefaultTableModel or IlvTableModel. If this is not the case, an exception is thrown.

Overrides:
addObjectImpl in class IlvBasicSDMModel
Parameters:
object - The new object to add to the model.
parent - This parameter must be null, because this model does not handle subgraphs. If this parameter is not null, an IllegalArgumentException is thrown.
before - An existing object of the model before which the new object must be inserted. You can pass null to append the new object at the end of the model.

removeObject

public void removeObject(Object object)
This method removes a row from the table if the Table model is an instance of DefaultTableModel or IlvTableModel. If this is not the case, an exception is thrown.

Specified by:
removeObject in interface IlvSDMModel
Overrides:
removeObject in class IlvBasicSDMModel
Parameters:
object - The object to remove from the model.

clear

public void clear()
Removes all the objects from the model.

Specified by:
clear in interface IlvSDMModel

getFromID

public String getFromID(Object link)
Description copied from interface: IlvInterModelLinks
Returns the ID of the source node of a link.

Specified by:
getFromID in interface IlvInterModelLinks

getToID

public String getToID(Object link)
Description copied from interface: IlvInterModelLinks
Returns the ID of the destination node of a link.

Specified by:
getToID in interface IlvInterModelLinks

setFromID

public void setFromID(Object link,
                      String id)
Description copied from interface: IlvInterModelLinks
Sets the ID of the source node of a link.

Specified by:
setFromID in interface IlvInterModelLinks

setToID

public void setToID(Object link,
                    String id)
Description copied from interface: IlvInterModelLinks
Sets the ID of the destination node of a link.

Specified by:
setToID in interface IlvInterModelLinks


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.