Search in sources :

Example 1 with NodeClickedRef

use of org.olat.course.run.navigation.NodeClickedRef in project OpenOLAT by OpenOLAT.

the class PreviewRunController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Component source, Event event) {
    if (source == luTree) {
        if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
            TreeEvent tev = (TreeEvent) event;
            // goto node:
            // after a click in the tree, evaluate the model anew, set the tree
            // model anew, and set the selection of the tree again
            NodeClickedRef nclr = navHandler.evaluateJumpToTreeNode(ureq, getWindowControl(), treeModel, tev, this, null, currentNodeController);
            if (!nclr.isVisible()) {
                getWindowControl().setWarning(translate("warn.notvisible"));
                return;
            }
            if (nclr.isHandledBySubTreeModelListener()) {
                // not used:
                return;
            }
            // set the new treemodel
            treeModel = nclr.getTreeModel();
            luTree.setTreeModel(treeModel);
            // set the new tree selection
            luTree.setSelectedNodeId(nclr.getSelectedNodeId());
            luTree.setOpenNodeIds(nclr.getOpenNodeIds());
            // get the controller (in this case it is a preview controller). Dispose only if not already disposed in navHandler.evaluateJumpToTreeNode()
            if (nclr.getRunController() != null) {
                if (currentNodeController != null && !currentNodeController.isDisposed() && !navHandler.isListening(currentNodeController)) {
                    currentNodeController.dispose();
                }
                currentNodeController = nclr.getRunController();
            }
            CourseNode cn = nclr.getCalledCourseNode();
            if (cn != null) {
                Condition c = cn.getPreConditionVisibility();
                String visibilityExpr = (c.getConditionExpression() == null ? translate("details.visibility.none") : c.getConditionExpression());
                detail.contextPut("visibilityExpr", visibilityExpr);
                detail.contextPut("coursenode", cn);
                currentCourseNode = cn;
            }
            Component nodeComp = currentNodeController.getInitialComponent();
            content.setContent(nodeComp);
        }
    } else if (source == configButton) {
        fireEvent(ureq, new Event("command.config"));
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) Condition(org.olat.course.condition.Condition) TreeEvent(org.olat.core.gui.components.tree.TreeEvent) Event(org.olat.core.gui.control.Event) OlatCmdEvent(org.olat.core.gui.components.htmlsite.OlatCmdEvent) CourseNode(org.olat.course.nodes.CourseNode) NodeClickedRef(org.olat.course.run.navigation.NodeClickedRef) Component(org.olat.core.gui.components.Component)

Example 2 with NodeClickedRef

use of org.olat.course.run.navigation.NodeClickedRef in project openolat by klemens.

the class PreviewRunController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Component source, Event event) {
    if (source == luTree) {
        if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
            TreeEvent tev = (TreeEvent) event;
            // goto node:
            // after a click in the tree, evaluate the model anew, set the tree
            // model anew, and set the selection of the tree again
            NodeClickedRef nclr = navHandler.evaluateJumpToTreeNode(ureq, getWindowControl(), treeModel, tev, this, null, currentNodeController);
            if (!nclr.isVisible()) {
                getWindowControl().setWarning(translate("warn.notvisible"));
                return;
            }
            if (nclr.isHandledBySubTreeModelListener()) {
                // not used:
                return;
            }
            // set the new treemodel
            treeModel = nclr.getTreeModel();
            luTree.setTreeModel(treeModel);
            // set the new tree selection
            luTree.setSelectedNodeId(nclr.getSelectedNodeId());
            luTree.setOpenNodeIds(nclr.getOpenNodeIds());
            // get the controller (in this case it is a preview controller). Dispose only if not already disposed in navHandler.evaluateJumpToTreeNode()
            if (nclr.getRunController() != null) {
                if (currentNodeController != null && !currentNodeController.isDisposed() && !navHandler.isListening(currentNodeController)) {
                    currentNodeController.dispose();
                }
                currentNodeController = nclr.getRunController();
            }
            CourseNode cn = nclr.getCalledCourseNode();
            if (cn != null) {
                Condition c = cn.getPreConditionVisibility();
                String visibilityExpr = (c.getConditionExpression() == null ? translate("details.visibility.none") : c.getConditionExpression());
                detail.contextPut("visibilityExpr", visibilityExpr);
                detail.contextPut("coursenode", cn);
                currentCourseNode = cn;
            }
            Component nodeComp = currentNodeController.getInitialComponent();
            content.setContent(nodeComp);
        }
    } else if (source == configButton) {
        fireEvent(ureq, new Event("command.config"));
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) Condition(org.olat.course.condition.Condition) TreeEvent(org.olat.core.gui.components.tree.TreeEvent) Event(org.olat.core.gui.control.Event) OlatCmdEvent(org.olat.core.gui.components.htmlsite.OlatCmdEvent) CourseNode(org.olat.course.nodes.CourseNode) NodeClickedRef(org.olat.course.run.navigation.NodeClickedRef) Component(org.olat.core.gui.components.Component)

Example 3 with NodeClickedRef

use of org.olat.course.run.navigation.NodeClickedRef in project openolat by klemens.

the class RunMainController method updateAfterChanges.

