Esempio n. 1
0
  private static void addEach(
      final TreeNode aRootNode, final TreeNode aNode, final List<TreeNode> aPathStack) {
    aPathStack.add(aNode);

    if (aNode != aRootNode) {
      addEach(aRootNode, aNode.getParent(), aPathStack);
    }
  }
Esempio n. 2
0
  public static TreePath getPath(final TreeNode aRootNode, final TreeNode aNode) {
    final List<TreeNode> pathStack = new ArrayList<TreeNode>();
    addEach(aRootNode, aNode, pathStack);

    final Object[] pathElements = new Object[pathStack.size()];

    for (int i = pathStack.size() - 1; i >= 0; i--) {
      pathElements[pathStack.size() - i - 1] = pathStack.get(i);
    }

    return new TreePath(pathElements);
  }