www.element4solution.com

e4s.html.tree
Class E4TreeNode

java.lang.Object
  extended by e4s.util.E4Object
      extended by e4s.html.tree.E4TreeNode
All Implemented Interfaces:
E4TreeNode_Intf
Direct Known Subclasses:
E4DBTreeNodeDictionary

public class E4TreeNode
extends E4Object
implements E4TreeNode_Intf

Node of a tree, holds the data. The E4TreeNode is an implementation of the related interface, it handles simple tree nodes (represented by a text). Each node can have one or more subnodes.

Example_Tree.java

Since:
JDK 1.4
See Also:
E4TreeElement, E4Tree, E4ModuleTreeHandling

Field Summary
protected  java.lang.Object m_action
           
 java.util.Vector m_additional_elements
           
 long m_id
           
 boolean m_isactive
           
protected  boolean m_isopen
           
 java.lang.Object m_obj
           
 java.util.Vector m_sub
           
 E4Label_Intf m_text
           
protected static long ms_last_id
           
 
Fields inherited from class e4s.util.E4Object
CRLF, E4S_CORE_SYSTEM_LANGUAGE, NBSP, NULLSTR, URL_ENCODING_CHARSET
 
Constructor Summary
E4TreeNode()
          Create a node, and associate it with an automatically incremental ID.
E4TreeNode(E4Label_Intf text)
          Create a node, and associate it with an automatically incremental ID.
E4TreeNode(int public_id)
          Create a node, and associate it with a general, public id - not recommended.
E4TreeNode(java.lang.String text)
          Create a node, and associate it with an automatically incremental ID.
 
Method Summary
static java.lang.String _getSVNVersionString()
          Get version info string from subversion.
 void addAdditionalElement(E4HtmlElement_Intf element)
           
 E4TreeNode addNode()
          Create and add a node to the current node.
 E4TreeNode addNode(E4Label_Intf label)
          Create and add a node to the current node.
 void addNode(E4TreeNode_Intf node)
          Add a node to the current node.
 E4TreeNode addNode(java.lang.String label)
          Create and add a node to the current node.
 void collectScripts(E4ScriptsVec v, E4ServletImplementation_Intf servlet)
          Append the current script to the Vector, each script is identified by a name and can only appear onece in the Vector.
 void collectStylesForEditing(E4StylesHash vec, E4ServletImplementation_Intf servlet)
          Build a list (Vector) with style definitions used so far during display of this page.
 void collectTranslationsForEditing(E4TranslationsVec v, E4ServletImplementation_Intf servlet)
           
 E4TreeNode_Intf copy()
           
 E4TreeNode copy(boolean copy_sub)
           
 int countNodes()
           
 java.lang.Object findAdditionalElement(java.lang.Class clazz)
           
static E4TreeNode_Intf findNode(E4CgiParams params, E4ServletImplementation_Intf servlet)
          Find the tree-node which is stored in the session of the servlet, identified by parameters E4ModuleTreeHandling._PARAM_TREE_OBJ and E4ModuleTreeHandling._PARAM_NODE_ID.
 E4TreeNode_Intf findSubnode(long nodeId)
          Find a subnode within a tree.
 E4TreeNode_Intf findSubnodeText(E4String text)
          Find a subnode within a tree.
 E4TreeNode_Intf findSubnodeText(java.lang.String text)
          Find a subnode using the text.
 java.lang.Object getAction()
          Get the associated action.
 java.util.Enumeration getAdditionalElements()
           
 E4Color getBgColor()
           
 FONT getFONT()
           
 java.lang.String getFormattedText(Language lang)
          Get the displayed text, formatted.
 long getId()
          Get the identification for a tree node.
 IMG getImage()
          Get the associated image for the node, depending on the isActive() state.
 IMG getImage(boolean mode)
          Get the associated image for the node.
 java.lang.Object getObj()
          Get the object associated with the tree node.
 CLASS_Name getSTYLE()
          Get the E4CSS definition for this tree node.
 java.util.Enumeration getSubNodes()
          Get an enumeration of all direct associated sub-nodes in the next level (not recursivley deeper).
 E4TreeNode_Intf[] getSubNodesArray()
          Get an array of all direct associated sub-nodes in the next level (not recursivley deeper).
 E4Label_Intf getText()
          Get the displayed text.
 boolean hasSubnodes()
          Determine, if a node has subnodes.
 boolean isActive()
          Get the active state of a tree node.
 boolean isOpen()
          Get the open state of a tree node.
 void removeAllNodes()
          Removes all subnodes from this node.
 boolean removeNode(E4TreeNode_Intf node)
          Remove a node.
 boolean removeNode(long nodeId)
          Remove a node.
 void resetAction()
          Reset an action associated with this node.
 void setAction(A_Multiple mref)
          Define an action associated with this node.
 void setAction(E4Method mref)
          Define an action associated with this node.
 void setActive(long lookup_node)
          Sets the active state of this node to true (active) and resets all subnodes to false (inactive).
 void setBgColor(E4Color color)
           
 void setFONT(FONT font)
           
 void setId(long id)
          Set's the ID of an node.
 void setImage(IMG image)
           
 void setImage(IMG image0, IMG image1)
           
 void setObj(java.lang.Object obj)
          Define an object that is stored with the tree node.
 void setOpen(boolean open)
          Change the open status of a node.
 void setOpen(boolean open, int levels)
          Change the open status of a node.
 void setSTYLE(CLASS_Name css_class)
           
 void setText(E4Label_Intf text)
          Define the text associated and displayed with this tree node.
 void setText(E4String text)
          Define the text associated and displayed with this tree node.
 void setText(java.lang.String text)
          Define the text associated and displayed with this tree node.
 void sort(Language language)
          Sort the sub-elements of this node ascending.
 void sort(Language language, boolean ascending)
          Sort the sub-elements of this node.
 java.lang.String toString()
           
 
