Search in sources :

Example 11 with FormToggle

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

the class PortfolioFilterController method resetTagLinks.

private void resetTagLinks() {
    for (FormToggle link : tagCmpList) {
        link.toggleOff();
        selectedTagsList.clear();
    }
    tagEditBtn.toggleOff();
}
Also used : FormToggle(org.olat.core.gui.components.form.flexible.elements.FormToggle)

Example 12 with FormToggle

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

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 13 with FormToggle

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

the class UsrPropContextEditController method addTableRowComponents.

/**
 * adds tableRow-Components (Toggles and Links) for the given Handler
 *
 * @param handler The handler to create Components for
 * @param moveable if true, additional "up"/"down" Links will be rendered
 */
private void addTableRowComponents(UserPropertyHandler handler, boolean moveable) {
    List<FormItem> rowFormItemComponents = new ArrayList<FormItem>();
    final String handlername = handler.getName();
    final boolean isIncluded = context.contains(handler);
    final boolean isMandatory = context.isMandatoryUserProperty(handler);
    final boolean isAdminOnly = context.isForAdministrativeUserOnly(handler);
    final boolean isUserReadOnly = context.isUserViewReadOnly(handler);
    // put the translation (in the current language) for the property
    String translatedName = I18nManager.getInstance().getLocalizedString(UserPropertyHandler.class.getPackage().getName(), handler.i18nFormElementLabelKey(), null, getLocale(), true, true);
    uifactory.addStaticTextElement(FT_NAME_PREFIX_TRANS + handlername, (translatedName == null ? "-" : translatedName), contTableFlc);
    FormToggle ftMandatory = uifactory.addToggleButton(FT_NAME_PREFIX_MAND + handlername, "&nbsp;&nbsp;&nbsp;&nbsp;", contTableFlc, null, null);
    ftMandatory.setUserObject(handler);
    if (isMandatory)
        ftMandatory.toggleOn();
    else
        ftMandatory.toggleOff();
    if (!isIncluded) {
        ftMandatory.setEnabled(false);
        ftMandatory.setVisible(false);
    }
    FormToggle ftAdminonly = uifactory.addToggleButton(FT_NAME_PREFIX_ADMN + handlername, "&nbsp;&nbsp;&nbsp;&nbsp;", contTableFlc, null, null);
    ftAdminonly.setUserObject(handler);
    if (isAdminOnly)
        ftAdminonly.toggleOn();
    else
        ftAdminonly.toggleOff();
    if (!isIncluded) {
        ftAdminonly.setEnabled(false);
        ftAdminonly.setVisible(false);
    }
    FormToggle ftUserreadonly = uifactory.addToggleButton(FT_NAME_PREFIX_USR + handlername, "&nbsp;&nbsp;&nbsp;&nbsp;", contTableFlc, null, null);
    ftUserreadonly.setUserObject(handler);
    if (isUserReadOnly)
        ftUserreadonly.toggleOn();
    else
        ftUserreadonly.toggleOff();
    if (!isIncluded) {
        ftUserreadonly.setEnabled(false);
        ftUserreadonly.setVisible(false);
    }
    FormToggle ftInclude = uifactory.addToggleButton(FT_NAME_PREFIX_INCL + handlername, "&nbsp;&nbsp;&nbsp;&nbsp;", contTableFlc, null, null);
    ftInclude.setUserObject(handler);
    if (isIncluded) {
        ftInclude.toggleOn();
        includedPropertiesCount++;
    } else
        ftInclude.toggleOff();
    // up/down links
    FormLink fl_up = uifactory.addFormLink(FT_NAME_PREFIX_MUP + handlername, " ", null, contTableFlc, Link.NONTRANSLATED);
    fl_up.setIconLeftCSS("o_icon o_icon_move_up o_icon-lg");
    fl_up.setUserObject(handler);
    FormLink fl_down = uifactory.addFormLink(FT_NAME_PREFIX_MDN + handlername, " ", null, contTableFlc, Link.NONTRANSLATED);
    fl_down.setIconRightCSS("o_icon o_icon_move_down o_icon-lg");
    fl_down.setUserObject(handler);
    if (!moveable) {
        fl_up.setEnabled(false);
        fl_up.setVisible(false);
        fl_down.setEnabled(false);
        fl_down.setVisible(false);
    }
    rowFormItemComponents.add(ftMandatory);
    rowFormItemComponents.add(ftAdminonly);
    rowFormItemComponents.add(ftUserreadonly);
    rowFormItemComponents.add(fl_up);
    rowFormItemComponents.add(fl_down);
    rowToggleButtonsMap.put(handlername, rowFormItemComponents);
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) FormToggle(org.olat.core.gui.components.form.flexible.elements.FormToggle) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 14 with FormToggle

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

