org.apache.beehive.netui.tags.tree
Class TreeElement

Object
  extended by TreeElement
All Implemented Interfaces:
Serializable, IUrlParams
Direct Known Subclasses:
TreeRootElement

public class TreeElement
extends Object
implements IUrlParams, Serializable

An individual node of a Tree, and rendered by that Tree instance.

See Also:
Serialized Form

Field Summary
 ArrayList _attribute
           
static String EXPAND_NODE
           
static String SELECTED_NODE
           
static String TREE_AJAX_COMMAND_PREFIX
           
static String TREE_AJAX_PARAMTER
           
static String TREE_ANCHOR
          Constant used to indicate an anchor is an expand/collapse tree node
static String TREE_ANCHOR_ID
           
static String TREE_ANCHOR_INIT
           
static String TREE_COLLAPSE_IMAGE
           
static String TREE_COLLAPSE_STATE
           
static String TREE_EXPAND
           
static String TREE_EXPAND_IMAGE
           
static String TREE_EXPAND_PATH
           
static String TREE_EXPAND_STATE
           
static String TREE_EXPANDED
          Constant used to indicate that a tree node anchor should be set expanded.
static String TREE_ID
           
static String TREE_JAVASCRIPT_CLASS
           
static String TREE_LEVEL
           
static String TREE_NODE_LAST
           
 
Constructor Summary
TreeElement()
          Default constructor for creating a simple tree.
TreeElement(String label, boolean expanded)
          Construct a new TreeElement with the specified parameters.
 
Method Summary
 void addAttribute(TreeHtmlAttributeInfo attr)
          This method is called by the children tags of the TreeItem.
 void addChild(int offset, TreeElement child)
          Add a new child node at the specified position in the child list.
 void addChild(TreeElement child)
          Add a new child node to the end of the list.
 void addParameter(String name, Object value, String facet)
          This method will allow a tag that produces one or more Urls to have parameters set on the tag.
 void clearChildren()
           
 TreeElement findNode(String nodeName)
          Given a node, find the named child.
 String getAction()
          Gets the action invoked if this node is selected by the user.
 ArrayList getAttributeList()
          Return the list of attributes.
 TreeElement getChild(int index)
          Return the child node at the given zero-relative index.
 TreeElement[] getChildren()
          Return the set of child nodes for this node.
 String getClientAction()
          Gets the client action invoked if this node is selected by the user.
 String getContent()
          Return the content.
 String getHref()
          Gets the hyperlink to which control will be directed if this node is selected by the user.
 String getIcon()
          Gets the pathname to the icon file displayed when this node is visible, relative to the image directory for the images.
 InheritableState getInheritableState()
           
 String getLabel()
          Gets the label that will be displayed when this node is visible.
 int getLevel()
           
 String getName()
          Returns the unique name of the node.
 HashMap getParams()
           
 TreeElement getParent()
          Gets the parent node of this node, or null if this is the root node.
static TreeElement getRoot(TreeElement node)
          Gets the root node of this tree.
 String getScope()
          Get the target scope for this node's URI.
 String getTagId()
          Return the ID of the tag.
 String getTarget()
          Gets the window target for the hyperlink identified by the action property, if this node is selected.
 String getTitle()
          Set the title attribute for the node.
 boolean isDisabled()
          Gets whether this node currently selected.
 boolean isExpanded()
          Gets if this node is currently expanded.
 boolean isExpandOnServer()
          This method will return the state of the expand on server attribute.
 boolean isLabelLegalAsAlt()
           
 boolean isLast()
          Gets whether or not this is the last node in the set of children for the parent node.
 boolean isLeaf()
          Gets whether or not this a "leaf" node (i.e. one with no children)
 boolean isSelected()
          Gets whether this node currently selected.
 void onExpand(ServletRequest request, ServletResponse response)
          Code that runs when the node is expanded.
 void onSelect(ServletRequest request)
          Code that runs when the node is selected.
 void removeChild(int offset)
          Remove the child node (and all children of that child) at the specified position in the child list.
 void removeChild(TreeElement child)
          Remove the specified child node.
 void setAction(String action)
          Set the action to be called when the node is selected.
 void setClientAction(String clientAction)
          Set the client action to be called when the node is selected.
 void setContent(String content)
          Set the content of the node.
 void setDisabled(boolean disabled)
          Sets whether this node currently selected.
 void setExpanded(boolean expanded)
          Sets if this node is currently expanded.
 void setExpandOnServer(boolean expandOnServer)
          Set the value of the expandOnServer attribute.
 void setHref(String href)
          Set the hyperlink which will be called when the node is selected.
 void setIcon(String icon)
          Set the pathname to the icon to display when this node is visible.
 void setInheritableState(InheritableState state)
           
 void setLabel(String label)
          Set the text of the label associated with this node.
