Пример #1
0
  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;
  }
Пример #2
0
  // 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;
  }
Пример #3
0
  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;
    }
  }