Search in sources :

Example 11 with GenericTreeModel

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

the class GenericMainController method activate.

// fxdiff BAKS-7 Resume function
private void activate(UserRequest ureq, String viewIdentifier) {
    ActionExtension ae;
    if (viewIdentifier != null && viewIdentifier.startsWith(GMCMT)) {
        Long extensionID = Long.parseLong(viewIdentifier.substring(viewIdentifier.indexOf(':') + 1));
        Extension ee = ExtManager.getInstance().getExtensionByID(extensionID);
        if (ee == null) {
            logWarn("ExtManager did not find an Extension for extensionID '" + extensionID + "'. Activate canceled...", null);
            return;
        }
        ae = (ActionExtension) ee.getExtensionFor(className, ureq);
    } else {
        int vwindex = viewIdentifier.lastIndexOf(":");
        String naviKey = viewIdentifier;
        if (vwindex >= 0) {
            naviKey = viewIdentifier.substring(0, viewIdentifier.indexOf(':'));
        }
        ae = ExtManager.getInstance().getActionExtensioByNavigationKey(className, naviKey);
        if (ae == null) {
            // this happens, if someone uses a navigation key, that no actionExtension uses...
            logWarn("couldn't find an ActionExtension for  navigationKey '" + naviKey + "' . I suggest adjusting spring configuration for GenericMainController..", null);
        }
    }
    if (ae == null) {
        // no action extension to activate...
        return;
    }
    try {
        if (olatMenuTree.getTreeModel() instanceof GenericTreeModel) {
            activateTreeNodeByActionExtension(ureq, ae);
        } else {
            // just for precaution (treenode selection won't work, but correct
            // content is displayed)
            contentCtr = getContentCtr(ae, ureq);
            listenTo(contentCtr);
            Component resComp = contentCtr.getInitialComponent();
            content.setContent(resComp);
            // fxdiff BAKS-7 Resume function
            addToHistory(ureq, contentCtr);
        }
    } catch (Exception e) {
        logWarn("", e);
    }
}
Also used : Extension(org.olat.core.extensions.Extension) ActionExtension(org.olat.core.extensions.action.ActionExtension) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) ActionExtension(org.olat.core.extensions.action.ActionExtension) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) Component(org.olat.core.gui.components.Component) AssertException(org.olat.core.logging.AssertException)

Example 12 with GenericTreeModel

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

the class GenericMainController method activateTreeNodeByActionExtension.

/**
 * activates the correct treenode for a given ActionExtension
 * @param ureq
 * @param ae
 */
