Search in sources :

Example 6 with NodeClickedRef

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

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 7 with NodeClickedRef

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

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 8 with NodeClickedRef

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

the class RunMainController method doNodeClick.

private void doNodeClick(UserRequest ureq, TreeEvent tev) {
    if (assessmentChangedEventReceived) {
        uce.getScoreAccounting().evaluateAll();
        assessmentChangedEventReceived = false;
    }
    // goto node:
    // after a click in the tree, evaluate the 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("msg.nodenotavailableanymore"));
        // go to root since the current node is no more visible
        updateTreeAndContent(ureq, null, null);
        updateNextPrevious();
        updateCourseDataAttributes(nclr.getCalledCourseNode());
        return;
    }
    // a click to a subtree's node
    if (nclr.isHandledBySubTreeModelListener() || nclr.getSelectedNodeId() == null) {
        if (nclr.getRunController() != null) {
            // there is an update to the currentNodeController, apply it
            if (currentNodeController != null && !currentNodeController.isDisposed() && !navHandler.isListening(currentNodeController)) {
                currentNodeController.dispose();
            }
            currentNodeController = nclr.getRunController();
            Component nodeComp = currentNodeController.getInitialComponent();
            contentP.setContent(nodeComp);
            updateLastUsage(nclr.getCalledCourseNode());
        }
        if (nclr.getSelectedNodeId() != null && nclr.getOpenNodeIds() != null) {
            luTree.setSelectedNodeId(nclr.getSelectedNodeId());
            luTree.setOpenNodeIds(nclr.getOpenNodeIds());
        }
        updateNextPrevious();
        updateCourseDataAttributes(nclr.getCalledCourseNode());
        return;
    }
    // set the new treemodel
    treeModel = nclr.getTreeModel();
    luTree.setTreeModel(treeModel);
    // set the new tree selection
    String nodeId = nclr.getSelectedNodeId();
    luTree.setSelectedNodeId(nodeId);
    luTree.setOpenNodeIds(nclr.getOpenNodeIds());
    currentCourseNode = nclr.getCalledCourseNode();
    // get new run controller. Dispose only if not already disposed in navHandler.evaluateJumpToTreeNode()
    if (currentNodeController != null && !currentNodeController.isDisposed() && !navHandler.isListening(currentNodeController)) {
        currentNodeController.dispose();
    }
    currentNodeController = nclr.getRunController();
    updateLastUsage(nclr.getCalledCourseNode());
    Component nodeComp = currentNodeController.getInitialComponent();
    contentP.setContent(nodeComp);
    addToHistory(ureq, currentNodeController);
    // stuff properly when in AJAX mode
    if (glossaryMarkerCtr != null && glossaryMarkerCtr.isTextMarkingEnabled()) {
        glossaryMarkerCtr.getInitialComponent().setDirty(true);
    }
    updateNextPrevious();
    updateCourseDataAttributes(nclr.getCalledCourseNode());
}
Also used : NodeClickedRef(org.olat.course.run.navigation.NodeClickedRef) Component(org.olat.core.gui.components.Component)

Example 9 with NodeClickedRef

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

the class RunMainController method doNodeClick.

private void doNodeClick(UserRequest ureq, TreeEvent tev) {
    if (assessmentChangedEventReceived) {
        uce.getScoreAccounting().evaluateAll();
        assessmentChangedEventReceived = false;
    }
    // goto node:
    // after a click in the tree, evaluate the 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("msg.nodenotavailableanymore"));
        // go to root since the current node is no more visible
        updateTreeAndContent(ureq, null, null);
        updateNextPrevious();
        updateCourseDataAttributes(nclr.getCalledCourseNode());
        return;
    }
    // a click to a subtree's node
    if (nclr.isHandledBySubTreeModelListener() || nclr.getSelectedNodeId() == null) {
        if (nclr.getRunController() != null) {
            // there is an update to the currentNodeController, apply it
            if (currentNodeController != null && !currentNodeController.isDisposed() && !navHandler.isListening(currentNodeController)) {
                currentNodeController.dispose();
            }
            currentNodeController = nclr.getRunController();
            Component nodeComp = currentNodeController.getInitialComponent();
            contentP.setContent(nodeComp);
            updateLastUsage(nclr.getCalledCourseNode());
        }
        if (nclr.getSelectedNodeId() != null && nclr.getOpenNodeIds() != null) {
            luTree.setSelectedNodeId(nclr.getSelectedNodeId());
            luTree.setOpenNodeIds(nclr.getOpenNodeIds());
        }
        updateNextPrevious();
        updateCourseDataAttributes(nclr.getCalledCourseNode());
        return;
    }
    // set the new treemodel
    treeModel = nclr.getTreeModel();
    luTree.setTreeModel(treeModel);
    // set the new tree selection
    String nodeId = nclr.getSelectedNodeId();
    luTree.setSelectedNodeId(nodeId);
    luTree.setOpenNodeIds(nclr.getOpenNodeIds());
    currentCourseNode = nclr.getCalledCourseNode();
    // get new run controller. Dispose only if not already disposed in navHandler.evaluateJumpToTreeNode()
    if (currentNodeController != null && !currentNodeController.isDisposed() && !navHandler.isListening(currentNodeController)) {
        currentNodeController.dispose();
    }
    currentNodeController = nclr.getRunController();
    updateLastUsage(nclr.getCalledCourseNode());
    Component nodeComp = currentNodeController.getInitialComponent();
    contentP.setContent(nodeComp);
    addToHistory(ureq, currentNodeController);
    // stuff properly when in AJAX mode
    if (glossaryMarkerCtr != null && glossaryMarkerCtr.isTextMarkingEnabled()) {
        glossaryMarkerCtr.getInitialComponent().setDirty(true);
    }
    updateNextPrevious();
    updateCourseDataAttributes(nclr.getCalledCourseNode());
}
Also used : NodeClickedRef(org.olat.course.run.navigation.NodeClickedRef) Component(org.olat.core.gui.components.Component)

Example 10 with NodeClickedRef

use of org.olat.course.run.navigation.NodeClickedRef 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)

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