Search in sources :

Example 1 with MultipleSelectionElement

use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.

the class BinderAssessmentController method forgeAssessmentSection.

private void forgeAssessmentSection(AssessmentSectionWrapper row) {
    AssessmentSection assessmentSection = row.getAssessmentSection();
    Section section = row.getSection();
    if (!SectionStatus.isClosed(section)) {
        // score
        String pointVal = null;
        if (assessmentSection != null && assessmentSection.getScore() != null) {
            BigDecimal score = assessmentSection.getScore();
            pointVal = AssessmentHelper.getRoundedScore(score);
        }
        TextElement pointEl = uifactory.addTextElement("point" + (++counter), null, 5, pointVal, flc);
        pointEl.setDisplaySize(5);
        row.setScoreEl(pointEl);
        // passed
        Boolean passed = assessmentSection == null ? null : assessmentSection.getPassed();
        MultipleSelectionElement passedEl = uifactory.addCheckboxesHorizontal("check" + (++counter), null, flc, onKeys, onValues);
        if (passed != null && passed.booleanValue()) {
            passedEl.select(onKeys[0], passed.booleanValue());
        }
        row.setPassedEl(passedEl);
    }
    if (SectionStatus.isClosed(section)) {
        FormLink reopenButton = uifactory.addFormLink("reopen" + (++counter), "reopen", "reopen", null, flc, Link.BUTTON);
        reopenButton.setElementCssClass("o_sel_pf_reopen_section");
        reopenButton.setUserObject(row);
        row.setButton(reopenButton);
    } else {
        FormLink closeButton = uifactory.addFormLink("close" + (++counter), "close", "close.section", null, flc, Link.BUTTON);
        closeButton.setElementCssClass("o_sel_pf_close_section");
        closeButton.setUserObject(row);
        row.setButton(closeButton);
    }
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) BigDecimal(java.math.BigDecimal)

Example 2 with MultipleSelectionElement

use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.

the class AccessRightsEditController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (removeLink == source) {
        fireEvent(ureq, new AccessRightsEvent(AccessRightsEvent.REMOVE_ALL_RIGHTS));
    } else if (selectAll == source) {
        binderRow.setCoach();
        binderRow.recalculate();
    } else if (deselectAll == source) {
        binderRow.unsetCoach();
        binderRow.unsetReviewer();
        for (SectionAccessRightsRow sectionRow : binderRow.getSections()) {
            sectionRow.unsetCoach();
            sectionRow.unsetReviewer();
            for (PortfolioElementAccessRightsRow pageRow : sectionRow.getPages()) {
                pageRow.unsetCoach();
                pageRow.unsetReviewer();
            }
        }
    } else if (source instanceof MultipleSelectionElement) {
        binderRow.recalculate();
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) AccessRightsEvent(org.olat.modules.portfolio.ui.event.AccessRightsEvent)

Example 3 with MultipleSelectionElement

use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.

the class SingleParticipantCallController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        int numOfChecks = lectureBlock.getPlannedLecturesNumber();
        List<Integer> absences = rollCall.getLecturesAbsentList();
        for (int i = 0; i < numOfChecks; i++) {
            String checkId = "check_" + i;
            MultipleSelectionElement check = uifactory.addCheckboxesHorizontal(checkId, null, layoutCont, onKeys, onValues);
            check.setDomReplacementWrapperRequired(false);
            check.addActionListener(FormEvent.ONCHANGE);
            if (absences.contains(i)) {
                check.select(onKeys[0], true);
            }
            checks.add(check);
        }
        layoutCont.contextPut("checks", checks);
        DisplayPortraitController portraitCtr = new DisplayPortraitController(ureq, getWindowControl(), calledIdentity, true, false);
        listenTo(portraitCtr);
        layoutCont.getFormItemComponent().put("portrait", portraitCtr.getInitialComponent());
        UserShortDescription userDescr = new UserShortDescription(ureq, getWindowControl(), calledIdentity);
        listenTo(userDescr);
        layoutCont.getFormItemComponent().put("userDescr", userDescr.getInitialComponent());
    }
    if (autorizedAbsenceEnabled) {
        authorizedAbsencedEl = uifactory.addCheckboxesHorizontal("authorized.absence", "authorized.absence", formLayout, onKeys, onValues);
        authorizedAbsencedEl.setDomReplacementWrapperRequired(false);
        authorizedAbsencedEl.addActionListener(FormEvent.ONCHANGE);
        if (rollCall.getAbsenceAuthorized() != null && rollCall.getAbsenceAuthorized().booleanValue()) {
            authorizedAbsencedEl.select(onKeys[0], true);
        }
        String reason = rollCall.getAbsenceReason();
        absenceReasonEl = uifactory.addTextAreaElement("absence.reason", "authorized.absence.reason", 2000, 4, 36, false, reason, formLayout);
        absenceReasonEl.setDomReplacementWrapperRequired(false);
        absenceReasonEl.setPlaceholderKey("authorized.absence.reason", null);
        absenceReasonEl.setVisible(authorizedAbsencedEl.isAtLeastSelected(1));
        absenceReasonEl.setMandatory(!absenceDefaultAuthorized);
    }
    String comment = rollCall.getComment();
    commentEl = uifactory.addTextAreaElement("comment", "rollcall.comment", 2000, 4, 36, false, comment, formLayout);
    commentEl.setPlaceholderKey("rollcall.comment", null);
    selectAllLink = uifactory.addFormLink("all", formLayout);
    uifactory.addFormSubmitButton("save", "save.next", formLayout);
    uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
}
Also used : DisplayPortraitController(org.olat.user.DisplayPortraitController) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) UserShortDescription(org.olat.admin.user.UserShortDescription) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 4 with MultipleSelectionElement

