Search in sources :

Example 76 with MultipleSelectionElement

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

the class UserInterestsController method getSelectedInterests.

/**
 * Returns a string which contains the identifiers of the selected checkboxes, delimited by colons.
 *
 * @return a string which contains the i18n keys of the selected checkboxes, delimited by colons.
 */
public String getSelectedInterests() {
    // Retrieve the i18n keys of the selected checkboxes
    Set<String> selectedInterestsKeysAsSet = new HashSet<String>();
    for (MultipleSelectionElement checkboxGroup : this.checkboxGroups) {
        selectedInterestsKeysAsSet.addAll(checkboxGroup.getSelectedKeys());
    }
    if (selectedInterestsKeysAsSet.size() > 0) {
        // convert these keys into IDs
        @SuppressWarnings("hiding") Set<String> selectedInterestsIDs = new HashSet<String>();
        for (String selectedInterestKey : selectedInterestsKeysAsSet) {
            selectedInterestsIDs.add(selectedInterestKey.replace(UserInterestsPropertyHandler.SUBCATEGORY_I18N_PREFIX, ""));
        }
        StringBuffer selectedInterestsKeys = new StringBuffer();
        selectedInterestsKeys.append(":");
        for (String selectedInterestID : selectedInterestsIDs) {
            selectedInterestsKeys.append(selectedInterestID);
            selectedInterestsKeys.append(":");
        }
        return selectedInterestsKeys.toString();
    } else {
        return "";
    }
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) HashSet(java.util.HashSet)

Example 77 with MultipleSelectionElement

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

the class PortfolioAdminController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    // module configuration
    FormLayoutContainer moduleFlc = FormLayoutContainer.createDefaultFormLayout("flc_module", getTranslator());
    formLayout.add(moduleFlc);
    String[] enabledValues = new String[] { translate("enabled") };
    String[] enabledPortfolioValues = new String[] { translate("enabled"), translate("portfolio.v1.module.enabled") };
    portfoliosEnabled = uifactory.addCheckboxesVertical("portfolio.module.enabled", moduleFlc, enabledPortfolioKeys, enabledPortfolioValues, 1);
    if (portfolioModule.isEnabled() || portfolioV2Module.isEnabled()) {
        portfoliosEnabled.select(enabledPortfolioKeys[0], true);
    }
    if (portfolioModule.isEnabled()) {
        portfoliosEnabled.select(enabledPortfolioKeys[1], true);
    }
    portfoliosEnabled.addActionListener(FormEvent.ONCHANGE);
    createBinderEl = uifactory.addCheckboxesVertical("portfolio.user.create.binder", moduleFlc, BINDER_CREATE_KEYS, translateKeys(BINDER_CREATE_KEYS), 1);
    createBinderEl.addActionListener(FormEvent.ONCHANGE);
    String[] entryPointKeys = new String[] { PortfolioV2Module.ENTRY_POINT_TOC, PortfolioV2Module.ENTRY_POINT_ENTRIES };
    String[] entryPointValues = new String[] { translate("binder.entry.point.toc"), translate("binder.entry.point.entries") };
    entryPointEl = uifactory.addDropdownSingleselect("binder.entry.point", "binder.entry.point", moduleFlc, entryPointKeys, entryPointValues, null);
    entryPointEl.addActionListener(FormEvent.ONCHANGE);
    String entryPoint = portfolioV2Module.getBinderEntryPoint();
    for (String entryPointKey : entryPointKeys) {
        if (entryPointKey.equals(entryPoint)) {
            entryPointEl.select(entryPointKey, true);
        }
    }
    if (!entryPointEl.isOneSelected()) {
        entryPointEl.select(entryPointKeys[0], true);
    }
    sectionVisibilityEl = uifactory.addCheckboxesVertical("section.enabled", moduleFlc, SECTION_VISIBILITY_KEYS, translateKeys(SECTION_VISIBILITY_KEYS), 1);
    sectionVisibilityEl.addActionListener(FormEvent.ONCHANGE);
    entryElementsVisibilityEl = uifactory.addCheckboxesVertical("entries.elements.enabled", moduleFlc, ENTRIES_ELEMENTS_KEYS, translateKeys(ENTRIES_ELEMENTS_KEYS), 1);
    entryElementsVisibilityEl.addActionListener(FormEvent.ONCHANGE);
    commentsVisibilityEl = uifactory.addCheckboxesVertical("comments.enabled", moduleFlc, COMMENTS_KEYS, translateKeys(COMMENTS_KEYS), 1);
    commentsVisibilityEl.addActionListener(FormEvent.ONCHANGE);
    entriesViewEl = uifactory.addDropdownSingleselect("entries.view", moduleFlc, ENTRIES_VIEW_KEYS, translateKeys(ENTRIES_VIEW_KEYS));
    String selectedKey = ENTRIES_BOTH_ENABLED;
    if (portfolioV2Module.isEntriesTableEnabled() && !portfolioV2Module.isEntriesListEnabled()) {
        selectedKey = ENTRIES_TABLE_ENABLED;
    } else if (!portfolioV2Module.isEntriesTableEnabled() && portfolioV2Module.isEntriesListEnabled()) {
        selectedKey = ENTRIES_LIST_ENABLED;
    }
    entriesViewEl.select(selectedKey, true);
    entriesViewEl.addActionListener(FormEvent.ONCHANGE);
    // handlers configuration
    FormLayoutContainer handlersFlc = FormLayoutContainer.createDefaultFormLayout("flc_handlers", getTranslator());
    formLayout.add(handlersFlc);
    List<EPArtefactHandler<?>> handlers = portfolioModule.getAllAvailableArtefactHandlers();
    for (EPArtefactHandler<?> handler : handlers) {
        Translator handlerTrans = handler.getHandlerTranslator(getTranslator());
        handlersFlc.setTranslator(handlerTrans);
        String handlerClass = PortfolioFilterController.HANDLER_PREFIX + handler.getClass().getSimpleName() + PortfolioFilterController.HANDLER_TITLE_SUFFIX;
        MultipleSelectionElement handlerEnabled = uifactory.addCheckboxesHorizontal(handlerClass, handlersFlc, enabledKeys, enabledValues);
        handlerEnabled.select(enabledKeys[0], handler.isEnabled());
        handlerEnabled.setUserObject(handler);
        handlerEnabled.addActionListener(FormEvent.ONCHANGE);
        handlersEnabled.add(handlerEnabled);
    }
    // configure steps in artefact collection wizard
    wizardFlc = FormLayoutContainer.createDefaultFormLayout("flc_wizard", getTranslator());
    formLayout.add(wizardFlc);
    copyrightStepCB = uifactory.addCheckboxesHorizontal("wizard.step.copyright", wizardFlc, enabledKeys, enabledValues);
    copyrightStepCB.select(enabledKeys[0], portfolioModule.isCopyrightStepEnabled());
    copyrightStepCB.addActionListener(FormEvent.ONCHANGE);
    reflexionStepCB = uifactory.addCheckboxesHorizontal("wizard.step.reflexion", wizardFlc, enabledKeys, enabledValues);
    reflexionStepCB.select(enabledKeys[0], portfolioModule.isReflexionStepEnabled());
    reflexionStepCB.addActionListener(FormEvent.ONCHANGE);
    wizardFlc.setVisible(portfoliosEnabled.isSelected(1));
    updateV2UI();
}
Also used : EPArtefactHandler(org.olat.portfolio.EPArtefactHandler) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) Translator(org.olat.core.gui.translator.Translator) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 78 with MultipleSelectionElement

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

