Search in sources :

Example 6 with DeliveryOptions

use of org.olat.core.gui.control.generic.iframe.DeliveryOptions in project OpenOLAT by OpenOLAT.

the class SPRunController method doInlineIntegration.

private void doInlineIntegration(UserRequest ureq, boolean hasEditRightsTo) {
    boolean allowRelativeLinks = config.getBooleanSafe(SPEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS);
    // create the possibility to float
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(ICourse.class, userCourseEnv.getCourseEnvironment().getCourseResourceableId());
    DeliveryOptions deliveryOptions = (DeliveryOptions) config.get(SPEditController.CONFIG_KEY_DELIVERYOPTIONS);
    spCtr = new SinglePageController(ureq, getWindowControl(), courseFolderContainer, fileName, allowRelativeLinks, null, ores, deliveryOptions, userCourseEnv.getCourseEnvironment().isPreview());
    spCtr.setAllowDownload(true);
    // only for inline integration: register for controller event to forward a olatcmd to the course,
    // and also to remember latest position in the script
    listenTo(spCtr);
    // enable edit mode if user has the according rights
    if (hasEditRightsTo) {
        spCtr.allowPageEditing();
        // set the link tree model to internal for the HTML editor
        if (linkTreeModel != null) {
            spCtr.setInternalLinkTreeModel(linkTreeModel);
        }
    }
    // create clone wrapper layout
    CloneLayoutControllerCreatorCallback clccc = new CloneLayoutControllerCreatorCallback() {

        public ControllerCreator createLayoutControllerCreator(UserRequest uureq, final ControllerCreator contentControllerCreator) {
            return BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(uureq, new ControllerCreator() {

                public Controller createController(UserRequest lureq, WindowControl lwControl) {
                    // Wrap in column layout, popup window needs a layout controller
                    Controller ctr = contentControllerCreator.createController(lureq, lwControl);
                    LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, ctr);
                    layoutCtr.setCustomCSS(CourseFactory.getCustomCourseCss(lureq.getUserSession(), userCourseEnv.getCourseEnvironment()));
                    // Controller titledCtrl = TitledWrapperHelper.getWrapper(lureq, lwControl, ctr, courseNode, "o_sp_icon");
                    layoutCtr.addDisposableChildController(ctr);
                    return layoutCtr;
                }
            });
        }
    };
    Controller ctrl = TitledWrapperHelper.getWrapper(ureq, getWindowControl(), spCtr, courseNode, "o_sp_icon");
    if (ctrl instanceof CloneableController) {
        cloneC = new CloneController(ureq, getWindowControl(), (CloneableController) ctrl, clccc);
        listenTo(cloneC);
        main.setContent(cloneC.getInitialComponent());
    } else {
        throw new AssertException("Controller must be cloneable");
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) OLATResourceable(org.olat.core.id.OLATResourceable) CloneableController(org.olat.core.gui.control.generic.clone.CloneableController) SinglePageController(org.olat.core.commons.modules.singlepage.SinglePageController) WindowControl(org.olat.core.gui.control.WindowControl) CloneableController(org.olat.core.gui.control.generic.clone.CloneableController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) CloneController(org.olat.core.gui.control.generic.clone.CloneController) Controller(org.olat.core.gui.control.Controller) BasicController(org.olat.core.gui.control.controller.BasicController) SinglePageController(org.olat.core.commons.modules.singlepage.SinglePageController) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) CloneController(org.olat.core.gui.control.generic.clone.CloneController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) CloneLayoutControllerCreatorCallback(org.olat.core.gui.control.generic.clone.CloneLayoutControllerCreatorCallback) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions) UserRequest(org.olat.core.gui.UserRequest)

Example 7 with DeliveryOptions

use of org.olat.core.gui.control.generic.iframe.DeliveryOptions in project OpenOLAT by OpenOLAT.

the class CompMenuForm 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)
 */
