Search in sources :

Example 51 with MultipleSelectionElement

use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project openolat by klemens.

the class MetadataBulkChangeController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (checkboxSwitch.contains(source)) {
        MultipleSelectionElement checkbox = (MultipleSelectionElement) source;
        FormItem item = (FormItem) checkbox.getUserObject();
        item.setVisible(checkbox.isAtLeastSelected(1));
        checkboxContainer.get(checkbox).setDirty(true);
    } else if (licenseEl == source) {
        updateLicenseVisibility();
        licenseWrapperCont.setDirty(true);
    } else {
        super.formInnerEvent(ureq, source, event);
    }
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) FormItem(org.olat.core.gui.components.form.flexible.FormItem)

Example 52 with MultipleSelectionElement

use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project openolat by klemens.

the class MetadataBulkChangeController method decorate.

private FormItem decorate(FormItem item, FormLayoutContainer formLayout) {
    String itemName = item.getName();
    MultipleSelectionElement checkbox = uifactory.addCheckboxesHorizontal("cbx_" + itemName, itemName, formLayout, new String[] { itemName }, EMPTY_VALUES);
    checkbox.select(itemName, false);
    checkbox.addActionListener(FormEvent.ONCLICK);
    checkbox.setUserObject(item);
    checkboxSwitch.add(checkbox);
    item.setLabel(null, null);
    item.setVisible(false);
    item.setUserObject(checkbox);
    checkboxContainer.put(checkbox, formLayout);
    formLayout.moveBefore(checkbox, item);
    return checkbox;
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)

Example 53 with MultipleSelectionElement

use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project openolat by klemens.

the class ViteroAdminBookingRawInfosController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    uifactory.addStaticTextElement("booking.id", Integer.toString(booking.getBookingId()), formLayout);
    uifactory.addStaticTextElement("booking.begin", formatter.formatDateAndTime(booking.getStart()), formLayout);
    uifactory.addStaticTextElement("booking.end", formatter.formatDateAndTime(booking.getEnd()), formLayout);
    uifactory.addStaticTextElement("booking.beginBuffer", Integer.toString(booking.getStartBuffer()), formLayout);
    uifactory.addStaticTextElement("booking.endBuffer", Integer.toString(booking.getEndBuffer()), formLayout);
    uifactory.addStaticTextElement("booking.roomSize", Integer.toString(booking.getRoomSize()), formLayout);
    uifactory.addStaticTextElement("group.numOfParticipants", Integer.toString(group.getNumOfParticipants()), formLayout);
    uifactory.addStaticTextElement("group.id", Integer.toString(group.getGroupId()), formLayout);
    String name = group.getName();
    int sepIndex = name.indexOf("_OLAT_");
    if (sepIndex > 0) {
        name = name.substring(0, sepIndex);
    }
    uifactory.addStaticTextElement("group.name", name, formLayout);
    MultipleSelectionElement autoSignIn = uifactory.addCheckboxesHorizontal("booking.autoSignIn", formLayout, autoSignInKeys, autoSignInValues);
    if (booking.isAutoSignIn()) {
        autoSignIn.select(autoSignInKeys[0], true);
    }
    autoSignIn.setEnabled(false);
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)

Example 54 with MultipleSelectionElement

use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project openolat by klemens.

the class HomePageSettingsController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    boolean firstGroup = true;
    List<UserPropertyHandler> homepagePropertyHanders = userManager.getUserPropertyHandlersFor(HomePageConfig.class.getCanonicalName(), isAdministrativeUser);
    Map<String, FormLayoutContainer> groupContainerMap = new HashMap<>();
    HomePageConfig conf = hpcm.loadConfigFor(identityToModify.getName());
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler == null) {
            continue;
        }
        // add spacer if necessary (i.e. when group name changes)
        String group = userPropertyHandler.getGroup();
        FormLayoutContainer groupContainer;
        if (groupContainerMap.containsKey(group)) {
            groupContainer = groupContainerMap.get(group);
        } else {
            groupContainer = FormLayoutContainer.createDefaultFormLayout("group." + group, getTranslator());
            groupContainer.setFormTitle(translate("form.group." + group));
            formLayout.add(groupContainer);
            groupContainerMap.put(group, groupContainer);
            if (firstGroup) {
                groupContainer.setFormContextHelp("Configuration");
                firstGroup = false;
            }
        }
        if (homepagePropertyHanders.contains(userPropertyHandler)) {
            // add checkbox to container if configured for homepage usage identifier
            String checkboxName = userPropertyHandler.getName();
            MultipleSelectionElement publishCheckbox = uifactory.addCheckboxesHorizontal(checkboxName, userPropertyHandler.i18nFormElementLabelKey(), groupContainer, checkKeys, checkValues);
            boolean isEnabled = conf.isEnabled(userPropertyHandler.getName());
            publishCheckbox.select(checkKeys[0], isEnabled);
            publishCheckbox.setUserObject(userPropertyHandler.getName());
            // Mandatory homepage properties can not be changed by user
            if (userManager.isMandatoryUserProperty(HomePageConfig.class.getCanonicalName(), userPropertyHandler)) {
                publishCheckbox.select(checkKeys[0], true);
                publishCheckbox.setEnabled(false);
            } else {
                publishCheckbox.addActionListener(FormEvent.ONCHANGE);
            }
        }
    }
    String previewPage = velocity_root + "/homepage_preview.html";
    previewContainer = FormLayoutContainer.createCustomFormLayout("preview", getTranslator(), previewPage);
    previewContainer.setFormTitle(translate("tab.preview"));
    previewContainer.setRootForm(mainForm);
    formLayout.add(previewContainer);
    updatePreview(ureq);
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) HashMap(java.util.HashMap) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 55 with MultipleSelectionElement

use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project openolat by klemens.

the class GenericSelectionPropertyHandler method getStringValue.

@Override
public String getStringValue(FormItem formItem) {
    if (isMultiselect) {
        Collection<String> selectedKeys = ((MultipleSelectionElement) formItem).getSelectedKeys();
        StringBuilder sb = new StringBuilder();
        for (String sKey : selectedKeys) {
            sb.append(sKey).append(KEY_DELIMITER);
        }
        return sb.toString();
    }
    if (formItem instanceof SingleSelection) {
        SingleSelection sel = (SingleSelection) formItem;
        if (sel.isOneSelected()) {
            return sel.getSelectedKey();
        } else {
            return null;
        }
    }
    return null;
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection)

Aggregations

MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)136 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)22 ArrayList (java.util.ArrayList)20 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)16 MultipleSelectionElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.MultipleSelectionElementImpl)16 HashMap (java.util.HashMap)12 HashSet (java.util.HashSet)12 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)12 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)10 FormItem (org.olat.core.gui.components.form.flexible.FormItem)8 Identity (org.olat.core.id.Identity)8 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)8 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)6 ICourse (org.olat.course.ICourse)6 Checkbox (org.olat.course.nodes.cl.model.Checkbox)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)5 VFSItem (org.olat.core.util.vfs.VFSItem)5 Section (org.olat.modules.portfolio.Section)5 File (java.io.File)4 UserShortDescription (org.olat.admin.user.UserShortDescription)4