Class TreeNode

  • All Implemented Interfaces:
    java.lang.Comparable

    public class TreeNode
    extends java.lang.Object
    implements java.lang.Comparable

    The TreeNode is the class used by the TreeBox to identify a single node.

    Users create an Array of TreeNode objects and pass the corresponding Enumeration to the TreeBox. The enumeration represents a single level in a hierarchal tree.

    The TreeNode class is also used by the TreeView to identify a single node.

    In either case users populate the TreeView with TreeNodes to render a tree. The TreeView has a root node by default to which the user can add more TreeNodes as children which themselves can have children and thus renprest a tree structure.

    For each node, the user needs to specify:

    • Its display name (as displayed by the browser).
    • Its ID (to uniquely identify the node).
    • The associated WebEvent (to expand the node).
    • If it's a leaf (those nodes that are leaf may not be expanded).

    When a node is expanded, the associated WebEvent is executed using the iFrame technology. With this, the tree can be dynamically populated without refreshing the whole page.

    Since:
    MicroStrategy Web 7.5.0
    See Also:
    and com.microstrategy.web.app.gui.TreeView
    • Constructor Summary

      Constructors 
      Constructor Description
      TreeNode()  
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void addChild​(int index, TreeNode child)
      this method adds a child node at a specifc index position
      void addChild​(TreeNode child)  
      void addExtraArgument​(java.lang.String key, java.lang.String value)  
      boolean canMultiSelect()
      Determines if this node can be used in multiselection or not.
      int compareTo​(java.lang.Object obj)  
      boolean equals​(java.lang.Object o)  
      HashList extraArguments()
      Function that returns a HashList object, that will represent a set of {argument key, argument value} pairs.
      TreeNode getChild​(int i)  
      int getChildCount()  
      java.lang.String getCssClass()  
      java.lang.String getDisplayName()
      Function that returns the name the text that will be displayed in the tree node.
      java.lang.String getID()
      Function that returns the ID of the tree node.
      int getLevel()
      Deprecated.
      Add children to the TreeNode using (@link TreeNode#addChild(TreeNode)} to get multiple levels.
      java.lang.String getNodeImage()
      Function that gets the image used to represent the tree node.
      TreeNode getParent()  
      boolean getSelected()  
      boolean getShouldRenderIcon()  
      int getType()
      Deprecated.
      You should assign the "tp" attribute directly as part of the extraArguments.
      boolean getUseIFrame()
      Indicates whether the instance uses IFrames for its link.
      java.lang.String getValue()
      Deprecated.
      You should assign the "val" attribute directly as part of the extraArguments.
      WebEvent getWebEvent()
      Function that returns the WebEvent object associated with the tree node.
      boolean hasChildren()  
      int hashCode()  
      boolean isExpanded()
      Function that specifies whether the tree node is expanded or collapsed.
      boolean isLeaf()
      Function that specifies whether the tree node is a leaf or not.
      void removeChild​(java.lang.String id)  
      void setCssClass​(java.lang.String value)
      This sets a css style name for the image that is associated with this tree node.
      void setDisplayName​(java.lang.String displayName)
      Function that sets the name that will be displayed in the tree node.
      void setExpanded​(boolean expanded)
      Function that sets whether the tree is expanded or collapsed.
      void setID​(java.lang.String id)
      Function that sets the ID of the tree node.
      void setLeaf​(boolean leaf)
      Function that sets whether the tree node is a leaf or not.
      void setLevel​(int level)
      Deprecated.
      Add children to the TreeNode using (@link TreeNode#addChild(TreeNode)} to get multiple levels.
      void setMultiSelect​(boolean value)
      Determines if this node can be used in multiselection or not.
      void setNodeImage​(java.lang.String imagePath)
      Function that sets the image used to represent the tree node.
      void setParent​(TreeNode parent)  
      void setSelected​(boolean selected)  
      void setShouldRenderIcon​(boolean displayIcon)  
      void setType​(int type)
      Deprecated.
      You should assign the "tp" attribute directly as part of the extraArguments.
      void setUseIFrame​(boolean value)
      Sets whether a ReportFrameElement should use IFrames in its output.
      void setValue​(java.lang.String value)
      Deprecated.
      You should assign the "val" attribute directly as part of the extraArguments.
      void setWebEvent​(WebEvent event)
      Function that sets the WebEvent object associated with the tree node.
      void sortChildren()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TreeNode

        public TreeNode()
    • Method Detail

      • getShouldRenderIcon

        public boolean getShouldRenderIcon()
      • setShouldRenderIcon

        public void setShouldRenderIcon​(boolean displayIcon)
      • setLevel

        public void setLevel​(int level)
        Deprecated.
        Add children to the TreeNode using (@link TreeNode#addChild(TreeNode)} to get multiple levels.
        Function that sets the level of indentation of the tree node in the tree.
        Parameters:
        level - number that specifies the indentation of the tree node in the tree.
      • getLevel

        public int getLevel()
        Deprecated.
        Add children to the TreeNode using (@link TreeNode#addChild(TreeNode)} to get multiple levels.
        Function that returns the level of indentation of the tree node in the tree.
        Returns:
        the level of indentation of the tree node in the tree.
      • setDisplayName

        public void setDisplayName​(java.lang.String displayName)
        Function that sets the name that will be displayed in the tree node.
        Parameters:
        displayName - the name to display in the tree.
      • getDisplayName

        public java.lang.String getDisplayName()
        Function that returns the name the text that will be displayed in the tree node.
        Returns:
        text displayed in the tree node.
      • setValue

        public void setValue​(java.lang.String value)
        Deprecated.
        You should assign the "val" attribute directly as part of the extraArguments.
        Function that sets the value of the tree node.
        Parameters:
        value - the value of the tree node.
      • addExtraArgument

        public void addExtraArgument​(java.lang.String key,
                                     java.lang.String value)
        Since:
        MicroStrategy Web 9.0.0
      • getValue

        public java.lang.String getValue()
        Deprecated.
        You should assign the "val" attribute directly as part of the extraArguments.
        Function that returns the value of the tree node.
        Returns:
        the value of the tree node.
      • setID

        public void setID​(java.lang.String id)
        Function that sets the ID of the tree node.
        Parameters:
        id - the ID of the tree node.
      • getID

        public java.lang.String getID()
        Function that returns the ID of the tree node.
        Returns:
        the ID of the tree node.
      • setType

        public void setType​(int type)
        Deprecated.
        You should assign the "tp" attribute directly as part of the extraArguments.
        Function that sets the type of object represented by the tree node.
        Parameters:
        type - the type of object represented by the tree node.
      • getType

        public int getType()
        Deprecated.
        You should assign the "tp" attribute directly as part of the extraArguments.
        Function that returns the type of object represented by the tree node.
        Returns:
        the type of object represented by the tree node.
      • isExpanded

        public boolean isExpanded()
        Function that specifies whether the tree node is expanded or collapsed.
        Returns:
        whether the tree node is expanded or collapsed.
      • setExpanded

        public void setExpanded​(boolean expanded)
        Function that sets whether the tree is expanded or collapsed.
        Parameters:
        expanded - specifies whether the tree is expanded or collapsed.
      • isLeaf

        public boolean isLeaf()
        Function that specifies whether the tree node is a leaf or not.
        Returns:
        whether the tree node is a leaf or not.
      • setLeaf

        public void setLeaf​(boolean leaf)
        Function that sets whether the tree node is a leaf or not.
        Parameters:
        leaf - specifies whether the tree node is a leaf or not.
      • extraArguments

        public HashList extraArguments()
        Function that returns a HashList object, that will represent a set of {argument key, argument value} pairs.
        For example, if the user wants to add an argument to represent whether the node is locked or not, then the key will be the argument name "locked" and the value will be an Integer object representing whether is locked or not.
        Returns:
        a HashList object with the extra arguments used by the tree node.
      • setWebEvent

        public void setWebEvent​(WebEvent event)
        Function that sets the WebEvent object associated with the tree node.
        Parameters:
        event - the WebEvent object associated with the tree node.
      • getWebEvent

        public WebEvent getWebEvent()
        Function that returns the WebEvent object associated with the tree node.
        Returns:
        the WebEvent object associated with the tree node.
      • getNodeImage

        public java.lang.String getNodeImage()
        Function that gets the image used to represent the tree node.
        Returns:
        the image used to represent the tree node.
      • setNodeImage

        public void setNodeImage​(java.lang.String imagePath)
        Function that sets the image used to represent the tree node.
        Parameters:
        imagePath - the image used to represent the tree node.
      • setMultiSelect

        public void setMultiSelect​(boolean value)
        Determines if this node can be used in multiselection or not.
        Parameters:
        value - if true, this node can be used for multiselection.
        Since:
        MicroStrategy Web 8.0.1
      • canMultiSelect

        public boolean canMultiSelect()
        Determines if this node can be used in multiselection or not.
        Returns:
        if true, this node can be used for multiselection.
        Since:
        MicroStrategy Web 8.0.1
      • setUseIFrame

        public void setUseIFrame​(boolean value)
        Sets whether a ReportFrameElement should use IFrames in its output.
        Parameters:
        value - true if IFrrames are enabled.
        Since:
        MicroStrategy Web 8.0.1
      • getUseIFrame

        public boolean getUseIFrame()
        Indicates whether the instance uses IFrames for its link. If useIFrame has not been explicitly set, it will always use iFrame for nodes and not use iFrame for leafs.
        Returns:
        true if it uses IFrames.
        Since:
        MicroStrategy Web 8.0.1
      • setCssClass

        public void setCssClass​(java.lang.String value)
        This sets a css style name for the image that is associated with this tree node. Please note that inorder to use this css style, the nodeImage has to be set using the setNodeImage method. Otherwise the class attribute is not rendered
        Parameters:
        value -
        Since:
        MicroStrategy Web 9.0.0
      • getCssClass

        public java.lang.String getCssClass()
        Since:
        MicroStrategy Web 9.0.0
      • addChild

        public void addChild​(TreeNode child)
        Since:
        MicroStrategy Web 9.0.0
      • addChild

        public void addChild​(int index,
                             TreeNode child)
        this method adds a child node at a specifc index position
        Parameters:
        child - TreeNode the child tree node to be added
        index - int the index of the position where we want the child node to be placed among its siblings
        Since:
        MicroStrategy Web 9.0.0
      • removeChild

        public void removeChild​(java.lang.String id)
      • sortChildren

        public void sortChildren()
        Since:
        MicroStrategy Web 9.0.0
      • getChild

        public TreeNode getChild​(int i)
        Since:
        MicroStrategy Web 9.0.0
      • setParent

        public void setParent​(TreeNode parent)
        Since:
        MicroStrategy Web 9.0.0
      • getParent

        public TreeNode getParent()
        Since:
        MicroStrategy Web 9.0.0
      • getChildCount

        public int getChildCount()
        Since:
        MicroStrategy Web 9.0.0
      • hasChildren

        public boolean hasChildren()
        Since:
        MicroStrategy Web 9.0.0
      • compareTo

        public int compareTo​(java.lang.Object obj)
        Specified by:
        compareTo in interface java.lang.Comparable
        Since:
        MicroStrategy Web 9.0.0
      • setSelected

        public void setSelected​(boolean selected)
        Since:
        MicroStrategy Web 9.0.0
      • getSelected

        public boolean getSelected()
        Since:
        MicroStrategy Web 9.0.0
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object