Search in sources :

Example 26 with SingleSelection

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;
}
Also used : EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) ArrayList(java.util.ArrayList) CollectRestriction(org.olat.portfolio.model.restriction.CollectRestriction) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement)

Example 27 with SingleSelection

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;
}
Also used : SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) SelectboxSelectionImpl(org.olat.core.gui.components.form.flexible.impl.elements.SelectboxSelectionImpl)

Example 28 with SingleSelection

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;
}
Also used : SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) SingleSelectionImpl(org.olat.core.gui.components.form.flexible.impl.elements.SingleSelectionImpl)

Example 29 with SingleSelection

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);
}
Also used : SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection)

Example 30 with SingleSelection

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);
}
Also used : SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection)

Aggregations

SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)88 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)34 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)26 FormItem (org.olat.core.gui.components.form.flexible.FormItem)18 ArrayList (java.util.ArrayList)14 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)12 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)12 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)12 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)10 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)8 CollectRestriction (org.olat.portfolio.model.restriction.CollectRestriction)8 File (java.io.File)6 Map (java.util.Map)6 FormLinkImpl (org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl)6 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)6 SliderWrapper (org.olat.modules.forms.ui.model.SliderWrapper)6 UserManager (org.olat.user.UserManager)6 HashMap (java.util.HashMap)4 List (java.util.List)4 EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)4