Search in sources :

Example 6 with SelectItem

use of com.agiletec.aps.util.SelectItem in project entando-core by entando.

the class PageTreeMenuAction method addGroup.

private void addGroup(String code, Map<String, List<SelectItem>> mapping, List<List<SelectItem>> group) {
    List<SelectItem> singleGroup = mapping.get(code);
    if (null != singleGroup) {
        BeanComparator comparator = new BeanComparator("value");
        Collections.sort(singleGroup, comparator);
        group.add(singleGroup);
    }
}
Also used : SelectItem(com.agiletec.aps.util.SelectItem) BeanComparator(org.apache.commons.beanutils.BeanComparator)

Example 7 with SelectItem

use of com.agiletec.aps.util.SelectItem in project entando-core by entando.

the class PageTreeMenuAction method getWidgetFlavoursMapping.

protected Map<String, List<SelectItem>> getWidgetFlavoursMapping(List<String> pluginCodes) {
    Map<String, List<SelectItem>> mapping = new HashMap<String, List<SelectItem>>();
    List<WidgetType> types = this.getWidgetTypeManager().getWidgetTypes();
    for (int i = 0; i < types.size(); i++) {
        WidgetType type = types.get(i);
        String pluginCode = type.getPluginCode();
        if (null != pluginCode && pluginCode.trim().length() > 0) {
            // is a plugin's widgets
            if (!pluginCodes.contains(pluginCode)) {
                pluginCodes.add(pluginCode);
            }
            this.addFlavourWidgetType(pluginCode, type, mapping);
        } else if (type.isUserType()) {
            // is a user widgets
            this.addFlavourWidgetType(USER_WIDGETS_CODE, type, mapping);
        } else if (this.getStockWidgetCodes().contains(type.getCode())) {
            this.addFlavourWidgetType(STOCK_WIDGETS_CODE, type, mapping);
        } else {
            this.addFlavourWidgetType(CUSTOM_WIDGETS_CODE, type, mapping);
        }
    }
    Collections.sort(pluginCodes);
    return mapping;
}
Also used : HashMap(java.util.HashMap) SelectItem(com.agiletec.aps.util.SelectItem) ArrayList(java.util.ArrayList) List(java.util.List) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 8 with SelectItem

use of com.agiletec.aps.util.SelectItem in project entando-core by entando.

the class PageTreeMenuAction method addFlavourWidgetType.

protected void addFlavourWidgetType(String mapCode, WidgetType type, Map<String, List<SelectItem>> mapping) {
    List<SelectItem> widgetTypes = mapping.get(mapCode);
    if (null == widgetTypes) {
        widgetTypes = new ArrayList<SelectItem>();
        mapping.put(mapCode, widgetTypes);
    }
    String title = super.getTitle(type.getCode(), type.getTitles());
    SelectItem item = new SelectItem(type.getCode(), title, mapCode);
    widgetTypes.add(item);
}
Also used : SelectItem(com.agiletec.aps.util.SelectItem)

Example 9 with SelectItem

use of com.agiletec.aps.util.SelectItem in project entando-core by entando.

the class AbstractPortalAction method getWidgetFlavoursMapping.

protected Map<String, List<SelectItem>> getWidgetFlavoursMapping(List<String> pluginCodes) {
    Map<String, List<SelectItem>> mapping = new HashMap<String, List<SelectItem>>();
    List<WidgetType> types = this.getWidgetTypeManager().getWidgetTypes();
    for (int i = 0; i < types.size(); i++) {
        WidgetType type = types.get(i);
        String pluginCode = type.getPluginCode();
        if (null != pluginCode && pluginCode.trim().length() > 0) {
            // is a plugin's widgets
            if (!pluginCodes.contains(pluginCode)) {
                pluginCodes.add(pluginCode);
            }
            this.addFlavourWidgetType(pluginCode, type, mapping);
        } else if (type.isUserType()) {
            // is a user widgets
            this.addFlavourWidgetType(USER_WIDGETS_CODE, type, mapping);
        } else // is a core widgets
        {
            if (this.getStockWidgetCodes().contains(type.getCode())) {
                this.addFlavourWidgetType(STOCK_WIDGETS_CODE, type, mapping);
            } else {
                this.addFlavourWidgetType(CUSTOM_WIDGETS_CODE, type, mapping);
            }
        }
    }
    Collections.sort(pluginCodes);
    return mapping;
}
Also used : HashMap(java.util.HashMap) SelectItem(com.agiletec.aps.util.SelectItem) ArrayList(java.util.ArrayList) List(java.util.List) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 10 with SelectItem

use of com.agiletec.aps.util.SelectItem in project entando-core by entando.

the class EnumeratorMapAttribute method extractStaticItems.

private SelectItem[] extractStaticItems() {
    List<SelectItem> items = new ArrayList<SelectItem>();
    if (!StringUtils.isEmpty(this.getStaticItems())) {
        String[] entries = this.getStaticItems().split(this.getCustomSeparator());
        for (String entry : entries) {
            if (!StringUtils.isEmpty(entry) && entry.contains(DEFAULT_KEY_VALUE_SEPARATOR)) {
                String[] keyValue = entry.split(DEFAULT_KEY_VALUE_SEPARATOR);
                if (keyValue.length == 2) {
                    items.add(new SelectItem(keyValue[0].trim(), keyValue[1].trim()));
                }
            }
        }
    }
    BeanComparator c = new BeanComparator("value");
    Collections.sort(items, c);
    SelectItem[] array = new SelectItem[items.size()];
    for (int i = 0; i < items.size(); i++) {
        array[i] = items.get(i);
    }
    return array;
}
Also used : SelectItem(com.agiletec.aps.util.SelectItem) ArrayList(java.util.ArrayList) BeanComparator(org.apache.commons.beanutils.BeanComparator)

Aggregations

SelectItem (com.agiletec.aps.util.SelectItem)22 ArrayList (java.util.ArrayList)15 BeanComparator (org.apache.commons.beanutils.BeanComparator)6 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)4 List (java.util.List)4 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)3 HashMap (java.util.HashMap)3 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)2 Category (com.agiletec.aps.system.services.category.Category)2 Lang (com.agiletec.aps.system.services.lang.Lang)2 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)2 RequestContext (com.agiletec.aps.system.RequestContext)1 ICategoryManager (com.agiletec.aps.system.services.category.ICategoryManager)1 IPage (com.agiletec.aps.system.services.page.IPage)1 Permission (com.agiletec.aps.system.services.role.Permission)1 ContentUtilizer (com.agiletec.plugins.jacms.aps.system.services.content.ContentUtilizer)1 ServletRequest (javax.servlet.ServletRequest)1 JspException (javax.servlet.jsp.JspException)1 RootFolderAttributeView (org.entando.entando.aps.system.services.storage.RootFolderAttributeView)1 Shortcut (org.entando.entando.apsadmin.system.services.shortcut.model.Shortcut)1