use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project openolat by klemens.
the class EPStructureDetailsController method validateFormLogic.
/**
* @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#validateFormLogic(org.olat.core.gui.UserRequest)
*/
@Override
protected boolean validateFormLogic(UserRequest ureq) {
if (rootStructure instanceof EPStructuredMapTemplate && restrictionElements != null) {
setCollectRestrictions();
clearErrors();
ArrayList<String> usedTypes = new ArrayList<String>();
int i = 0;
boolean hasError = false;
for (SingleSelection restrictionElement : restrictionElements) {
CollectRestriction restriction = (CollectRestriction) restrictionElement.getUserObject();
if (usedTypes.contains(restriction.getArtefactType())) {
StaticTextElement thisErrorEl = errorElements.get(i);
thisErrorEl.setVisible(true);
thisErrorEl.setValue(translate("collect.restriction.duplicate.type"));
hasError = true;
}
usedTypes.add(restriction.getArtefactType());
boolean hasRestriction = StringHelper.containsNonWhitespace(restriction.getRestriction());
boolean hasArtType = StringHelper.containsNonWhitespace(restriction.getArtefactType());
boolean hasAmount = restriction.getAmount() > 0;
boolean isValid = restriction.isValid();
if (!isValid && (hasRestriction || hasArtType || hasAmount)) {
StaticTextElement thisErrorEl = errorElements.get(i);
thisErrorEl.setVisible(true);
thisErrorEl.setValue(translate("collect.restriction.incomplete"));
hasError = true;
}
i++;
}
return !hasError;
}
return true;
}
use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project openolat by klemens.
the class FormUIFactory method addDropdownSingleselect.
/**
* Add a drop down menu (also called pulldown menu).
* @param id The unique identifier of the selection box (can be null, will be auto generated)
* @param name
* @param labelKey i18n key for the label, may be <code>null</code> indicating no label.
* @param formLayout
* @param theKeys
* @param theValues
* @param theCssClasses
* @return
*/
public SingleSelection addDropdownSingleselect(final String id, final String name, final String i18nLabel, FormItemContainer formLayout, final String[] theKeys, final String[] theValues, final String[] theCssClasses) {
SingleSelection ss = new SelectboxSelectionImpl(id, name, formLayout.getTranslator().getLocale());
ss.setKeysAndValues(theKeys, theValues, theCssClasses);
setLabelIfNotNull(i18nLabel, ss);
formLayout.add(ss);
return ss;
}
use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project openolat by klemens.
the class FormUIFactory method addRadiosVertical.
/**
* Add vertical aligned radio buttons<br>
*
* @param name
* @param i18nLabel
* @param formLayout
* @param theKeys
* @param theValues
* @return
*/
public SingleSelection addRadiosVertical(final String name, final String i18nLabel, FormItemContainer formLayout, final String[] theKeys, final String[] theValues) {
SingleSelection ss = new SingleSelectionImpl(name, name, SingleSelection.Layout.vertical);
ss.setKeysAndValues(theKeys, theValues, null);
setLabelIfNotNull(i18nLabel, ss);
formLayout.add(ss);
return ss;
}
use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project openolat by klemens.
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 klemens.
the class AttributeEasyRowAdderController method formInnerEvent.
/**
* @see org.olat.core.gui.components.form.flexible.FormDefaultController#formInnerEvent(org.olat.core.gui.components.form.flexible.FormItem, org.olat.core.gui.components.form.flexible.FormEvent)
*/
@Override
protected void formInnerEvent(final UserRequest ureq, final FormItem source, final FormEvent event) {
if (isinit) {
final String compName = source.getName();
if (columnAddRow.contains(compName)) {
// add link clicked
final int clickPos = ((Integer) source.getUserObject()).intValue();
addRowAt(clickPos + 1);
} else if (columnRemoveRow.contains(compName)) {
// remove link clicked
final int clickPos = ((Integer) source.getUserObject()).intValue();
removeRowAt(clickPos);
}
if (compName.startsWith(PRE_ATTRIBUTE)) {
// one of the attribute selection drop boxes has been clicked
final SingleSelection s1 = (SingleSelection) source;
String attr;
if (s1.isOneSelected()) {
attr = s1.getSelectedKey();
} else {
// Special case: two new rows, modify the attribute on the second one
// without touching the first one -> nothing selected on the first row
// In this case we use the first one which is the visible one.
attr = s1.getKey(0);
}
// update the value form element depending on the selected attribute
final int clickPos = ((Integer) s1.getUserObject()).intValue();
updateValueElementForAttribute(attr, clickPos, null);
}
}
// update whole container to reflect changes.
this.flc.setDirty(true);
}
Aggregations