Search in sources :

Example 31 with Controller

use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.

the class CourseSite method createController.

@Override
protected MainLayoutController createController(UserRequest ureq, WindowControl wControl, SiteConfiguration config) {
    RepositoryManager rm = RepositoryManager.getInstance();
    RepositoryService rs = CoreSpringFactory.getImpl(RepositoryService.class);
    RepositoryEntry entry = rm.lookupRepositoryEntryBySoftkey(repositorySoftKey, false);
    if (entry == null) {
        return getAlternativeController(ureq, wControl, config);
    }
    MainLayoutController c;
    ICourse course = CourseFactory.loadCourse(entry);
    UserSession usess = ureq.getUserSession();
    // course-launch-state depending course-settings
    RepositoryEntrySecurity reSecurity = rm.isAllowed(ureq, entry);
    boolean isAllowedToLaunch = reSecurity.canLaunch();
    boolean hasAccess = false;
    if (isAllowedToLaunch) {
        // either check with securityCallback or use access-settings from course-nodes
        if (siteSecCallback != null) {
            hasAccess = siteSecCallback.isAllowedToLaunchSite(ureq);
        } else if (usess.isInAssessmentModeProcess() && !usess.matchLockResource(course)) {
            hasAccess = false;
        } else {
            // check within course: accessibility of course root node
            CourseNode rootNode = course.getRunStructure().getRootNode();
            UserCourseEnvironmentImpl uce = new UserCourseEnvironmentImpl(ureq.getUserSession().getIdentityEnvironment(), course.getCourseEnvironment());
            NodeEvaluation nodeEval = rootNode.eval(uce.getConditionInterpreter(), new TreeEvaluation(), new VisibleTreeFilter());
            boolean mayAccessWholeTreeUp = NavigationHandler.mayAccessWholeTreeUp(nodeEval);
            hasAccess = mayAccessWholeTreeUp && nodeEval.isVisible();
        }
    }
    // load course (admins always see content) or alternative controller if course is not launchable
    if (hasAccess || usess.getRoles().isOLATAdmin()) {
        rs.incrementLaunchCounter(entry);
        // build up the context path for linked course
        WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ureq, entry, new StateSite(this), wControl, true);
        CourseRuntimeController runCtr = new CourseRuntimeController(ureq, bwControl, entry, reSecurity, new RuntimeControllerCreator() {

            @Override
            public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry re, RepositoryEntrySecurity security, AssessmentMode assessmentMode) {
                return new RunMainController(uureq, wwControl, toolbarPanel, CourseFactory.loadCourse(re), re, security, assessmentMode);
            }
        }, false, true);
        // Configure run controller
        // a: don't show close link, is opened as site not tab
        runCtr.setCourseCloseEnabled(false);
        // b: don't show toolbar
        if (!showToolController) {
            runCtr.setToolControllerEnabled(false);
        }
        c = runCtr;
    } else {
        // access restricted (not in group / author) -> show controller
        // defined in olat_extensions (type autoCreator)
        c = getAlternativeController(ureq, wControl, config);
    }
    return c;
}
Also used : TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) AssessmentMode(org.olat.course.assessment.AssessmentMode) StateSite(org.olat.core.id.context.StateSite) VisibleTreeFilter(org.olat.course.run.userview.VisibleTreeFilter) RunMainController(org.olat.course.run.RunMainController) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) MainLayoutController(org.olat.core.gui.control.generic.layout.MainLayoutController) RunMainController(org.olat.course.run.RunMainController) CourseRuntimeController(org.olat.course.run.CourseRuntimeController) Controller(org.olat.core.gui.control.Controller) RuntimeControllerCreator(org.olat.repository.ui.RepositoryEntryRuntimeController.RuntimeControllerCreator) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) RepositoryEntrySecurity(org.olat.repository.model.RepositoryEntrySecurity) CourseRuntimeController(org.olat.course.run.CourseRuntimeController) UserSession(org.olat.core.util.UserSession) TreeEvaluation(org.olat.course.run.userview.TreeEvaluation) MainLayoutController(org.olat.core.gui.control.generic.layout.MainLayoutController) RepositoryManager(org.olat.repository.RepositoryManager) CourseNode(org.olat.course.nodes.CourseNode) NodeEvaluation(org.olat.course.run.userview.NodeEvaluation) UserRequest(org.olat.core.gui.UserRequest) RepositoryService(org.olat.repository.RepositoryService)

