Search in sources :

Example 71 with GenericTreeNode

use of org.olat.core.gui.components.tree.GenericTreeNode in project OpenOLAT by OpenOLAT.

the class NodeEvaluation method build.

/**
 * 1. Calculate if the node should be accessible at all. <br/>
 * 2. If the coursenode is visible, build a treenode.
 */
public void build() {
    // if at least one access	capability is true
    for (Iterator<Boolean> iter = accesses.values().iterator(); iter.hasNext(); ) {
        Boolean entry = iter.next();
        atLeastOneAccessible = atLeastOneAccessible || entry.booleanValue();
    }
    // if the coursenode is visible, build a treenode
    if (isVisible()) {
        gtn = new GenericTreeNode(courseNode.getIdent());
        gtn.setTitle(courseNode.getShortTitle());
        gtn.setAltText(courseNode.getLongTitle());
        String type = courseNode.getType();
        CourseNodeConfiguration cnConfig = CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(type);
        if (cnConfig != null) {
            String nodeCssClass = null;
            if (courseNode.getParent() == null) {
                // Spacial case for root node
                nodeCssClass = "o_CourseModule_icon";
            } else {
                nodeCssClass = cnConfig.getIconCSSClass();
            }
            gtn.setIconCssClass(nodeCssClass);
        }
        // the current NodeEval is set into the treenode
        gtn.setUserObject(this);
        // as the userobject
        // all treenodes added here are set to be visible/accessible, since the
        // invisible are not pushed by convention
        gtn.setAccessible(true);
    }
// else treenode is null
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration)

Example 72 with GenericTreeNode

use of org.olat.core.gui.components.tree.GenericTreeNode in project OpenOLAT by OpenOLAT.

the class GenericMainController method buildTreeModel.

private TreeModel buildTreeModel(UserRequest ureq) {
    GenericTreeNode rootTreeNode = new GenericTreeNode();
    rootTreeNode.setTitle(getTranslator().translate("main.menu.title"));
    rootTreeNode.setAltText(getTranslator().translate("main.menu.title.alt"));
    GenericTreeModel gtm = new GenericTreeModel();
    gtm.setRootNode(rootTreeNode);
    // Prepend
    boolean rootNodeSet = false;
    if (nodesToPrepend.size() != 0) {
        for (GenericTreeNode node : nodesToPrepend) {
            rootTreeNode.addChild(node);
            if (!rootNodeSet) {
                rootTreeNode.setDelegate(node);
                rootTreeNode.setUserObject(node.getUserObject());
                rootNodeSet = true;
            }
        }
    }
    // add extension menues
    ExtManager extm = ExtManager.getInstance();
    int j = 0;
    GenericTreeNode gtnChild;
    Map<GenericTreeNode, String> subMenuNodes = new LinkedHashMap<GenericTreeNode, String>();
    for (Extension anExt : extm.getExtensions()) {
        // check for sites
        ActionExtension ae = (ActionExtension) anExt.getExtensionFor(className, ureq);
        if (ae != null && ae instanceof GenericActionExtension) {
            if (anExt.isEnabled()) {
                GenericActionExtension gAe = (GenericActionExtension) ae;
                gtnChild = gAe.createMenuNode(ureq);
                if (StringHelper.containsNonWhitespace(gAe.getNavigationKey())) {
                    gtnChild.setCssClass("o_sel_" + gAe.getNavigationKey());
                }
                if (gAe.getNodeIdentifierIfParent() != null) {
                    // it's a parent-node, set identifier
                    gtnChild.setIdent(gAe.getNodeIdentifierIfParent());
                }
                if (j == 0 && !rootNodeSet) {
                    // first node, set as delegate of rootTreenode
                    rootTreeNode.setDelegate(gtnChild);
                    rootTreeNode.setUserObject(gAe);
                    rootTreeNode.addChild(gtnChild);
                } else // navigation (submenues)
                if (gAe.getParentTreeNodeIdentifier() != null) {
                    // this is a sub-menu-node, do not add to tree-model already, since
                    // parent tree may not yet be in model
                    // (parent could be "after" child, in ActionExtensions-Collection)
                    String parentNodeID = gAe.getParentTreeNodeIdentifier();
                    subMenuNodes.put(gtnChild, parentNodeID);
                } else // "normal" menu-entry
                {
                    rootTreeNode.addChild(gtnChild);
                }
                j++;
            } else {
                logInfo("found disabled GenericActionExtension for " + className + " ", ae.toString());
            }
        }
    }
    // loop over submenuNodes and add to their parents
    for (Entry<GenericTreeNode, String> childNodeEntry : subMenuNodes.entrySet()) {
        GenericTreeNode childNode = childNodeEntry.getKey();
        GenericTreeNode parentNode = (GenericTreeNode) gtm.getNodeById(childNodeEntry.getValue());
        if (parentNode != null) {
            parentNode.addChild(childNode);
            if (parentNode.getDelegate() == null) {
                boolean addDelegate = true;
                // add delegate only if hte parent hasn't not a controller defined
                Object uo = parentNode.getUserObject();
                if (uo instanceof GenericActionExtension) {
                    GenericActionExtension gae = (GenericActionExtension) uo;
                    if (StringHelper.containsNonWhitespace(gae.getClassNameOfCorrespondingController())) {
                        addDelegate = false;
                    }
                }
                if (addDelegate) {
                    parentNode.setDelegate(childNode);
                    parentNode.setUserObject(childNode.getUserObject());
                }
            }
        } else {
            logWarn("Could not add navigation-menu (" + childNode.getTitle() + ") to parent:: " + childNodeEntry.getValue(), null);
            // make it at least appear on top level
            rootTreeNode.addChild(childNode);
        }
    }
    // Append
    if (nodesToAppend.size() != 0) {
        for (GenericTreeNode node : nodesToAppend) {
            rootTreeNode.addChild(node);
        }
    }
    return gtm;
}
Also used : ExtManager(org.olat.core.extensions.ExtManager) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) LinkedHashMap(java.util.LinkedHashMap) Extension(org.olat.core.extensions.Extension) ActionExtension(org.olat.core.extensions.action.ActionExtension) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) ActionExtension(org.olat.core.extensions.action.ActionExtension) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel)

