Search in sources :

Example 56 with GenericTreeModel

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

the class StatisticCourseNodesController method buildTreeModel.

private TreeModel buildTreeModel(final UserRequest ureq, final UserCourseEnvironment userCourseEnv) {
    final GenericTreeModel gtm = new GenericTreeModel();
    final GenericTreeNode rootTreeNode = new GenericTreeNode();
    rootTreeNode.setTitle("start");
    gtm.setRootNode(rootTreeNode);
    ICourse course = CourseFactory.loadCourse(userCourseEnv.getCourseEnvironment().getCourseResourceableId());
    new TreeVisitor(new Visitor() {

        @Override
        public void visit(INode node) {
            CourseNode courseNode = (CourseNode) node;
            StatisticResourceResult result = courseNode.createStatisticNodeResult(ureq, getWindowControl(), userCourseEnv, options, types);
            if (result != null) {
                StatisticResourceNode courseNodeTreeNode = new StatisticResourceNode(courseNode, result);
                rootTreeNode.addChild(courseNodeTreeNode);
                TreeModel subTreeModel = result.getSubTreeModel();
                if (subTreeModel != null) {
                    TreeNode subRootNode = subTreeModel.getRootNode();
                    List<INode> subNodes = new ArrayList<>();
                    for (int i = 0; i < subRootNode.getChildCount(); i++) {
                        subNodes.add(subRootNode.getChildAt(i));
                    }
                    for (INode subNode : subNodes) {
                        courseNodeTreeNode.addChild(subNode);
                    }
                }
            }
        }
    }, course.getRunStructure().getRootNode(), true).visitAll();
    return gtm;
}
Also used : INode(org.olat.core.util.nodes.INode) TreeVisitor(org.olat.core.util.tree.TreeVisitor) Visitor(org.olat.core.util.tree.Visitor) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) TreeVisitor(org.olat.core.util.tree.TreeVisitor) TreeModel(org.olat.core.gui.components.tree.TreeModel) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) CourseNode(org.olat.course.nodes.CourseNode)

Example 57 with GenericTreeModel

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

the class PreviewRunController method updateTreeAndContent.

/**
 * side-effecty to content and luTree
 *
 * @param ureq
 * @param calledCourseNode the node to jump to, if null = jump to root node
 * @return true if the node jumped to is visible
 */
private boolean updateTreeAndContent(UserRequest ureq, CourseNode calledCourseNode) {
    // build menu (treemodel)
    NodeClickedRef nclr = navHandler.evaluateJumpToCourseNode(ureq, getWindowControl(), calledCourseNode, this, null);
    if (!nclr.isVisible()) {
        // if not root -> fallback to root. e.g. when a direct node jump fails
        if (calledCourseNode != null) {
            nclr = navHandler.evaluateJumpToCourseNode(ureq, getWindowControl(), null, this, null);
        }
        if (!nclr.isVisible()) {
            getWindowControl().setWarning(translate("msg.nodenotavailableanymore"));
            content.setContent(null);
            luTree.setTreeModel(new GenericTreeModel());
            return false;
        }
    }
    treeModel = nclr.getTreeModel();
    luTree.setTreeModel(treeModel);
    String selNodeId = nclr.getSelectedNodeId();
    luTree.setSelectedNodeId(selNodeId);
    luTree.setOpenNodeIds(nclr.getOpenNodeIds());
    // dispose old node controller
    if (currentNodeController != null && !currentNodeController.isDisposed() && !navHandler.isListening(currentNodeController)) {
        currentNodeController.dispose();
    }
    currentNodeController = nclr.getRunController();
    content.setContent(currentNodeController.getInitialComponent());
    return true;
}
Also used : GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) NodeClickedRef(org.olat.course.run.navigation.NodeClickedRef)

Example 58 with GenericTreeModel

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

the class BusinessGroupMainRunController method buildTreeModel.

/**
 * @return The menu tree model
 */
