Search in sources :

Example 1 with CloneLayoutControllerCreatorCallback

use of org.olat.core.gui.control.generic.clone.CloneLayoutControllerCreatorCallback in project OpenOLAT by OpenOLAT.

the class STCourseNode method createNodeRunConstructionResult.

/**
 * @see org.olat.course.nodes.CourseNode#createNodeRunConstructionResult(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.WindowControl,
 *      org.olat.course.run.userview.UserCourseEnvironment,
 *      org.olat.course.run.userview.NodeEvaluation)
 */
@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, final UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
    updateModuleConfigDefaults(false);
    Controller cont;
    String displayType = getModuleConfiguration().getStringValue(STCourseNodeEditController.CONFIG_KEY_DISPLAY_TYPE);
    String relPath = STCourseNodeEditController.getFileName(getModuleConfiguration());
    if (relPath != null && displayType.equals(STCourseNodeEditController.CONFIG_VALUE_DISPLAY_FILE)) {
        // we want a user chosen overview, so display the chosen file from the
        // material folder, otherwise display the normal overview
        // reuse the Run controller from the "Single Page" building block, since
        // we need to do exactly the same task
        Boolean allowRelativeLinks = getModuleConfiguration().getBooleanEntry(STCourseNodeEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS);
        if (allowRelativeLinks == null) {
            allowRelativeLinks = Boolean.FALSE;
        }
        DeliveryOptions deliveryOptions = (DeliveryOptions) getModuleConfiguration().get(SPEditController.CONFIG_KEY_DELIVERYOPTIONS);
        OLATResourceable ores = OresHelper.createOLATResourceableInstance(CourseModule.class, userCourseEnv.getCourseEnvironment().getCourseResourceableId());
        SinglePageController spCtr = new SinglePageController(ureq, wControl, userCourseEnv.getCourseEnvironment().getCourseFolderContainer(), relPath, allowRelativeLinks.booleanValue(), null, ores, deliveryOptions, userCourseEnv.getCourseEnvironment().isPreview());
        // check if user is allowed to edit the page in the run view
        CourseGroupManager cgm = userCourseEnv.getCourseEnvironment().getCourseGroupManager();
        boolean hasEditRights = (cgm.isIdentityCourseAdministrator(ureq.getIdentity()) || cgm.hasRight(ureq.getIdentity(), CourseRights.RIGHT_COURSEEDITOR)) || (getModuleConfiguration().getBooleanSafe(SPEditController.CONFIG_KEY_ALLOW_COACH_EDIT, false) && cgm.isIdentityCourseCoach(ureq.getIdentity()));
        if (hasEditRights) {
            spCtr.allowPageEditing();
            // set the link tree model to internal for the HTML editor
            CustomLinkTreeModel linkTreeModel = new CourseInternalLinkTreeModel(userCourseEnv.getCourseEnvironment().getRunStructure().getRootNode());
            spCtr.setInternalLinkTreeModel(linkTreeModel);
        }
        spCtr.addLoggingResourceable(LoggingResourceable.wrap(this));
        // create clone wrapper layout, allow popping into second window
        CloneLayoutControllerCreatorCallback clccc = new CloneLayoutControllerCreatorCallback() {

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

                    @Override
                    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 wrappedCtrl = TitledWrapperHelper.getWrapper(lureq, lwControl, ctr, STCourseNode.this, ICON_CSS_CLASS);
                        layoutCtr.addDisposableChildController(wrappedCtrl);
                        return layoutCtr;
                    }
                });
            }
        };
        Controller wrappedCtrl = TitledWrapperHelper.getWrapper(ureq, wControl, spCtr, this, ICON_CSS_CLASS);
        if (wrappedCtrl instanceof CloneableController) {
            cont = new CloneController(ureq, wControl, (CloneableController) wrappedCtrl, clccc);
        } else {
            throw new AssertException("Need to be a cloneable");
        }
    } else {
        // evaluate the score accounting for this node. this uses the score accountings local
        // cache hash map to reduce unnecessary calculations
        ScoreEvaluation se = userCourseEnv.getScoreAccounting().evalCourseNode(this);
        cont = TitledWrapperHelper.getWrapper(ureq, wControl, new STCourseNodeRunController(ureq, wControl, userCourseEnv, this, se, ne), this, ICON_CSS_CLASS);
    }
    // displayed in the ST-Runcontroller
    return new NodeRunConstructionResult(cont);
}
Also used : STCourseNodeRunController(org.olat.course.nodes.st.STCourseNodeRunController) CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) 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) SPPeekviewController(org.olat.course.nodes.sp.SPPeekviewController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) NodeEditController(org.olat.course.editor.NodeEditController) STCourseNodeRunController(org.olat.course.nodes.st.STCourseNodeRunController) TabbableController(org.olat.core.gui.control.generic.tabbable.TabbableController) CloneableController(org.olat.core.gui.control.generic.clone.CloneableController) AssessmentCourseNodeController(org.olat.course.assessment.ui.tool.AssessmentCourseNodeController) SPEditController(org.olat.course.nodes.sp.SPEditController) CloneController(org.olat.core.gui.control.generic.clone.CloneController) STCourseNodeEditController(org.olat.course.nodes.st.STCourseNodeEditController) Controller(org.olat.core.gui.control.Controller) STPeekViewController(org.olat.course.nodes.st.STPeekViewController) STIdentityListCourseNodeController(org.olat.course.nodes.st.STIdentityListCourseNodeController) SinglePageController(org.olat.core.commons.modules.singlepage.SinglePageController) WindowControl(org.olat.core.gui.control.WindowControl) NodeRunConstructionResult(org.olat.course.run.navigation.NodeRunConstructionResult) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) CustomLinkTreeModel(org.olat.core.commons.controllers.linkchooser.CustomLinkTreeModel) 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) CourseInternalLinkTreeModel(org.olat.course.tree.CourseInternalLinkTreeModel)

