Class TreeNodeManager

java.lang.Object
com.amrdeveloper.treeview.TreeNodeManager

public class TreeNodeManager extends Object
Manager class for TreeNodes to easily apply operations on them and to make it easy for testing and extending
  • Constructor Details

    • TreeNodeManager

      public TreeNodeManager()
      Simple constructor
  • Method Details

    • setTreeNodes

      public void setTreeNodes(List<TreeNode> treeNodes)
      Set the current visible tree nodes
      Parameters:
      treeNodes - New tree nodes
    • getTreeNodes

      public List<TreeNode> getTreeNodes()
      Get the Current visible Tree nodes
      Returns:
      The visible Tree nodes main
    • get

      public TreeNode get(int index)
      Get TreeNode from the current nodes by index
      Parameters:
      index - of node to get it
      Returns:
      TreeNode from by index from current tree nodes if exists
    • addNode

      public boolean addNode(TreeNode node)
      Add new node to the current tree nodes
      Parameters:
      node - to add it to the current tree nodes
      Returns:
      true of this node is added
    • updateNodes

      public void updateNodes(List<TreeNode> newNodes)
      Clear the current nodes and insert new nodes
      Parameters:
      newNodes - to update the current nodes with them
    • removeNode

      public boolean removeNode(TreeNode node)
      Delete one node from the visible nodes
      Parameters:
      node - to delete it from the current nodes
      Returns:
      true of this node is deleted
    • clearNodes

      public void clearNodes()
      Clear the current nodes
    • size

      public int size()
      Get the current number of visible nodes
      Returns:
      the size of visible nodes
    • collapseNode

      public int collapseNode(TreeNode node)
      Collapsing node and all of his children
      Parameters:
      node - The node to collapse it
      Returns:
      the index of this node if it exists in the list
    • expandNode

      public int expandNode(TreeNode node)
      Expanding node and all of his children
      Parameters:
      node - The node to expand it
      Returns:
      the index of this node if it exists in the list
    • collapseNodeBranch

      public int collapseNodeBranch(TreeNode node)
      Parameters:
      node - The node to collapse the branch of it
      Returns:
      the index of this node if it exists in the list
    • expandNodeBranch

      public int expandNodeBranch(TreeNode node)
      Expanding node full branches
      Parameters:
      node - The node to expand the branch of it
      Returns:
      the index of this node if it exists in the list
    • expandNodeToLevel

      public void expandNodeToLevel(TreeNode node, int level)
      Expanding one node branch to until specific level
      Parameters:
      node - to expand branch of it until level
      level - to expand node branches to it
    • expandNodesAtLevel

      public void expandNodesAtLevel(int level)
      Expanding all tree nodes branches to until specific level
      Parameters:
      level - to expand all nodes branches to it
    • collapseAll

      public void collapseAll()
      Collapsing all nodes in the tree with their children
    • expandAll

      public void expandAll()
      Expanding all nodes in the tree with their children