Search in sources :

Example 11 with TreeEvent

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

the class CPDisplayController 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 == cpTree) {
        // TreeEvent.dito...
        if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
            TreeEvent te = (TreeEvent) event;
            switchToPage(ureq, te);
        }
    } else if (source == cpComponent) {
        if (event instanceof NewInlineUriEvent) {
            NewInlineUriEvent nue = (NewInlineUriEvent) event;
            // adjust the tree selection to the current choice if found
            selectTreeNode(ureq, nue.getNewUri());
        }
    } else if (source == nextLink) {
        TreeNode nextUri = (TreeNode) nextLink.getUserObject();
        switchToPage(ureq, nextUri);
        if (cpTree != null) {
            cpTree.setSelectedNode(nextUri);
        }
        fireEvent(ureq, new TreeNodeEvent(nextUri));
    } else if (source == previousLink) {
        TreeNode previousUri = (TreeNode) previousLink.getUserObject();
        if (cpTree != null) {
            cpTree.setSelectedNode(previousUri);
        }
        switchToPage(ureq, previousUri);
        fireEvent(ureq, new TreeNodeEvent(previousUri));
    } else if (source == printLink) {
        selectPagesToPrint(ureq);
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) TreeNode(org.olat.core.gui.components.tree.TreeNode) NewInlineUriEvent(org.olat.core.gui.components.htmlsite.NewInlineUriEvent)

Example 12 with TreeEvent

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

the class QTI21RuntimeStatisticsController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (courseTree == source) {
        if (event instanceof TreeEvent) {
            TreeEvent te = (TreeEvent) event;
            if (MenuTree.COMMAND_TREENODE_CLICKED.equals(te.getCommand())) {
                String ident = te.getNodeId();
                TreeNode selectedNode = courseTree.getTreeModel().getNodeById(ident);
                doSelectNode(ureq, selectedNode);
            }
        }
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) TreeNode(org.olat.core.gui.components.tree.TreeNode)

Example 13 with TreeEvent

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

the class GenericMainController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == olatMenuTree) {
        if (event instanceof TreeEvent && event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
            TreeEvent te = (TreeEvent) event;
            if (te.getSubCommand() != null) {
            // filter open/close events
            } else {
                // process menu commands
                TreeNode selTreeNode = olatMenuTree.getSelectedNode();
                // cleanup old content controller (never null)
                removeAsListenerAndDispose(contentCtr);
                // create new content controller
                // Following cases:
                // 1a) Simple Action Extension using only ureq and windowControl ->
                // handled by default implementation of createController
                // 1b) Specialised Action Extension which needs some more internals ->
                // handled by the class extending GenericMainController, by overwriting
                // createController
                // 2) uobject is something special which needs evaluation by class
                // extending GenericMainController
                Object uobject = selTreeNode.getUserObject();
                TreeNode delegatee = selTreeNode.getDelegate();
                if (delegatee != null) {
                    olatMenuTree.setSelectedNode(delegatee);
                }
                contentCtr = getContentCtr(uobject, ureq);
                listenTo(contentCtr);
                Component resComp = contentCtr.getInitialComponent();
                content.setContent(resComp);
                addToHistory(ureq, contentCtr);
            }
        } else {
            // the action was not allowed anymore
            // display an empty field (empty panel)
            content.setContent(null);
        }
    } else {
        logWarn("Unhandled olatMenuTree event: " + event.getCommand(), null);
    }
}
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) Component(org.olat.core.gui.components.Component)

Example 14 with TreeEvent

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

the class CPTreeController method event.

/**
 * Event-handling from components
 */
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == importLink) {
        uploadCtr = new CPFileImportController(ureq, getWindowControl(), cp, currentPage);
        listenTo(uploadCtr);
        String title = translate("cpfileuploadcontroller.form.title");
        cmc = new CloseableModalController(getWindowControl(), translate("close"), uploadCtr.getInitialComponent(), true, title);
        listenTo(cmc);
        cmc.activate();
    } else if (source == newLink) {
        fireEvent(ureq, new Event("New Page"));
    } else if (source == copyLink) {
        if (currentPage.isOrgaPage()) {
            showInfo("cptreecontroller.orga.cannot.be.copied");
        } else {
            String newIdentifier = copyPage(currentPage);
            contentCtr.displayPageWithMetadataEditor(ureq, newIdentifier);
        }
    } else if (source == deleteLink) {
        if (currentPage.isOrgaPage()) {
            showInfo("cptreecontroller.orga.cannot.be.deleted");
        } else {
            List<String> buttonLables = new ArrayList<String>();
            buttonLables.add(translate("cptreecontrolller.delete.items.and.files"));
            buttonLables.add(translate("cptreecontrolller.delete.items.only"));
            buttonLables.add(translate("cancel"));
            dialogCtr = DialogBoxUIFactory.createGenericDialog(ureq, getWindowControl(), translate("cptreecontroller.q_delete_title"), translate("cptreecontroller.q_delete_text", getCurrentPageInfoStringHTML()), buttonLables);
            listenTo(dialogCtr);
            dialogCtr.activate();
        }
    } else if (source == treeCtr) {
        if (event instanceof TreeEvent) {
            TreeEvent te = (TreeEvent) event;
            String selectedNodeID = treeModel.getIdentifierForNodeID(te.getNodeId());
            currentPage = new CPPage(selectedNodeID, cp);
            fireEvent(ureq, new TreeEvent(TreeEvent.COMMAND_TREENODE_CLICKED, selectedNodeID));
        } else if (event instanceof TreeDropEvent) {
            TreeDropEvent te = (TreeDropEvent) event;
            doDrop(ureq, te.getDroppedNodeId(), te.getTargetNodeId(), te.isAsChild());
        }
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) TreeEvent(org.olat.core.gui.components.tree.TreeEvent) TreeDropEvent(org.olat.core.gui.components.tree.TreeDropEvent) Event(org.olat.core.gui.control.Event) ArrayList(java.util.ArrayList) List(java.util.List) TreeDropEvent(org.olat.core.gui.components.tree.TreeDropEvent)

Example 15 with TreeEvent

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

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