Example 2 with CloneLayoutControllerCreatorCallback

use of org.olat.core.gui.control.generic.clone.CloneLayoutControllerCreatorCallback 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 3 with CloneLayoutControllerCreatorCallback

use of org.olat.core.gui.control.generic.clone.CloneLayoutControllerCreatorCallback in project openolat by klemens.

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 4 with CloneLayoutControllerCreatorCallback

use of org.olat.core.gui.control.generic.clone.CloneLayoutControllerCreatorCallback in project openolat by klemens.

the class TURunController method doLaunch.

private void doLaunch(UserRequest ureq) {
    boolean iniframe = config.getBooleanSafe(TUConfigForm.CONFIG_IFRAME);
    // create the possibility to float
    CloneableController controller;
    if (iniframe) {
        // Do not dispose this controller if the course is closed...
        IframeTunnelController ifC = new IframeTunnelController(ureq, getWindowControl(), config);
        controller = ifC;
    } else {
        TunnelController tuC = new TunnelController(ureq, getWindowControl(), config);
        controller = tuC;
    }
    listenTo(controller);
    // create clone wrapper layout
    CloneLayoutControllerCreatorCallback clccc = new CloneLayoutControllerCreatorCallback() {

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

                @SuppressWarnings("synthetic-access")
                public Controller createController(UserRequest lureq, WindowControl lwControl) {
                    // wrapp 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(), courseEnv));
                    layoutCtr.addDisposableChildController(ctr);
                    return layoutCtr;
                }
            });
        }
    };
    Controller ctrl = TitledWrapperHelper.getWrapper(ureq, getWindowControl(), controller, courseNode, "o_tu_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) CloneableController(org.olat.core.gui.control.generic.clone.CloneableController) WindowControl(org.olat.core.gui.control.WindowControl) CloneableController(org.olat.core.gui.control.generic.clone.CloneableController) TunnelController(org.olat.modules.tu.TunnelController) CloneController(org.olat.core.gui.control.generic.clone.CloneController) Controller(org.olat.core.gui.control.Controller) BasicController(org.olat.core.gui.control.controller.BasicController) IframeTunnelController(org.olat.modules.tu.IframeTunnelController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) 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) TunnelController(org.olat.modules.tu.TunnelController) IframeTunnelController(org.olat.modules.tu.IframeTunnelController) IframeTunnelController(org.olat.modules.tu.IframeTunnelController) UserRequest(org.olat.core.gui.UserRequest)

Example 5 with CloneLayoutControllerCreatorCallback

use of org.olat.core.gui.control.generic.clone.CloneLayoutControllerCreatorCallback in project OpenOLAT by OpenOLAT.

the class TURunController method doLaunch.

private void doLaunch(UserRequest ureq) {
    boolean iniframe = config.getBooleanSafe(TUConfigForm.CONFIG_IFRAME);
    // create the possibility to float
    CloneableController controller;
    if (iniframe) {
        // Do not dispose this controller if the course is closed...
        IframeTunnelController ifC = new IframeTunnelController(ureq, getWindowControl(), config);
        controller = ifC;
    } else {
        TunnelController tuC = new TunnelController(ureq, getWindowControl(), config);
        controller = tuC;
    }
    listenTo(controller);
    // create clone wrapper layout
    CloneLayoutControllerCreatorCallback clccc = new CloneLayoutControllerCreatorCallback() {

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

                @SuppressWarnings("synthetic-access")
                public Controller createController(UserRequest lureq, WindowControl lwControl) {
                    // wrapp 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(), courseEnv));
                    layoutCtr.addDisposableChildController(ctr);
                    return layoutCtr;
                }
            });
        }
    };
    Controller ctrl = TitledWrapperHelper.getWrapper(ureq, getWindowControl(), controller, courseNode, "o_tu_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) CloneableController(org.olat.core.gui.control.generic.clone.CloneableController) WindowControl(org.olat.core.gui.control.WindowControl) CloneableController(org.olat.core.gui.control.generic.clone.CloneableController) TunnelController(org.olat.modules.tu.TunnelController) CloneController(org.olat.core.gui.control.generic.clone.CloneController) Controller(org.olat.core.gui.control.Controller) BasicController(org.olat.core.gui.control.controller.BasicController) IframeTunnelController(org.olat.modules.tu.IframeTunnelController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) 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) TunnelController(org.olat.modules.tu.TunnelController) IframeTunnelController(org.olat.modules.tu.IframeTunnelController) IframeTunnelController(org.olat.modules.tu.IframeTunnelController) UserRequest(org.olat.core.gui.UserRequest)

Aggregations

LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)6 UserRequest (org.olat.core.gui.UserRequest)6 Controller (org.olat.core.gui.control.Controller)6 WindowControl (org.olat.core.gui.control.WindowControl)6 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)6 CloneController (org.olat.core.gui.control.generic.clone.CloneController)6 CloneLayoutControllerCreatorCallback (org.olat.core.gui.control.generic.clone.CloneLayoutControllerCreatorCallback)6 CloneableController (org.olat.core.gui.control.generic.clone.CloneableController)6 AssertException (org.olat.core.logging.AssertException)6 SinglePageController (org.olat.core.commons.modules.singlepage.SinglePageController)4 BasicController (org.olat.core.gui.control.controller.BasicController)4 DeliveryOptions (org.olat.core.gui.control.generic.iframe.DeliveryOptions)4 OLATResourceable (org.olat.core.id.OLATResourceable)4 CustomLinkTreeModel (org.olat.core.commons.controllers.linkchooser.CustomLinkTreeModel)2 TabbableController (org.olat.core.gui.control.generic.tabbable.TabbableController)2 AssessmentCourseNodeController (org.olat.course.assessment.ui.tool.AssessmentCourseNodeController)2 NodeEditController (org.olat.course.editor.NodeEditController)2 CourseGroupManager (org.olat.course.groupsandrights.CourseGroupManager)2 SPEditController (org.olat.course.nodes.sp.SPEditController)2 SPPeekviewController (org.olat.course.nodes.sp.SPPeekviewController)2