/**
  * Opens all nodes. this is called when '+' Expand All button is clicked on the screen
  *
  * @param treeNode the tree node
  */
 @Override
 public void openAllNodes(TreeNode treeNode) {
   if (treeNode != null) {
     for (int i = 0; i < treeNode.getChildCount(); i++) {
       TreeNode subTree = treeNode.setChildOpen(i, true);
       if ((subTree != null) && (subTree.getChildCount() > 0)) {
         openAllNodes(subTree);
       }
     }
   }
 }
Example #2
0
 private void refreshTree(TreeNode node) {
   int childCount = node.getChildCount();
   for (int i = 0; i < childCount; i++) {
     if (!node.isChildLeaf(i) && node.isChildOpen(i)) {
       node.setChildOpen(i, false);
       TreeNode child = node.setChildOpen(i, true);
       if (child != null) {
         refreshTree(child);
       }
     }
   }
 }
 /* (non-Javadoc)
  * @see mat.client.clause.clauseworkspace.presenter.XmlTreeDisplay#expandSelected(com.google.gwt.user.cellview.client.TreeNode)
  */
 @Override
 public void expandSelected(TreeNode treeNode) {
   if (treeNode != null) {
     for (int i = 0; i < treeNode.getChildCount(); i++) {
       TreeNode subTree = null;
       if (treeNode
           .getChildValue(i)
           .equals(
               selectedNode)) { // this check is performed since IE was giving JavaScriptError
                                // after removing a node and closing all nodes.
         // to avoid that we are closing the parent of the removed node.
         subTree = treeNode.setChildOpen(i, true, true);
         if ((subTree != null) && (subTree.getChildCount() > 0)) {
           openAllNodes(subTree);
         }
         break;
       }
       subTree =
           treeNode.setChildOpen(
               i,
               ((CellTreeNode) treeNode.getChildValue(i)).isOpen(),
               ((CellTreeNode) treeNode.getChildValue(i)).isOpen());
       if ((subTree != null) && (subTree.getChildCount() > 0)) {
         expandSelected(subTree);
       }
     }
   }
 }
 /**
  * This method is called after adding a child node to the parent. After adding a child node, close
  * the Parent node and open. Remaining all nodes will be opened or closed based on the isOpen
  * boolean in CellTreeNode
  *
  * @param treeNode the tree node
  */
 private void closeSelectedOpenNodes(TreeNode treeNode) {
   if (treeNode != null) {
     for (int i = 0; i < treeNode.getChildCount(); i++) {
       TreeNode subTree = null;
       if (treeNode.getChildValue(i).equals(selectedNode)) { // this check is performed since IE
         // was giving JavaScriptError after removing a node and closing all nodes.
         // to avoid that we are closing the parent of the removed node.
         subTree = treeNode.setChildOpen(i, false, false);
       }
       subTree = treeNode.setChildOpen(i, ((CellTreeNode) treeNode.getChildValue(i)).isOpen());
       if ((subTree != null) && (subTree.getChildCount() > 0)) {
         closeSelectedOpenNodes(subTree);
       }
     }
   }
 }
  /* (non-Javadoc)
   * @see mat.client.clause.clauseworkspace.presenter.XmlTreeDisplay#validateCellTreeNodes(com.google.gwt.user.cellview.client.TreeNode)
   */
  @Override
  public boolean validateCellTreeNodes(TreeNode treeNode) {

    if (treeNode != null) {
      openAllNodes(treeNode);
      for (int i = 0; i < treeNode.getChildCount(); i++) {
        TreeNode subTree = null;
        CellTreeNode node = (CellTreeNode) treeNode.getChildValue(i);
        if ((node.getNodeType() == CellTreeNode.TIMING_NODE)
            || (node.getNodeType() == CellTreeNode.RELATIONSHIP_NODE)) {
          // this check is performed since IE was giving JavaScriptError after removing a node and
          // closing all nodes.
          subTree = treeNode.setChildOpen(i, true, true);
          if ((subTree != null) && (subTree.getChildCount() == 2)) {
            if (!node.getValidNode()) {
              editNode(true, node, subTree);
            }
          } else {
            editNode(false, node, subTree);
            if (isValid) {
              isValid = false;
            }
          }
        }
        subTree =
            treeNode.setChildOpen(
                i,
                ((CellTreeNode) treeNode.getChildValue(i)).isOpen(),
                ((CellTreeNode) treeNode.getChildValue(i)).isOpen());
        if ((subTree != null) && (subTree.getChildCount() > 0)) {
          validateCellTreeNodes(subTree);
        }
      }
    }
    return isValid;
  }
  /**
   * Closing all nodes in the CellTree except for the Master Root Node which is the Population node.
   * This method is called when '-' Collapse All button is clicked on the Screen
   *
   * @param node the node
   */
  @Override
  public void closeNodes(TreeNode node) {
    if (node != null) {
      for (int i = 0; i < node.getChildCount(); i++) {
        TreeNode subTree = null;
        if (((CellTreeNode) node.getChildValue(i)).getNodeType() == CellTreeNode.MASTER_ROOT_NODE) {
          subTree = node.setChildOpen(i, true, true);
        } else {
          subTree = node.setChildOpen(i, false, true);
        }

        if ((subTree != null) && (subTree.getChildCount() > 0)) {
          closeNodes(subTree);
        }
      }
    }
  }
Example #7
0
 private boolean openNode(TreeNode node, TreePlace place) {
   int childCount = node.getChildCount();
   for (int i = 0; i < childCount; i++) {
     if (node.getChildValue(i).equals(place)) {
       // node.setChildOpen(i, true, true);
       return true;
     } else if (!node.isChildLeaf(i)) {
       boolean wasOpen = node.isChildOpen(i);
       TreeNode child = node.setChildOpen(i, true);
       if (child != null && openNode(child, place)) {
         return true;
       } else if (!wasOpen) {
         node.setChildOpen(i, false);
       }
     }
   }
   return false;
 }