protected  void setName(String name)
          Set the unique name of the node.
protected  void setParent(TreeElement parent)
          Sets the parent node of this node.
 void setScope(String scope)
          Set the target scope for this anchor's URI.
 void setSelected(boolean selected)
          Sets whether this node currently selected.
 void setTagId(String tagId)
          Set the ID of the tag.
 void setTarget(String target)
          Set the window target for the hyperlink indentified by the action.
 void setTitle(String title)
          Returns the current title attribute for the node.
 int size()
          This method will return the number of children of the node.
protected  void updateName(TreeElement parentNode, int index)
          This method will update the name of this node and all of the children node.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELECTED_NODE

public static final String SELECTED_NODE
See Also:
Constant Field Values

EXPAND_NODE

public static final String EXPAND_NODE
See Also:
Constant Field Values

TREE_ID

public static final String TREE_ID
See Also:
Constant Field Values

TREE_JAVASCRIPT_CLASS

public static final String TREE_JAVASCRIPT_CLASS
See Also:
Constant Field Values

TREE_ANCHOR

public static final String TREE_ANCHOR
Constant used to indicate an anchor is an expand/collapse tree node

See Also:
Constant Field Values

TREE_ANCHOR_INIT

public static final String TREE_ANCHOR_INIT
See Also:
Constant Field Values

TREE_ANCHOR_ID

public static final String TREE_ANCHOR_ID
See Also:
Constant Field Values

TREE_EXPAND

public static final String TREE_EXPAND
See Also:
Constant Field Values

TREE_EXPAND_PATH

public static final String TREE_EXPAND_PATH
See Also:
Constant Field Values

TREE_NODE_LAST

public static final String TREE_NODE_LAST
See Also:
Constant Field Values

TREE_EXPAND_STATE

public static final String TREE_EXPAND_STATE
See Also:
Constant Field Values

TREE_COLLAPSE_STATE

public static final String TREE_COLLAPSE_STATE
See Also:
Constant Field Values

TREE_LEVEL

public static final String TREE_LEVEL
See Also:
Constant Field Values

TREE_AJAX_COMMAND_PREFIX

public static final String TREE_AJAX_COMMAND_PREFIX
See Also:
Constant Field Values

TREE_AJAX_PARAMTER

public static final String TREE_AJAX_PARAMTER
See Also:
Constant Field Values

TREE_EXPAND_IMAGE

public static final String TREE_EXPAND_IMAGE
See Also:
Constant Field Values

TREE_COLLAPSE_IMAGE

public static final String TREE_COLLAPSE_IMAGE
See Also:
Constant Field Values

TREE_EXPANDED

public static final String TREE_EXPANDED
Constant used to indicate that a tree node anchor should be set expanded.

See Also:
Constant Field Values

_attribute

public ArrayList _attribute
Constructor Detail

TreeElement

public TreeElement()
Default constructor for creating a simple tree.


TreeElement

public TreeElement(String label,
                   boolean expanded)
Construct a new TreeElement with the specified parameters.

Parameters:
expanded - Should this node be expanded?
Method Detail

getIcon

public String getIcon()
Gets the pathname to the icon file displayed when this node is visible, relative to the image directory for the images.

Returns:
the icon pathname

setIcon

public void setIcon(String icon)
Set the pathname to the icon to display when this node is visible. The name is relative to the image directory.

