Package org.olat.core.gui.control.generic.ajax.tree

Examples of org.olat.core.gui.control.generic.ajax.tree.AjaxTreeNode


    // load children of item and add them to the list
    if (item instanceof VFSContainer) {
      VFSContainer directory = (VFSContainer) item;
      List<VFSItem> childItems = directory.getItems(vfsFilter);
      for (VFSItem childItem : childItems) {
        AjaxTreeNode childNode = buildNode(childItem, nodePath);
        childNodes.add(childNode);
      }
    }
    return childNodes;
  }
View Full Code Here


   * @param vfsItem
   * @param nodePathPrefix prefix representing the path hierarchy
   * @return
   */
  private AjaxTreeNode buildNode(VFSItem vfsItem, String nodePathPrefix) {
    AjaxTreeNode node;
    try {
      // as node ID we use the file path relative to the root container, as
      // delimiter we use our special delimiter to not get in conflict with the
      // ext tree delimiter which uses "/".
      node = new AjaxTreeNode(nodePathPrefix + DELIMITER_NODE + vfsItem.getName(), vfsItem.getName());
     
      // Setting some node attributes - see the Treenode or the extjs
      // documentation on what else you could use
      boolean isContainer = (vfsItem instanceof VFSContainer);
      if (isContainer) {
        VFSContainer directory = (VFSContainer) vfsItem;
        // mark as of type non-leaf for sorting
        node.put(AjaxTreeNode.CONF_IS_TYPE_LEAF, false);
        // set leaf = true when this container contains no children - no
        // expand icon!
        if (directory.getItems(vfsFilter).size() == 0) {
          node.put(AjaxTreeNode.CONF_LEAF, true);
          node.put(AjaxTreeNode.CONF_DISABLED, true);
        } else {
          node.put(AjaxTreeNode.CONF_LEAF, false);
        }
        // use folder css class
        node.put(AjaxTreeNode.CONF_ICON_CSS_CLASS, "b_filetype_folder");
      } else {
        // mark as of type leaf for sorting
        node.put(AjaxTreeNode.CONF_IS_TYPE_LEAF, true);
        // mark as leaf to not show expand/collapse icon
        node.put(AjaxTreeNode.CONF_LEAF, true);
        // create cssclass for the given type
        String name = vfsItem.getName();
        String cssClass = "b_filetype_file"; // default
        int typePos = name.lastIndexOf(".");
        if (typePos > 0) {
          cssClass = "b_filetype_" + name.substring(typePos + 1);
        }
        node.put(AjaxTreeNode.CONF_ICON_CSS_CLASS, cssClass);
      }
      // disable drag&drop support
      node.put(AjaxTreeNode.CONF_ALLOWDRAG, false);
      node.put(AjaxTreeNode.CONF_ALLOWDROP, false);
    } catch (JSONException e) {
      throw new OLATRuntimeException("Error while creating AjaxTreeNode for VFSItem::" + vfsItem, e);
    }

    return node;
View Full Code Here

  private AjaxTreeModel buildTreeModel() {
    AjaxTreeModel model = new AjaxTreeModel("demomodelsdf"){
      @Override
      public List<AjaxTreeNode> getChildrenFor(String nodeId) {
        List<AjaxTreeNode> children = new ArrayList<AjaxTreeNode>();
        AjaxTreeNode child;
        try {
          child = new AjaxTreeNode( nodeId + ".1", "A wonderful day " + Calendar.getInstance().getTime().toString());
          // Setting some node attributes - see the Treenode or the extjs
          // documentation on what else you could use
          child.put(AjaxTreeNode.CONF_LEAF, true);// leafs can't be opened
          child.put(AjaxTreeNode.CONF_IS_TYPE_LEAF, true);
          child.put(AjaxTreeNode.CONF_ALLOWDRAG, true);
          child.put(AjaxTreeNode.CONF_ALLOWDROP, false);
          children.add(child);
          child = new AjaxTreeNode( nodeId + ".2", " Hello World " + Calendar.getInstance().getTime().toString());
          child.put(AjaxTreeNode.CONF_LEAF, false);
          child.put(AjaxTreeNode.CONF_IS_TYPE_LEAF, false); // sort folders above leafs
          child.put(AjaxTreeNode.CONF_ALLOWDRAG, true);
          child.put(AjaxTreeNode.CONF_ALLOWDROP, true);
          children.add(child);
          child = new AjaxTreeNode( nodeId + ".3", "I'm number two " + Calendar.getInstance().getTime().toString());
          child.put(AjaxTreeNode.CONF_LEAF, true); // leafs can't be opened
          child.put(AjaxTreeNode.CONF_IS_TYPE_LEAF, true);
          child.put(AjaxTreeNode.CONF_ICON_CSS_CLASS, "b_filetype_doc"); // a custom icon css class
          child.put(AjaxTreeNode.CONF_ALLOWDRAG, true);
          child.put(AjaxTreeNode.CONF_ALLOWDROP, false);
          children.add(child);
          child = new AjaxTreeNode( nodeId + ".4", "Folder " + Calendar.getInstance().getTime().toString());
          child.put(AjaxTreeNode.CONF_LEAF, false);
          child.put(AjaxTreeNode.CONF_IS_TYPE_LEAF, false); // sort folders above leafs
          child.put(AjaxTreeNode.CONF_ALLOWDRAG, true);
          child.put(AjaxTreeNode.CONF_ALLOWDROP, true);
          children.add(child);
        } catch (JSONException e) {
          throw new OLATRuntimeException("Error while creating gui demo ajax tree model", e);
        }
        return children;
View Full Code Here

        continue;
      }     
      // Add children of type node and children of type leaf only when leafs
      // should be shown
      if (childEntry.getType() == CatalogEntry.TYPE_NODE || showLeafs) {
        AjaxTreeNode childNode = buildNode(childEntry);
        childNodes.add(childNode);
      }
    }
    return childNodes;
  }
View Full Code Here

   * Internal helper to build a tree node from a catalog entry
   * @param catalogEntry
   * @return
   */
  private AjaxTreeNode buildNode(CatalogEntry catalogEntry) {   
    AjaxTreeNode node;
    try {
      node = new AjaxTreeNode(catalogEntry.getKey().toString(), catalogEntry.getName());
      // Setting some node attributes - see the Treenode or the extjs
      // documentation on what else you could use
      node.put(AjaxTreeNode.CONF_LEAF, (catalogEntry.getType() == CatalogEntry.TYPE_LEAF));
      if (catalogEntry.getType() == CatalogEntry.TYPE_NODE) {
        // set different css class depending on access rights
        CatalogManager cm = CatalogManager.getInstance();     
        if (ownedEntries != null && !cm.isEntryWithinCategory(catalogEntry, ownedEntries)) {
          node.put(AjaxTreeNode.CONF_ICON_CSS_CLASS, "o_catalog_cat_noaccess_icon");
        } else {
          node.put(AjaxTreeNode.CONF_ICON_CSS_CLASS, "o_catalog_cat_icon");         
        }
        // Check if node is expandable. ignore this check in d&d mode,
        // otherwhise those categories could not act as drop zones
        if (!allowDragNdrop && !cm.hasChildEntries(catalogEntry, CatalogEntry.TYPE_NODE)) {
          node.put(AjaxTreeNode.CONF_LEAF, true);
        }
       
      } else {
        node.put(AjaxTreeNode.CONF_ICON_CSS_CLASS, "o_catalog_entry_icon");
      }
      // use description as hoover text
      node.put(AjaxTreeNode.CONF_QTIP, catalogEntry.getDescription());
      // dragging for leafs and nodes, but only when configured
      node.put(AjaxTreeNode.CONF_ALLOWDRAG, allowDragNdrop);
      // top zones only for nodes
      node.put(AjaxTreeNode.CONF_ALLOWDROP, (allowDragNdrop && catalogEntry.getType() == CatalogEntry.TYPE_NODE));
    } catch (JSONException e) {
      throw new OLATRuntimeException("Error while creating AjaxTreeNode for catalog entry::" + catalogEntry, e);
    }
   
    return node;
View Full Code Here

   * @throws JSONException
   */
  private void addItem(Vector<AjaxTreeNode> nodeList, CPItem item) throws JSONException {
    String nId;
    nId = putIdentifierForNodeID(item.getIdentifier());
    AjaxTreeNode child = new AjaxTreeNode(nId, item.getTitle());
    if (item.getItems().size() == 0) {
      // Expand the leaf in order to get rid of the plus sign in front of it.
      child.put(AjaxTreeNode.CONF_EXPANDED, true);
    }
    child.put(AjaxTreeNode.CONF_ICON_CSS_CLASS, "o_cp_item");
    nodeList.add(child);
  }
View Full Code Here

    TreeNode treeNode = findNode(nodeId, getRootNode());
    // Now build the ajax tree nodes for each child
    int childCount = treeNode.getChildCount();
    for (int i = 0; i < childCount; i++) {
      INode childNode = treeNode.getChildAt(i);
      AjaxTreeNode childAjaxNode = buildAjaxTreeNode((TreeNode) childNode);
      childAjaxTreeNodes.add(childAjaxNode);
    }
    return childAjaxTreeNodes;   
  }
View Full Code Here

   *
   * @param vfsItem
   * @return
   */
  private AjaxTreeNode buildAjaxTreeNode(TreeNode treeNode) {
    AjaxTreeNode node;
    try {
      // as node ID we use the file path relative to the root container, as
      // delimiter we use our special delimiter to not get in conflict with the
      // ext tree delimiter which uses "/".
      node = new AjaxTreeNode(treeNode.getIdent(), treeNode.getTitle());
      // use folder css class
      node.put(AjaxTreeNode.CONF_ICON_CSS_CLASS, treeNode.getIconCssClass());
      // disable drag&drop support
      node.put(AjaxTreeNode.CONF_ALLOWDRAG, false);
      node.put(AjaxTreeNode.CONF_ALLOWDROP, false);
      // set open-icon only when there are children available
      node.put(AjaxTreeNode.CONF_LEAF, (treeNode.getChildCount() < 1));
    } catch (JSONException e) {
      throw new OLATRuntimeException("Error while creating AjaxTreeNode for treeNode::" + treeNode.getIdent(), e);
    }

    return node;
View Full Code Here

TOP

Related Classes of org.olat.core.gui.control.generic.ajax.tree.AjaxTreeNode

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.