private CourseNode updateAfterChanges(CourseNode courseNode) {
    if (currentCourseNode == null)
        return null;
    CourseNode newCurrentCourseNode;
    NodeClickedRef nclr = navHandler.reloadTreeAfterChanges(courseNode);
    if (nclr == null) {
        doDisposeAfterEvent();
        newCurrentCourseNode = null;
    } else {
        treeModel = nclr.getTreeModel();
        luTree.setTreeModel(treeModel);
        String selNodeId = nclr.getSelectedNodeId();
        luTree.setSelectedNodeId(selNodeId);
        luTree.setOpenNodeIds(nclr.getOpenNodeIds());
        newCurrentCourseNode = nclr.getCalledCourseNode();
    }
    return newCurrentCourseNode;
}
Also used : CourseNode(org.olat.course.nodes.CourseNode) NodeClickedRef(org.olat.course.run.navigation.NodeClickedRef)

Example 4 with NodeClickedRef

use of org.olat.course.run.navigation.NodeClickedRef in project openolat by klemens.

the class RunMainController method updateTreeAndContent.

private CourseNode updateTreeAndContent(UserRequest ureq, CourseNode calledCourseNode, String nodecmd, List<ContextEntry> entries, StateEntry state) {
    // might be used in both controllers with the same ID (e.g. the course folder)
    if (currentNodeController != null && !currentNodeController.isDisposed() && !navHandler.isListening(currentNodeController)) {
        currentNodeController.dispose();
    }
    NodeClickedRef nclr = navHandler.evaluateJumpToCourseNode(ureq, getWindowControl(), calledCourseNode, this, nodecmd);
    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()) {
            MessageController msgController = MessageUIFactory.createInfoMessage(ureq, getWindowControl(), translate("course.noaccess.title"), translate("course.noaccess.text"));
            contentP.setContent(msgController.getInitialComponent());
            luTree.setTreeModel(new GenericTreeModel());
            return null;
        }
    }
    treeModel = nclr.getTreeModel();
    luTree.setTreeModel(treeModel);
    String selNodeId = nclr.getSelectedNodeId();
    luTree.setSelectedNodeId(selNodeId);
    luTree.setOpenNodeIds(nclr.getOpenNodeIds());
    // get new run controller.
    currentNodeController = nclr.getRunController();
    addToHistory(ureq, currentNodeController);
    if (currentNodeController instanceof TitledWrapperController) {
        Controller contentcontroller = ((TitledWrapperController) currentNodeController).getContentController();
        addToHistory(ureq, contentcontroller);
        if (contentcontroller instanceof Activateable2) {
            ((Activateable2) contentcontroller).activate(ureq, entries, state);
        }
    } else if (currentNodeController instanceof Activateable2) {
        ((Activateable2) currentNodeController).activate(ureq, entries, state);
    }
    if (currentNodeController != null) {
        contentP.setContent(currentNodeController.getInitialComponent());
    } else {
        MessageController msgCtrl = MessageUIFactory.createWarnMessage(ureq, getWindowControl(), null, translate("msg.nodenotavailableanymore"));
        listenTo(msgCtrl);
        contentP.setContent(msgCtrl.getInitialComponent());
    }
    updateNextPrevious();
    updateCourseDataAttributes(nclr.getCalledCourseNode());
    updateLastUsage(nclr.getCalledCourseNode());
    return nclr.getCalledCourseNode();
}
Also used : MessageController(org.olat.core.gui.control.generic.messages.MessageController) Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) TitledWrapperController(org.olat.core.gui.control.generic.title.TitledWrapperController) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) NodeClickedRef(org.olat.course.run.navigation.NodeClickedRef) DisposedCourseRestartController(org.olat.course.DisposedCourseRestartController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) MessageController(org.olat.core.gui.control.generic.messages.MessageController) CourseGlossaryToolLinkController(org.olat.course.run.glossary.CourseGlossaryToolLinkController) TitledWrapperController(org.olat.core.gui.control.generic.title.TitledWrapperController) Controller(org.olat.core.gui.control.Controller) GlossaryMarkupItemController(org.olat.core.gui.control.generic.textmarker.GlossaryMarkupItemController) MainLayoutBasicController(org.olat.core.gui.control.controller.MainLayoutBasicController)

Example 5 with NodeClickedRef

use of org.olat.course.run.navigation.NodeClickedRef in project OpenOLAT by OpenOLAT.

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)

Aggregations

NodeClickedRef (org.olat.course.run.navigation.NodeClickedRef)10 Component (org.olat.core.gui.components.Component)4 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)4 CourseNode (org.olat.course.nodes.CourseNode)4 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)2 OlatCmdEvent (org.olat.core.gui.components.htmlsite.OlatCmdEvent)2 TreeEvent (org.olat.core.gui.components.tree.TreeEvent)2 Controller (org.olat.core.gui.control.Controller)2 Event (org.olat.core.gui.control.Event)2 MainLayoutBasicController (org.olat.core.gui.control.controller.MainLayoutBasicController)2 Activateable2 (org.olat.core.gui.control.generic.dtabs.Activateable2)2 MessageController (org.olat.core.gui.control.generic.messages.MessageController)2 GlossaryMarkupItemController (org.olat.core.gui.control.generic.textmarker.GlossaryMarkupItemController)2 TitledWrapperController (org.olat.core.gui.control.generic.title.TitledWrapperController)2 DisposedCourseRestartController (org.olat.course.DisposedCourseRestartController)2 Condition (org.olat.course.condition.Condition)2 CourseGlossaryToolLinkController (org.olat.course.run.glossary.CourseGlossaryToolLinkController)2