com.esri.adf.web.data
Class TocNode

java.lang.Object
  extended by com.esri.adf.web.data.TocNode
All Implemented Interfaces:
Serializable

public class TocNode
extends Object
implements Serializable

A TocNode stores content, maintains hierarchical relationships, and responds to events that occur on a table of contents node. To store content, a TocNode requires a TocNodeContent object to encapsulate the content at that node. A TocNode handles its own expand or collapse event and delegates the check box event—for layer visibility—and the node operation—when node content is clicked—to the TocNodeContent’s event handling methods.

See Also:
Serialized Form

Field Summary
static int CONTEXT_MENU_OPERATION
          The context menu operation.
static int EXPAND_COLLAPSE_OPERATION
          The expand/collapse operation.
static int NODE_OPERATION
          The node click operation.
 
Constructor Summary
  TocNode(TocNodeContent content)
          Constructs a TocNode.
  TocNode(TocNodeContent content, int order)
          Constructs the TocNode and positions the node at the specified position.
protected TocNode(TocNodeContent content, int order, TocNode parent)
          Constructs the TocNode and adds it to the parent at the specified position.
 
Method Summary
 TocNode addChild(int position, TocNodeContent cont)
          Adds a child to the TOC node placed at the specified order (Order starts at 1).
 void addChild(TocNode childNode)
          Adds a TocNode to this node's children.
 TocNode addChild(TocNodeContent cont)
          Adds a child to the TOC node.
 void addChild(TocNode childNode, int position)
          Adds a TocNode to this node's children at the specified position.
 TocNode findNode(long id)
          Finds a node in this node's sub tree based on a nodeId.
 TocNode findNode(String nodeKey)
          Finds a node in this node's sub tree based on the key of the TocNode.
 Collection<TocNode> getChildren()
          Returns all the children of this node.
 TocNodeContent getContent()
          Returns the content of this node.
 String getKey()
          Returns the key identifying this node in its current position.
 int getLevel()
          Returns the level of this node which is the level of its parent + 1.
 long getNodeId()
           
 int getOrder()
          Returns the order of this node among its siblings.
 TocNode getParent()
           
 void handleCheckedEvent(boolean pChecked, TocEvent args)
          Handles the checked/unchecked operations for the node.
 void handleNodeEvent(TocEvent args)
          Handles the node event at this node.
 boolean isChecked()
           
 boolean isDirty()
           
 boolean isDisabled()
           
 boolean isExpanded()
          Returns an indicator whether the node is expanded.
 void move(int newPos)
          Moves the node at the specified position in the current parent's children tree.
 void move(TocNode newParent)
          Moves the node to a new parent node at the end of its children tree.
 void move(TocNode newParent, int newPos)
          Moves the node to the new parent at the specified position.
 boolean removeChild(long id)
          Removes a child node according to the nodeId provided.
 boolean removeChild(String nodeKey)
          Removes a child node according to the key provided.
 boolean removeChild(TocNode node)
          Removes a node from this node's children.
 void setAllExpanded(boolean expanded, int level)
          Sets the expand level for all the nodes.
 void setChecked(boolean checked)
           
 void setDirty(boolean dirty)
           
 void setDisabled(boolean disabled)
           
 void setExpanded(boolean expanded)
          Sets whether the node is expanded.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EXPAND_COLLAPSE_OPERATION

public static final int EXPAND_COLLAPSE_OPERATION
The expand/collapse operation.

See Also:
Constant Field Values

NODE_OPERATION

public static final int NODE_OPERATION
The node click operation.

See Also:
Constant Field Values

CONTEXT_MENU_OPERATION

public static final int CONTEXT_MENU_OPERATION
The context menu operation.

See Also:
Constant Field Values
Constructor Detail

TocNode

public TocNode(TocNodeContent content)
Constructs a TocNode.

Parameters:
content - the TocNodeContent to store at the top level.

TocNode

public TocNode(TocNodeContent content,
               int order)
Constructs the TocNode and positions the node at the specified position.

Parameters:
content - the TocNodeContent
order - the index in the parent's children tree

TocNode

protected TocNode(TocNodeContent content,
                  int order,
                  TocNode parent)
Constructs the TocNode and adds it to the parent at the specified position.

Parameters:
content - the TocNodeContent
order - the index in the parent's children tree
parent - the parent node
Method Detail

getParent

public TocNode getParent()
Returns:
the parent

move

public void move(TocNode newParent,
                 int newPos)
Moves the node to the new parent at the specified position.

Parameters:
newParent - the new parent node
newPos - the new position in the parent's children tree

move

public void move(int newPos)
Moves the node at the specified position in the current parent's children tree.

Parameters:
newPos - the new position in the parent's children tree

move

