private TreeNode createTree(Classification raiz, Collection<Classification> lista) {
    TreeNode node = new DefaultTreeNode(raiz, null);
    TreeNode child = null;

    Collection<Classification> hijos = getChildren(raiz, lista);

    for (Classification hijo : hijos) {
      if (hijo.getClassificationList() != null) {
        child = createTree(hijo, lista);
        child.setParent(node);
      } else {
        child = new DefaultTreeNode(hijo, node);
        child.setParent(node);
      }
      // node.addChild(child);

    }
    return node;
  }
Esempio n. 2
0
 /** Removes all child nodes of the supplied root node. */
 private void removeAllChildsOfRootNode(final TreeNode rootNode) {
   if ((rootNode != null) && (rootNode.getChildCount() > 0)) {
     final TreeNode[] array =
         rootNode.getChildren().toArray(new TreeNode[rootNode.getChildCount()]);
     for (TreeNode child : array) {
       child.setParent(null);
       child = null;
     }
   }
 }
  // Lo que se cambio para el Primefaces3.2
  private void createClassificationTree() {
    try {
      Classification raiz = classificationFacade.findRootByClient(getClient());
      classificationList = classificationFacade.getEagerClassificationListByClient(getClient());
      root = new DefaultTreeNode("root", null);

      TreeNode arbol = createTree(getRootFromClassificationList(raiz), getClassificationList());
      arbol.setExpanded(true);
      arbol.setParent(root);
      // root.getChildren().add(arbol);

      classificationList = null;

    } catch (GenericFacadeException ex) {
      Logger.getLogger(CrudUserphoneBean.class.getName()).log(Level.SEVERE, null, ex);
    }
  }