Search in sources :

Example 6 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 7 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)

Example 8 with TreeEvent

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

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

the class WikiMainController method event.

@Override
public void event(UserRequest ureq, Controller source, Event event) {
    Wiki wiki = getWiki();
    if (wiki == null) {
        mainPanel.setContent(createVelocityContainer("deleted"));
        return;
    }
    // reload page from cache
    WikiPage page = wiki.getPage(pageId, true);
    // set recent page id to the page currently used
    this.pageId = page.getPageId();
    if (event instanceof TreeEvent) {
        TreeEvent te = (TreeEvent) event;
        String nodeId = te.getNodeId();
        if (navAZNode.getIdent().equals(nodeId)) {
            openAtoZPage(ureq, wiki);
        } else if (navChangesNode.getIdent().equals(nodeId)) {
            openLastChangesPage(ureq, wiki);
        } else if (navMainPageNode.getIdent().equals(nodeId)) {
            page = openIndexPage(ureq, wiki);
        } else if (wikiMenuNode.getIdent().equals(nodeId)) {
            page = openPage(ureq, WikiPage.WIKI_MENU_PAGE, wiki);
        } else {
            TreeNode node = wikiMenuModel.getNodeById(nodeId);
            if (node != null && node.getUserObject() instanceof String) {
                String link = (String) node.getUserObject();
                page = openPage(ureq, link, wiki);
            }
        }
        if (page != null) {
            this.pageId = page.getPageId();
        }
    } else if (source == versioningTableCtr) {
        /**
         ***********************************************************************
         * history table events
         ***********************************************************************
         */
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            if (te.getActionId().equals(ACTION_COMPARE)) {
                selectedPage = versioningTableModel.getObject(te.getRowId());
                diffs = wiki.getDiff(page, selectedPage.getVersion() - 1, selectedPage.getVersion());
                versioningContent.contextPut("diffs", diffs);
                versioningContent.remove(wikiVersionDisplayComp);
                versioningContent.contextPut("page", selectedPage);
            } else if (te.getActionId().equals(ACTION_SHOW)) {
                versioningContent.contextRemove("diffs");
                selectedPage = versioningTableModel.getObject(te.getRowId());
                selectedPage = wiki.loadVersion(selectedPage, selectedPage.getVersion());
                wikiVersionDisplayComp.setWikiContent(selectedPage.getContent());
                wikiVersionDisplayComp.setImageMapperUri(ureq, wikiContainer);
                versioningContent.put("versionDisplay", wikiVersionDisplayComp);
                versioningContent.contextPut("page", selectedPage);
            }
        }
    } else if (source == wikiUploadFileCtr) {
        if (event.getCommand().equals(FolderEvent.UPLOAD_EVENT)) {
            FolderEvent fEvent = (FolderEvent) event;
            createMediaMetadataFile(fEvent.getFilename(), ureq.getIdentity().getKey());
            updateFileAndLinkList(wiki);
        }
        cmc.deactivate();
        cleanUp();
    } else if (source == removePageDialogCtr) {
        if (DialogBoxUIFactory.isOkEvent(event)) {
            wiki.removePage(page);
            breadcrumpDropdown.removeComponent(page.getPageName());
            WikiManager.getInstance().deleteWikiPage(ores, page);
            page = wiki.getPage(WikiPage.WIKI_INDEX_PAGE);
            updatePageContext(ureq, page);
            tabs.setSelectedPane(ureq, 0);
        }
    } else if (source == mediaTableCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            if (te.getActionId().equals(ACTION_DELETE_MEDIA)) {
                List<MediaFileElement> list = new ArrayList<MediaFileElement>(1);
                list.add(mediaFilesTableModel.getObject(te.getRowId()));
                deleteMediaFile(list, ureq);
            } else if (te.getActionId().equals(ACTION_SHOW_MEDIA)) {
                // show a selected file from the media folder
                MediaFileElement element = mediaFilesTableModel.getObject(te.getRowId());
                if (isImage(element.getFilename())) {
                    // show images inline
                    // as modal overlay
                    imageDisplay.contextPut("mediaElement", element);
                    imageDisplay.contextPut("imageUri", wikiArticleComp.getImageBaseUri());
                    removeAsListenerAndDispose(cmc);
                    cmc = new CloseableModalController(getWindowControl(), translate("close"), imageDisplay);
                    listenTo(cmc);
                    cmc.activate();
                } else {
                    deliverMediaFile(ureq, element.getFilename());
                }
            }
        } else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
            TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
            if (tmse.getAction().equals(ACTION_DELETE_MEDIAS)) {
                deleteMediaFile(mediaFilesTableModel.getObjects(tmse.getSelection()), ureq);
                updateFileAndLinkList(wiki);
            }
        }
    } else if (source == archiveWikiDialogCtr) {
        if (DialogBoxUIFactory.isOkEvent(event)) {
            WikiToCPResource rsrc = new WikiToCPResource(ores, getIdentity(), getTranslator());
            ureq.getDispatchResult().setResultingMediaResource(rsrc);
        }
    } else if (source == createArticleForm) {
        calloutCtrl.deactivate();
        String query = createArticleForm.getQuery();
        if (!StringHelper.containsNonWhitespace(query)) {
            query = WikiPage.WIKI_INDEX_PAGE;
        }
        page = wiki.findPage(query);
        pageId = page.getPageId();
        if (page.getPageName().equals(Wiki.NEW_PAGE)) {
            setTabsEnabled(false);
        }
        page.incrementViewCount();
        updatePageContext(ureq, page);
        if (!page.getPageName().startsWith("O_")) {
            Link pageLink = LinkFactory.createToolLink(page.getPageName(), "select-page", page.getPageName(), this);
            breadcrumpDropdown.addComponent(pageLink);
        }
        tabs.setSelectedPane(ureq, 0);
    } else if (source == wikiEditForm) {
        // set recent page id to the page currently used
        this.pageId = page.getPageId();
        boolean wantPreview = false;
        boolean wantSave = false;
        boolean wantClose = false;
        if (event == Event.CANCELLED_EVENT) {
            wantClose = true;
        } else if (event == Event.DONE_EVENT) {
            wantSave = true;
        } else if (event.getCommand().equals("save.and.close")) {
            wantClose = true;
            wantSave = true;
            event = Event.DONE_EVENT;
        } else if (event.getCommand().equals("preview")) {
            wantPreview = true;
            event = Event.DONE_EVENT;
        } else if (event.getCommand().equals("delete.page")) {
            String msg = translate("question", page.getPageName());
            removePageDialogCtr = activateOkCancelDialog(ureq, null, msg, removePageDialogCtr);
            return;
        } else if (event.getCommand().equals("media.upload")) {
            doUploadFiles(ureq);
            return;
        } else if (event.getCommand().equals("manage.media")) {
            doManageMedias(ureq, wiki);
            return;
        }
        boolean dirty = !wikiEditForm.getWikiContent().equals(page.getContent());
        if (wantPreview) {
            WikiPage preview = new WikiPage("temp");
            preview.setContent(wikiEditForm.getWikiContent());
            wikiVersionDisplayComp.setWikiContent(preview.getContent());
            editContent.put("versionDisplay", wikiVersionDisplayComp);
        }
        if (wantSave && dirty) {
            editContent.contextPut("isDirty", Boolean.valueOf(false));
            page.setContent(wikiEditForm.getWikiContent());
            page.setModifyAuthor(getIdentity().getKey().longValue());
            page.setUpdateComment(wikiEditForm.getUpdateComment());
            if (page.getInitalAuthor() == 0)
                page.setInitalAuthor(getIdentity().getKey().longValue());
            // changed
            if (page.getPageName().equals(WikiPage.WIKI_MENU_PAGE)) {
                updateWikiMenu(wiki);
            }
            WikiManager.getInstance().saveWikiPage(ores, page, true, wiki);
            // inform subscription context about changes
            NotificationsManager.getInstance().markPublisherNews(subsContext, ureq.getIdentity(), true);
            updatePageContext(ureq, page);
        }
        if (dirty && wantPreview && !wantSave) {
            // wikiEditForm.setDirty(true);
            editContent.contextPut("isDirty", Boolean.valueOf(dirty));
        }
        if (wantClose) {
            tabs.setSelectedPane(ureq, 0);
            doReleaseEditLock();
            return;
        }
    }
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) ArrayList(java.util.ArrayList) TreeEvent(org.olat.core.gui.components.tree.TreeEvent) TableEvent(org.olat.core.gui.components.table.TableEvent) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) FolderEvent(org.olat.core.commons.modules.bc.FolderEvent) Link(org.olat.core.gui.components.link.Link)

Example 10 with TreeEvent

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

the class QTI21StatisticsToolController 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)

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