Search in sources :

Example 11 with SingleSelection

use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.

the class UsrPropCfgTableController method buildPropertyHandlerTable.

/**
 * builds the userPropertyHandler-Table
 */
private void buildPropertyHandlerTable() {
    List<UserPropertyHandler> myHandlerList = usrPropCfgMng.getUserPropertiesConfigObject().getPropertyHandlers();
    // first search for all group-values in the propertyHandlers
    List<String> allGroupValues = new ArrayList<>();
    for (UserPropertyHandler handler : myHandlerList) {
        String group = handler.getGroup();
        if (!allGroupValues.contains(group))
            allGroupValues.add(group);
    }
    // take the defaults
    for (int k = 0; k < GROUP_KEYS.length; k++) {
        String group = GROUP_KEYS[k];
        if (!allGroupValues.contains(group))
            allGroupValues.add(group);
    }
    final String[] selectableGroups = allGroupValues.toArray(new String[0]);
    // the table-rows
    String handlerName;
    SingleSelection groupDropdown;
    FormToggle fi;
    FormLink translateLink;
    FormLink handlerLink;
    String translatedName;
    for (UserPropertyHandler handler : myHandlerList) {
        handlerName = handler.getName();
        // the group field
        groupDropdown = uifactory.addDropdownSingleselect(FT_NAME_PREFIX_GRPN + handlerName, propTableFlc, selectableGroups, selectableGroups, null);
        if (Arrays.asList(selectableGroups).contains(handler.getGroup())) {
            groupDropdown.select(handler.getGroup(), true);
        } else {
            logWarn("could not set group-select to " + handler.getGroup() + " (" + handler.getName() + ")", null);
        }
        groupDropdown.setUserObject(handler);
        groupDropdown.showLabel(false);
        groupDropdown.addActionListener(FormEvent.ONCHANGE);
        // the "active"-toggle button
        fi = uifactory.addToggleButton(FT_NAME_PREFIX_TGL + handlerName, "&nbsp;", propTableFlc, null, null);
        if (usrPropCfgMng.getUserPropertiesConfigObject().isActiveHandler(handler))
            fi.toggleOn();
        else
            fi.toggleOff();
        if (!UsrPropCfgManager.canBeDeactivated(handler))
            fi.setEnabled(false);
        fi.setUserObject(handler);
        rowToggleButtonsMap.put(handlerName, fi);
        // the "translate" link
        if (isPropertyHandlerTranslated(handler)) {
            translateLink = uifactory.addFormLink(FT_NAME_PREFIX_TRANSL + handlerName, "upc.edittranslate", "label", propTableFlc, Link.LINK);
        } else {
            translateLink = uifactory.addFormLink(FT_NAME_PREFIX_TRANSL + handlerName, "upc.translate", "label", propTableFlc, Link.LINK);
            translateLink.setCustomEnabledLinkCSS("o_ochre");
        }
        translateLink.setUserObject(handler);
        // the "handler-config" link
        if (handlerConfigCtrlFactory.hasConfig(handler)) {
            handlerLink = uifactory.addFormLink(FT_NAME_PREFIX_HDNL + handlerName, "upc.hndlconfig", "label", propTableFlc, Link.LINK);
            handlerLink.setUserObject(handler);
        }
        // put the translation (in the current language) for the property
        translatedName = I18nManager.getInstance().getLocalizedString(UserPropertyHandler.class.getPackage().getName(), handler.i18nFormElementLabelKey(), null, getLocale(), true, true);
        uifactory.addStaticTextElement(FT_NAME_PREFIX_TRANSNAME + handlerName, (translatedName == null ? "-" : translatedName), propTableFlc);
    }
    propTableFlc.contextPut("rows", myHandlerList);
}
Also used : SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) ArrayList(java.util.ArrayList) FormToggle(org.olat.core.gui.components.form.flexible.elements.FormToggle) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 12 with SingleSelection

use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.