private void activateTreeNodeByActionExtension(UserRequest ureq, ActionExtension ae) {
    TreeNode node = ((GenericTreeModel) olatMenuTree.getTreeModel()).findNodeByUserObject(ae);
    if (node != null) {
        olatMenuTree.setSelectedNodeId(node.getIdent());
        TreeEvent te = new TreeEvent(MenuTree.COMMAND_TREENODE_CLICKED, node.getIdent());
        event(ureq, olatMenuTree, te);
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel)

Example 13 with GenericTreeModel

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

the class MergedCourseContainer method init.

protected void init(PersistingCourseImpl persistingCourse) {
    super.init();
    RepositoryEntry courseRe = persistingCourse.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    courseReadOnly = !overrideReadOnly && (courseRe.getRepositoryEntryStatus().isClosed() || courseRe.getRepositoryEntryStatus().isUnpublished());
    if (courseReadOnly) {
        setLocalSecurityCallback(new ReadOnlyCallback());
    }
    if (identityEnv == null || identityEnv.getRoles().isOLATAdmin()) {
        VFSContainer courseContainer = persistingCourse.getIsolatedCourseFolder();
        if (courseReadOnly) {
            courseContainer.setLocalSecurityCallback(new ReadOnlyCallback());
        }
        addContainersChildren(courseContainer, true);
    } else {
        RepositoryEntry re = persistingCourse.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
        RepositoryEntrySecurity reSecurity = RepositoryManager.getInstance().isAllowed(identityEnv.getIdentity(), identityEnv.getRoles(), re);
        if (reSecurity.isEntryAdmin()) {
            VFSContainer courseContainer = persistingCourse.getIsolatedCourseFolder();
            if (courseReadOnly) {
                courseContainer.setLocalSecurityCallback(new ReadOnlyCallback());
            }
            addContainersChildren(courseContainer, true);
        }
    }
    initSharedFolder(persistingCourse);
    // add all course building blocks of type BC to a virtual folder
    MergeSource nodesContainer = new MergeSource(null, "_courseelementdata");
    if (identityEnv == null) {
        CourseNode rootNode = persistingCourse.getRunStructure().getRootNode();
        addFoldersForAdmin(persistingCourse, nodesContainer, rootNode);
    } else {
        TreeEvaluation treeEval = new TreeEvaluation();
        GenericTreeModel treeModel = new GenericTreeModel();
        UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(identityEnv, persistingCourse.getCourseEnvironment());
        CourseNode rootCn = userCourseEnv.getCourseEnvironment().getRunStructure().getRootNode();
        NodeEvaluation rootNodeEval = rootCn.eval(userCourseEnv.getConditionInterpreter(), treeEval, new VisibleTreeFilter());
        TreeNode treeRoot = rootNodeEval.getTreeNode();
        treeModel.setRootNode(treeRoot);
        addFolders(persistingCourse, nodesContainer, treeRoot);
    }
    if (nodesContainer.getItems().size() > 0) {
        addContainer(nodesContainer);
    }
}
Also used : ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) VisibleTreeFilter(org.olat.course.run.userview.VisibleTreeFilter) VFSContainer(org.olat.core.util.vfs.VFSContainer) RepositoryEntry(org.olat.repository.RepositoryEntry) MergeSource(org.olat.core.util.vfs.MergeSource) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) RepositoryEntrySecurity(org.olat.repository.model.RepositoryEntrySecurity) TreeNode(org.olat.core.gui.components.tree.TreeNode) TreeEvaluation(org.olat.course.run.userview.TreeEvaluation) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) PFCourseNode(org.olat.course.nodes.PFCourseNode) CourseNode(org.olat.course.nodes.CourseNode) BCCourseNode(org.olat.course.nodes.BCCourseNode) NodeEvaluation(org.olat.course.run.userview.NodeEvaluation)

Example 14 with GenericTreeModel

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

the class ArchiverMainController method buildTreeModel.

/**
 * Generates the archiver menu
 * @return The generated menu tree model
 */