Example 32 with Controller

use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.

the class CourseSiteContextEntryControllerCreator method messageController.

private Controller messageController(UserRequest ureq, WindowControl wControl, String i18nMesageKey) {
    Translator trans = Util.createPackageTranslator(RepositoryService.class, ureq.getLocale());
    String text = trans.translate(i18nMesageKey);
    Controller c = MessageUIFactory.createInfoMessage(ureq, wControl, null, text);
    // use on column layout
    LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(ureq, wControl, c);
    // dispose content on layout dispose
    layoutCtr.addDisposableChildController(c);
    return layoutCtr;
}
Also used : Translator(org.olat.core.gui.translator.Translator) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) MainLayoutController(org.olat.core.gui.control.generic.layout.MainLayoutController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) Controller(org.olat.core.gui.control.Controller)

Example 33 with Controller

use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.

the class StatisticAutoCreator method createController.

public Controller createController(UserRequest lureq, WindowControl lwControl, ICourse course) {
    Exception re = null;
    try {
        Class<?> cclazz = Thread.currentThread().getContextClassLoader().loadClass(className);
        Constructor<?> con = cclazz.getConstructor(ARGCLASSES);
        Object o = con.newInstance(new Object[] { lureq, lwControl, course, statisticManager_ });
        Controller c = (Controller) o;
        return c;
    } catch (ClassNotFoundException e) {
        re = e;
    } catch (SecurityException e) {
        re = e;
    } catch (NoSuchMethodException e) {
        re = e;
    } catch (IllegalArgumentException e) {
        re = e;
    } catch (InstantiationException e) {
        re = e;
    } catch (IllegalAccessException e) {
        re = e;
    } catch (InvocationTargetException e) {
        re = e;
    } finally {
        if (re != null) {
            throw new AssertException("could not create controller via reflection. classname:" + className, re);
        }
    }
    return null;
}
Also used : AssertException(org.olat.core.logging.AssertException) Controller(org.olat.core.gui.control.Controller) AssertException(org.olat.core.logging.AssertException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 34 with Controller

use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.

the class MultiEvaluationFormController method initOnePageView.

private void initOnePageView(UserRequest ureq, List<Identity> otherEvaluators, boolean anonym) {
    mainVC = createVelocityContainer("multi_evaluation_one_page");
    List<EvaluatorPanel> panels = new ArrayList<>();
    mainVC.contextPut("panels", panels);
    boolean viewOthers = isViewOthers();
    if (owner != null) {
        String ownerFullname = userManager.getUserDisplayName(owner);
        Evaluator evaluator = new Evaluator(owner, ownerFullname);
        evaluators.add(evaluator);
        boolean me = owner.equals(getIdentity());
        if (me || viewOthers) {
            Controller ctrl = createEvalutationForm(ureq, owner);
            String componentName = "panel_" + (++count);
            panels.add(new EvaluatorPanel(evaluator, componentName, ctrl.getInitialComponent()));
            mainVC.put(componentName, ctrl.getInitialComponent());
        }
    }
    if (otherEvaluators != null && otherEvaluators.size() > 0) {
        int countEva = 1;
        for (Identity evaluator : otherEvaluators) {
            boolean me = evaluator.equals(ureq.getIdentity());
            String evaluatorFullname;
            if (!me && anonym) {
                evaluatorFullname = translate("anonym.evaluator", new String[] { Integer.toString(countEva++) });
            } else {
                evaluatorFullname = userManager.getUserDisplayName(evaluator);
            }
            Evaluator eval = new Evaluator(evaluator, evaluatorFullname);
            evaluators.add(eval);
            if (me || viewOthers) {
                Controller ctrl = createEvalutationForm(ureq, evaluator);
                String componentName = "panel_" + (++count);
                panels.add(new EvaluatorPanel(eval, componentName, ctrl.getInitialComponent()));
                mainVC.put(componentName, ctrl.getInitialComponent());
            }
        }
    }
    if (viewOthers && (owner != null && otherEvaluators != null && otherEvaluators.size() > 0) || (otherEvaluators != null && otherEvaluators.size() > 1)) {
        removeAsListenerAndDispose(compareEvaluationCtrl);
        CompareEvaluationsFormController ctrl = new CompareEvaluationsFormController(ureq, getWindowControl(), evaluators, anchor, formEntry);
        listenTo(ctrl);
        Evaluator eval = new Evaluator(null, translate("compare.evaluations"));
        String componentName = "panel_" + (++count);
        panels.add(new EvaluatorPanel(eval, componentName, ctrl.getInitialComponent()));
        mainVC.put(componentName, ctrl.getInitialComponent());
    }
}
Also used : CompareEvaluationsFormController(org.olat.modules.forms.ui.CompareEvaluationsFormController) ArrayList(java.util.ArrayList) Evaluator(org.olat.modules.forms.ui.model.Evaluator) CompareEvaluationsFormController(org.olat.modules.forms.ui.CompareEvaluationsFormController) Controller(org.olat.core.gui.control.Controller) EvaluationFormController(org.olat.modules.forms.ui.EvaluationFormController) BasicController(org.olat.core.gui.control.controller.BasicController) Identity(org.olat.core.id.Identity)

Example 35 with Controller

use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.

the class MembersManagementMainController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty())
        return;
    ContextEntry currentEntry = entries.get(0);
    String cmd = currentEntry.getOLATResourceable().getResourceableTypeName();
    Controller selectedCtrl = selectMenuItem(ureq, cmd);
    if (selectedCtrl instanceof Activateable2) {
        List<ContextEntry> subEntries = entries.subList(1, entries.size());
        ((Activateable2) selectedCtrl).activate(ureq, subEntries, currentEntry.getTransientState());
    }
}
Also used : Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) GroupsAndRightsController(org.olat.course.groupsandrights.GroupsAndRightsController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) Controller(org.olat.core.gui.control.Controller) MainLayoutBasicController(org.olat.core.gui.control.controller.MainLayoutBasicController) OrdersAdminController(org.olat.resource.accesscontrol.ui.OrdersAdminController) ContextEntry(org.olat.core.id.context.ContextEntry)

Aggregations

Controller (org.olat.core.gui.control.Controller)372 BasicController (org.olat.core.gui.control.controller.BasicController)114 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)82 NodeEditController (org.olat.course.editor.NodeEditController)82 WindowControl (org.olat.core.gui.control.WindowControl)78 TabbableController (org.olat.core.gui.control.generic.tabbable.TabbableController)74 NodeRunConstructionResult (org.olat.course.run.navigation.NodeRunConstructionResult)62 RepositoryEntry (org.olat.repository.RepositoryEntry)60 Translator (org.olat.core.gui.translator.Translator)54 UserRequest (org.olat.core.gui.UserRequest)52 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)50 OLATResourceable (org.olat.core.id.OLATResourceable)46 ArrayList (java.util.ArrayList)40 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)40 MainLayoutBasicController (org.olat.core.gui.control.controller.MainLayoutBasicController)36 Component (org.olat.core.gui.components.Component)34 Roles (org.olat.core.id.Roles)34 Activateable2 (org.olat.core.gui.control.generic.dtabs.Activateable2)32 FormBasicController (org.olat.core.gui.components.form.flexible.impl.FormBasicController)30 ContextEntry (org.olat.core.id.context.ContextEntry)30