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;
}
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;
}
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;
}
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());
}
}
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);
}
}
Aggregations