the class CustomfieldsFormController method createFormElemente.

private void createFormElemente(FormItemContainer formLayout, int i, CustomField customField) {
    TextElement nameElement = uifactory.addTextElement("customfield_name_" + i, "-", 50, customField.getName(), formLayout);
    nameElement.setLabel("customfield.name.label", null);
    if (i == 0)
        nameElement.setExampleKey("customfield.example.name", null);
    customFieldNameElementList.add(nameElement);
    TextElement valueElement = uifactory.addTextAreaElement("customfield_value_" + i, "-", 2500, 5, 2, true, customField.getValue(), formLayout);
    valueElement.setLabel("customfield.value.label", null);
    if (i == 0)
        valueElement.setExampleKey("customfield.example.value", null);
    customFieldValueElementList.add(valueElement);
    MultipleSelectionElement tableEnabledElement = uifactory.addCheckboxesHorizontal("customfield.table.enabled." + i, null, formLayout, keys, values);
    tableEnabledElement.select(keys[0], customField.isTableViewEnabled());
    customFieldTableFlagElementList.add(tableEnabledElement);
    FormLink deleteLink = uifactory.addFormLink("customfield.delete.link." + i, formLayout, Link.BUTTON_SMALL);
    deleteLink.setUserObject(new Integer(i));
    customFieldLinkElementList.add(deleteLink);
    SpacerElement spacerElement = uifactory.addSpacerElement("spacer" + i, formLayout, false);
    customFieldSpacerElementList.add(spacerElement);
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) SpacerElement(org.olat.core.gui.components.form.flexible.elements.SpacerElement) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 79 with MultipleSelectionElement

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

the class BGConfigToolsStepController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    BGConfigBusinessGroup configuration = new BGConfigBusinessGroup();
    for (MultipleSelectionElement toolEl : toolList) {
        if (toolEl.isAtLeastSelected(1)) {
            ToolConfig config = (ToolConfig) toolEl.getUserObject();
            String tool = config.getToolKey();
            boolean enabled = config.enableEl.isSelected(0);
            if (enabled) {
                configuration.getToolsToEnable().add(tool);
            } else {
                configuration.getToolsToDisable().add(tool);
            }
            if (tool.equals(CollaborationTools.TOOL_CALENDAR)) {
                configuration.setCalendarAccess(config.calendarCtrl.getCalendarAccess());
            } else if (tool.equals(CollaborationTools.TOOL_FOLDER)) {
                configuration.setFolderAccess(config.folderCtrl.getFolderAccess());
                // only admin are allowed to configure quota
                if (ureq.getUserSession().getRoles().isOLATAdmin() && config.quotaCtrl != null) {
                    Long quotaKB = config.quotaCtrl.getQuotaKB();
                    Long ulLimit = config.quotaCtrl.getULLimit();
                    Quota quota = quotaManager.createQuota(null, quotaKB, ulLimit);
                    configuration.setQuota(quota);
                }
            }
        }
    }
    addToRunContext("configuration", configuration);
    fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) Quota(org.olat.core.util.vfs.Quota)

Example 80 with MultipleSelectionElement

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

the class GuiDemoFlexiTablesController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    Object obj = tableDataModel.getValueAt(0, 2);
    if (obj instanceof MultipleSelectionElement) {
        MultipleSelectionElement selection = (MultipleSelectionElement) obj;
        System.out.println(selection.getSelectedKeys());
    }
    fireEvent(ureq, Event.DONE_EVENT);
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)

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