Search in sources :

Example 31 with CloseableModalController

use of org.olat.core.gui.control.generic.closablewrapper.CloseableModalController in project OpenOLAT by OpenOLAT.

the class LectureListRepositoryController method doEditLectureBlock.

private void doEditLectureBlock(UserRequest ureq, LectureBlockRow row) {
    if (editLectureCtrl != null)
        return;
    LectureBlock block = lectureService.getLectureBlock(row);
    editLectureCtrl = new EditLectureBlockController(ureq, getWindowControl(), entry, block);
    listenTo(editLectureCtrl);
    cmc = new CloseableModalController(getWindowControl(), "close", editLectureCtrl.getInitialComponent(), true, translate("add.lecture"));
    listenTo(cmc);
    cmc.activate();
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)

Example 32 with CloseableModalController

use of org.olat.core.gui.control.generic.closablewrapper.CloseableModalController 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 33 with CloseableModalController

use of org.olat.core.gui.control.generic.closablewrapper.CloseableModalController in project OpenOLAT by OpenOLAT.

the class WikiMainController method doManageMedias.

private void doManageMedias(UserRequest ureq, Wiki wiki) {
    if (wiki.getMediaFileListWithMetadata().size() > 0) {
        mediaMgntContent = createVelocityContainer("media");
        refreshTableDataModel(ureq, wiki);
        mediaMgntContent.put("mediaMgmtTable", mediaTableCtr.getInitialComponent());
        removeAsListenerAndDispose(cmc);
        cmc = new CloseableModalController(getWindowControl(), translate("close"), mediaMgntContent, true, translate("manage.media"));
        listenTo(cmc);
        cmc.activate();
    }
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)

Example 34 with CloseableModalController

use of org.olat.core.gui.control.generic.closablewrapper.CloseableModalController in project OpenOLAT by OpenOLAT.

the class ItemsController method activateModalDialog.

/**
 * @param controller
 *            The <code>FormBasicController</code> to be displayed in the
 *            modal dialog.
 */
private void activateModalDialog(FormBasicController controller, String title) {
    listenTo(controller);
    cmc = new CloseableModalController(getWindowControl(), translate("close"), controller.getInitialComponent(), true, title);
    listenTo(cmc);
    cmc.activate();
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)

Example 35 with CloseableModalController

use of org.olat.core.gui.control.generic.closablewrapper.CloseableModalController in project OpenOLAT by OpenOLAT.

the class SearchInputController method popupResultsSearchController.

private void popupResultsSearchController() {
    String title = translate("search.title");
    String close = translate("close");
    searchDialogBox = new CloseableModalController(getWindowControl(), close, resultCtlr.getInitialComponent(), true, title);
    searchDialogBox.activate();
    listenTo(searchDialogBox);
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)

Aggregations

CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)789 RepositoryEntry (org.olat.repository.RepositoryEntry)52 ArrayList (java.util.ArrayList)48 Identity (org.olat.core.id.Identity)42 ReferencableEntriesSearchController (org.olat.repository.controllers.ReferencableEntriesSearchController)38 VFSContainer (org.olat.core.util.vfs.VFSContainer)24 Component (org.olat.core.gui.components.Component)20 ContactMessage (org.olat.core.util.mail.ContactMessage)20 ContactFormController (org.olat.modules.co.ContactFormController)20 File (java.io.File)17 List (java.util.List)16 UserSearchController (org.olat.admin.user.UserSearchController)16 TableEvent (org.olat.core.gui.components.table.TableEvent)16 TableMultiSelectEvent (org.olat.core.gui.components.table.TableMultiSelectEvent)16 ContactList (org.olat.core.util.mail.ContactList)16 MailTemplate (org.olat.core.util.mail.MailTemplate)14 OLATResourceable (org.olat.core.id.OLATResourceable)12 MailNotificationEditController (org.olat.core.util.mail.MailNotificationEditController)12 OLATSecurityException (org.olat.core.logging.OLATSecurityException)10 Roles (org.olat.core.id.Roles)8