private TreeModel buildTreeModel() {
    GenericTreeNode gtnChild, root;
    GenericTreeModel gtm = new GenericTreeModel();
    root = new GenericTreeNode(nodeIdPrefix.concat("-root"));
    root.setTitle(businessGroup.getName());
    root.setUserObject(ACTIVITY_MENUSELECT_OVERVIEW);
    root.setAltText(translate("menutree.top.alt") + " " + businessGroup.getName());
    root.setIconCssClass("o_icon o_icon_group");
    gtm.setRootNode(root);
    CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(this.businessGroup);
    if (collabTools.isToolEnabled(CollaborationTools.TOOL_NEWS)) {
        gtnChild = new GenericTreeNode(nodeIdPrefix.concat("new"));
        gtnChild.setTitle(translate("menutree.news"));
        gtnChild.setUserObject(ACTIVITY_MENUSELECT_INFORMATION);
        gtnChild.setAltText(translate("menutree.news.alt"));
        gtnChild.setIconCssClass("o_icon_news");
        gtnChild.setCssClass("o_sel_group_news");
        root.addChild(gtnChild);
        nodeInformation = gtnChild;
    }
    if (calendarModule.isEnabled() && calendarModule.isEnableGroupCalendar() && collabTools.isToolEnabled(CollaborationTools.TOOL_CALENDAR)) {
        gtnChild = new GenericTreeNode(nodeIdPrefix.concat("cal"));
        gtnChild.setTitle(translate("menutree.calendar"));
        gtnChild.setUserObject(ACTIVITY_MENUSELECT_CALENDAR);
        gtnChild.setAltText(translate("menutree.calendar.alt"));
        gtnChild.setIconCssClass("o_calendar_icon");
        gtnChild.setCssClass("o_sel_group_calendar");
        root.addChild(gtnChild);
        nodeCal = gtnChild;
    }
    boolean hasResources = businessGroupService.hasResources(businessGroup);
    if (hasResources) {
        gtnChild = new GenericTreeNode(nodeIdPrefix.concat("courses"));
        gtnChild.setTitle(translate("menutree.resources"));
        gtnChild.setUserObject(ACTIVITY_MENUSELECT_SHOW_RESOURCES);
        gtnChild.setAltText(translate("menutree.resources.alt"));
        gtnChild.setIconCssClass("o_CourseModule_icon");
        gtnChild.setCssClass("o_sel_group_resources");
        root.addChild(gtnChild);
        nodeResources = gtnChild;
    }
    if (businessGroup.isOwnersVisibleIntern() || businessGroup.isParticipantsVisibleIntern() || businessGroup.isWaitingListVisibleIntern()) {
        // either owners, participants, the waiting list or all three are visible
        // otherwise the node is not visible
        gtnChild = new GenericTreeNode(nodeIdPrefix.concat("members"));
        gtnChild.setTitle(translate("menutree.members"));
        gtnChild.setUserObject(ACTIVITY_MENUSELECT_MEMBERSLIST);
        gtnChild.setAltText(translate("menutree.members.alt"));
        gtnChild.setIconCssClass("o_icon_group");
        gtnChild.setCssClass("o_sel_group_members");
        root.addChild(gtnChild);
        nodeGroupOwners = gtnChild;
    }
    if (collabTools.isToolEnabled(CollaborationTools.TOOL_CONTACT)) {
        gtnChild = new GenericTreeNode(nodeIdPrefix.concat("contact"));
        gtnChild.setTitle(translate("menutree.contactform"));
        gtnChild.setUserObject(ACTIVITY_MENUSELECT_CONTACTFORM);
        gtnChild.setAltText(translate("menutree.contactform.alt"));
        gtnChild.setIconCssClass("o_co_icon");
        gtnChild.setCssClass("o_sel_group_contact");
        root.addChild(gtnChild);
        nodeContact = gtnChild;
    }
    if (collabTools.isToolEnabled(CollaborationTools.TOOL_FOLDER)) {
        gtnChild = new GenericTreeNode(nodeIdPrefix.concat("folder"));
        gtnChild.setTitle(translate("menutree.folder"));
        gtnChild.setUserObject(ACTIVITY_MENUSELECT_FOLDER);
        gtnChild.setAltText(translate("menutree.folder.alt"));
        gtnChild.setIconCssClass("o_bc_icon");
        gtnChild.setCssClass("o_sel_group_folder");
        root.addChild(gtnChild);
        nodeFolder = gtnChild;
    }
    if (collabTools.isToolEnabled(CollaborationTools.TOOL_FORUM)) {
        gtnChild = new GenericTreeNode(nodeIdPrefix.concat("forum"));
        gtnChild.setTitle(translate("menutree.forum"));
        gtnChild.setUserObject(ACTIVITY_MENUSELECT_FORUM);
        gtnChild.setAltText(translate("menutree.forum.alt"));
        gtnChild.setIconCssClass("o_fo_icon");
        gtnChild.setCssClass("o_sel_group_forum");
        root.addChild(gtnChild);
        nodeForum = gtnChild;
    }
    if (chatAvailable) {
        gtnChild = new GenericTreeNode(nodeIdPrefix.concat("chat"));
        gtnChild.setTitle(translate("menutree.chat"));
        gtnChild.setUserObject(ACTIVITY_MENUSELECT_CHAT);
        gtnChild.setAltText(translate("menutree.chat.alt"));
        gtnChild.setIconCssClass("o_icon_chat");
        gtnChild.setCssClass("o_sel_group_chat");
        root.addChild(gtnChild);
    }
    BaseSecurityModule securityModule = CoreSpringFactory.getImpl(BaseSecurityModule.class);
    if (collabTools.isToolEnabled(CollaborationTools.TOOL_WIKI) && securityModule.isWikiEnabled()) {
        gtnChild = new GenericTreeNode(nodeIdPrefix.concat("wiki"));
        gtnChild.setTitle(translate("menutree.wiki"));
        gtnChild.setUserObject(ACTIVITY_MENUSELECT_WIKI);
        gtnChild.setAltText(translate("menutree.wiki.alt"));
        gtnChild.setIconCssClass("o_wiki_icon");
        gtnChild.setCssClass("o_sel_group_wiki");
        root.addChild(gtnChild);
        nodeWiki = gtnChild;
    }
    if (collabTools.isToolEnabled(CollaborationTools.TOOL_PORTFOLIO) && (portfolioModule.isEnabled() || portfolioV2Module.isEnabled())) {
        gtnChild = new GenericTreeNode(nodeIdPrefix.concat("eportfolio"));
        gtnChild.setTitle(translate("menutree.portfolio"));
        gtnChild.setUserObject(ACTIVITY_MENUSELECT_PORTFOLIO);
        gtnChild.setAltText(translate("menutree.portfolio.alt"));
        gtnChild.setIconCssClass("o_ep_icon");
        gtnChild.setCssClass("o_sel_group_portfolio");
        root.addChild(gtnChild);
        nodePortfolio = gtnChild;
    }
    OpenMeetingsModule openMeetingsModule = CoreSpringFactory.getImpl(OpenMeetingsModule.class);
    if (openMeetingsModule.isEnabled() && collabTools.isToolEnabled(CollaborationTools.TOOL_OPENMEETINGS)) {
        gtnChild = new GenericTreeNode(nodeIdPrefix.concat("meetings"));
        gtnChild.setTitle(translate("menutree.openmeetings"));
        gtnChild.setUserObject(ACTIVITY_MENUSELECT_OPENMEETINGS);
        gtnChild.setAltText(translate("menutree.openmeetings.alt"));
        gtnChild.setIconCssClass("o_openmeetings_icon");
        root.addChild(gtnChild);
        nodeOpenMeetings = gtnChild;
    }
    if (isAdmin) {
        gtnChild = new GenericTreeNode(nodeIdPrefix.concat("admin"));
        gtnChild.setTitle(translate("menutree.administration"));
        gtnChild.setUserObject(ACTIVITY_MENUSELECT_ADMINISTRATION);
        gtnChild.setIdent(ACTIVITY_MENUSELECT_ADMINISTRATION);
        gtnChild.setAltText(translate("menutree.administration.alt"));
        gtnChild.setIconCssClass("o_icon_settings");
        root.addChild(gtnChild);
        adminNodeId = gtnChild.getIdent();
        nodeAdmin = gtnChild;
        AccessControlModule acModule = (AccessControlModule) CoreSpringFactory.getBean("acModule");
        if (acModule.isEnabled() && acService.isResourceAccessControled(businessGroup.getResource(), null)) {
            gtnChild = new GenericTreeNode(nodeIdPrefix.concat("ac"));
            gtnChild.setTitle(translate("menutree.ac"));
            gtnChild.setUserObject(ACTIVITY_MENUSELECT_AC);
            gtnChild.setIdent(ACTIVITY_MENUSELECT_AC);
            gtnChild.setAltText(translate("menutree.ac.alt"));
            gtnChild.setIconCssClass("o_icon_booking");
            root.addChild(gtnChild);
        }
    }
    return gtm;
}
Also used : AccessControlModule(org.olat.resource.accesscontrol.AccessControlModule) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) CollaborationTools(org.olat.collaboration.CollaborationTools) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) BaseSecurityModule(org.olat.basesecurity.BaseSecurityModule) OpenMeetingsModule(org.olat.modules.openmeetings.OpenMeetingsModule)

Example 59 with GenericTreeModel

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

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 60 with GenericTreeModel

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

the class QTI21StatisticResourceResult method getSubTreeModel.

/**
 * Return the tree model for a course and a specific test.
 */
@Override
public TreeModel getSubTreeModel() {
    GenericTreeModel subTreeModel = new GenericTreeModel();
    StatisticResourceNode rootTreeNode = new StatisticResourceNode(courseNode, this);
    subTreeModel.setRootNode(rootTreeNode);
    FileResourceManager frm = FileResourceManager.getInstance();
    File unzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
    resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
    AssessmentTest test = resolvedAssessmentTest.getTestLookup().getRootNodeHolder().getRootNode();
    buildRecursively(test, rootTreeNode);
    return subTreeModel;
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) FileResourceManager(org.olat.fileresource.FileResourceManager) StatisticResourceNode(org.olat.course.statistic.StatisticResourceNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) File(java.io.File)

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