Search in sources :

Example 1 with LinkChooserController

use of org.olat.core.commons.controllers.linkchooser.LinkChooserController in project openolat by klemens.

the class RichTextElementComponent method createFileSelectorPopupWindow.

private void createFileSelectorPopupWindow(final UserRequest ureq, final String type, final String fileName) {
    // Get allowed suffixes from configuration and requested media browser type from event
    final RichTextConfiguration config = element.getEditorConfiguration();
    final boolean allowCustomMediaFactory = config.isAllowCustomMediaFactory();
    final boolean uriValidation = config.isFilenameUriValidation();
    final String[] suffixes;
    if (type.equals(CMD_FILEBROWSER)) {
        suffixes = null;
    } else if (type.equals(CMD_IMAGEBROWSER)) {
        suffixes = config.getLinkBrowserImageSuffixes();
    } else if (type.equals(CMD_FLASHPLAYERBROWSER)) {
        suffixes = config.getLinkBrowserFlashPlayerSuffixes();
    } else {
        suffixes = config.getLinkBrowserMediaSuffixes();
    }
    // Show popup window with file browser to select file
    // Only one popup file chooser allowed at any time. ccc contains icc,
    // icc gets disposed by ccc
    // helper code which is used to create link chooser controller
    ControllerCreator linkChooserControllerCreator = new ControllerCreator() {

        @Override
        public Controller createController(UserRequest lureq, WindowControl lwControl) {
            LinkChooserController myLinkChooserController;
            VFSContainer baseContainer = config.getLinkBrowserBaseContainer();
            String uploadRelPath = config.getLinkBrowserUploadRelPath();
            String absolutePath = config.getLinkBrowserAbsolutFilePath();
            CustomLinkTreeModel linkBrowserCustomTreeModel = config.getLinkBrowserCustomLinkTreeModel();
            if (type.equals(CMD_FILEBROWSER)) {
                // when in file mode we include the internal links to the selection
                myLinkChooserController = new LinkChooserController(lureq, lwControl, baseContainer, uploadRelPath, absolutePath, suffixes, uriValidation, fileName, linkBrowserCustomTreeModel, allowCustomMediaFactory);
            } else {
                // in media or image mode, internal links make no sense here
                myLinkChooserController = new LinkChooserController(lureq, lwControl, baseContainer, uploadRelPath, absolutePath, suffixes, uriValidation, fileName, null, allowCustomMediaFactory);
            }
            return new LayoutMain3ColsController(lureq, lwControl, myLinkChooserController);
        }
    };
    PopupBrowserWindow pbw = Windows.getWindows(ureq).getWindowManager().createNewPopupBrowserWindowFor(ureq, linkChooserControllerCreator);
    pbw.open(ureq);
}
Also used : CustomLinkTreeModel(org.olat.core.commons.controllers.linkchooser.CustomLinkTreeModel) LinkChooserController(org.olat.core.commons.controllers.linkchooser.LinkChooserController) PopupBrowserWindow(org.olat.core.gui.control.generic.popup.PopupBrowserWindow) VFSContainer(org.olat.core.util.vfs.VFSContainer) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) WindowControl(org.olat.core.gui.control.WindowControl) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) UserRequest(org.olat.core.gui.UserRequest)

Example 2 with LinkChooserController

use of org.olat.core.commons.controllers.linkchooser.LinkChooserController in project OpenOLAT by OpenOLAT.

the class RichTextElementComponent method createFileSelectorPopupWindow.

private void createFileSelectorPopupWindow(final UserRequest ureq, final String type, final String fileName) {
    // Get allowed suffixes from configuration and requested media browser type from event
    final RichTextConfiguration config = element.getEditorConfiguration();
    final boolean allowCustomMediaFactory = config.isAllowCustomMediaFactory();
    final boolean uriValidation = config.isFilenameUriValidation();
    final String[] suffixes;
    if (type.equals(CMD_FILEBROWSER)) {
        suffixes = null;
    } else if (type.equals(CMD_IMAGEBROWSER)) {
        suffixes = config.getLinkBrowserImageSuffixes();
    } else if (type.equals(CMD_FLASHPLAYERBROWSER)) {
        suffixes = config.getLinkBrowserFlashPlayerSuffixes();
    } else {
        suffixes = config.getLinkBrowserMediaSuffixes();
    }
    // Show popup window with file browser to select file
    // Only one popup file chooser allowed at any time. ccc contains icc,
    // icc gets disposed by ccc
    // helper code which is used to create link chooser controller
    ControllerCreator linkChooserControllerCreator = new ControllerCreator() {

        @Override
        public Controller createController(UserRequest lureq, WindowControl lwControl) {
            LinkChooserController myLinkChooserController;
            VFSContainer baseContainer = config.getLinkBrowserBaseContainer();
            String uploadRelPath = config.getLinkBrowserUploadRelPath();
            String absolutePath = config.getLinkBrowserAbsolutFilePath();
            CustomLinkTreeModel linkBrowserCustomTreeModel = config.getLinkBrowserCustomLinkTreeModel();
            if (type.equals(CMD_FILEBROWSER)) {
                // when in file mode we include the internal links to the selection
                myLinkChooserController = new LinkChooserController(lureq, lwControl, baseContainer, uploadRelPath, absolutePath, suffixes, uriValidation, fileName, linkBrowserCustomTreeModel, allowCustomMediaFactory);
            } else {
                // in media or image mode, internal links make no sense here
                myLinkChooserController = new LinkChooserController(lureq, lwControl, baseContainer, uploadRelPath, absolutePath, suffixes, uriValidation, fileName, null, allowCustomMediaFactory);
            }
            return new LayoutMain3ColsController(lureq, lwControl, myLinkChooserController);
        }
    };
    PopupBrowserWindow pbw = Windows.getWindows(ureq).getWindowManager().createNewPopupBrowserWindowFor(ureq, linkChooserControllerCreator);
    pbw.open(ureq);
}
Also used : CustomLinkTreeModel(org.olat.core.commons.controllers.linkchooser.CustomLinkTreeModel) LinkChooserController(org.olat.core.commons.controllers.linkchooser.LinkChooserController) PopupBrowserWindow(org.olat.core.gui.control.generic.popup.PopupBrowserWindow) VFSContainer(org.olat.core.util.vfs.VFSContainer) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) WindowControl(org.olat.core.gui.control.WindowControl) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) UserRequest(org.olat.core.gui.UserRequest)

Aggregations

CustomLinkTreeModel (org.olat.core.commons.controllers.linkchooser.CustomLinkTreeModel)2 LinkChooserController (org.olat.core.commons.controllers.linkchooser.LinkChooserController)2 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)2 UserRequest (org.olat.core.gui.UserRequest)2 WindowControl (org.olat.core.gui.control.WindowControl)2 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)2 PopupBrowserWindow (org.olat.core.gui.control.generic.popup.PopupBrowserWindow)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2