ilog.cpl.tree
Class IlpDefaultTreeNode

java.lang.Object
  extended by ilog.cpl.tree.IlpDefaultTreeNode
All Implemented Interfaces:
ilog.cpl.css.internal.IlpCSSObject, IlpAttributeValueHolder, IlpRepresentationObject, IlpTreeNode, IlpTreeNodeHelper, MutableTreeNode, TreeNode

public class IlpDefaultTreeNode
extends Object
implements IlpTreeNode, ilog.cpl.css.internal.IlpCSSObject

Default implementation of IlpTreeNode. An expansion strategy is used to load the children of a node when it expands. Depending on the implementation of the expansion strategy the children may be loaded asynchronously or synchronously. There is no definitive way to know when all the children are loaded. The following operations trigger the loading of the children: getChildAt(int), getChildCount(), children().

Since:
JTGO 3.0
See Also:
IlpExpansionStrategy

Field Summary
 
Fields inherited from interface ilog.cpl.model.IlpAttributeValueHolder
VALUE_NOT_SET
 
Constructor Summary
IlpDefaultTreeNode(IlpAttributeGroup attributeGroup, boolean allowsChildren, IlpExpansionStrategy expansionStrategy)
          Creates an IlpTreeNode object without an underlying IlpObject object.
IlpDefaultTreeNode(IlpObject object, boolean allowsChildren, IlpExpansionStrategy expansionStrategy)
          Creates an IlpTreeNode object with an underlying IlpObject object.
IlpDefaultTreeNode(IlpObject object, IlpExtendedAttributeGroup attributeGroup, boolean allowsChildren, IlpExpansionStrategy expansionStrategy)
          Creates an IlpTreeNode object with an underlying IlpObject object.
 
Method Summary
 void addAttributeValueListener(AttributeValueListener l)
          Adds a listener to attribute value changes.
 Enumeration children()
          Returns the children of this node as an Enumeration.
 void fireEvent(AttributeValueEvent ev)
          Fires an event to the listeners.
 boolean getAllowsChildren()
          Returns true if this node allows children.
 IlpAttributeGroup getAttributeGroup()
          Returns the attribute group that defines which attributes are allowed in this instance.
 Object getAttributeValue(IlpAttribute a)
          Retrieves the value of an attribute of this object.
 Object getAttributeValue(String name)
          Returns the value of an attribute of this object.
 TreeNode getChildAt(int childIndex)
          Returns the child TreeNode at index childIndex.
 int getChildCount()
          Returns the number of child TreeNodes this node contains.
 List getChildren()
          Returns the children as an unmodifiable list.
 String getCSSClasses()
          Returns the CSS classes of the object.
 String getCSSID(IlpContext appc)
          Returns the ID of the object.
 String getCSSType()
          Returns the type of the object.
 ilog.cpl.model.edit.IlpRepresentationObjectEditor getEditor()
          Get the editor for this object.
 IlpExpansionStrategy getExpansionStrategy()
          Returns the expansion strategy.
 IlpObject getIlpObject()
          Retrieves the IlpObject of this representation.
 int getIndex(TreeNode node)
          Returns the index of node in this node's child array.
 TreeNode getParent()
          Returns the parent TreeNode of this node.
 boolean hasAttributeValue(IlpAttribute a)
          Returns true if the requested attribute is part of the attribute group of this instance and if a value has been set for this attribute.
 void insert(MutableTreeNode newChild, int index)
          Adds newChild to this node at index.
 boolean isExpanded()
          Deprecated. Please use IlpExpansionStrategy.areChildrenLoaded instead.
 boolean isLeaf()
          Returns true if this node is a leaf.
 void remove(int index)
          Removes the child at index from this node.
 void remove(MutableTreeNode node)
          Removes node from this node.
 void removeAttributeValueListener(AttributeValueListener l)
          Removes the given listener from the attribute value changes notifications.
 void removeFromParent()
          Removes this node from its parent.
 void setAttributeValue(IlpAttribute attribute, Object value)
          Sets the value of an attribute of this object.
 void setAttributeValue(String name, Object value)
          Sets the value of an attribute of this object.
 void setChildren(List children)
          Sets the children.
 void setParent(MutableTreeNode newParent)
          Sets this node's parent to newParent but does not change the parent's child array.
 void setUserObject(Object object)
          Resets the user object of this node to object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlpDefaultTreeNode

public IlpDefaultTreeNode(IlpObject object,
                          IlpExtendedAttributeGroup attributeGroup,
                          boolean allowsChildren,
                          IlpExpansionStrategy expansionStrategy)
