Search in sources :

Example 21 with MultipleSelectionElement

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

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 22 with MultipleSelectionElement

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

the class HomePageSettingsController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source instanceof MultipleSelectionElement) {
        MultipleSelectionElement publishCheckbox = (MultipleSelectionElement) source;
        if (publishCheckbox.isEnabled()) {
            boolean enabled = publishCheckbox.isAtLeastSelected(1);
            String propName = (String) publishCheckbox.getUserObject();
            // load and update config
            HomePageConfig conf = hpcm.loadConfigFor(identityToModify.getName());
            conf.setEnabled(propName, enabled);
            hpcm.saveConfigTo(identityToModify.getName(), conf);
            updatePreview(ureq, conf);
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)

Example 23 with MultipleSelectionElement

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

the class BGConfigToolsStepController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    boolean first = true;
    String containerPage = velocity_root + "/tool_config_container.html";
    String[] availableTools = CollaborationToolsFactory.getInstance().getAvailableTools().clone();
    for (String k : availableTools) {
        if (k.equals(CollaborationTools.TOOL_CHAT) || k.equals(CollaborationTools.TOOL_NEWS)) {
            continue;
        }
        String[] keys = new String[] { "on" };
        String[] values = new String[] { translate("collabtools.named." + k) };
        String i18n = first ? "config.tools.desc" : null;
        MultipleSelectionElement selectEl = uifactory.addCheckboxesHorizontal(k, i18n, formLayout, keys, values);
        selectEl.addActionListener(FormEvent.ONCHANGE);
        toolList.add(selectEl);
        ToolConfig config = new ToolConfig(k);
        config.configContainer = FormLayoutContainer.createCustomFormLayout("config.container." + k, getTranslator(), containerPage);
        config.configContainer.contextPut("tool", k);
        config.configContainer.setVisible(false);
        config.configContainer.setRootForm(mainForm);
        formLayout.add(config.configContainer);
        config.enableEl = uifactory.addRadiosHorizontal("config.enable." + k, null, config.configContainer, enableKeys, enableValues);
        config.enableEl.addActionListener(FormEvent.ONCHANGE);
        config.enableEl.select("off", true);
        enableList.add(config.enableEl);
        config.enableEl.setUserObject(config);
        if (k.equals(CollaborationTools.TOOL_CALENDAR)) {
            config.calendarCtrl = new CalendarToolSettingsController(ureq, getWindowControl(), mainForm, CollaborationTools.CALENDAR_ACCESS_OWNERS);
            config.configContainer.add("calendar", config.calendarCtrl.getInitialFormItem());
            config.calendarCtrl.getInitialFormItem().setVisible(false);
        } else if (k.equals(CollaborationTools.TOOL_FOLDER)) {
            // add folder access configuration
            config.folderCtrl = new FolderToolSettingsController(ureq, getWindowControl(), mainForm, CollaborationTools.FOLDER_ACCESS_OWNERS);
            config.configContainer.add("folder", config.folderCtrl.getInitialFormItem());
            config.folderCtrl.getInitialFormItem().setVisible(false);
            // add quota configuration for admin only
            if (ureq.getUserSession().getRoles().isOLATAdmin()) {
                Quota quota = quotaManager.createQuota(null, null, null);
                config.quotaCtrl = new BGConfigQuotaController(ureq, getWindowControl(), quota, mainForm);
                config.configContainer.add("quota", config.quotaCtrl.getInitialFormItem());
                config.quotaCtrl.getInitialFormItem().setVisible(false);
            }
        }
        selectEl.setUserObject(config);
        first = false;
    }
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) Quota(org.olat.core.util.vfs.Quota) FolderToolSettingsController(org.olat.collaboration.FolderToolSettingsController) CalendarToolSettingsController(org.olat.collaboration.CalendarToolSettingsController)

Example 24 with MultipleSelectionElement

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

the class TeacherRollCallController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source == tableEl) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            String cmd = se.getCommand();
            TeacherRollCallRow row = tableModel.getObject(se.getIndex());
            if ("all".equals(cmd)) {
                doCheckAllRow(row);
            }
        }
    } else if (source instanceof MultipleSelectionElement) {
        MultipleSelectionElement check = (MultipleSelectionElement) source;
        TeacherRollCallRow row = (TeacherRollCallRow) check.getUserObject();
        if (row.getAuthorizedAbsence() == check) {
            doAuthorizedAbsence(row, check);
            if (check.isAtLeastSelected(1)) {
                doCalloutReasonAbsence(ureq, check.getFormDispatchId() + "_C_0", row);
            }
        } else {
            doCheckRow(row, check);
        }
    } else if (reopenButton == source) {
        doReopen(ureq);
    } else if (closeLectureBlocksButton == source) {
        if (validateFormLogic(ureq)) {
            saveLectureBlocks();
            doConfirmCloseLectureBlock(ureq);
        }
    } else if (cancelLectureBlockButton == source) {
        saveLectureBlocks();
        doConfirmCancelLectureBlock(ureq);
    } else if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        String cmd = link.getCmd();
        if (cmd != null && cmd.startsWith("abs_reason_")) {
            TeacherRollCallRow row = (TeacherRollCallRow) link.getUserObject();
            doCalloutReasonAbsence(ureq, link.getFormDispatchId(), row);
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 25 with MultipleSelectionElement

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

the class EPArtefactTypeSelectionController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormDescription("filter.type.intro");
    String[] keys = new String[] { "onoff" };
    String[] values = new String[] { translate("filter.type.enabled") };
    List<EPArtefactHandler<?>> handlers = portfolioModule.getAllAvailableArtefactHandlers();
    typeCmpList = new ArrayList<MultipleSelectionElement>();
    for (EPArtefactHandler<?> handler : handlers) {
        Translator handlerTrans = handler.getHandlerTranslator(getTranslator());
        this.flc.setTranslator(handlerTrans);
        String handlerClass = PortfolioFilterController.HANDLER_PREFIX + handler.getClass().getSimpleName() + PortfolioFilterController.HANDLER_TITLE_SUFFIX;
        MultipleSelectionElement chkBox = uifactory.addCheckboxesHorizontal(handlerClass, formLayout, keys, values);
        if (selectedTypeList != null && selectedTypeList.contains(handler.getType())) {
            chkBox.select(keys[0], true);
        }
        chkBox.addActionListener(FormEvent.ONCHANGE);
        chkBox.setUserObject(handler.getType());
        typeCmpList.add(chkBox);
    }
    uifactory.addFormSubmitButton("filter.type.submit", formLayout);
}
Also used : EPArtefactHandler(org.olat.portfolio.EPArtefactHandler) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) Translator(org.olat.core.gui.translator.Translator)

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