Parameters:
icon - The relative path to the icond.

getLabel

public String getLabel()
Gets the label that will be displayed when this node is visible.

Returns:
the label

setLabel

public void setLabel(String label)
Set the text of the label associated with this node.

Parameters:
label - The text of the tree node.

isLabelLegalAsAlt

public boolean isLabelLegalAsAlt()

getContent

public String getContent()
Return the content. The content is extra HTML that will be output to the right of the Nodes's label.

Returns:
the content

setContent

public void setContent(String content)
Set the content of the node. The content will be output to the right of the Nodes label.

Parameters:
content - The text of the tree node.

getAction

public String getAction()
Gets the action invoked if this node is selected by the user.

Returns:
the action

setAction

public void setAction(String action)
Set the action to be called when the node is selected. A tree node may only have a action or href or clientAction set but not both.

Parameters:
action - an action in the page flow that will run when the node is selected.

getClientAction

public String getClientAction()
Gets the client action invoked if this node is selected by the user.

Returns:
the action

setClientAction

public void setClientAction(String clientAction)
Set the client action to be called when the node is selected. A tree node may only have a action or href or clientAction set but not both.

Parameters:
clientAction - an action in the page flow that will run when the node is selected.

getTagId

public String getTagId()
Return the ID of the tag. The id may be rewritten by the container (such as a portal) to make sure it is unique. JavaScript may lookup the actual id of the element by looking it up in the netui_names table written into the HTML.

Returns:
the tagId.

setTagId

public void setTagId(String tagId)
Set the ID of the tag.

Parameters:
tagId - the tagId.

getHref

public String getHref()
Gets the hyperlink to which control will be directed if this node is selected by the user.

Returns:
the action

setHref

public void setHref(String href)
Set the hyperlink which will be called when the node is selected. A tree node may only have a action or href or clientAction set but not both.

Parameters:
href - The hyperlink called when the node is selected.

getTarget

public String getTarget()
Gets the window target for the hyperlink identified by the action property, if this node is selected.

Returns:
the window target

setTarget

public void setTarget(String target)
Set the window target for the hyperlink indentified by the action.

Parameters:
target - the window target.

isExpanded

public boolean isExpanded()
Gets if this node is currently expanded.

Returns:
the expanded state

setExpanded

public void setExpanded(boolean expanded)
Sets if this node is currently expanded.

Parameters:
expanded - the expanded state

isExpandOnServer

public boolean isExpandOnServer()
This method will return the state of the expand on server attribute.

Returns:
the boolean value of the expandOnServer attribute.

setExpandOnServer

public void setExpandOnServer(boolean expandOnServer)
Set the value of the expandOnServer attribute. If the attribute is true and runAtClient is also true, then an expansion on this node will cause that to happen on the server. When runAtClient is false, all expansions will happen on the server.

Parameters:
expandOnServer - boolean value indicating if the node should be expanded on the server.

getScope

public String getScope()
Get the target scope for this node's URI.

Returns:
a String that identifies the target scope for this node's URI.
See Also:
setScope(java.lang.String)

setScope

public void setScope(String scope)
Set the target scope for this anchor's URI. Any page flow that handles the URI will be made active within the given scope. Scopes allow multiple page flows to be active within the same user session; page flows in different scopes do not in general interact with each other. This attribute is commonly used in conjunction with the target attribute to invoke a new page flow in a separate window.

Parameters:
scope - a String that identifies the scope in which the target page flow will be made active.

getTitle

public String getTitle()
Set the title attribute for the node.

Returns:
String

setTitle

public void setTitle(String title)
Returns the current title attribute for the node.

Parameters:
title -

getInheritableState

public InheritableState getInheritableState()

setInheritableState

public void setInheritableState(InheritableState state)

addParameter

public void addParameter(String name,
                         Object value,
                         String facet)
Description copied from interface: IUrlParams
This method will allow a tag that produces one or more Urls to have parameters set on the tag. The name and value should be required. The facet is optional, and allows tags producing more than one URL to have parameters set on different URLs.

