use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.
the class AbstractLayoutAttribute method getFormItem.
// as per default attaches a dropdown and selects what is given
public FormItem getFormItem(String compName, FormItemContainer formLayout) {
FormUIFactory uifact = FormUIFactory.getInstance();
SingleSelection fi = uifact.addDropdownSingleselect(compName, null, formLayout, availKeys, availValues, availCSS);
if (attributeValue != null && Arrays.asList(availKeys).contains(attributeValue)) {
fi.select(attributeValue, true);
fi.showLabel(false);
}
return fi;
}
use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.
the class CourseLayoutGeneratorController method compileCustomConfigFromGuiWrapper.
private Map<String, Map<String, Object>> compileCustomConfigFromGuiWrapper() {
// get config from wrapper-object
elWithErrorExists = false;
Map<String, Map<String, Object>> customConfig = new HashMap<String, Map<String, Object>>();
for (Iterator<Entry<String, Map<String, FormItem>>> iterator = guiWrapper.entrySet().iterator(); iterator.hasNext(); ) {
Entry<String, Map<String, FormItem>> type = iterator.next();
String cIdent = type.getKey();
Map<String, Object> elementConfig = new HashMap<String, Object>();
Map<String, FormItem> element = type.getValue();
for (Entry<String, FormItem> entry : element.entrySet()) {
String attribName = entry.getKey();
if (!attribName.equals(PreviewLA.IDENTIFIER)) {
// exclude preview
FormItem foItem = entry.getValue();
String value = "";
if (foItem instanceof SingleSelection) {
value = ((SingleSelection) foItem).isOneSelected() ? ((SingleSelection) foItem).getSelectedKey() : "";
} else if (foItem.getUserObject() != null && foItem.getUserObject() instanceof SpecialAttributeFormItemHandler) {
// enclosed item
SpecialAttributeFormItemHandler specHandler = (SpecialAttributeFormItemHandler) foItem.getUserObject();
value = specHandler.getValue();
if (specHandler.hasError()) {
elWithErrorExists = true;
}
} else {
throw new AssertException("implement a getValue for this FormItem to get back a processable value.");
}
elementConfig.put(attribName, value);
}
}
customConfig.put(cIdent, elementConfig);
}
return customConfig;
}
use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.
the class CourseReminderEditController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source instanceof SingleSelection) {
RuleElement panelToUpdate = null;
for (RuleElement ruleEl : ruleEls) {
if (source == ruleEl.getTypeEl()) {
panelToUpdate = ruleEl;
}
}
if (panelToUpdate != null) {
SingleSelection typeEl = (SingleSelection) source;
RuleSPI type = reminderModule.getRuleSPIByType(typeEl.getSelectedKey());
doUpdateRuleForm(ureq, panelToUpdate, type);
}
} else if (source instanceof FormLink) {
FormLink button = (FormLink) source;
String cmd = button.getCmd();
if ("add".equals(cmd)) {
doAddRule(ureq, (RuleElement) button.getUserObject());
} else if ("delete".equals(cmd)) {
doDeleteRule(ureq, (RuleElement) button.getUserObject());
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.
the class SingleSelectionTriggerdDependencyRule method doesTrigger.
@Override
protected boolean doesTrigger() {
SingleSelection singlsel = (SingleSelection) this.triggerElement;
String selected = singlsel.getSelectedKey();
return selected.equals(this.triggerVal);
}
use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.
the class LTIConfigForm method createNameValuePair.
private void createNameValuePair(String key, String value, int index) {
String guid = Long.toString(CodeHelper.getRAMUniqueID());
NameValuePair pair = new NameValuePair(guid);
TextElement nameEl = uifactory.addTextElement("name_" + guid, null, 15, key, customParamLayout);
nameEl.setDisplaySize(16);
pair.setNameEl(nameEl);
SingleSelection typeEl = uifactory.addDropdownSingleselect("typ_" + guid, customParamLayout, customTypeKeys, customTypeValues, null);
typeEl.setUserObject(pair);
typeEl.addActionListener(FormEvent.ONCHANGE);
pair.setCustomType(typeEl);
boolean userprops = value != null && value.startsWith(LTIManager.USER_PROPS_PREFIX);
if (userprops) {
typeEl.select("userprops", true);
value = value.substring(LTIManager.USER_PROPS_PREFIX.length(), value.length());
} else {
typeEl.select("free", true);
}
SingleSelection userPropsChoice = uifactory.addDropdownSingleselect("userprops_" + guid, customParamLayout, userPropKeys, userPropValues, null);
userPropsChoice.setUserObject(pair);
userPropsChoice.setVisible(userprops);
if (userprops) {
for (String userPropKey : userPropKeys) {
if (userPropKey.equals(value)) {
userPropsChoice.select(userPropKey, true);
}
}
}
pair.setUserPropsChoice(userPropsChoice);
TextElement valEl = uifactory.addTextElement("val_" + guid, null, 15, value, customParamLayout);
valEl.setDisplaySize(16);
valEl.setVisible(!userprops);
pair.setValueEl(valEl);
FormLink addButton = uifactory.addFormLink("add_" + guid, "add", null, customParamLayout, Link.BUTTON_XSMALL);
addButton.setUserObject(pair);
pair.setAddButton(addButton);
FormLink removeButton = uifactory.addFormLink("rm_" + guid, "remove", null, customParamLayout, Link.BUTTON_XSMALL);
removeButton.setUserObject(pair);
pair.setRemoveButton(removeButton);
if (index < 0 || index >= nameValuePairs.size()) {
nameValuePairs.add(pair);
} else {
nameValuePairs.add(index, pair);
}
}
Aggregations