Creates an IlpTreeNode object with an underlying IlpObject object.

Parameters:
object - The underlying IlpObject object.
attributeGroup - The attribute group of the IlpTreeNode. It is supposed to include the IlpClass of the object.
allowsChildren - Indicates if this node may have children.
expansionStrategy - The expansion strategy to be used when the node expands or collapses.

IlpDefaultTreeNode

public IlpDefaultTreeNode(IlpObject object,
                          boolean allowsChildren,
                          IlpExpansionStrategy expansionStrategy)
Creates an IlpTreeNode object with an underlying IlpObject object. The attribute model is the attribute model from the given IlpObject.

Parameters:
object - The underlying IlpObject object.
allowsChildren - Indicates if this node may have children.
expansionStrategy - The expansion strategy to be used when the node expands or collapses.

IlpDefaultTreeNode

public IlpDefaultTreeNode(IlpAttributeGroup attributeGroup,
                          boolean allowsChildren,
                          IlpExpansionStrategy expansionStrategy)
Creates an IlpTreeNode object without an underlying IlpObject object.

Parameters:
attributeGroup - The attribute group of the IlpTreeNode object.
allowsChildren - Indicates if this node may have children.
expansionStrategy - The expansion strategy to be used when the node expands or collapses.
Method Detail

getIlpObject

public IlpObject getIlpObject()
Retrieves the IlpObject of this representation.

Specified by:
getIlpObject in interface IlpRepresentationObject
Returns:
The IlpObject of this representation. It may be null.

getAttributeGroup

public IlpAttributeGroup getAttributeGroup()
Returns the attribute group that defines which attributes are allowed in this instance.

Specified by:
getAttributeGroup in interface IlpAttributeValueHolder

getAttributeValue

public Object getAttributeValue(IlpAttribute a)
Retrieves the value of an attribute of this object.

Specified by:
getAttributeValue in interface IlpAttributeValueHolder
Parameters:
a - The attribute whose value is to be retrieved.
Returns:
The value of the attribute or VALUE_NOT_SET if no value has been set.

hasAttributeValue

public boolean hasAttributeValue(IlpAttribute a)
Returns true if the requested attribute is part of the attribute group of this instance and if a value has been set for this attribute.

Specified by:
hasAttributeValue in interface IlpAttributeValueHolder

setAttributeValue

public void setAttributeValue(IlpAttribute attribute,
                              Object value)
Sets the value of an attribute of this object. To remove the value of an attribute, you can pass VALUE_NOT_SET for the value argument.

Specified by:
setAttributeValue in interface IlpAttributeValueHolder
Parameters:
attribute - The attribute whose value is set.
value - The new value of the attribute or VALUE_NOT_SET to remove the value of the attribute.
Throws:
IllegalArgumentException - if the attribute cannot have its value modified.

getAttributeValue

public Object getAttributeValue(String name)
Returns the value of an attribute of this object.

Specified by:
getAttributeValue in interface IlpAttributeValueHolder
Parameters:
name - The name of the attribute.
Returns:
The value of the attribute.
Since:
JTGO 4.0

setAttributeValue

public void setAttributeValue(String name,
                              Object value)
Sets the value of an attribute of this object. If the attribute does not exist, a default attribute with the given name will be created and added to the local attribute model.

Specified by:
setAttributeValue in interface IlpAttributeValueHolder
Parameters:
name - The name of the attribute.
value - The new value of the attribute.
Since:
JTGO 4.0

addAttributeValueListener

public void addAttributeValueListener(AttributeValueListener l)
Adds a listener to attribute value changes.

Specified by:
addAttributeValueListener in interface IlpAttributeValueHolder
Parameters:
l - The listener to be added.

removeAttributeValueListener

public void removeAttributeValueListener(AttributeValueListener l)
Removes the given listener from the attribute value changes notifications.

Specified by:
removeAttributeValueListener in interface IlpAttributeValueHolder
Parameters:
l - The listener to be removed.

fireEvent

public void fireEvent(AttributeValueEvent ev)
Fires an event to the listeners.

Specified by:
fireEvent in interface IlpAttributeValueHolder
Parameters:
ev - The attribute value change event to fire.

getChildAt

public TreeNode getChildAt(int childIndex)
Returns the child TreeNode at index childIndex. Invoking this method will call loadChildren on the expansion strategy, which will load this node's children.

Specified by:
getChildAt in interface TreeNode
Parameters:
childIndex - The index in the child array of the node.

getChildCount