public void event(UserRequest ureq, Component source, Event event) {
    if (source == chooseCPButton || source == changeCPButton) {
        removeAsListenerAndDispose(searchController);
        searchController = new ReferencableEntriesSearchController(getWindowControl(), ureq, ImsCPFileResource.TYPE_NAME, translate(NLS_COMMAND_CHOOSECP));
        listenTo(searchController);
        removeAsListenerAndDispose(cmc);
        cmc = new CloseableModalController(getWindowControl(), translate("close"), searchController.getInitialComponent(), true, translate(NLS_COMMAND_CREATECP));
        listenTo(cmc);
        cmc.activate();
    } else if (source == previewLink) {
        // Preview as modal dialogue only if the config is valid
        RepositoryEntry re = getCPReference(config, false);
        if (re == null) {
            // we cannot preview it, because the repository entry
            // had been deleted between the time when it was chosen here, and now
            showError(NLS_ERROR_CPREPOENTRYMISSING);
        } else {
            File cpRoot = FileResourceManager.getInstance().unzipFileResource(re.getOlatResource());
            Boolean showMenuB = config.getBooleanEntry(NodeEditController.CONFIG_COMPONENT_MENU);
            // pre: showMenuB != null
            removeAsListenerAndDispose(previewCtr);
            DeliveryOptions previewOptions = deliveryOptionsCtrl.getOptionsForPreview();
            previewCtr = CPUIFactory.getInstance().createMainLayoutPreviewController_v2(ureq, getWindowControl(), new LocalFolderImpl(cpRoot), showMenuB.booleanValue(), previewOptions);
            stackPanel.pushController(translate("preview.cp"), previewCtr);
        }
    } else if (source == editLink) {
        CourseNodeFactory.getInstance().launchReferencedRepoEntryEditor(ureq, getWindowControl(), cpNode);
    }
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) RepositoryEntry(org.olat.repository.RepositoryEntry) ReferencableEntriesSearchController(org.olat.repository.controllers.ReferencableEntriesSearchController) File(java.io.File) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 8 with DeliveryOptions

use of org.olat.core.gui.control.generic.iframe.DeliveryOptions in project OpenOLAT by OpenOLAT.

