Search in sources :

Example 41 with MultipleSelectionElement

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

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 42 with MultipleSelectionElement

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

the class CheckboxAssessmentController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (checkboxEl == source) {
        int nextCheckboxIndex = checkboxEl.getSelected();
        saveCurrentSelectCheckbox();
        Checkbox box = checkboxList.getList().get(nextCheckboxIndex);
        boolean hasPoints = box.getPoints() != null && box.getPoints().floatValue() > 0f;
        List<CheckboxAssessmentRow> rows = model.getObjects();
        for (CheckboxAssessmentRow row : rows) {
            Boolean[] checkedArr = row.getChecked();
            if (checkedArr[nextCheckboxIndex] != null && checkedArr[nextCheckboxIndex].booleanValue()) {
                row.getCheckedEl().select(onKeys[0], true);
            } else {
                row.getCheckedEl().select(onKeys[0], false);
            }
            Float[] scores = row.getScores();
            if (scores[nextCheckboxIndex] != null && scores[nextCheckboxIndex] != null) {
                row.getPointEl().setValue(AssessmentHelper.getRoundedScore(scores[nextCheckboxIndex]));
            } else {
                row.getPointEl().setValue("");
            }
            row.getPointEl().setVisible(hasPoints);
        }
        currentCheckboxIndex = nextCheckboxIndex;
    } else if (source instanceof MultipleSelectionElement) {
        MultipleSelectionElement checkEl = (MultipleSelectionElement) source;
        if (checkEl.getUserObject() instanceof CheckboxAssessmentRow) {
            CheckboxAssessmentRow row = (CheckboxAssessmentRow) checkEl.getUserObject();
            if (row.getPointEl().isVisible()) {
                boolean checked = checkEl.isAtLeastSelected(1);
                if (checked) {
                    int nextCheckboxIndex = checkboxEl.getSelected();
                    Checkbox box = checkboxList.getList().get(nextCheckboxIndex);
                    String pointVal = AssessmentHelper.getRoundedScore(box.getPoints());
                    row.getPointEl().setValue(pointVal);
                } else {
                    row.getPointEl().setValue("");
                }
            }
        }
    } else if (selectAllBoxButton == source) {
        doSelectAll();
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) Checkbox(org.olat.course.nodes.cl.model.Checkbox)

Example 43 with MultipleSelectionElement

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

the class AssessedIdentityCheckListController 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();
        doUpdateCheck(wrapper, boxEl.isAtLeastSelected(1));
    } else if (saveAndCloseLink == source) {
        if (validateFormLogic(ureq)) {
            doSave();
            fireEvent(ureq, Event.DONE_EVENT);
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)

Example 44 with MultipleSelectionElement

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

the class CustomfieldsFormController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    // loop over all Element to store values
    for (int i = 0; i < customFields.size(); i++) {
        TextElement nameTextElement = customFieldNameElementList.get(i);
        if (!customFields.get(i).getName().equals(nameTextElement.getValue())) {
            customFields.get(i).setName(nameTextElement.getValue());
        }
        TextElement valueTextElement = customFieldValueElementList.get(i);
        if (!customFields.get(i).getValue().equals(valueTextElement.getValue())) {
            customFields.get(i).setValue(valueTextElement.getValue());
        }
        MultipleSelectionElement tableViewElement = customFieldTableFlagElementList.get(i);
        if (customFields.get(i).isTableViewEnabled() != tableViewElement.isSelected(0)) {
            customFields.get(i).setTableViewEnabled(tableViewElement.isSelected(0));
        }
    }
    config.setCustomFields(customFields);
    fireEvent(ureq, Event.DONE_EVENT);
    fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)

Example 45 with MultipleSelectionElement

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

the class CustomfieldsFormController method createFormElemente.

private void createFormElemente(FormItemContainer formLayout, int i, CustomField customField) {
    TextElement nameElement = uifactory.addTextElement("customfield_name_" + i, "-", 50, customField.getName(), formLayout);
    nameElement.setLabel("customfield.name.label", null);
    if (i == 0)
        nameElement.setExampleKey("customfield.example.name", null);
    customFieldNameElementList.add(nameElement);
    TextElement valueElement = uifactory.addTextAreaElement("customfield_value_" + i, "-", 2500, 5, 2, true, customField.getValue(), formLayout);
    valueElement.setLabel("customfield.value.label", null);
    if (i == 0)
        valueElement.setExampleKey("customfield.example.value", null);
    customFieldValueElementList.add(valueElement);
    MultipleSelectionElement tableEnabledElement = uifactory.addCheckboxesHorizontal("customfield.table.enabled." + i, null, formLayout, keys, values);
    tableEnabledElement.select(keys[0], customField.isTableViewEnabled());
    customFieldTableFlagElementList.add(tableEnabledElement);
    FormLink deleteLink = uifactory.addFormLink("customfield.delete.link." + i, formLayout, Link.BUTTON_SMALL);
    deleteLink.setUserObject(new Integer(i));
    customFieldLinkElementList.add(deleteLink);
    SpacerElement spacerElement = uifactory.addSpacerElement("spacer" + i, formLayout, false);
    customFieldSpacerElementList.add(spacerElement);
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) SpacerElement(org.olat.core.gui.components.form.flexible.elements.SpacerElement) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

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