public ItTreeNode findProjectNode(Element project) { ItTreeNode root = (ItTreeNode) getModel().getRoot(); for (int i = 0; i < root.getChildCount(); i++) { ItTreeNode projectNode = (ItTreeNode) root.getChildAt(i); if (projectNode.getData() == project) { return projectNode; } } return null; }
// returns the project based on the project header id public Element getProject(String id) { Element project = null; TreeNode root = (TreeNode) treeModel.getRoot(); for (int i = 0; i < root.getChildCount(); i++) { ItTreeNode child = (ItTreeNode) root.getChildAt(i); Element projectHeader = child.getReference(); if (id.equals(projectHeader.getAttributeValue("id"))) { project = child.getData(); break; } } return project; }
public ItTreeNode findNodeFromData(ItTreeNode node, Element data) { if (node == null) { return null; } if (node.getData() == data) { return node; } else { ItTreeNode element = null; ItTreeNode result = null; for (int i = 0; i < node.getChildCount(); i++) { element = (ItTreeNode) node.getChildAt(i); result = findNodeFromData(element, data); if (result != null) { return result; } } return null; } }