the class VarForm method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
public void event(UserRequest urequest, Controller source, Event event) {
    if (source == searchController) {
        cmc.deactivate();
        if (event == ReferencableEntriesSearchController.EVENT_REPOSITORY_ENTRY_SELECTED) {
            // search controller done
            RepositoryEntry re = searchController.getSelectedEntry();
            if (re != null) {
                setScormCPReference(re, config);
                cpConfigurationVc.contextPut("showPreviewButton", Boolean.TRUE);
                String displayname = StringHelper.escapeHtml(re.getDisplayname());
                previewLink = LinkFactory.createCustomLink("command.preview", "command.preview", displayname, Link.NONTRANSLATED, cpConfigurationVc, this);
                previewLink.setIconLeftCSS("o_icon o_icon-fw o_icon_preview");
                previewLink.setCustomEnabledLinkCSS("o_preview");
                previewLink.setTitle(getTranslator().translate("command.preview"));
                // fire event so the updated config is saved by the
                // editormaincontroller
                fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
                ScormPackageConfig scormConfig = ScormMainManager.getInstance().getScormPackageConfig(re.getOlatResource());
                DeliveryOptions parentConfig = scormConfig == null ? null : scormConfig.getDeliveryOptions();
                deliveryOptionsCtrl.setParentDeliveryOptions(parentConfig);
            }
        // else cancelled repo search
        }
    } else if (source == accessibilityCondContr) {
        if (event == Event.CHANGED_EVENT) {
            Condition cond = accessibilityCondContr.getCondition();
            scormNode.setPreConditionAccess(cond);
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == scorevarform) {
        if (event == Event.DONE_EVENT) {
            // save form-values to config
            config.setBooleanEntry(CONFIG_SHOWMENU, scorevarform.isShowMenu());
            config.setBooleanEntry(CONFIG_SKIPLAUNCHPAGE, scorevarform.isSkipLaunchPage());
            config.setBooleanEntry(CONFIG_SHOWNAVBUTTONS, scorevarform.isShowNavButtons());
            config.setBooleanEntry(CONFIG_ISASSESSABLE, scorevarform.isAssessable());
            config.setStringValue(CONFIG_ASSESSABLE_TYPE, scorevarform.getAssessableType());
            config.setIntValue(CONFIG_CUTVALUE, scorevarform.getCutValue());
            config.setBooleanEntry(CONFIG_FULLWINDOW, scorevarform.isFullWindow());
            config.setBooleanEntry(CONFIG_CLOSE_ON_FINISH, scorevarform.isCloseOnFinish());
            // <OLATCE-289>
            config.setIntValue(CONFIG_MAXATTEMPTS, scorevarform.getAttemptsValue());
            config.setBooleanEntry(CONFIG_ADVANCESCORE, scorevarform.isAdvanceScore());
            config.setBooleanEntry(CONFIG_ATTEMPTSDEPENDONSCORE, scorevarform.getAttemptsDependOnScore());
            // </OLATCE-289>
            // fire event so the updated config is saved by the
            // editormaincontroller
            updateHighscoreTab();
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == deliveryOptionsCtrl) {
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            config.set(CONFIG_DELIVERY_OPTIONS, deliveryOptionsCtrl.getDeliveryOptions());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == highScoreNodeConfigController) {
        if (event == Event.DONE_EVENT) {
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    }
}
Also used : Condition(org.olat.course.condition.Condition) ScormPackageConfig(org.olat.modules.scorm.ScormPackageConfig) RepositoryEntry(org.olat.repository.RepositoryEntry) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions)

Example 9 with DeliveryOptions

use of org.olat.core.gui.control.generic.iframe.DeliveryOptions in project openolat by klemens.

the class CPRunController method doLaunch.

private void doLaunch(UserRequest ureq) {
    DeliveryOptions deliveryOptions = (DeliveryOptions) config.get(CPEditController.CONFIG_DELIVERYOPTIONS);
    if (cpRoot == null) {
        // it is the first time we start the contentpackaging from this instance
        // of this controller.
        // need to be strict when launching -> "true"
        RepositoryEntry re = CPEditController.getCPReference(config, false);
        if (re == null) {
            showError(CPEditController.NLS_ERROR_CPREPOENTRYMISSING);
            return;
        }
        cpRoot = FileResourceManager.getInstance().unzipFileResource(re.getOlatResource());
        // nodes reference them
        if (cpRoot == null) {
            showError(CPEditController.NLS_ERROR_CPREPOENTRYMISSING);
            return;
        }
        if (deliveryOptions != null && deliveryOptions.getInherit() != null && deliveryOptions.getInherit().booleanValue()) {
            CPPackageConfig packageConfig = CPManager.getInstance().getCPPackageConfig(re.getOlatResource());
            if (packageConfig != null && packageConfig.getDeliveryOptions() != null) {
                deliveryOptions = packageConfig.getDeliveryOptions();
            }
        }
    }
    // else cpRoot is already set (save some db access if the user opens /
    // closes / reopens the cp from the same CPRuncontroller instance)
    boolean activateFirstPage = true;
    if ((nodecmd != null) && !nodecmd.equals("")) {
        activateFirstPage = false;
    }
    boolean showNavigation = !config.getBooleanSafe(NodeEditController.CONFIG_COMPONENT_MENU);
    cpDispC = CPUIFactory.getInstance().createContentOnlyCPDisplayController(ureq, getWindowControl(), new LocalFolderImpl(cpRoot), activateFirstPage, showNavigation, deliveryOptions, nodecmd, courseResource, cpNode.getIdent(), preview);
    cpDispC.setContentEncoding(deliveryOptions.getContentEncoding());
    cpDispC.setJSEncoding(deliveryOptions.getJavascriptEncoding());
    cpDispC.addControllerListener(this);
    main.setContent(cpDispC.getInitialComponent());
    if (isExternalMenuConfigured()) {
        treeModel = cpDispC.getTreeModel();
        treeNodeClickListener = this;
        if (activateFirstPage) {
            selNodeId = cpDispC.getInitialSelectedNodeId();
        } else {
            String uri = nodecmd;
            if (uri.startsWith("/")) {
                uri = uri.substring(1, uri.length());
            }
            selNodeId = cpDispC.getNodeByUri(uri);
        }
    }
}
Also used : CPPackageConfig(org.olat.ims.cp.ui.CPPackageConfig) RepositoryEntry(org.olat.repository.RepositoryEntry) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 10 with DeliveryOptions

use of org.olat.core.gui.control.generic.iframe.DeliveryOptions in project openolat by klemens.

the class VarForm method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
public void event(UserRequest urequest, Controller source, Event event) {
    if (source == searchController) {
        cmc.deactivate();
        if (event == ReferencableEntriesSearchController.EVENT_REPOSITORY_ENTRY_SELECTED) {
            // search controller done
            RepositoryEntry re = searchController.getSelectedEntry();
            if (re != null) {
                setScormCPReference(re, config);
                cpConfigurationVc.contextPut("showPreviewButton", Boolean.TRUE);
                String displayname = StringHelper.escapeHtml(re.getDisplayname());
                previewLink = LinkFactory.createCustomLink("command.preview", "command.preview", displayname, Link.NONTRANSLATED, cpConfigurationVc, this);
                previewLink.setIconLeftCSS("o_icon o_icon-fw o_icon_preview");
                previewLink.setCustomEnabledLinkCSS("o_preview");
                previewLink.setTitle(getTranslator().translate("command.preview"));
                // fire event so the updated config is saved by the
                // editormaincontroller
                fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
                ScormPackageConfig scormConfig = ScormMainManager.getInstance().getScormPackageConfig(re.getOlatResource());
                DeliveryOptions parentConfig = scormConfig == null ? null : scormConfig.getDeliveryOptions();
                deliveryOptionsCtrl.setParentDeliveryOptions(parentConfig);
            }
        // else cancelled repo search
        }
    } else if (source == accessibilityCondContr) {
        if (event == Event.CHANGED_EVENT) {
            Condition cond = accessibilityCondContr.getCondition();
            scormNode.setPreConditionAccess(cond);
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == scorevarform) {
        if (event == Event.DONE_EVENT) {
            // save form-values to config
            config.setBooleanEntry(CONFIG_SHOWMENU, scorevarform.isShowMenu());
            config.setBooleanEntry(CONFIG_SKIPLAUNCHPAGE, scorevarform.isSkipLaunchPage());
            config.setBooleanEntry(CONFIG_SHOWNAVBUTTONS, scorevarform.isShowNavButtons());
            config.setBooleanEntry(CONFIG_ISASSESSABLE, scorevarform.isAssessable());
            config.setStringValue(CONFIG_ASSESSABLE_TYPE, scorevarform.getAssessableType());
            config.setIntValue(CONFIG_CUTVALUE, scorevarform.getCutValue());
            config.setBooleanEntry(CONFIG_FULLWINDOW, scorevarform.isFullWindow());
            config.setBooleanEntry(CONFIG_CLOSE_ON_FINISH, scorevarform.isCloseOnFinish());
            // <OLATCE-289>
            config.setIntValue(CONFIG_MAXATTEMPTS, scorevarform.getAttemptsValue());
            config.setBooleanEntry(CONFIG_ADVANCESCORE, scorevarform.isAdvanceScore());
            config.setBooleanEntry(CONFIG_ATTEMPTSDEPENDONSCORE, scorevarform.getAttemptsDependOnScore());
            // </OLATCE-289>
            // fire event so the updated config is saved by the
            // editormaincontroller
            updateHighscoreTab();
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == deliveryOptionsCtrl) {
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            config.set(CONFIG_DELIVERY_OPTIONS, deliveryOptionsCtrl.getDeliveryOptions());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == highScoreNodeConfigController) {
        if (event == Event.DONE_EVENT) {
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    }
}
Also used : Condition(org.olat.course.condition.Condition) ScormPackageConfig(org.olat.modules.scorm.ScormPackageConfig) RepositoryEntry(org.olat.repository.RepositoryEntry) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions)

Aggregations

DeliveryOptions (org.olat.core.gui.control.generic.iframe.DeliveryOptions)34 RepositoryEntry (org.olat.repository.RepositoryEntry)18 UserRequest (org.olat.core.gui.UserRequest)10 Controller (org.olat.core.gui.control.Controller)10 WindowControl (org.olat.core.gui.control.WindowControl)10 File (java.io.File)8 LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)8 CPPackageConfig (org.olat.ims.cp.ui.CPPackageConfig)8 ModuleConfiguration (org.olat.modules.ModuleConfiguration)8 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)6 OLATResource (org.olat.resource.OLATResource)6 SinglePageController (org.olat.core.commons.modules.singlepage.SinglePageController)4 ControllerEventListener (org.olat.core.gui.control.ControllerEventListener)4 Event (org.olat.core.gui.control.Event)4 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)4 CloneController (org.olat.core.gui.control.generic.clone.CloneController)4 CloneLayoutControllerCreatorCallback (org.olat.core.gui.control.generic.clone.CloneLayoutControllerCreatorCallback)4 CloneableController (org.olat.core.gui.control.generic.clone.CloneableController)4 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)4 DeliveryOptionsConfigurationController (org.olat.core.gui.control.generic.iframe.DeliveryOptionsConfigurationController)4