Example 73 with GenericTreeNode

use of org.olat.core.gui.components.tree.GenericTreeNode in project OpenOLAT by OpenOLAT.

the class GroupInfoMainController method buildTreeModel.

private TreeModel buildTreeModel() {
    // Builds the model for the navigation tree
    GenericTreeModel treeModel = new GenericTreeModel();
    GenericTreeNode rootNode = new GenericTreeNode();
    rootNode.setTitle(translate("main.menu.title"));
    treeModel.setRootNode(rootNode);
    GenericTreeNode childNode = new GenericTreeNode();
    childNode.setTitle(translate("main.menu.title"));
    childNode.setUserObject(COMMAND_MENU_GROUPINFO);
    childNode.setCssClass("o_sel_groupcard_infos");
    childNode.setSelected(true);
    rootNode.addChild(childNode);
    rootNode.setDelegate(childNode);
    if (calendarModule.isEnableGroupCalendar() && isCalendarEnabled()) {
        childNode = new GenericTreeNode();
        childNode.setTitle(translate("main.menu.calendar"));
        childNode.setUserObject(COMMAND_MENU_GROUPCALENDAR);
        childNode.setCssClass("o_sel_groupcard_calendar");
        rootNode.addChild(childNode);
    }
    if (businessGroup.isOwnersVisiblePublic() || businessGroup.isParticipantsVisiblePublic() || businessGroup.isWaitingListVisiblePublic()) {
        childNode = new GenericTreeNode();
        childNode.setTitle(translate("main.menu.members"));
        childNode.setUserObject(COMMAND_MENU_GROUPMEMBERS);
        childNode.setCssClass("o_sel_groupcard_members");
        rootNode.addChild(childNode);
    }
    if (isContactEnabled()) {
        childNode = new GenericTreeNode();
        childNode.setTitle(translate("main.menu.contact"));
        childNode.setUserObject(COMMAND_MENU_GROUPCONTACT);
        childNode.setCssClass("o_sel_groupcard_contact");
        rootNode.addChild(childNode);
    }
    return treeModel;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel)

Example 74 with GenericTreeNode

use of org.olat.core.gui.components.tree.GenericTreeNode in project OpenOLAT by OpenOLAT.

the class InsertItemTreeModel method buildNode.

private TreeNode buildNode(TreeNode parent) {
    GenericTreeNode ctn = new GenericTreeNode(parent.getTitle(), parent);
    ctn.setIconCssClass(parent.getIconCssClass());
    int childcnt = parent.getChildCount();
    for (int i = 0; i < childcnt; i++) {
        // add child itself
        TreeNode ctchild = buildNode((TreeNode) parent.getChildAt(i));
        ctn.addChild(ctchild);
    }
    return ctn;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode)

Example 75 with GenericTreeNode

use of org.olat.core.gui.components.tree.GenericTreeNode in project OpenOLAT by OpenOLAT.

the class AssessmentTestComposerController method doUpdate.

private void doUpdate(Identifier identifier, String newTitle) {
    TreeNode node = menuTree.getTreeModel().getNodeById(identifier.toString());
    if (node instanceof GenericTreeNode) {
        GenericTreeNode itemNode = (GenericTreeNode) node;
        if (!newTitle.equals(itemNode.getTitle())) {
            itemNode.setTitle(newTitle);
            menuTree.setDirty(true);
        }
    }
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode)

Aggregations

GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)124 TreeNode (org.olat.core.gui.components.tree.TreeNode)30 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)24 CourseNode (org.olat.course.nodes.CourseNode)10 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)10 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)10 HashMap (java.util.HashMap)8 INode (org.olat.core.util.nodes.INode)8 ArrayList (java.util.ArrayList)6 Element (org.dom4j.Element)6 XPath (org.dom4j.XPath)6 ExtManager (org.olat.core.extensions.ExtManager)6 Extension (org.olat.core.extensions.Extension)6 CatalogEntry (org.olat.repository.CatalogEntry)6 ActionExtension (org.olat.core.extensions.action.ActionExtension)4 GenericActionExtension (org.olat.core.extensions.action.GenericActionExtension)4 CourseNodeConfiguration (org.olat.course.nodes.CourseNodeConfiguration)4 QTI21QuestionType (org.olat.ims.qti21.model.QTI21QuestionType)4 Taxonomy (org.olat.modules.taxonomy.Taxonomy)4 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)4