Specified by:
addParameter in interface IUrlParams
Parameters:
name - The name of the parameter to be added to the URL.
value - The value of the parameter.
facet - The name of a facet for which the parameter should be added.

getParams

public HashMap getParams()

isLast

public boolean isLast()
Gets whether or not this is the last node in the set of children for the parent node.

Returns:
if this is the last or not

getLevel

public int getLevel()

isLeaf

public boolean isLeaf()
Gets whether or not this a "leaf" node (i.e. one with no children)

Returns:
if this is the last or not

getName

public String getName()
Returns the unique name of the node. The unique name is set when the child is added to the tree.

Returns:
The unique name of the node.

getParent

public TreeElement getParent()
Gets the parent node of this node, or null if this is the root node.

Returns:
the TreeElement parent

isSelected

public boolean isSelected()
Gets whether this node currently selected. This is set by the tag render method.

Returns:
the selected state

setSelected

public void setSelected(boolean selected)
Sets whether this node currently selected.

Parameters:
selected - the selected state

isDisabled

public boolean isDisabled()
Gets whether this node currently selected. This is set by the tag render method.

Returns:
the selected state

setDisabled

public void setDisabled(boolean disabled)
Sets whether this node currently selected.

Parameters:
disabled - the selected state

addAttribute

public void addAttribute(TreeHtmlAttributeInfo attr)
This method is called by the children tags of the TreeItem. If there is a TreeHtmlAttribute it will set the attribute name and value.

Parameters:
attr -

getAttributeList

public ArrayList getAttributeList()
Return the list of attributes. This method may return null if there are no elements. In addition, the map may be exist but be empty.

Returns:
a ArrayList of attribute values or null.

setName

protected void setName(String name)
Set the unique name of the node. Uniqueness is not verified by this routine. This routine is protected because it is only called during add and remove of children.

Parameters:
name - the name of the node.

setParent

protected void setParent(TreeElement parent)
Sets the parent node of this node. This node will set the width value (which is really the depth in the tree of the node).

Parameters:
parent - the TreeElement parent

onExpand

public void onExpand(ServletRequest request,
                     ServletResponse response)
Code that runs when the node is expanded.


onSelect

public void onSelect(ServletRequest request)
Code that runs when the node is selected.


addChild

public void addChild(TreeElement child)
              throws IllegalArgumentException
Add a new child node to the end of the list.

Parameters:
child - The new child node
Throws:
IllegalArgumentException - if the name of the new child node is not unique

size

public int size()
This method will return the number of children of the node.

Returns:
the number of children of this tree element.

addChild

public void addChild(int offset,
                     TreeElement child)
              throws IllegalArgumentException
Add a new child node at the specified position in the child list.

Parameters:
offset - Zero-relative offset at which the new node should be inserted
child - The new child node
Throws:
IllegalArgumentException - if the name of the new child node is not unique

clearChildren

public void clearChildren()

getChildren

public TreeElement[] getChildren()
Return the set of child nodes for this node.

Returns:
the child node array

getChild

public TreeElement getChild(int index)
Return the child node at the given zero-relative index.

Parameters:
index - The child node index
Returns:
the child node

removeChild

public void removeChild(int offset)
Remove the child node (and all children of that child) at the specified position in the child list. If there are no children or the specified child position is too large, then this method just returns. (I.e. no runtime exception if the offset argument is too large)

Parameters:
offset - Zero-relative offset at which the existing node should be removed

removeChild

public void removeChild(TreeElement child)
Remove the specified child node. All of the children of this child node will also be removed.

Parameters:
child - Child node to be removed

updateName

protected void updateName(TreeElement parentNode,
                          int index)
This method will update the name of this node and all of the children node. The name of a node reflects it's position in the tree.

Parameters:
parentNode - The parent node of this node.
index - the index position of this node within the parent node.

getRoot

public static TreeElement getRoot(TreeElement node)
Gets the root node of this tree.

Parameters:
node - The TreeElement to start from
Returns:
The root node

findNode

public TreeElement findNode(String nodeName)
Given a node, find the named child.

Parameters:
nodeName - the name of the child to find.
Returns:
the node identified by the name