Examples of AjaxTreeModel


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

  /**
   * Internal helper to build a dummy tree model which displays some time codes
   * @return
   */
  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;
      }     
    };
    // Set a custom icon for the root node
    model.setCustomRootIconCssClass("o_st_icon");
    return model;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.