Search in sources :

Example 76 with ControllerCreator

use of org.olat.core.gui.control.creator.ControllerCreator in project openolat by klemens.

the class TranslationToolLauncherController method event.

/*
	 * (non-Javadoc)
	 * 
	 * @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
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == startTranslationToolLink) {
        // wrap the content controller into a full header layout
        ControllerCreator controllerCreator = new ControllerCreator() {

            @Override
            public Controller createController(UserRequest uureq, WindowControl wControl) {
                return new TranslationToolMainController(uureq, wControl, !i18nModule.isTransToolEnabled());
            }
        };
        // no need for later disposal, opens in popup window and will be disposed
        // by window manager
        ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, controllerCreator);
        PopupBrowserWindow pbw = getWindowControl().getWindowBackOffice().getWindowManager().createNewPopupBrowserWindowFor(ureq, layoutCtrlr);
        pbw.open(ureq);
    } else if (source == enableInlineTranslationLink) {
        setNewInlineStatus(ureq, true);
    } else if (source == disableInlineTranslationLink) {
        setNewInlineStatus(ureq, false);
    } else if (source == cacheFlushLink) {
        // clear i18n cache
        i18nModule.reInitializeAndFlushCache();
        showInfo("cache.flush.ok");
    }
}
Also used : PopupBrowserWindow(org.olat.core.gui.control.generic.popup.PopupBrowserWindow) WindowControl(org.olat.core.gui.control.WindowControl) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) UserRequest(org.olat.core.gui.UserRequest)

Example 77 with ControllerCreator

use of org.olat.core.gui.control.creator.ControllerCreator in project openolat by klemens.

the class StepsMainRunController method event.

@Override
protected /*
	 * (non-Javadoc)
	 * 
	 * @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)
	 */
void event(final UserRequest ureq, Controller source, Event event) {
    /*
		 * FIXME:pb: 
		 */
    if (source == stepPagesController.peek()) {
        if (event == StepsEvent.ACTIVATE_NEXT && !finishCycle) {
            // intermediate steps wants to proceed - and next link was clicked
            lastEvent = event;
            doAfterDispatch = true;
            // activate next event on source
            Step current = steps.peek();
            // TODO:pb detach previous from "submit" cycle
            nextStep = current.nextStep();
            if (nextStep == Step.NOSTEP) {
                // next but no more step -> finish
                finishWizard(ureq);
            } else {
                nextChildCreator = new ControllerCreator() {

                    private final UserRequest ureqForAfterDispatch = ureq;

                    @Override
                    public Controller createController(UserRequest lureq, WindowControl lwControl) {
                        // taken
                        return nextStep.getStepController(ureqForAfterDispatch, lwControl, stepsContext, mainForm);
                    }
                };
            }
        // creation of controller and setting the controller is deferred to
        // the afterDispatch Cycle
        // 
        } else if (event == StepsEvent.ACTIVATE_NEXT && finishCycle) {
            // intermediate step wants to proceed - but finish link was clicked
            // this means current step validated and we are ready to terminate
            // the wizard.
            finishWizard(ureq);
        } else if (event == StepsEvent.INFORM_FINISHED) {
            // finish link was clicked -> step form controller has valid data ->
            // fires
            // FINISH EVENT
            // all relevant data for finishing the wizards work must now be
            // present in the stepsContext
            finishWizard(ureq);
        }
    }
}
Also used : WindowControl(org.olat.core.gui.control.WindowControl) Controller(org.olat.core.gui.control.Controller) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) UserRequest(org.olat.core.gui.UserRequest)

Example 78 with ControllerCreator

use of org.olat.core.gui.control.creator.ControllerCreator in project openolat by klemens.

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 79 with ControllerCreator

use of org.olat.core.gui.control.creator.ControllerCreator in project openolat by klemens.

the class CourseRuntimeController method launchCalendar.

private void launchCalendar(UserRequest ureq) {
    ControllerCreator ctrlCreator = new ControllerCreator() {

        @Override
        public Controller createController(UserRequest lureq, WindowControl lwControl) {
            ICourse course = CourseFactory.loadCourse(getRepositoryEntry());
            ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(getRepositoryEntry());
            WindowControl llwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, lwControl);
            CourseCalendarController calendarController = new CourseCalendarController(lureq, llwControl, getUserCourseEnvironment());
            // use a one-column main layout
            LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, llwControl, calendarController);
            layoutCtr.setCustomCSS(CourseFactory.getCustomCourseCss(lureq.getUserSession(), course.getCourseEnvironment()));
            // dispose calendar on layout dispose
            layoutCtr.addDisposableChildController(calendarController);
            return layoutCtr;
        }
    };
    // wrap the content controller into a full header layout
    ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator);
    // open in new browser window
    PopupBrowserWindow pbw = getWindowControl().getWindowBackOffice().getWindowManager().createNewPopupBrowserWindowFor(ureq, layoutCtrlr);
    pbw.open(ureq);
}
Also used : PopupBrowserWindow(org.olat.core.gui.control.generic.popup.PopupBrowserWindow) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) ICourse(org.olat.course.ICourse) WindowControl(org.olat.core.gui.control.WindowControl) CourseCalendarController(org.olat.course.run.calendar.CourseCalendarController) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) UserRequest(org.olat.core.gui.UserRequest) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 80 with ControllerCreator

use of org.olat.core.gui.control.creator.ControllerCreator in project openolat by klemens.

the class OlatDmzTopNavController method doImpressum.

private void doImpressum(UserRequest ureq) {
    ControllerCreator impressumControllerCreator = new ControllerCreator() {

        @Override
        public Controller createController(UserRequest lureq, WindowControl lwControl) {
            return new ImpressumDmzMainController(lureq, lwControl);
        }
    };
    PopupBrowserWindow popupBrowserWindow = Windows.getWindows(ureq).getWindowManager().createNewUnauthenticatedPopupWindowFor(ureq, impressumControllerCreator);
    popupBrowserWindow.open(ureq);
}
Also used : ImpressumDmzMainController(org.olat.core.commons.controllers.impressum.ImpressumDmzMainController) PopupBrowserWindow(org.olat.core.gui.control.generic.popup.PopupBrowserWindow) WindowControl(org.olat.core.gui.control.WindowControl) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) UserRequest(org.olat.core.gui.UserRequest)

Aggregations

ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)92 UserRequest (org.olat.core.gui.UserRequest)72 WindowControl (org.olat.core.gui.control.WindowControl)72 Controller (org.olat.core.gui.control.Controller)42 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)28 PopupBrowserWindow (org.olat.core.gui.control.generic.popup.PopupBrowserWindow)28 LockableController (org.olat.core.commons.fullWebApp.LockableController)20 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)12 Identity (org.olat.core.id.Identity)12 ArrayList (java.util.ArrayList)10 List (java.util.List)10 FormBasicController (org.olat.core.gui.components.form.flexible.impl.FormBasicController)10 TableEvent (org.olat.core.gui.components.table.TableEvent)10 AssertException (org.olat.core.logging.AssertException)10 UserInfoMainController (org.olat.user.UserInfoMainController)10 OlatFooterController (org.olat.gui.control.OlatFooterController)8 HashMap (java.util.HashMap)6 SingleIdentityChosenEvent (org.olat.basesecurity.events.SingleIdentityChosenEvent)6 TableMultiSelectEvent (org.olat.core.gui.components.table.TableMultiSelectEvent)6 Event (org.olat.core.gui.control.Event)6