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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations