Search in sources :

Example 16 with SelectItem

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

the class ApiResourceAction method getMethodAuthorityOptions.

public List<SelectItem> getMethodAuthorityOptions() {
    List<SelectItem> masterList = super.getPermissionAutorityOptions();
    List<SelectItem> items = new ArrayList<SelectItem>();
    items.add(new SelectItem("", this.getText("label.none")));
    items.add(new SelectItem("0", this.getText("label.api.authority.autenticationRequired")));
    items.addAll(masterList);
    return items;
}
Also used : SelectItem(com.agiletec.aps.util.SelectItem) ArrayList(java.util.ArrayList)

Example 17 with SelectItem

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

the class ShortcutListTag method getAllowedShortcutSelectItems.

public List<SelectItem> getAllowedShortcutSelectItems(List<Shortcut> myShortcuts, UserDetails currentUser) {
    List<SelectItem> items = new ArrayList<SelectItem>();
    if (null == myShortcuts || myShortcuts.isEmpty()) {
        _logger.debug("shortcut list null");
        return items;
    }
    try {
        Map<String, List<SelectItem>> groups = new HashMap<String, List<SelectItem>>();
        for (int i = 0; i < myShortcuts.size(); i++) {
            Shortcut shortcut = myShortcuts.get(i);
            String groupCode = shortcut.getSource();
            String optgroup = shortcut.getSource();
            if (groupCode.equals("core")) {
                groupCode += " - " + shortcut.getMenuSection().getId();
                String sectDescrKey = shortcut.getMenuSection().getDescriptionKey();
                String sectDescr = this.getText(sectDescrKey);
                if (null == sectDescrKey || sectDescrKey.equals(sectDescr)) {
                    sectDescr = shortcut.getMenuSection().getDescription();
                }
                optgroup += " - " + sectDescr;
            } else {
                String labelCode = optgroup + ".name";
                String optgroupDescr = this.getText(labelCode);
                if (!optgroupDescr.equals(labelCode)) {
                    optgroup = optgroupDescr;
                }
            }
            String descrKey = shortcut.getDescriptionKey();
            String descr = this.getText(descrKey);
            if (null == descrKey || descrKey.equals(descr)) {
                descr = shortcut.getDescription();
            }
            List<SelectItem> itemsByGroup = groups.get(groupCode);
            if (null == itemsByGroup) {
                itemsByGroup = new ArrayList<SelectItem>();
                groups.put(groupCode, itemsByGroup);
            }
            SelectItem selectItem = new SelectItem(shortcut.getId(), descr, optgroup);
            itemsByGroup.add(selectItem);
        }
        List<String> keys = new ArrayList<String>(groups.keySet());
        Collections.sort(keys);
        for (int i = 0; i < keys.size(); i++) {
            List<SelectItem> itemsByGroup = groups.get(keys.get(i));
            BeanComparator comparator = new BeanComparator("value");
            Collections.sort(itemsByGroup, comparator);
            items.addAll(itemsByGroup);
        }
    } catch (Throwable t) {
        _logger.error("Error extracting allowed shortcut items by user {}", currentUser.getUsername(), t);
        throw new RuntimeException("Error extracting allowed shortcut items by user " + currentUser.getUsername(), t);
    }
    return items;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BeanComparator(org.apache.commons.beanutils.BeanComparator) SelectItem(com.agiletec.aps.util.SelectItem) Shortcut(org.entando.entando.apsadmin.system.services.shortcut.model.Shortcut) ArrayList(java.util.ArrayList) List(java.util.List)

Example 18 with SelectItem

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

the class FileBrowserAction method getBreadCrumbsTargets.

public List<SelectItem> getBreadCrumbsTargets() {
    if (null == this.getProtectedFolder()) {
        return null;
    }
    List<SelectItem> items = new ArrayList<>();
    RootFolderAttributeView rootFolder = this.getRootFolder(this.getProtectedFolderBoolean());
    items.add(new SelectItem(null, rootFolder.getName()));
    String currentPath = this.getCurrentPath();
    if (StringUtils.isEmpty(currentPath)) {
        return items;
    }
    String[] folders = currentPath.split("/");
    for (int i = 0; i < folders.length; i++) {
        String folderName = folders[i];
        String subpath = null;
        if (i == 0) {
            subpath = folderName + "/";
        } else if (i == (folders.length - 1)) {
            subpath = currentPath;
        } else {
            int index = currentPath.indexOf(folderName) + folderName.length();
            subpath = currentPath.substring(0, index) + "/";
        }
        items.add(new SelectItem(subpath, folderName));
    }
    return items;
}
Also used : SelectItem(com.agiletec.aps.util.SelectItem) ArrayList(java.util.ArrayList) RootFolderAttributeView(org.entando.entando.aps.system.services.storage.RootFolderAttributeView)

Example 19 with SelectItem

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

the class TestWidgetsViewerAction method testGetWidgetFlavours.

public void testGetWidgetFlavours() throws Throwable {
    String result = this.executeViewWidgets("admin");
    assertEquals(Action.SUCCESS, result);
    AbstractPortalAction action = (AbstractPortalAction) this.getAction();
    List<List<SelectItem>> widgetFlavours = action.getWidgetFlavours();
    assertNotNull(widgetFlavours);
    assertTrue(widgetFlavours.size() >= 3);
    Lang currentLang = action.getCurrentLang();
    List<SelectItem> userWidgets = widgetFlavours.get(0);
    assertEquals(1, userWidgets.size());
    SelectItem userType = userWidgets.get(0);
    assertEquals(AbstractPortalAction.USER_WIDGETS_CODE, userType.getOptgroup());
    if (currentLang.getCode().equals("it")) {
        assertEquals("logic_type", userType.getKey());
        assertEquals("Tipo logico per test", userType.getValue());
    } else {
        assertEquals("logic_type", userType.getKey());
        assertEquals("Logic type for test", userType.getValue());
    }
    List<SelectItem> customWidgets = widgetFlavours.get(1);
    assertEquals(1, customWidgets.size());
    SelectItem customType = customWidgets.get(0);
    assertEquals(AbstractPortalAction.CUSTOM_WIDGETS_CODE, customType.getOptgroup());
    if (currentLang.getCode().equals("it")) {
        assertEquals("leftmenu", customType.getKey());
        assertEquals("Menu di navigazione verticale", customType.getValue());
    } else {
        assertEquals("leftmenu", customType.getKey());
        assertEquals("Vertical Navigation Menu", customType.getValue());
    }
    List<SelectItem> stockWidgets = widgetFlavours.get(widgetFlavours.size() - 1);
    assertEquals(4, stockWidgets.size());
    SelectItem stockType = stockWidgets.get(3);
    assertEquals(AbstractPortalAction.STOCK_WIDGETS_CODE, stockType.getOptgroup());
    if (currentLang.getCode().equals("it")) {
        assertEquals("login_form", stockType.getKey());
        assertEquals("Widget di Login", stockType.getValue());
    } else {
        assertEquals("messages_system", stockType.getKey());
        assertEquals("System Messages", stockType.getValue());
    }
}
Also used : SelectItem(com.agiletec.aps.util.SelectItem) List(java.util.List) Lang(com.agiletec.aps.system.services.lang.Lang)

Example 20 with SelectItem

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

the class CategoriesTag method addSmallCategory.

private void addSmallCategory(List<SelectItem> categories, Category category, String langCode, String titleStyle, ICategoryManager catManager) {
    String[] children = category.getChildrenCodes();
    if (null == children) {
        return;
    }
    for (int i = 0; i < children.length; i++) {
        Category child = catManager.getCategory(children[i]);
        String title = null;
        if (null == titleStyle || titleStyle.equals(TITLE_TYPE_DEFAULT)) {
            title = child.getTitles().getProperty(langCode);
        } else if (titleStyle.equals(TITLE_TYPE_FULL)) {
            if (null != this.getFullTitleSeparator()) {
                title = child.getFullTitle(langCode, this.getFullTitleSeparator(), catManager);
            } else {
                title = child.getFullTitle(langCode, catManager);
            }
        } else if (titleStyle.equals(TITLE_TYPE_PRETTY_FULL)) {
            if (null != this.getFullTitleSeparator()) {
                title = child.getShortFullTitle(langCode, this.getFullTitleSeparator(), catManager);
            } else {
                title = child.getShortFullTitle(langCode, catManager);
            }
        }
        SelectItem catSmall = new SelectItem(child.getCode(), title);
        categories.add(catSmall);
        this.addSmallCategory(categories, child, langCode, titleStyle, catManager);
    }
}
Also used : Category(com.agiletec.aps.system.services.category.Category) SelectItem(com.agiletec.aps.util.SelectItem)

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