Methods inherited from class e4s.util.E4Object
Calendar, CName, CName, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelNone, E4LabelNone, E4LabelNone, E4LabelNone, E4LabelSys, E4LabelSys, e4sCopyright, e4sVersion, encode, encode, encode, encodeHtml, encodeHtml, encodeHtml, encodeURL, encodeURL, encodeURL, finalize, getLINE, getTRACE, getTRACE, getTRACE, getTRACE, getTRACE, getTRACE, getTraceMemory, HtmlEncode, HtmlEncode, HtmlEncode, isdecimal, isdigit, isnotok, isnotok, isnumeric, isok, isok, isok, isok, lastCallingFunction, lastCallingFunction, lastCallingFunction, lastCallingFunction, lastCallingStack, mkdirs, null2nbsp, null2nbsp, null2nbsp, ok, ok, ok, ok, outPrintln, setLogFile4Trace, setTraceMemory, STACKTRACE, toDebug, toDouble, toFloat, toFloat, TRACE_CALLS, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, wait
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_sub

public java.util.Vector m_sub

m_action

protected java.lang.Object m_action

m_text

public E4Label_Intf m_text

m_obj

public java.lang.Object m_obj

m_id

public long m_id

ms_last_id

protected static long ms_last_id

m_isopen

protected boolean m_isopen

m_isactive

public boolean m_isactive

m_additional_elements

public java.util.Vector m_additional_elements
Constructor Detail

E4TreeNode

public E4TreeNode()
Create a node, and associate it with an automatically incremental ID.

See Also:
E4TreeNode(int), getId()

E4TreeNode

public E4TreeNode(java.lang.String text)
Create a node, and associate it with an automatically incremental ID. Define the associated text for display.

See Also:
E4TreeNode(int), E4TreeNode(), setText(String)

E4TreeNode

public E4TreeNode(E4Label_Intf text)
Create a node, and associate it with an automatically incremental ID. Define the associated text for display.

See Also:
E4TreeNode(int), E4TreeNode(), setText(String)

E4TreeNode

public E4TreeNode(int public_id)
Create a node, and associate it with a general, public id - not recommended. It is recommended, not to assign ID's unless there is a reason for later direct accessign this node. Note, that all ID's must be unique. If no ID is assigned (the default constructor), then an incremental ID starting with 0 is used. This may cause conflicts with overlapping own assigned numbers. They should start at very high numbers or use negative numbers therefore.

Parameters:
public_id - the id associated with.
See Also:
E4TreeNode(), getId()
Method Detail

findNode

public static E4TreeNode_Intf findNode(E4CgiParams params,
                                       E4ServletImplementation_Intf servlet)
                                throws java.lang.Exception
Find the tree-node which is stored in the session of the servlet, identified by parameters E4ModuleTreeHandling._PARAM_TREE_OBJ and E4ModuleTreeHandling._PARAM_NODE_ID. Throws an exception if parameters are missing, or the tree-element or the tree-node cannot be found.

Parameters:
params - the parameters, must contain at least E4ModuleTreeHandling._PARAM_TREE_OBJ and E4ModuleTreeHandling._PARAM_NODE_ID.
Throws:
java.lang.Exception

setId

public void setId(long id)
Set's the ID of an node.

Specified by:
setId in interface E4TreeNode_Intf
Parameters:
id - the new id
See Also:
E4Tree.renumberNodes(), getId()

