Search in sources :

Example 41 with TreeEvent

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

the class FileChooserController 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
protected void event(UserRequest ureq, Component source, Event event) {
    // events from ajax tree view
    if (source == cancelLink) {
        fireEvent(ureq, Event.CANCELLED_EVENT);
    } else if (source == selectLink) {
        if (selectedItem != null) {
            // fxdiff FXOLAT-125: virtual file system for CP
            if (onlyLeafsSelectable && !(selectedItem instanceof VFSLeaf)) {
                showWarning("filechooser.tree.error.only.leafs", selectedItem.getName());
            } else {
                fireEvent(ureq, new FileChoosenEvent(selectedItem));
            }
        } else {
            fireEvent(ureq, Event.FAILED_EVENT);
        }
    } else if (source == selectionTree) {
        TreeEvent te = (TreeEvent) event;
        if (te.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
            String selectedPath = treeModel.getSelectedPath(selectionTree.getSelectedNode());
            selectedItem = rootContainer.resolve(selectedPath);
            selectLink.setCustomEnabledLinkCSS("btn btn-default o_button_dirty");
        }
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) VFSLeaf(org.olat.core.util.vfs.VFSLeaf)

Example 42 with TreeEvent

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

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 43 with TreeEvent

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

the class CourseNodeSelectionController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == menuTree) {
        if (event instanceof TreeEvent) {
            TreeEvent te = (TreeEvent) event;
            if (TreeEvent.COMMAND_TREENODE_OPEN.equals(te.getSubCommand()) || TreeEvent.COMMAND_TREENODE_CLOSE.equals(te.getSubCommand())) {
                Object uo = menuTree.getSelectedNode().getUserObject();
                if (menuTree.getSelectedNode() == menuTree.getTreeModel().getRootNode()) {
                // do nothing
                } else if (uo instanceof AssessableCourseNode && !(uo instanceof STCourseNode)) {
                    AssessableCourseNode selectedNode = (AssessableCourseNode) uo;
                    fireEvent(ureq, new CourseNodeEvent(CourseNodeEvent.SELECT_COURSE_NODE, selectedNode.getIdent()));
                }
            } else if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
                Object uo = menuTree.getSelectedNode().getUserObject();
                if (menuTree.getSelectedNode() == menuTree.getTreeModel().getRootNode()) {
                    CourseNode rootNode = (CourseNode) uo;
                    fireEvent(ureq, new CourseNodeEvent(CourseNodeEvent.SELECT_COURSE_NODE, rootNode.getIdent()));
                } else if (uo instanceof AssessableCourseNode && !(uo instanceof STCourseNode)) {
                    AssessableCourseNode selectedNode = (AssessableCourseNode) uo;
                    fireEvent(ureq, new CourseNodeEvent(CourseNodeEvent.SELECT_COURSE_NODE, selectedNode.getIdent()));
                }
            }
        }
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) STCourseNode(org.olat.course.nodes.STCourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) STCourseNode(org.olat.course.nodes.STCourseNode) CourseNode(org.olat.course.nodes.CourseNode) CourseNodeEvent(org.olat.course.assessment.ui.tool.event.CourseNodeEvent)

Example 44 with TreeEvent

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

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 45 with TreeEvent

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

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)

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