the class PortfolioFilterController method initOrUpdateTypeFlc.

/**
 */
private void initOrUpdateTypeFlc(int limit) {
    typeFlc.setLabel("filter.view", null);
    typeAllBtn = uifactory.addToggleButton("filter.all", null, typeFlc, null, null);
    typeAllBtn.toggleOff();
    List<EPArtefactHandler<?>> handlers = portfolioModule.getAllAvailableArtefactHandlers();
    typeCmpList = new ArrayList<FormToggle>();
    int i = 0;
    List<String> allActiveTypeToggles = new ArrayList<String>();
    for (EPArtefactHandler<?> handler : handlers) {
        String handlerClass = PortfolioFilterController.HANDLER_PREFIX + handler.getClass().getSimpleName() + HANDLER_TITLE_SUFFIX;
        FormToggle link = (FormToggle) typeFlc.getFormComponent(handlerClass);
        if (link == null) {
            Translator handlerTrans = handler.getHandlerTranslator(getTranslator());
            typeFlc.setTranslator(handlerTrans);
            link = uifactory.addToggleButton(handlerClass, null, typeFlc, null, null);
            link.setUserObject(handler.getType());
        }
        if (selectedTypeList.contains(handler.getType())) {
            link.toggleOn();
            allActiveTypeToggles.add(handler.getType());
        } else {
            link.toggleOff();
        }
        typeCmpList.add(link);
        i++;
        if (i > limit)
            break;
    }
    typeFlc.contextPut("typeCmpList", typeCmpList);
    typeEditBtn = uifactory.addToggleButton("filter.edit", null, typeFlc, null, null);
    typeEditBtn.toggleOff();
    if (!allActiveTypeToggles.containsAll(selectedTypeList))
        typeEditBtn.toggleOn();
    if (selectedTypeList.isEmpty())
        typeAllBtn.toggleOn();
}
Also used : EPArtefactHandler(org.olat.portfolio.EPArtefactHandler) Translator(org.olat.core.gui.translator.Translator) ArrayList(java.util.ArrayList) FormToggle(org.olat.core.gui.components.form.flexible.elements.FormToggle)

Example 15 with FormToggle

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

the class PortfolioFilterController method resetTypeLinks.

private void resetTypeLinks() {
    for (FormToggle link : typeCmpList) {
        link.toggleOff();
        selectedTypeList.clear();
    }
    typeEditBtn.toggleOff();
}
Also used : FormToggle(org.olat.core.gui.components.form.flexible.elements.FormToggle)

Aggregations

FormToggle (org.olat.core.gui.components.form.flexible.elements.FormToggle)16 ArrayList (java.util.ArrayList)10 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)8 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)6 FormItem (org.olat.core.gui.components.form.flexible.FormItem)4 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)4 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Entry (java.util.Map.Entry)2 CloseableCalloutWindowController (org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 Translator (org.olat.core.gui.translator.Translator)2 SingleKeyTranslatorController (org.olat.core.util.i18n.ui.SingleKeyTranslatorController)2 EPArtefactHandler (org.olat.portfolio.EPArtefactHandler)2