Search in sources :

Example 61 with SingleSelection

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

Example 62 with SingleSelection

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;
}
Also used : AssertException(org.olat.core.logging.AssertException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormItem(org.olat.core.gui.components.form.flexible.FormItem) SpecialAttributeFormItemHandler(org.olat.course.config.ui.courselayout.attribs.SpecialAttributeFormItemHandler) Entry(java.util.Map.Entry) RepositoryEntry(org.olat.repository.RepositoryEntry) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 63 with SingleSelection

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

Example 64 with SingleSelection

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

Example 65 with SingleSelection

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

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