getId

public long getId()
Get the identification for a tree node. Note each tree element has a unique node id within the tree.

Specified by:
getId in interface E4TreeNode_Intf
Returns:
the node ID

getText

public E4Label_Intf getText()
Get the displayed text.

Specified by:
getText in interface E4TreeNode_Intf
Returns:
the associated (displayed) text for this tree node.
See Also:
E4TreeNode_Intf.getFormattedText(e4s.application.Language)

getFormattedText

public java.lang.String getFormattedText(Language lang)
Get the displayed text, formatted. In this implementation there is no difference between getText() and this function.

Specified by:
getFormattedText in interface E4TreeNode_Intf
Returns:
the displayed text for this tree node.
See Also:
getText()

getImage

public IMG getImage(boolean mode)
Get the associated image for the node. Each node is associated with one or two images. In a tree, only one node can be the active node (isActive() and setActive(long node_id). In the case, that two images are defined (e.g. one for the closed inactive and another for the active node) the parameter mode defines which image to be displayed. In the case, that only one image is defined (regardless if the node is active or not), this image will be displayed.

Specified by:
getImage in interface E4TreeNode_Intf
Parameters:
mode - false: return the first image defined, true: return the second image if defined, or return the first image if only one is defined.
Returns:
the associated image for this mode
See Also:
getImage()

getImage

public IMG getImage()
Get the associated image for the node, depending on the isActive() state. This function is equal to getImage(isActive()).

Specified by:
getImage in interface E4TreeNode_Intf
Returns:
the associated image for this mode
See Also:
getImage(boolean mode)

getSubNodes

public java.util.Enumeration getSubNodes()
Get an enumeration of all direct associated sub-nodes in the next level (not recursivley deeper). It is recommended to use getSubNodesArray() instead of this function.

Specified by:
getSubNodes in interface E4TreeNode_Intf
Returns:
null if no sub nodes are defined or an enumeration representing all subnodes in the following level
See Also:
addNode(String), getSubNodesArray()

getSubNodesArray

public E4TreeNode_Intf[] getSubNodesArray()
Get an array of all direct associated sub-nodes in the next level (not recursivley deeper).

Specified by:
getSubNodesArray in interface E4TreeNode_Intf
Returns:
null if no sub nodes are defined or an array representing all subnodes in the following level
See Also:
addNode(String), getSubNodes()

setAction

public void setAction(E4Method mref)
Define an action associated with this node.

Parameters:
mref - the method (function) to be invoced when the user clicks the text of this tree node (leaf). This only works for one frame or the actual window.
See Also:
setAction(A_Multiple), resetAction(), E4Tree.setDefaultMethod(E4Method)

setAction

public void setAction(A_Multiple mref)
Define an action associated with this node.

Parameters:
mref - enables multiple frames to be updated at the same time.
See Also:
setAction(A_Multiple), resetAction(), E4Tree.setDefaultMethod(E4Method)

resetAction

public void resetAction()
Reset an action associated with this node.

See Also:
setAction(e4s.html.E4Method), E4Tree.setDefaultMethod(E4Method)

setText

public void setText(java.lang.String text)
Define the text associated and displayed with this tree node.

Parameters:
text - the text for display.
See Also:
setObj(java.lang.Object), getText(), setText(E4Label_Intf)

setText

public void setText(E4Label_Intf text)
Define the text associated and displayed with this tree node.

Parameters:
text - the text for display.
See Also:
setObj(java.lang.Object), getText(), setText(String)

setText

public void setText(E4String text)
Define the text associated and displayed with this tree node.

Parameters:
text - the text for display.
See Also:
setObj(java.lang.Object), getText()

setObj

public void setObj(java.lang.Object obj)
Define an object that is stored with the tree node.

Specified by:
setObj in interface E4TreeNode_Intf
Parameters:
obj - anything that needs to be stored
See Also:
setText(java.lang.String), getObj()

getAdditionalElements

public java.util.Enumeration getAdditionalElements()
Specified by:
getAdditionalElements in interface E4TreeNode_Intf

addAdditionalElement

public void addAdditionalElement(E4HtmlElement_Intf element)

findAdditionalElement

public java.lang.Object findAdditionalElement(java.lang.Class clazz)
Specified by:
findAdditionalElement in interface E4TreeNode_Intf

getObj

public java.lang.Object getObj()
Get the object associated with the tree node.

Specified by:
getObj in interface E4TreeNode_Intf
Returns:
the object
See Also:
getText(), setObj(java.lang.Object)

getAction

public java.lang.Object getAction()
Get the associated action. This can be either a Integer, representing an Alias from a E4Method, or it is from type A_Multiple to avoid multiple frames to be changed.

Specified by:
getAction in interface E4TreeNode_Intf
See Also:
setAction(A_Multiple), setAction(E4Method), resetAction()

setImage

public void setImage(IMG image0,
                     IMG image1)
Specified by:
setImage in interface E4TreeNode_Intf

setImage

public void setImage(IMG image)
Specified by:
setImage in interface E4TreeNode_Intf

addNode

public void addNode(E4TreeNode_Intf node)
Add a node to the current node. Each node can have more than one subnode.

Specified by:
addNode in interface E4TreeNode_Intf
Parameters:
node - the subnode to add (this can be an end node - leaf - or it can recursive have subnodes either.
See Also:
getSubNodes(), findSubnode(long), addNode(), addNode(String)

addNode

public E4TreeNode addNode()
Create and add a node to the current node. Each node can have more than one subnode. Node elements for the new created sub node (images, font, background) are inhertitaed from the current node. No label (text) assigned

Returns:
the new node created
See Also:
getSubNodes(), findSubnode(long), addNode(E4TreeNode_Intf), addNode(String)

addNode

public E4TreeNode addNode(E4Label_Intf label)
Create and add a node to the current node. Each node can have more than one subnode. Node elements for the new created sub node (images, font, background) are inhertitaed from the current node. A label (text) can be assigned to the node.

Parameters:
label - label for the new created node.
Returns:
the new node created
See Also:
getSubNodes(), findSubnode(long), addNode(E4TreeNode_Intf)

addNode

public E4TreeNode addNode(java.lang.String label)
Create and add a node to the current node. Each node can have more than one subnode. Node elements for the new created sub node (images, font, background) are inhertitaed from the current node. A label (text) can be assigned to the node.

Parameters:
label - label for the new created node.
Returns:
the new node created
See Also:
getSubNodes(), findSubnode(long), addNode(E4TreeNode_Intf)

isOpen

public boolean isOpen()
Get the open state of a tree node. The open state represents if subnodes of a tree are displayed in the tree view. This has nothing to do with the isActive() state. Note, that there can be many or all nodes in a tree having this isOpen() state, depending on the user's choice. See also setOpen(boolean open)

Specified by:
isOpen in interface E4TreeNode_Intf
Returns:
true subnodes are shown, false otherwise
See Also:
setOpen(boolean), getImage(boolean), setImage(IMG,IMG)

setOpen

public void setOpen(boolean open)
Change the open status of a node.

Specified by:
setOpen in interface E4TreeNode_Intf
See Also:
isOpen()

setOpen

public void setOpen(boolean open,
                    int levels)
Change the open status of a node.

Specified by:
setOpen in interface E4TreeNode_Intf
Parameters:
open - true sets the node open, false sets the node closed
levels - go throught sub levels, repeat levels - 1 recursive. A value of MAX_INTEGER means all.
See Also:
isOpen()

isActive

public boolean isActive()
Get the active state of a tree node. The active state represents if this particular node was clicked by the user to run some detailed functionality, such as display a item. If a tree node is clicked, the flag is set tu true only for this node, and reset for all other nodes. So only one node within a tree should have this flag set to true. Use the function setActive(long node_id) to do so. This has nothing to do with the isOpen() state.

Specified by:
isActive in interface E4TreeNode_Intf
Returns:
true this is the selected node by the user
See Also:
setActive(long)

setActive

public void setActive(long lookup_node)
Sets the active state of this node to true (active) and resets all subnodes to false (inactive). It is highly recommended, to use this function never on a particular node but on the root node of the whole tree. All subnodes are preocessed, and only if the parameter node_id matches with one of the subnodes getId() value, then this one node is set to true (active). By default, tree handling is associated within module E4ModuleTreeHandling.

Specified by:
setActive in interface E4TreeNode_Intf
Parameters:
lookup_node - the node-ID (see getId()) to be changed to active
See Also:
isActive()

findSubnode

public E4TreeNode_Intf findSubnode(long nodeId)
Find a subnode within a tree. It is highly recommended, to use this function never on a particular node but on the root node of the whole tree, as all subnodes are searched recursivley.

Specified by:
findSubnode in interface E4TreeNode_Intf
Parameters:
nodeId - the node-ID (see getId()) to be searched for
Returns:
null if not found, a associated Tree-Node if found

findSubnodeText

public E4TreeNode_Intf findSubnodeText(java.lang.String text)
Find a subnode using the text.

Specified by:
findSubnodeText in interface E4TreeNode_Intf
Parameters:
text - the text of a tree node
Returns:
null if not found, a associated Tree-Node if found
See Also:
findSubnode(long), #findSubnode(E4String)

findSubnodeText

public E4TreeNode_Intf findSubnodeText(E4String text)
Description copied from interface: E4TreeNode_Intf
Find a subnode within a tree. It is highly recommended, to use this function never on a particular node but on the root node of the whole tree, as all subnodes are searched recursivley.

Specified by:
findSubnodeText in interface E4TreeNode_Intf
Parameters:
text - the text of a tree node
Returns:
null if not found, a associated Tree-Node if found

removeAllNodes

public void removeAllNodes()
Removes all subnodes from this node.

Specified by:
removeAllNodes in interface E4TreeNode_Intf
See Also:
addNode(e4s.html.tree.E4TreeNode_Intf), getSubNodes(), findSubnode(long)

hasSubnodes

public boolean hasSubnodes()
Determine, if a node has subnodes. Regardless, what is the open state returned by isOpen(), a tree can have subnodes. Subnodes are defined as objects from (implementing-)type E4TreeNode_Intf. Note that the declaration of sub nodes is part of the implementation, not of the interface.

Specified by:
hasSubnodes in interface E4TreeNode_Intf
Returns:
true if there is at least one subnode

toString

public java.lang.String toString()
Overrides:
toString in class E4Object

collectScripts

public void collectScripts(E4ScriptsVec v,
                           E4ServletImplementation_Intf servlet)
Append the current script to the Vector, each script is identified by a name and can only appear onece in the Vector.

Specified by:
collectScripts in interface E4TreeNode_Intf
Parameters:
v - the Vector where scripts are added.
See Also:
E4JavaScript

collectStylesForEditing

public void collectStylesForEditing(E4StylesHash vec,
                                    E4ServletImplementation_Intf servlet)
Build a list (Vector) with style definitions used so far during display of this page. Run throught all subclasses elements and collect their styles as well. Note, that a style will only be added one time. The Vector contains elements of class E4StyleUsage.

Specified by:
collectStylesForEditing in interface E4TreeNode_Intf
Parameters:
v - the Vector where the styles will be collected, may not be null
See Also:
E4ServletImplementation_Intf.sessionCanEditStyles(), #collectStylesForEditing( e4s.html.style.E4StylesHash, STYLE_Name, boolean)

setBgColor

public void setBgColor(E4Color color)

getBgColor

public E4Color getBgColor()
Specified by:
getBgColor in interface E4TreeNode_Intf

setFONT

public void setFONT(FONT font)

getFONT

public FONT getFONT()
Specified by:
getFONT in interface E4TreeNode_Intf

setSTYLE

public void setSTYLE(CLASS_Name css_class)

getSTYLE

public CLASS_Name getSTYLE()
Description copied from interface: E4TreeNode_Intf
Get the E4CSS definition for this tree node.

Specified by:
getSTYLE in interface E4TreeNode_Intf
See Also:
setSTYLE(e4s.html.style.CLASS_Name)

collectTranslationsForEditing

public void collectTranslationsForEditing(E4TranslationsVec v,
                                          E4ServletImplementation_Intf servlet)
Specified by:
collectTranslationsForEditing in interface E4TreeNode_Intf

removeNode

public boolean removeNode(E4TreeNode_Intf node)
Remove a node.

Specified by:
removeNode in interface E4TreeNode_Intf
Parameters:
node - the node to be removed
Returns:
true if node was found and removed
See Also:
removeNode(long)

removeNode

public boolean removeNode(long nodeId)
Description copied from interface: E4TreeNode_Intf
Remove a node.

Specified by:
removeNode in interface E4TreeNode_Intf
Parameters:
nodeId - the ID of the node
Returns:
true if node was found and removed

sort

public void sort(Language language)
Sort the sub-elements of this node ascending.

Specified by:
sort in interface E4TreeNode_Intf
See Also:
sort(e4s.application.Language,boolean)

sort

public void sort(Language language,
                 boolean ascending)
Sort the sub-elements of this node.

Specified by:
sort in interface E4TreeNode_Intf
Parameters:
ascending - true = sort ascending, false = descending
See Also:
sort( e4s.application.Language )

copy

public E4TreeNode_Intf copy()
Specified by:
copy in interface E4TreeNode_Intf

copy

public E4TreeNode copy(boolean copy_sub)

countNodes

public int countNodes()
Specified by:
countNodes in interface E4TreeNode_Intf

_getSVNVersionString

public static java.lang.String _getSVNVersionString()
Get version info string from subversion.

Returns:
the version info string.
See Also:
E4Util.getRevisionCodeFromSVN(Class)

www.element4solution.com