Search in sources :

Example 81 with Component

use of org.olat.core.gui.components.Component in project openolat by klemens.

the class GenericMainController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == olatMenuTree) {
        if (event instanceof TreeEvent && event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
            TreeEvent te = (TreeEvent) event;
            if (te.getSubCommand() != null) {
            // filter open/close events
            } else {
                // process menu commands
                TreeNode selTreeNode = olatMenuTree.getSelectedNode();
                // cleanup old content controller (never null)
                removeAsListenerAndDispose(contentCtr);
                // create new content controller
                // Following cases:
                // 1a) Simple Action Extension using only ureq and windowControl ->
                // handled by default implementation of createController
                // 1b) Specialised Action Extension which needs some more internals ->
                // handled by the class extending GenericMainController, by overwriting
                // createController
                // 2) uobject is something special which needs evaluation by class
                // extending GenericMainController
                Object uobject = selTreeNode.getUserObject();
                TreeNode delegatee = selTreeNode.getDelegate();
                if (delegatee != null) {
                    olatMenuTree.setSelectedNode(delegatee);
                }
                contentCtr = getContentCtr(uobject, ureq);
                listenTo(contentCtr);
                Component resComp = contentCtr.getInitialComponent();
                content.setContent(resComp);
                addToHistory(ureq, contentCtr);
            }
        } else {
            // the action was not allowed anymore
            // display an empty field (empty panel)
            content.setContent(null);
        }
    } else {
        logWarn("Unhandled olatMenuTree event: " + event.getCommand(), null);
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) Component(org.olat.core.gui.components.Component)

Example 82 with Component

use of org.olat.core.gui.components.Component in project openolat by klemens.

the class CheckListBoxListEditController method doOpenEdit.

private void doOpenEdit(UserRequest ureq, Checkbox checkbox, boolean newCheckbox, String title) {
    if (editCtrl != null)
        return;
    Boolean hasScore = (Boolean) config.get(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD);
    boolean withScore = (hasScore == null || hasScore.booleanValue());
    editCtrl = new CheckboxEditController(ureq, getWindowControl(), courseOres, courseNode, checkbox, newCheckbox, withScore);
    listenTo(editCtrl);
    Component content = editCtrl.getInitialComponent();
    cmc = new CloseableModalController(getWindowControl(), translate("close"), content, true, title);
    listenTo(cmc);
    cmc.activate();
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) Component(org.olat.core.gui.components.Component)

Example 83 with Component

use of org.olat.core.gui.components.Component in project openolat by klemens.

the class CheckListRunController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    boolean readOnly = isReadOnly();
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("readOnly", Boolean.valueOf(readOnly));
        if (dueDate != null) {
            layoutCont.contextPut("dueDate", dueDate);
            layoutCont.contextPut("in-due-date", isPanelOpen(ureq, "due-date", true));
            if (dueDate.compareTo(new Date()) < 0) {
                layoutCont.contextPut("afterDueDate", Boolean.TRUE);
            }
        }
        layoutCont.contextPut("withScore", new Boolean(withScore));
        if (courseNode.getModuleConfiguration().getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD, false)) {
            HighScoreRunController highScoreCtr = new HighScoreRunController(ureq, getWindowControl(), userCourseEnv, courseNode, this.mainForm);
            if (highScoreCtr.isViewHighscore()) {
                Component highScoreComponent = highScoreCtr.getInitialComponent();
                layoutCont.put("highScore", highScoreComponent);
            }
        }
        List<DBCheck> checks = checkboxManager.loadCheck(getIdentity(), courseOres, courseNode.getIdent());
        Map<String, DBCheck> uuidToCheckMap = new HashMap<>();
        for (DBCheck check : checks) {
            uuidToCheckMap.put(check.getCheckbox().getCheckboxId(), check);
        }
        List<Checkbox> list = checkboxList.getList();
        List<CheckboxWrapper> wrappers = new ArrayList<>(list.size());
        for (Checkbox checkbox : list) {
            DBCheck check = uuidToCheckMap.get(checkbox.getCheckboxId());
            CheckboxWrapper wrapper = forgeCheckboxWrapper(checkbox, check, readOnly, formLayout);
            layoutCont.add(wrapper.getCheckboxEl());
            wrappers.add(wrapper);
        }
        layoutCont.contextPut("checkboxList", wrappers);
        if (withScore || withPassed) {
            layoutCont.contextPut("enableScoreInfo", Boolean.TRUE);
            exposeConfigToVC(ureq, layoutCont);
            exposeUserDataToVC(ureq, layoutCont);
        } else {
            layoutCont.contextPut("enableScoreInfo", Boolean.FALSE);
        }
    }
}
Also used : DBCheck(org.olat.course.nodes.cl.model.DBCheck) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) HighScoreRunController(org.olat.course.highscore.ui.HighScoreRunController) Date(java.util.Date) Checkbox(org.olat.course.nodes.cl.model.Checkbox) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Component(org.olat.core.gui.components.Component)

