com.esri.adf.web.data
Class TocNode

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

public class TocNode
extends java.lang.Object
implements java.io.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 places the content in the specified order.
protected TocNode(TocNodeContent content, int order, TocNode parent)
           
 
Method Summary
 TocNode addChild(int order, TocNodeContent content)
          Adds a child to the TOC content placed at the specified order.
 TocNode addChild(TocNodeContent content)
          Adds a child to the TOC content.
 TocNode findNode(java.lang.String key)
          Finds a node based on the key of the TocNode.
 java.util.Collection<TocNode> getChildren()
          Returns all the children of this node.
 TocNodeContent getContent()
          Returns the content of this node.
 java.lang.String getKey()
          Returns the unique key identifying this node.
 int getLevel()
          Returns the level of this node which is the level of its parent + 1.
 int getOrder()
          Returns the order of this node among its siblings.
 void handleCheckedEvent(boolean checked, TocEvent args)
          Handles the checked/unchecked operations for the node.
 void handleNodeEvent(TocEvent args)
          Handles the node event at this node.
 boolean isExpanded()
          Returns an indicator whether the node is expanded.
 void setAllExpanded(boolean expanded, int level)
          Sets the expand level for all the nodes.
 void setExpanded(boolean expanded)
          Sets whether the node is expanded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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 places the content in the specified order.

Parameters:
content - the TocNodeContent
order - the index in the TOC

TocNode

protected TocNode(TocNodeContent content,
                  int order,
                  TocNode parent)
Method Detail

addChild

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

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

addChild

public TocNode addChild(int order,
                        TocNodeContent content)
Adds a child to the TOC content placed at the specified order.

Parameters:
order - the index in the TOC
content - the TocNodeContent
Returns:
TocNode- the new TocNode

getChildren

public java.util.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

isExpanded

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

Returns:
boolean- if true, the node is expanded

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 java.lang.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:
java.lang.Exception

handleCheckedEvent

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

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

findNode

public TocNode findNode(java.lang.String key)
Finds a node 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:
key - the TocNode key
Returns:
TocNode- the TocNode which matches the key

getKey

public java.lang.String getKey()
Returns the unique key identifying this node.

Returns:
String- the key