use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.

the class CheckListRunController method forgeCheckboxWrapper.

private CheckboxWrapper forgeCheckboxWrapper(Checkbox checkbox, DBCheck check, boolean readOnly, FormItemContainer formLayout) {
    String[] values = new String[] { translate(checkbox.getLabel().i18nKey()) };
    boolean canCheck = CheckboxReleaseEnum.userAndCoach.equals(checkbox.getRelease());
    String boxId = "box_" + checkbox.getCheckboxId();
    MultipleSelectionElement el = uifactory.addCheckboxesHorizontal(boxId, null, formLayout, onKeys, values);
    el.setEnabled(canCheck && !readOnly && !userCourseEnv.isCourseReadOnly());
    el.addActionListener(FormEvent.ONCHANGE);
    DownloadLink downloadLink = null;
    if (StringHelper.containsNonWhitespace(checkbox.getFilename())) {
        VFSContainer container = checkboxManager.getFileContainer(userCourseEnv.getCourseEnvironment(), courseNode);
        VFSItem item = container.resolve(checkbox.getFilename());
        if (item instanceof VFSLeaf) {
            String name = "file_" + checkbox.getCheckboxId();
            downloadLink = uifactory.addDownloadLink(name, checkbox.getFilename(), null, (VFSLeaf) item, formLayout);
        }
    }
    CheckboxWrapper wrapper = new CheckboxWrapper(checkbox, downloadLink, el);
    el.setUserObject(wrapper);
    if (check != null && check.getChecked() != null && check.getChecked().booleanValue()) {
        el.select(onKeys[0], true);
        wrapper.setDbCheckbox(check.getCheckbox());
        wrapper.setScore(check.getScore());
    }
    if (downloadLink != null) {
        downloadLink.setUserObject(wrapper);
    }
    return wrapper;
}
Also used : DownloadLink(org.olat.core.gui.components.form.flexible.elements.DownloadLink) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 5 with MultipleSelectionElement

use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.

the class CheckListRunController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source instanceof MultipleSelectionElement) {
        MultipleSelectionElement boxEl = (MultipleSelectionElement) source;
        CheckboxWrapper wrapper = (CheckboxWrapper) boxEl.getUserObject();
        if (wrapper != null) {
            boolean checked = boxEl.isAtLeastSelected(1);
            if (doCheck(ureq, wrapper, checked)) {
                fireEvent(ureq, Event.CHANGED_EVENT);
            }
        }
    } else if ("ONCLICK".equals(event.getCommand())) {
        String cmd = ureq.getParameter("fcid");
        String panelId = ureq.getParameter("panel");
        if (StringHelper.containsNonWhitespace(cmd) && StringHelper.containsNonWhitespace(panelId)) {
            saveOpenPanel(ureq, panelId, "show".equals(cmd));
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)

Aggregations

MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)136 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)22 ArrayList (java.util.ArrayList)20 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)16 MultipleSelectionElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.MultipleSelectionElementImpl)16 HashMap (java.util.HashMap)12 HashSet (java.util.HashSet)12 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)12 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)10 FormItem (org.olat.core.gui.components.form.flexible.FormItem)8 Identity (org.olat.core.id.Identity)8 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)8 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)6 ICourse (org.olat.course.ICourse)6 Checkbox (org.olat.course.nodes.cl.model.Checkbox)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)5 VFSItem (org.olat.core.util.vfs.VFSItem)5 Section (org.olat.modules.portfolio.Section)5 File (java.io.File)4 UserShortDescription (org.olat.admin.user.UserShortDescription)4