public class IlvTableSDMModel extends IlvAbstractSDMModel implements IlvInterModelLinks
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:
ID
defines the identifier of the object. This property
is mandatory for nodes that have links connected to them.
FROM
defines the source of a link. This property must
contain the ID of a node in the same or in another
table (if this model is used in an
IlvMultipleSDMModel
).
TO
defines the destination of a link. This property must
contain the ID of a node in the same or in another
table (if this model is used in an
IlvMultipleSDMModel
).
TAG
defines the tag of an object. This property is optional;
if it is not mapped to any column, the default tag
returned by getDefaultTag()
will be used for
all objects in this model.
IS_LINK
defines whether an object is a node or a link.
This property is optional; if it is not mapped to
any column, the default boolean returned by
getDefaultIsLink()
will be used for all
objects in this model.
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.
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
getChildren, getFrom, getIDImpl, getObjectProperty, getObjectPropertyNames, getParent, getTag, getTo, isEditable, isLink, setEditable, setFrom, setIDImpl, setObjectProperty, setTo
addObject, addSDMModelListener, addSDMPropertyChangeListener, allocID, contains, fireAdjustmentFinished, fireDataChanged, fireIDChanged, fireLinkDestinationChanged, fireLinkSourceChanged, fireObjectAdded, fireObjectRemoved, firePropertyChanged, firePropertyChanged, getID, getObject, isAdjusting, removeSDMModelListener, removeSDMPropertyChangeListener, setAdjusting, setID
protected ArrayList rows
public static final String ID
public static final String IS_LINK
public static final String TAG
public static final String FROM
IlvMultipleSDMModel
.public static final String TO
IlvMultipleSDMModel
.public IlvTableSDMModel(IlvTableModelMapper tableMapper, String defaultTag, boolean defaultIsLink)
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.public IlvTableSDMModel(IlvTableModelMapper tableMapper, String defaultTag, boolean defaultIsLink, boolean mapAllColumns)
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)
public boolean getDefaultIsLink()
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.
public void setDefaultIsLink(boolean defaultIsLink)
If a mapping is defined for the IS_LINK
property, then this default value is not used.
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.public IlvTableModelMapper getTableMapper()
public void setTableMapper(IlvTableModelMapper tableMapper)
tableMapper
- the new table model mapperpublic String getDefaultTag()
If a mapping is defined for the TAG
property, then this default value is not used.
public void setDefaultTag(String defaultTag)
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.
defaultTag
- The tag of the objects.public void setMapAllColumns(boolean mapAllColumns)
The default value is true
.
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.IlvTableModelMapper
,
IlvTableModelMapper.addPropertyDescriptor(java.lang.String, ilog.views.util.data.IlvTableModelPropertyDescriptor, java.lang.Class)
public boolean isMapAllColumns()
setMapAllColumns(boolean)
public Enumeration getObjects()
getObjects
in interface IlvSDMModel
IlvGraphic
s by the
IlvSDMViewRenderer
associated with the
IlvSDMView
. The returned enumeration
can be null
if the model has no objects.public Object createNode(String tag)
If the model is configured to contain links (that is, if
getDefaultIsLink()
returns true
, this method returns null
.
createNode
in interface IlvSDMModel
createNode
in class IlvAbstractSDMModel
tag
- This parameter must be the same as the result of getDefaultTag()
,
otherwise this method returns null
public Object createLink(String tag)
If the model is configured to contain nodes (that is, if
getDefaultIsLink()
returns false
, this method returns null
.
createLink
in interface IlvSDMModel
createLink
in class IlvAbstractSDMModel
tag
- This parameter must be the same as the result of getDefaultTag()
,
otherwise this method returns null
protected void addObjectImpl(Object object, Object parent, Object before)
DefaultTableModel
or IlvTableModel
.
If this is not the case, an exception is thrown.
addObjectImpl
in class IlvBasicSDMModel
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.public void removeObject(Object object)
DefaultTableModel
or IlvTableModel
.
If this is not the case, an exception is thrown.
removeObject
in interface IlvSDMModel
removeObject
in class IlvBasicSDMModel
object
- The object to remove from the model.public void clear()
clear
in interface IlvSDMModel
public String getFromID(Object link)
getFromID
in interface IlvInterModelLinks
public String getToID(Object link)
getToID
in interface IlvInterModelLinks
public void setFromID(Object link, String id)
setFromID
in interface IlvInterModelLinks
public void setToID(Object link, String id)
setToID
in interface IlvInterModelLinks
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.