public int getChildCount()
Returns the number of child TreeNodes this node contains. Invoking this method will call loadChildren on the expansion strategy, which will load this node's children.

Specified by:
getChildCount in interface TreeNode

getParent

public TreeNode getParent()
Returns the parent TreeNode of this node.

Specified by:
getParent in interface TreeNode

getIndex

public int getIndex(TreeNode node)
Returns the index of node in this node's child array. If this node does not contain node, -1 will be returned.

Specified by:
getIndex in interface TreeNode
Parameters:
node - The node whose index is required.

getAllowsChildren

public boolean getAllowsChildren()
Returns true if this node allows children.

Specified by:
getAllowsChildren in interface TreeNode

isLeaf

public boolean isLeaf()
Returns true if this node is a leaf. Invoking this method does not load this node's children.

Specified by:
isLeaf in interface TreeNode

children

public Enumeration children()
Returns the children of this node as an Enumeration. Invoking this method will call loadChildren on the expansion strategy, which will load this node's children.

Specified by:
children in interface TreeNode

insert

public void insert(MutableTreeNode newChild,
                   int index)
Adds newChild to this node at index. The setParent message is sent to newChild to set this node as its parent.

Specified by:
insert in interface MutableTreeNode

remove

public void remove(int index)
Removes the child at index from this node.

Specified by:
remove in interface MutableTreeNode
Parameters:
index - The index of the child to be removed.

remove

public void remove(MutableTreeNode node)
Removes node from this node. The setParent message is sent to node to remove its parent.

Specified by:
remove in interface MutableTreeNode
Parameters:
node - The node to be removed.

setUserObject

public void setUserObject(Object object)
Resets the user object of this node to object.

Specified by:
setUserObject in interface MutableTreeNode
Throws:
UnsupportedOperationException - This operation is not supported.

removeFromParent

public void removeFromParent()
Removes this node from its parent.

Specified by:
removeFromParent in interface MutableTreeNode

setParent

public void setParent(MutableTreeNode newParent)
Sets this node's parent to newParent but does not change the parent's child array. This method is called from insert() and remove() to reassign a child's parent, it should not be called from anywhere else.

Specified by:
setParent in interface MutableTreeNode
Parameters:
newParent - This node's new parent.
Internal method or field: do not use!

getEditor

public ilog.cpl.model.edit.IlpRepresentationObjectEditor getEditor()
Description copied from interface: IlpRepresentationObject
Get the editor for this object. Should never return null. When the representation object is being updated, it should delegate all calls to getAttributeValue to the editor. In this case it should also stop propagating attribute value change events received from the BO.

Specified by:
getEditor in interface IlpRepresentationObject
Internal method or field: do not use!

isExpanded

public boolean isExpanded()
Deprecated. Please use IlpExpansionStrategy.areChildrenLoaded instead.

Returns true if the node has been expanded. In the case of an expansion strategy implementing a load-on-demand mechanism, isExpanded() returns true when the node's children are loaded.

The default implementation calls areChildrenLoaded in the node expansion strategy.

Specified by:
isExpanded in interface IlpTreeNodeHelper
Deprecated Since:
JTGO 4.0

getExpansionStrategy

public IlpExpansionStrategy getExpansionStrategy()
Returns the expansion strategy.

Specified by:
getExpansionStrategy in interface IlpTreeNodeHelper
Since:
JTGO 3.1

getChildren

public List getChildren()
Returns the children as an unmodifiable list.

Specified by:
getChildren in interface IlpTreeNodeHelper
Since:
JTGO 3.1

setChildren

public void setChildren(List children)
Sets the children.

Specified by:
setChildren in interface IlpTreeNodeHelper
Since:
JTGO 3.1

getCSSType

public String getCSSType()
Returns the type of the object.

Specified by:
getCSSType in interface ilog.cpl.css.internal.IlpCSSObject
Returns:
The string representing the type of the object in the model. Null is accepted.
Since:
JTGO 3.5
Internal method or field: do not use!

getCSSID

public String getCSSID(IlpContext appc)
Returns the ID of the object.

Specified by:
getCSSID in interface ilog.cpl.css.internal.IlpCSSObject
Parameters:
appc - The context
Returns:
The string representing the ID. null is accepted
Since:
JTGO 3.5
Internal method or field: do not use!

getCSSClasses

public String getCSSClasses()
Returns the CSS classes of the object.

Specified by:
getCSSClasses in interface ilog.cpl.css.internal.IlpCSSObject
Returns:
The string representing the css classes, separated by ' '. Null is accepted.
Since:
JTGO 3.5
Internal method or field: do not use!


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