Package org.richfaces.model

Examples of org.richfaces.model.TreeNode


    private void createTree() {
        this.root = new TreeNodeImpl();
        Map<ServerPluginType, List<PluginKey>> types = serverPluginsBean.getInstalledServerPluginsGroupedByType();

        for (ServerPluginType type : types.keySet()) {
            TreeNode typeNode = createTypeNode(type, types.get(type));

            if (typeNode != null) {
                typeNode.setParent(root);
                root.addChild(type, typeNode);
            }
        }
    }
View Full Code Here


            }
        }
    }

    private TreeNode createTypeNode(ServerPluginType type, List<PluginKey> plugins) {
        TreeNode typeNode = new TreeNodeImpl();
        typeNode.setData(type);

        if (plugins != null && plugins.size() > 0) {
            for (PluginKey pluginKey : plugins) {
                TreeNode pluginNode = createPluginNode(pluginKey);
                pluginNode.setParent(typeNode);

                typeNode.addChild(pluginKey, pluginNode);
            }
        }
View Full Code Here

    private TreeNode createPluginNode(PluginKey pluginKey) {
        ServerPlugin plugin = serverPluginsBean.getServerPlugin(pluginKey);
        plugin = serverPluginsBean.getServerPluginRelationships(plugin);

        TreeNode pluginNode = new TreeNodeImpl();
        pluginNode.setData(plugin);

        return pluginNode;
    }
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

  // 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;

  // 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;
  if (dropEvent.getDraggableSource() instanceof UIDragSupport && srcTree == null && draggedNode == null && dropEvent.getDragValue() instanceof TreeNode) {     
      srcTree = destTree;
      draggedNode = (TreeNode) dropEvent.getDragValue();
      dragNodeKey = srcTree.getTreeNodeRowKey(draggedNode) instanceof TreeRowKey ? (TreeRowKey) srcTree.getTreeNodeRowKey(draggedNode) : 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)) {
      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

           
      // Check the children for their nodes
      Iterator i = node.getChildren();
      while( i.hasNext() ) {
        Entry entry = (Entry) i.next();
        TreeNode child = (TreeNode)entry.getValue();
        checkTreeNode( type, (String)entry.getKey(), child );
      }
     
      //Click on the current node to close
      richClient.clickTreeNodeHandle( key, getNodeTemplateId(type, node) );
View Full Code Here

    assertNotNull("Unable to find ajax tree component ["+_AJAX_TREE_NAME+"]",ajaxTree);

    HtmlDivision treeElement = (HtmlDivision)client.getElement(_AJAX_TREE_NAME);
    assertNotNull("Unable to find tree root DIV",treeElement);
   
    TreeNode data = (TreeNode)ajaxTree.getValue();
    assertNotNull("Unable to query for tree data",data);

    Iterator i = data.getChildren();
    while( i.hasNext() ) {
      Entry entry = (Entry) i.next();
      TreeNode child = (TreeNode)entry.getValue();
      checkTreeNode( "ajax", (String)entry.getKey(), child );     
    }
   
    treeElement = (HtmlDivision)client.getElement(_AJAX_TREE_NAME);
    assertNotNull("Unable to find tree root DIV",treeElement);
View Full Code Here

    assertNotNull("Unable to find ajax tree component ["+_SERVER_TREE_NAME+"]",serverTree);

    HtmlDivision treeElement = (HtmlDivision)client.getElement(_SERVER_TREE_NAME);
    assertNotNull("Unable to find tree root DIV",treeElement);
   
    TreeNode data = (TreeNode)serverTree.getValue();
    assertNotNull("Unable to query for tree data",data);
   
    Iterator i = data.getChildren();
    while( i.hasNext() ) {
      Entry entry = (Entry) i.next();
      TreeNode child = (TreeNode)entry.getValue();
      checkTreeNode( "server", (String)entry.getKey(), child );     
    }
   
    treeElement = (HtmlDivision)client.getElement(_SERVER_TREE_NAME);
    assertNotNull("Unable to find tree root DIV",treeElement);
View Full Code Here

    tree.removeDragListener(dragListener);
    treeNode.removeDragListener(dragListener);
  }
 
  public final void testAddNode() {
      TreeNode rootNode = new TreeNodeImpl<String>();
      rootNode.setData("root");
      tree.setValue(rootNode);
      tree.setPreserveModel("");
     
      TreeNode<String> newNode = new TreeNodeImpl<String>();
      newNode.setData("Sample node");
View Full Code Here

      TreeNode<String> node = tree.getTreeNode(rowKey);
      assertSame(node, newNode);
  }
 
  public final void testRemoveNode() {
      TreeNode rootNode = new TreeNodeImpl<String>();
      rootNode.setData("root");
      tree.setValue(rootNode);
      tree.setPreserveModel("");
     
      TreeNode<String> newNode = new TreeNodeImpl<String>();
      newNode.setData("Sample node");
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.