Class TreeNodeUtils

java.lang.Object
com.inductiveautomation.ignition.designer.mvvm.binders.swing.TreeNodeUtils

public final class TreeNodeUtils extends Object
Static utility methods for working with BindableTreeNode trees.

Provides helpers to locate nodes by UUID and to find a node in a tree that has the same UUID as another node (useful when swapping trees but wanting to retain selection by stable identity).

  • Method Details

    • findByUuid

      public static <T> BindableTreeNode<T> findByUuid(BindableTreeNode<T> root, UUID uuid)
      Depth-first search for a node with the specified UUID within the given tree.
      Type Parameters:
      T - the node value type
      Parameters:
      root - the root of the tree to search (may be null)
      uuid - the UUID to match (may be null)
      Returns:
      the first node found with a matching UUID, or null if not found or inputs are null
    • findNodeWithSameUuid

      public static <T> BindableTreeNode<T> findNodeWithSameUuid(BindableTreeNode<T> root, BindableTreeNode<?> target)
      Convenience helper to find, within the provided tree, the node that has the same UUID as the target node.
      Type Parameters:
      T - the value type of the root tree
      Parameters:
      root - the root of the tree to search (may be null)
      target - the node whose UUID will be matched (may be null)
      Returns:
      the matching node in root's tree, or null if none found or inputs are null
    • getAllPaths

      public static <T> List<TreePath> getAllPaths(BindableTreeNode<T> root)
      Recursively collects all TreePaths in the given tree.
      Type Parameters:
      T - the node value type
      Parameters:
      root - the root of the tree
      Returns:
      a list containing all TreePaths from the root to every node in the tree
    • buildPath

      public static <T> TreePath buildPath(BindableTreeNode<T> node)
      Builds a TreePath for the given node by walking up to the root.
      Type Parameters:
      T - the node value type
      Parameters:
      node - the node to build the path for
      Returns:
      the TreePath for the node
    • createNodes

      public static BindableTreeNode<String> createNodes(double millions)
      Programmatically creates a tree with approximately the specified number of nodes (in millions), randomly nesting them up to a maximum depth.
      Parameters:
      millions - the number of nodes to create, in millions (e.g., 1.0 for 1,000,000 nodes)
      Returns:
      the root of the generated tree
    • createNodes

      public static BindableTreeNode<String> createNodes(double millions, int maxDepth)
      Programmatically creates a tree with approximately the specified number of nodes (in millions), randomly nesting them up to the specified maximum depth.
      Parameters:
      millions - the number of nodes to create, in millions (e.g., 1.0 for 1,000,000 nodes)
      maxDepth - the maximum depth of the tree (root is depth 0)
      Returns:
      the root of the generated tree