use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.
the class AssessedIdentityCheckListController method forgeCheckboxWrapper.
private CheckboxWrapper forgeCheckboxWrapper(Checkbox checkbox, DBCheck check, boolean readOnly, FormItemContainer formLayout) {
String[] values = new String[] { translate(checkbox.getLabel().i18nKey()) };
String boxId = "box_" + checkbox.getCheckboxId();
MultipleSelectionElement boxEl = uifactory.addCheckboxesHorizontal(boxId, null, formLayout, onKeys, values);
boxEl.setEnabled(!readOnly && !coachCourseEnv.isCourseReadOnly());
boxEl.setLabel(checkbox.getTitle(), null, false);
boxEl.showLabel(true);
boxEl.addActionListener(FormEvent.ONCHANGE);
TextElement pointEl = null;
if (withScore && checkbox.getPoints() != null) {
String pointId = "point_" + checkbox.getCheckboxId();
String points;
if (check != null && check.getChecked() != null && check.getChecked().booleanValue()) {
points = AssessmentHelper.getRoundedScore(check.getScore());
} else {
points = null;
}
pointEl = uifactory.addTextElement(pointId, null, 16, points, formLayout);
pointEl.setDisplaySize(5);
pointEl.setEnabled(!coachCourseEnv.isCourseReadOnly());
Float maxScore = checkbox.getPoints();
if (maxScore != null) {
String maxValue = AssessmentHelper.getRoundedScore(maxScore);
pointEl.setExampleKey("checklist.point.example", new String[] { "0", maxValue });
}
// hide when not yet checked
if (check != null) {
pointEl.setVisible(check.getChecked());
} else {
pointEl.setVisible(false);
}
}
CheckboxWrapper wrapper = new CheckboxWrapper(checkbox, check, boxEl, pointEl);
boxEl.setUserObject(wrapper);
if (check != null && check.getChecked() != null && check.getChecked().booleanValue()) {
boxEl.select(onKeys[0], true);
wrapper.setDbCheckbox(check.getCheckbox());
}
return wrapper;
}
use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.
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);
}
use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.
the class EditMembershipController method createSelection.
private MultipleSelectionElement createSelection(boolean selected, boolean enabled, String role) {
String name = "cb" + UUID.randomUUID().toString().replace("-", "");
MultipleSelectionElement selection = new MultipleSelectionElementImpl(name, Layout.horizontal);
selection.setElementCssClass("o_sel_role");
selection.addActionListener(FormEvent.ONCHANGE);
selection.setKeysAndValues(keys, values, new String[] { "o_sel_role_".concat(role) }, null);
flc.add(name, selection);
selection.select(keys[0], selected);
selection.setEnabled(enabled);
return selection;
}
use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.
the class TeacherRollCallController method doCheckAllRow.
private void doCheckAllRow(TeacherRollCallRow row) {
List<Integer> allAbsences = new ArrayList<>(numOfLectures);
for (int i = 0; i < numOfLectures; i++) {
allAbsences.add(i);
}
LectureBlockRollCall rollCall = lectureService.addRollCall(row.getIdentity(), lectureBlock, row.getRollCall(), null, allAbsences);
for (MultipleSelectionElement check : row.getChecks()) {
check.select(onKeys[0], true);
}
row.setRollCall(rollCall);
if (authorizedAbsenceEnabled) {
if (rollCall.getAbsenceAuthorized() != null && rollCall.getAbsenceAuthorized().booleanValue()) {
row.getAuthorizedAbsence().select(onKeys[0], true);
} else {
row.getAuthorizedAbsence().uncheckAll();
}
row.getAuthorizedAbsenceCont().setDirty(true);
}
row.getRollCallStatusEl().getComponent().setDirty(true);
tableEl.reloadData();
flc.setDirty(true);
}
use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.
the class TeacherRollCallController method updateUI.
private void updateUI() {
quickSaveButton.setVisible(secCallback.canEdit());
closeLectureBlocksButton.setVisible(secCallback.canEdit());
if (cancelLectureBlockButton != null) {
cancelLectureBlockButton.setVisible(secCallback.canEdit());
}
reopenButton.setVisible(secCallback.canReopen());
List<TeacherRollCallRow> rows = tableModel.getObjects();
if (rows != null) {
for (TeacherRollCallRow row : rows) {
MultipleSelectionElement[] checks = row.getChecks();
if (checks != null) {
for (MultipleSelectionElement check : checks) {
check.setEnabled(secCallback.canEditAbsences());
check.getComponent().setDirty(true);
}
}
row.getCommentEl().setEnabled(secCallback.canEdit());
if (row.getAuthorizedAbsence() != null) {
row.getAuthorizedAbsence().setEnabled(secCallback.canEdit() && secCallback.canEditAuthorizedAbsences());
}
}
}
tableEl.reset(false, false, true);
}
Aggregations