Package org.richfaces.model

Examples of org.richfaces.model.TreeNode


        }
       
        exclusions.add(id);
      }
     
      TreeNode node = new TreeNodeImpl();
      node.setData(xmlNodeData);
   
      this.treeNode.addChild(id, node);
      this.treeNodesList.add(this.treeNode);
      this.treeNode = node;
    }
View Full Code Here


  private TreeDataModel treeDataModel;

  public boolean isLeaf() {
    TreeRowKey rowKey = (TreeRowKey) getRowKey();
    TreeNode treeNode = locateTreeNode(rowKey);
    if (treeNode != null && !treeNode.isLeaf()) {
      return false;
    }
     
    treeNode = treeDataModel.locateTreeNode(rowKey);
    if (treeNode != null) {
      return treeNode.isLeaf();
    }

    return false;
  }
View Full Code Here

  public void walk(FacesContext context, final DataVisitor dataVisitor,
      Range range, Object rowKey, Object argument, boolean last)
      throws IOException {
   
    TreeNode cachedTreeNode = locateTreeNode((TreeRowKey) rowKey);
    TreeNode treeNode = treeDataModel.locateTreeNode((TreeRowKey) rowKey);
   
    if (treeNode != null) {
      if (cachedTreeNode == null || (cachedTreeNode.isLeaf() && !treeNode.isLeaf())) {
        //fill cache
        treeDataModel.walk(context, new Visitor(dataVisitor), range,
            rowKey, argument, last);
      } else {
        super.walk(context, dataVisitor, range, rowKey, argument, last);
View Full Code Here

    }

    @Override
    protected void proceedToNext() {
        Object key = childrenKeysIterator.next();
        TreeNode data = treeNode.getChild(key);

        setKeyAndData(key, data);
    }
View Full Code Here

  public void processSelection(NodeSelectedEvent event) {
    HtmlTree tree = (HtmlTree) event.getComponent();
    nodeTitle = (String) tree.getRowData();
    selectedNodeChildren.clear();
    TreeNode currentNode = tree.getModelTreeNode(tree.getRowKey());
    if (currentNode.isLeaf()){
      selectedNodeChildren.add((String)currentNode.getData());
    }else
    {
      Iterator<Map.Entry<Object, TreeNode>> it = currentNode.getChildren();
      while (it!=null &&it.hasNext()) {
          Map.Entry<Object, TreeNode> entry = it.next();
          selectedNodeChildren.add(entry.getValue().getData().toString());
      }
    }
View Full Code Here

  public void dropListener(DropEvent dropEvent) {
    // resolve drag source attributes
    UITreeNode srcNode = (dropEvent.getDraggableSource() instanceof UITreeNode) ? (UITreeNode) dropEvent.getDraggableSource() : null;
    UITree srcTree = srcNode != null ? srcNode.getUITree() : null;
    TreeRowKey dragNodeKey = (dropEvent.getDragValue() instanceof TreeRowKey) ? (TreeRowKey) dropEvent.getDragValue() : null;
    TreeNode draggedNode = dragNodeKey != null ? srcTree.getTreeNode(dragNodeKey) : null;

    // resolve drag destination attributes
    UITreeNode destNode = (dropEvent.getSource() instanceof UITreeNode) ? (UITreeNode) dropEvent.getSource() : null;
    UITree destTree = destNode != null ? destNode.getUITree() : null;
    TreeRowKey dropNodeKey = (dropEvent.getDropValue() instanceof TreeRowKey) ? (TreeRowKey) dropEvent.getDropValue() : null;
    TreeNode droppedInNode = dropNodeKey != null ? destTree.getTreeNode(dropNodeKey) : null;
   
    // Note: check if we dropped node on to itself or to item instead of folder here
    if (droppedInNode != null && (droppedInNode.equals(draggedNode) || droppedInNode.getParent().getParent() != null || draggedNode.getParent().getParent() == null)) {
        System.out.println("Warning: Can't drop on itself or to pic itself! Also can't move folders");
        return;
    }

    FacesContext context = FacesContext.getCurrentInstance();
   
    if (dropNodeKey != null) {
        // add destination node for rerender
        destTree.addRequestKey(dropNodeKey);
       
      Object state = null;
      if (dragNodeKey != null) { // Drag from this or other tree
          TreeNode parentNode = draggedNode.getParent();
          // 1. remove node from tree
          state = srcTree.removeNode(dragNodeKey);
          // 2. add parent for rerender
          Object rowKey = srcTree.getTreeNodeRowKey(parentNode);
          srcTree.addRequestKey(rowKey);       
View Full Code Here

TOP

Related Classes of org.richfaces.model.TreeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.