the class ExtendedSearchController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source == searchButton) {
        doSearch(ureq);
    } else if (source instanceof SingleSelection) {
        SingleSelection attrEl = (SingleSelection) source;
        if (attrEl.isOneSelected()) {
            Object uObject = attrEl.getUserObject();
            if (uObject instanceof ConditionalQuery) {
                ConditionalQuery query = (ConditionalQuery) uObject;
                query.selectAttributeType(attrEl.getSelectedKey(), null);
            }
        }
    } else if (source instanceof FormLink) {
        FormLink button = (FormLink) source;
        if (button.getCmd().startsWith("add")) {
            ConditionalQuery query = (ConditionalQuery) button.getUserObject();
            addParameter(query);
        } else if (button.getCmd().startsWith("remove")) {
            ConditionalQuery query = (ConditionalQuery) button.getUserObject();
            removeParameter(query);
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 13 with SingleSelection

use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.

the class CourseReminderEditController method initRuleForm.

protected RuleElement initRuleForm(UserRequest ureq, RuleSPI ruleSpi, ReminderRule rule) {
    String id = Integer.toString(counter++);
    String type = ruleSpi.getClass().getSimpleName();
    SingleSelection typeEl = uifactory.addDropdownSingleselect("rule.type.".concat(id), null, rulesCont, typeKeys, typeValues, null);
    typeEl.addActionListener(FormEvent.ONCHANGE);
    for (String typeKey : typeKeys) {
        if (type.equals(typeKey)) {
            typeEl.select(typeKey, true);
        }
    }
    FormLink addRuleButton = uifactory.addFormLink("add.rule.".concat(id), "add", "add.rule", null, rulesCont, Link.BUTTON);
    addRuleButton.setIconLeftCSS("o_icon o_icon-fw o_icon_add");
    addRuleButton.setElementCssClass("o_sel_course_add_rule");
    FormLink deleteRuleButton = uifactory.addFormLink("delete.rule.".concat(id), "delete", "delete.rule", null, rulesCont, Link.BUTTON);
    deleteRuleButton.setIconLeftCSS("o_icon o_icon-fw o_icon_delete_item");
    deleteRuleButton.setElementCssClass("o_sel_course_delete_rule");
    RuleEditorFragment editor = ruleSpi.getEditorFragment(rule, entry);
    FormItem customItem = editor.initForm(rulesCont, this, ureq);
    RuleElement ruleEl = new RuleElement(typeEl, addRuleButton, deleteRuleButton, editor, customItem);
    typeEl.setUserObject(ruleEl);
    addRuleButton.setUserObject(ruleEl);
    deleteRuleButton.setUserObject(ruleEl);
    return ruleEl;
}
Also used : RuleEditorFragment(org.olat.modules.reminder.RuleEditorFragment) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormItem(org.olat.core.gui.components.form.flexible.FormItem) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 14 with SingleSelection

use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.

the class EPShareListController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    // process all form-input fields and update data-model
    secureListBox();
    // policy might be persisted. check with validateFormLogic()
    if (source == addPolicyButton) {
        if (validateFormLogic(ureq)) {
            addEPSharePolicyWrapper(null);
            initPolicyUI();
        }
    } else if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        Object userObject = link.getUserObject();
        if (userObject instanceof EPSharePolicyWrapper) {
            EPSharePolicyWrapper wrapper = (EPSharePolicyWrapper) userObject;
            if (link.getName().startsWith("map.share.policy.add")) {
                if (validateFormLogic(ureq)) {
                    addEPSharePolicyWrapper(wrapper);
                    initPolicyUI();
                }
            } else if (link.getName().startsWith("map.share.policy.delete")) {
                removeEPSharePolicyWrapper(wrapper);
                initPolicyUI();
            } else if (link.getName().startsWith("map.share.policy.invite")) {
                if (validateFormLogic(ureq)) {
                    sendInvitation(ureq, wrapper);
                    initPolicyUI();
                }
            } else if (link.getName().startsWith("choose.group")) {
                doSelectGroup(ureq, wrapper);
            } else if (link.getName().startsWith("choose.identity")) {
                doSelectIdentity(ureq, wrapper);
            }
        } else if (userObject instanceof EPShareGroupWrapper) {
            EPShareGroupWrapper wrapper = (EPShareGroupWrapper) userObject;
            wrapper.remove();
            initPolicyUI();
        } else if (userObject instanceof EPShareUserWrapper) {
            EPShareUserWrapper wrapper = (EPShareUserWrapper) userObject;
            wrapper.remove();
            initPolicyUI();
        }
    } else if (source instanceof SingleSelection && source.getUserObject() instanceof EPSharePolicyWrapper) {
        SingleSelection selection = (SingleSelection) source;
        if (selection.isOneSelected()) {
            String type = selection.getSelectedKey();
            EPSharePolicyWrapper wrapper = (EPSharePolicyWrapper) selection.getUserObject();
            changeType(wrapper, type);
        }
        initPolicyUI();
    }
}
Also used : SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 15 with SingleSelection

use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.

the class EPStructureDetailsController method formOK.

/**
 * @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#formOK(org.olat.core.gui.UserRequest)
 */
@Override
protected void formOK(final UserRequest ureq) {
    editStructure = ePFMgr.reloadPortfolioStructure(editStructure);
    editStructure.setTitle(titleEl.getValue());
    editStructure.setDescription(descriptionEl.getValue());
    editStructure.setArtefactRepresentationMode(viewRadio.getSelectedKey());
    if (rootStructure instanceof EPStructuredMapTemplate && restrictionElements != null) {
        clearErrors();
        editStructure.getCollectRestrictions().clear();
        setCollectRestrictions();
        for (final SingleSelection restrictionElement : restrictionElements) {
            final CollectRestriction restriction = (CollectRestriction) restrictionElement.getUserObject();
            if (restriction.isValid()) {
                final CollectRestriction cr = new CollectRestriction(restriction);
                editStructure.getCollectRestrictions().add(cr);
            }
        }
    }
    ePFMgr.savePortfolioStructure(editStructure);
    fireEvent(ureq, new EPStructureEvent(EPStructureEvent.CHANGE, editStructure));
}
Also used : EPStructureEvent(org.olat.portfolio.ui.structel.EPStructureEvent) EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) CollectRestriction(org.olat.portfolio.model.restriction.CollectRestriction)

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