Search in sources :

Example 1 with TreeDropEvent

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

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

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 3 with TreeDropEvent

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

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

the class QuestionPoolMainEditorController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (menuTree == source) {
        if (event instanceof TreeDropEvent) {
            TreeDropEvent e = (TreeDropEvent) event;
            String targetId = e.getTargetNodeId();
            String dropId = e.getDroppedNodeId();
            // drop id w_o_fi1000002357-4
            doDrop(ureq, targetId, dropId);
        } else if (event instanceof TreeEvent) {
            TreeEvent te = (TreeEvent) event;
            if (MenuTree.COMMAND_TREENODE_CLICKED.equals(te.getCommand())) {
                TreeNode node = menuTree.getTreeModel().getNodeById(te.getNodeId());
                doSelectControllerTreeNode(ureq, node, null, null);
            }
        }
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) MyQuestionsTreeNode(org.olat.modules.qpool.ui.tree.MyQuestionsTreeNode) ControllerTreeNode(org.olat.modules.qpool.ui.tree.ControllerTreeNode) CollectionTreeNode(org.olat.modules.qpool.ui.tree.CollectionTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) MarkedQuestionsTreeNode(org.olat.modules.qpool.ui.tree.MarkedQuestionsTreeNode) TreeDropEvent(org.olat.core.gui.components.tree.TreeDropEvent)

Example 5 with TreeDropEvent

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

the class EPTOCController 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) {
    if (source instanceof Link) {
        Link link = (Link) source;
        if (link.getCommand().equals(DELETE_LINK_CMD)) {
            if (artefactClicked != null) {
                AbstractArtefact artefact = artefactClicked;
                PortfolioStructure parentStruct = getArtefactParentStruct(artefactClicked);
                ePFMgr.removeArtefactFromStructure(artefact, parentStruct);
                // refresh the view
                fireEvent(ureq, Event.CHANGED_EVENT);
            } else if (structureClicked != null) {
                if ((structureClicked instanceof EPPage) && !(structureClicked instanceof EPAbstractMap)) {
                    PortfolioStructure ps = structureClicked;
                    while (ePFMgr.loadStructureParent(ps) != null) {
                        ps = ePFMgr.loadStructureParent(ps);
                    }
                    int childPages = ePFMgr.countStructureChildren(ps);
                    if (childPages > 1) {
                        eSTMgr.removeStructureRecursively(structureClicked);
                        // refresh the view
                        fireEvent(ureq, Event.CHANGED_EVENT);
                    } else {
                        showError("last.page.not.deletable");
                    }
                } else if (structureClicked instanceof EPStructureElement && !(structureClicked instanceof EPAbstractMap)) {
                    // structures should always be deletable
                    eSTMgr.removeStructureRecursively(structureClicked);
                    // refresh the view
                    fireEvent(ureq, Event.CHANGED_EVENT);
                } else {
                    showInfo("element.not.deletable");
                }
            }
        }
    } else if (source == treeCtr) {
        if (event instanceof TreeEvent) {
            TreeEvent te = (TreeEvent) event;
            if (MenuTree.COMMAND_TREENODE_CLICKED.equals(te.getCommand())) {
                doSelectTreeElement(ureq, te);
            }
        } else if (event instanceof TreeDropEvent) {
            TreeDropEvent te = (TreeDropEvent) event;
            doDrop(ureq, te.getDroppedNodeId(), te.getTargetNodeId(), te.isAsChild());
        }
    }
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) TreeEvent(org.olat.core.gui.components.tree.TreeEvent) EPPage(org.olat.portfolio.model.structel.EPPage) EPAbstractMap(org.olat.portfolio.model.structel.EPAbstractMap) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) TreeDropEvent(org.olat.core.gui.components.tree.TreeDropEvent) Link(org.olat.core.gui.components.link.Link)

Aggregations

TreeDropEvent (org.olat.core.gui.components.tree.TreeDropEvent)10 TreeEvent (org.olat.core.gui.components.tree.TreeEvent)10 TreeNode (org.olat.core.gui.components.tree.TreeNode)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Link (org.olat.core.gui.components.link.Link)2 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)2 Event (org.olat.core.gui.control.Event)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 ICourse (org.olat.course.ICourse)2 CourseNode (org.olat.course.nodes.CourseNode)2 DrawingAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.DrawingAssessmentItemBuilder)2 EssayAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder)2 FIBAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder)2 HotspotAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.HotspotAssessmentItemBuilder)2 HottextAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder)2 KPrimAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder)2 MatchAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder)2 MultipleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder)2 SingleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder)2