Search in sources :

Example 1 with TreeEvent

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

the class RunMainController 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 (needsRebuildAfter) {
        currentCourseNode = updateAfterChanges(currentCourseNode);
        needsRebuildAfter = false;
    }
    // Links in editTools dropdown
    if (nextLink == source) {
        doNext(ureq);
    } else if (previousLink == source) {
        doPrevious(ureq);
    } else if (source == luTree) {
        if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED) || event.getCommand().equals(MenuTree.COMMAND_TREENODE_EXPANDED)) {
            TreeEvent tev = (TreeEvent) event;
            doNodeClick(ureq, tev);
        }
    } else if (source == coursemain) {
        if ("activateCourseNode".equals(event.getCommand())) {
            // Events from the JS function o_activateCourseNode() - activate the given node id
            String nodeid = ureq.getParameter("nodeid");
            if (nodeid != null) {
                CourseNode identNode = course.getRunStructure().getNode(nodeid);
                CourseNode node = updateTreeAndContent(ureq, identNode, null);
                if (node != null) {
                    currentCourseNode = node;
                } else {
                    getWindowControl().setWarning(translate("msg.nodenotavailableanymore"));
                }
            }
        }
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) CourseNode(org.olat.course.nodes.CourseNode)

Example 2 with TreeEvent

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

the class RunMainController method doPrevious.

private void doPrevious(UserRequest ureq) {
    List<TreeNode> flatList = new ArrayList<>();
    TreeNode currentNode = luTree.getSelectedNode();
    TreeHelper.makeTreeFlat(luTree.getTreeModel().getRootNode(), flatList);
    int index = flatList.indexOf(currentNode);
    if (index - 1 >= 0 && index - 1 < flatList.size()) {
        TreeNode previousNode = flatList.get(index - 1);
        TreeEvent tev = new TreeEvent(MenuTree.COMMAND_TREENODE_CLICKED, previousNode.getIdent());
        doNodeClick(ureq, tev);
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) TreeNode(org.olat.core.gui.components.tree.TreeNode) ArrayList(java.util.ArrayList)

Example 3 with TreeEvent

use of org.olat.core.gui.components.tree.TreeEvent 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 4 with TreeEvent

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

the class EditorMainController 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) {
    try {
        ICourse course = CourseFactory.getCourseEditSession(ores.getResourceableId());
        if (source == menuTree) {
            if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
                // goto node in edit mode
                TreeEvent te = (TreeEvent) event;
                String nodeId = te.getNodeId();
                updateViewForSelectedNodeId(ureq, nodeId);
            } else if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_DROP)) {
                TreeDropEvent te = (TreeDropEvent) event;
                dropNodeAsChild(ureq, course, te.getDroppedNodeId(), te.getTargetNodeId(), te.isAsChild(), te.isAtTheEnd());
            }
        } else if (source == main) {
            if (event.getCommand().startsWith(NLS_START_HELP_WIZARD)) {
                doStartHelpWizard(ureq, event);
            }
        } else if (source == undelButton) {
            doUndelete(ureq, course);
        } else if (source == alternativeLink) {
            CourseNode chosenNode = (CourseNode) alternativeLink.getUserObject();
            askForAlternative(ureq, chosenNode);
        } else if (previewLink == source) {
            launchPreview(ureq, course);
        } else if (publishLink == source) {
            launchPublishingWizard(ureq, course, false);
        } else if (closeLink == source) {
            doReleaseEditLock();
            fireEvent(ureq, Event.DONE_EVENT);
        } else if (createNodeLink == source) {
            doOpenNodeTypeChooser(ureq);
        } else if (deleteNodeLink == source) {
            doDeleteNode(ureq);
        } else if (moveNodeLink == source) {
            doMove(ureq, course, false);
        } else if (copyNodeLink == source) {
            doMove(ureq, course, true);
        } else if (statusLink == source) {
            doOpenStatusOverview(ureq);
        }
    } catch (RuntimeException e) {
        log.warn(RELEASE_LOCK_AT_CATCH_EXCEPTION + " [in event(UserRequest,Component,Event)]", e);
        dispose();
        throw e;
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) ICourse(org.olat.course.ICourse) TreeDropEvent(org.olat.core.gui.components.tree.TreeDropEvent) CourseNode(org.olat.course.nodes.CourseNode)

Example 5 with TreeEvent

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

the class CPEditMainController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == treeCtr) {
        if (event instanceof TreeEvent) {
            TreeEvent te = (TreeEvent) event;
            String nodeId = te.getNodeId();
            contentCtr.displayPage(ureq, nodeId);
        } else if (event.getCommand().equals("New Page")) {
            String newIdentifier = treeCtr.addNewHTMLPage();
            contentCtr.displayPageWithMetadataEditor(ureq, newIdentifier);
        } else if (event instanceof NewCPPageEvent) {
            contentCtr.displayPageWithMetadataEditor(ureq, ((NewCPPageEvent) event).getCPPage().getIdentifier());
        }
    } else if (source == contentCtr) {
        // event from contentController
        if (event instanceof NewCPPageEvent) {
            NewCPPageEvent ncpEvent = (NewCPPageEvent) event;
            CPPage page = ncpEvent.getCPPage();
            if (event.getCommand().equals("New Page Saved")) {
                String newNodeID = treeCtr.addPage(page);
                contentCtr.newPageAdded(newNodeID);
                treeCtr.updatePage(page);
            } else if (event.getCommand().equals("Page Saved")) {
                treeCtr.updatePage(page);
                // Title could have changed -> dirty view
                treeCtr.getInitialComponent().setDirty(true);
            }
        } else if (event.getCommand().equals("Page loaded")) {
            CPPage page = contentCtr.getCurrentPage();
            if (page != null) {
                treeCtr.selectTreeNodeByCPPage(page);
            }
        }
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent)

Aggregations

TreeEvent (org.olat.core.gui.components.tree.TreeEvent)50 TreeNode (org.olat.core.gui.components.tree.TreeNode)32 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)14 TreeDropEvent (org.olat.core.gui.components.tree.TreeDropEvent)12 CourseNode (org.olat.course.nodes.CourseNode)10 ArrayList (java.util.ArrayList)8 Event (org.olat.core.gui.control.Event)6 Component (org.olat.core.gui.components.Component)4 Link (org.olat.core.gui.components.link.Link)4 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)4 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)4 STCourseNode (org.olat.course.nodes.STCourseNode)4 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)4 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)4 List (java.util.List)2 FolderEvent (org.olat.core.commons.modules.bc.FolderEvent)2 NewInlineUriEvent (org.olat.core.gui.components.htmlsite.NewInlineUriEvent)2 OlatCmdEvent (org.olat.core.gui.components.htmlsite.OlatCmdEvent)2 PopEvent (org.olat.core.gui.components.stack.PopEvent)2 TableEvent (org.olat.core.gui.components.table.TableEvent)2