Example 84 with Component

use of org.olat.core.gui.components.Component in project openolat by klemens.

the class CheckListRunForCoachController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == segmentView) {
        if (event instanceof SegmentViewEvent) {
            SegmentViewEvent sve = (SegmentViewEvent) event;
            String segmentCName = sve.getComponentName();
            Component clickedLink = mainVC.getComponent(segmentCName);
            if (clickedLink == runLink) {
                doOpenRun(ureq);
            } else if (clickedLink == coachLink) {
                doOpenCoach(ureq);
            }
        }
    }
}
Also used : SegmentViewEvent(org.olat.core.gui.components.segmentedview.SegmentViewEvent) Component(org.olat.core.gui.components.Component) SegmentViewComponent(org.olat.core.gui.components.segmentedview.SegmentViewComponent)

Example 85 with Component

use of org.olat.core.gui.components.Component in project openolat by klemens.

the class ScormRunController method doStartPage.

private void doStartPage(UserRequest ureq) {
    // push title and learning objectives, only visible on intro page
    startPage.contextPut("menuTitle", scormNode.getShortTitle());
    startPage.contextPut("displayTitle", scormNode.getLongTitle());
    // Adding learning objectives
    String learningObj = scormNode.getLearningObjectives();
    if (learningObj != null) {
        Component learningObjectives = ObjectivesHelper.createLearningObjectivesComponent(learningObj, getLocale());
        startPage.put("learningObjectives", learningObjectives);
        startPage.contextPut("hasObjectives", Boolean.TRUE);
    } else {
        startPage.contextPut("hasObjectives", Boolean.FALSE);
    }
    if (isAssessable) {
        ScoreEvaluation scoreEval = scormNode.getUserScoreEvaluation(userCourseEnv);
        Float score = scoreEval.getScore();
        if (ScormEditController.CONFIG_ASSESSABLE_TYPE_SCORE.equals(assessableType)) {
            startPage.contextPut("score", score != null ? AssessmentHelper.getRoundedScore(score) : "0");
        }
        startPage.contextPut("hasPassedValue", (scoreEval.getPassed() == null ? Boolean.FALSE : Boolean.TRUE));
        startPage.contextPut("passed", scoreEval.getPassed());
        boolean resultsVisible = scoreEval.getUserVisible() == null || scoreEval.getUserVisible().booleanValue();
        startPage.contextPut("resultsVisible", resultsVisible);
        if (resultsVisible && scormNode.hasCommentConfigured()) {
            StringBuilder comment = Formatter.stripTabsAndReturns(scormNode.getUserUserComment(userCourseEnv));
            startPage.contextPut("comment", StringHelper.xssScan(comment));
        }
        startPage.contextPut("attempts", scormNode.getUserAttempts(userCourseEnv));
        if (ureq == null) {
            // High score need one
            ureq = new SyntheticUserRequest(getIdentity(), getLocale(), userSession);
        }
        HighScoreRunController highScoreCtr = new HighScoreRunController(ureq, getWindowControl(), userCourseEnv, scormNode);
        if (highScoreCtr.isViewHighscore()) {
            Component highScoreComponent = highScoreCtr.getInitialComponent();
            startPage.put("highScore", highScoreComponent);
        }
    }
    startPage.contextPut("isassessable", Boolean.valueOf(isAssessable));
    main.setContent(startPage);
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) HighScoreRunController(org.olat.course.highscore.ui.HighScoreRunController) SyntheticUserRequest(org.olat.core.gui.util.SyntheticUserRequest) Component(org.olat.core.gui.components.Component)

Aggregations

Component (org.olat.core.gui.components.Component)300 SegmentViewComponent (org.olat.core.gui.components.segmentedview.SegmentViewComponent)90 SegmentViewEvent (org.olat.core.gui.components.segmentedview.SegmentViewEvent)90 ArrayList (java.util.ArrayList)36 Controller (org.olat.core.gui.control.Controller)28 Link (org.olat.core.gui.components.link.Link)22 BasicController (org.olat.core.gui.control.controller.BasicController)22 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)22 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)18 Panel (org.olat.core.gui.components.panel.Panel)12 HighScoreRunController (org.olat.course.highscore.ui.HighScoreRunController)12 Date (java.util.Date)10 UserRequest (org.olat.core.gui.UserRequest)10 ComponentRenderer (org.olat.core.gui.components.ComponentRenderer)10 TreeNode (org.olat.core.gui.components.tree.TreeNode)10 RenderResult (org.olat.core.gui.render.RenderResult)10 StringOutput (org.olat.core.gui.render.StringOutput)10 Translator (org.olat.core.gui.translator.Translator)10 AbstractComponent (org.olat.core.gui.components.AbstractComponent)8 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)8