public void move(TocNode newParent)
Moves the node to a new parent node at the end of its children tree.

Parameters:
newParent -

addChild

public TocNode addChild(TocNodeContent cont)
Adds a child to the TOC node. The content is placed at the end of the TOC node children.

Parameters:
content - the TocNodeContent
Returns:
TocNode- the new TocNode

addChild

public TocNode addChild(int position,
                        TocNodeContent cont)
Adds a child to the TOC node placed at the specified order (Order starts at 1).

Parameters:
cont - the TocNodeContent
ord - the position in the TOC
Returns:
TocNode- the new TocNode

addChild

public void addChild(TocNode childNode)
Adds a TocNode to this node's children.

Parameters:
childNode - the TocNode to be added

addChild

public void addChild(TocNode childNode,
                     int position)
Adds a TocNode to this node's children at the specified position.

Parameters:
childNode - the TocNode to be added
position - the position in the parent's children tree

removeChild

public boolean removeChild(String nodeKey)
Removes a child node according to the key provided. Note: The key identify a node relatively to its position in the tree. If you want to identify a node independently of its position in the tree, use the nodeId instead.

Parameters:
nodeKey - the key identifying the node to be removed
Returns:
true if the node has been removed successfully, false otherwise.

removeChild

public boolean removeChild(long id)
Removes a child node according to the nodeId provided.

Parameters:
id - the nodeId identifying the node to be removed
Returns:
true if the node has been removed successfully, false otherwise.

removeChild

public boolean removeChild(TocNode node)
Removes a node from this node's children.

Parameters:
nodeKey - the key identifying the node to remove
Returns:
true if the node has been removed successfully, false otherwise.

getChildren

public Collection<TocNode> getChildren()
Returns all the children of this node.

Returns:
{java.util.Collection}- a collection of children nodes

getContent

public TocNodeContent getContent()
Returns the content of this node.

Returns:
TocNodeContent- the TocNodeContent

getOrder

public int getOrder()
Returns the order of this node among its siblings.

Returns:
int- a number representing the order in the TOC node tree

getLevel

public int getLevel()
Returns the level of this node which is the level of its parent + 1. For nodes without a parent, the level is 0.

Returns:
int- the level in the node tree

getNodeId

public long getNodeId()
Returns:
the nodeId

isExpanded

public boolean isExpanded()
Returns an indicator whether the node is expanded.

Returns:
boolean- if true, the node is expanded

isDisabled

public boolean isDisabled()
Returns:
the disabled

isChecked

public boolean isChecked()
Returns:
the checked

isDirty

public boolean isDirty()
Returns:
the dirty

setDirty

public void setDirty(boolean dirty)
Parameters:
dirty - the dirty state to set

setChecked

public void setChecked(boolean checked)
Parameters:
checked - the checked to set

setDisabled

public void setDisabled(boolean disabled)
Parameters:
disabled - the disabled to set

setExpanded

public void setExpanded(boolean expanded)
Sets whether the node is expanded.

Parameters:
expanded - if true, the node is expanded

setAllExpanded

public void setAllExpanded(boolean expanded,
                           int level)
Sets the expand level for all the nodes. If the level is less than zero all nodes will be fully expanded.

Parameters:
expanded - if true, set all nodes expanded.
level - the number of levels to be expanded. Fully expand if level < 0.

handleNodeEvent

public void handleNodeEvent(TocEvent args)
                     throws Exception
Handles the node event at this node. The TocControl calls this method for a TOC event which is not a check/uncheck operation. The expand/collapse operation is handled and the arguments are then passed on to the TocNodeContent of this node to handle any events which occurred at the content level.

Parameters:
args - the TocEvent
Throws:
Exception

handleCheckedEvent

public void handleCheckedEvent(boolean pChecked,
                               TocEvent args)
                        throws Exception
Handles the checked/unchecked operations for the node.

Parameters:
checked - if true, the node is checked
args - TocEvent
Throws:
Exception - if an error occurs for the checked event

findNode

public TocNode findNode(String nodeKey)
Finds a node in this node's sub tree based on the key of the TocNode. If the key is the key for this node it returns itself. If the key matches a child of this node it returns the TocNode for the child.

Parameters:
nodeKey - the TocNode key
Returns:
TocNode- the TocNode which matches the key

findNode

public TocNode findNode(long id)
Finds a node in this node's sub tree based on a nodeId.

Parameters:
nodeKey - the TocNode unique ID
Returns:
TocNode- the TocNode which matches the node ID provided

getKey

public String getKey()
Returns the key identifying this node in its current position. (to uniquely identify a node, use the nodeId instead as it doesn't rely on the position of the node in the tree)

Returns:
String- the key

toString

public String toString()
Overrides:
toString in class Object