private TreeModel buildTreeModel(UserRequest ureq) {
    GenericTreeNode root, gtn;
    GenericTreeModel gtm = new GenericTreeModel();
    root = new GenericTreeNode();
    root.setTitle(translate("menu.index"));
    root.setUserObject(CMD_INDEX);
    root.setAltText(translate("menu.index.alt"));
    gtm.setRootNode(root);
    if (archiverCallback.mayArchiveQtiResults()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.qtiresults"));
        gtn.setUserObject(CMD_QTISURVRESULTS);
        gtn.setAltText(translate("menu.qtiresults.alt"));
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveQtiTestResults()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.qtitestresults"));
        gtn.setUserObject(CMD_QTITESTRESULTS);
        gtn.setAltText("menu.qtitestresults.alt");
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveProperties()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.scoreaccounting"));
        gtn.setUserObject(CMD_SCOREACCOUNTING);
        gtn.setAltText(translate("menu.scoreaccounting.alt"));
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveHandedInTasks()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.handedintasks"));
        gtn.setUserObject(CMD_HANDEDINTASKS);
        gtn.setAltText(translate("menu.handedintasks.alt"));
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveHandedInTasks()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.grouptasks"));
        gtn.setUserObject(CMD_GROUPTASKS);
        gtn.setAltText(translate("menu.grouptasks.alt"));
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveProjectBroker()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.projectbroker"));
        gtn.setUserObject(CMD_PROJECTBROKER);
        gtn.setAltText(translate("menu.projectbroker.alt"));
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveLogfiles()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.archivelogfiles"));
        gtn.setUserObject(CMD_ARCHIVELOGFILES);
        gtn.setAltText(translate("menu.archivelogfiles.alt"));
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveForums()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.forums"));
        gtn.setUserObject(CMD_FORUMS);
        gtn.setAltText(translate("menu.forums.alt"));
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveDialogs()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.dialogs"));
        gtn.setUserObject(CMD_DIALOGS);
        gtn.setAltText(translate("menu.dialogs.alt"));
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveParticipantFolder()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.participantfolder"));
        gtn.setUserObject(CMD_PARTICIPANTFOLDER);
        gtn.setAltText("menu.participantfolder.alt");
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveWikis()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.wikis"));
        gtn.setUserObject(CMD_WIKIS);
        gtn.setAltText(translate("menu.wikis.alt"));
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveScorm()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.scorm"));
        gtn.setUserObject(CMD_SCORM);
        gtn.setAltText(translate("menu.scorm.alt"));
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveChecklist()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.checklist"));
        gtn.setUserObject(CMD_CHECKLIST);
        gtn.setAltText(translate("menu.checklist.alt"));
        root.addChild(gtn);
    }
    // add extension menues
    ExtManager extm = ExtManager.getInstance();
    Class extensionPointMenu = this.getClass();
    int cnt = extm.getExtensionCnt();
    for (int i = 0; i < cnt; i++) {
        Extension anExt = extm.getExtension(i);
        // check for sites
        ActionExtension ae = (ActionExtension) anExt.getExtensionFor(extensionPointMenu.getName(), ureq);
        if (ae != null && anExt.isEnabled()) {
            gtn = new GenericTreeNode();
            String menuText = ae.getActionText(locale);
            gtn.setTitle(menuText);
            gtn.setUserObject(ae);
            gtn.setAltText(ae.getDescription(locale));
            root.addChild(gtn);
            // inform only once
            if (!extensionLogged) {
                extensionLogged = true;
            }
        }
    }
    return gtm;
}
Also used : Extension(org.olat.core.extensions.Extension) ActionExtension(org.olat.core.extensions.action.ActionExtension) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) ExtManager(org.olat.core.extensions.ExtManager) ActionExtension(org.olat.core.extensions.action.ActionExtension) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel)

Example 15 with GenericTreeModel

use of org.olat.core.gui.components.tree.GenericTreeModel in project openolat by klemens.

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)

Aggregations

GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)62 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)42 TreeNode (org.olat.core.gui.components.tree.TreeNode)20 CourseNode (org.olat.course.nodes.CourseNode)12 Extension (org.olat.core.extensions.Extension)10 GenericActionExtension (org.olat.core.extensions.action.GenericActionExtension)10 AssertException (org.olat.core.logging.AssertException)10 ArrayList (java.util.ArrayList)8 ActionExtension (org.olat.core.extensions.action.ActionExtension)8 Controller (org.olat.core.gui.control.Controller)8 WindowControl (org.olat.core.gui.control.WindowControl)8 Identity (org.olat.core.id.Identity)8 OLATResourceable (org.olat.core.id.OLATResourceable)8 STCourseNode (org.olat.course.nodes.STCourseNode)8 NodeEvaluation (org.olat.course.run.userview.NodeEvaluation)8 List (java.util.List)6 ExtManager (org.olat.core.extensions.ExtManager)6 TreeModel (org.olat.core.gui.components.tree.TreeModel)6 ControllerEventListener (org.olat.core.gui.control.ControllerEventListener)6 TitledWrapperController (org.olat.core.gui.control.generic.title.TitledWrapperController)6