use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.
the class MultiSPController method create.
private void create(MultipleSelectionElement selection, ICourse course, CourseNode parentNode) {
SelectNodeObject node = (SelectNodeObject) selection.getUserObject();
if (selection.isMultiselect() && selection.isSelected(0)) {
VFSItem item = node.getItem();
CourseNode newNode = null;
if (item instanceof VFSLeaf) {
// create node
newNode = createCourseNode(item, "sp");
ModuleConfiguration moduleConfig = newNode.getModuleConfiguration();
String path = getRelativePath(item);
moduleConfig.set(SPEditController.CONFIG_KEY_FILE, path);
moduleConfig.setBooleanEntry(SPEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS, true);
} else if (item instanceof VFSContainer) {
// add structure
newNode = createCourseNode(item, "st");
}
int pos = -1;
if (position >= 0 && selectedNode.getCourseNode().getIdent().equals(parentNode.getIdent())) {
pos = position++;
}
if (pos < 0 || pos >= parentNode.getChildCount()) {
course.getEditorTreeModel().addCourseNode(newNode, parentNode);
} else {
course.getEditorTreeModel().insertCourseNodeAt(newNode, parentNode, pos);
}
if (item instanceof VFSContainer) {
parentNode = newNode;
}
}
// recurse
for (MultipleSelectionElement childElement : node.getChildren()) {
create(childElement, course, parentNode);
}
}
use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.
the class MetadataBulkChangeController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (checkboxSwitch.contains(source)) {
MultipleSelectionElement checkbox = (MultipleSelectionElement) source;
FormItem item = (FormItem) checkbox.getUserObject();
item.setVisible(checkbox.isAtLeastSelected(1));
checkboxContainer.get(checkbox).setDirty(true);
} else if (licenseEl == source) {
updateLicenseVisibility();
licenseWrapperCont.setDirty(true);
} else {
super.formInnerEvent(ureq, source, event);
}
}
use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.
the class EPArtefactAttributeSettingController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormDescription("display.option.intro");
String[] keys = new String[] { "onoff" };
String[] values = new String[] { translate("display.option.enabled") };
Map<String, Boolean> allArtAttribs = ePFMgr.getArtefactAttributeConfig(null);
for (Iterator<Entry<String, Boolean>> iterator = allArtAttribs.entrySet().iterator(); iterator.hasNext(); ) {
Entry<String, Boolean> entry = iterator.next();
String attKey = entry.getKey();
Boolean attVal = artAttribConfig.get(attKey);
MultipleSelectionElement chkBox = uifactory.addCheckboxesHorizontal(attKey, formLayout, keys, values);
chkBox.addActionListener(FormEvent.ONCHANGE);
// either use users settings or the defaults
if (attVal == null)
attVal = entry.getValue();
chkBox.select(keys[0], attVal);
}
uifactory.addFormSubmitButton("display.option.submit", formLayout);
}
use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.
the class GenericSelectionPropertyHandler method isValid.
@Override
public boolean isValid(User user, FormItem formItem, Map<String, String> formContext) {
if (formItem.isMandatory()) {
if (isMultiselect) {
MultipleSelectionElement msel = (MultipleSelectionElement) formItem;
msel.setErrorKey("form.legende.mandatory", null);
return msel.isAtLeastSelected(1);
} else {
SingleSelection ssel = (SingleSelection) formItem;
if (ssel.getSelectedKey().equals(NO_SEL_KEY)) {
ssel.setErrorKey("form.legende.mandatory", null);
return false;
}
}
}
return true;
}
use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.
the class UserInterestsController method initForm.
/**
* @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer, org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
*/
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormDescription("userinterests.description");
// Draw the checkboxes
for (int i = 0; i < this.availableUserInterests.size(); i++) {
UserInterestsCategory category = this.availableUserInterests.get(i);
Vector<String> keys = new Vector<String>();
for (UserInterestsCategory subcategory : category.getSubcategories()) {
keys.add(UserInterestsPropertyHandler.SUBCATEGORY_I18N_PREFIX + subcategory.getId());
}
String[] values = new String[keys.size()];
for (int j = 0; j < values.length; j++) {
values[j] = translate(keys.get(j));
}
MultipleSelectionElement interestCheckboxes = uifactory.addCheckboxesVertical("interest_" + category.getId(), formLayout, keys.toArray(new String[0]), values, null, 2);
this.checkboxGroups.add(interestCheckboxes);
interestCheckboxes.setLabel(UserInterestsPropertyHandler.CATEGORY_I18N_PREFIX + category.getId(), null);
interestCheckboxes.addActionListener(FormEvent.ONCHANGE);
if (i != this.availableUserInterests.size() - 1) {
uifactory.addSpacerElement("spacer_" + category.getId(), formLayout, false);
}
}
// Check boxes for the given interests
this.setSelectedInterests(this.selectedInterestsIDs);
// Disable the checkboxes if already the maximum number is selected.
if (getSelectionCount() >= maxNumOfInterests) {
Set<String> currentSelection = getCurrentSelection();
for (MultipleSelectionElement checkboxGroup : this.checkboxGroups) {
MultipleSelectionElementImpl multipleSelectionElementImpl = (MultipleSelectionElementImpl) checkboxGroup;
Set<String> allUncheckedCheckboxes = new HashSet<String>(multipleSelectionElementImpl.getKeys());
allUncheckedCheckboxes.removeAll(currentSelection);
multipleSelectionElementImpl.setEnabled(allUncheckedCheckboxes, false);
}
showWarning("form.warning.maxNumber");
}
// Add submit and cancel buttons
final FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator());
formLayout.add(buttonLayout);
uifactory.addFormSubmitButton("finish", buttonLayout);
uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
}
Aggregations