/** * Localized menu item caption. * * @param id screen ID as defined in <code>screens.xml</code> * @deprecated Use {@link MenuConfig#getItemCaption(String)} */ @Deprecated public static String getMenuItemCaption(String id) { MenuConfig menuConfig = AppBeans.get(MenuConfig.NAME); return menuConfig.getItemCaption(id); }
private void walkMenu(Node<BasicPermissionTarget> node) { for (MenuItem info : menuConfig.getRootItems()) { walkMenu(info, node); } }
checkDuplicateAction(idFromActions, runnableClass); idFromActions = StringUtils.isNotEmpty(runnableClass) ? runnableClass : idFromActions; checkDuplicateAction(idFromActions, bean, beanMethod); loadIcon(element, menuItem); loadShortcut(menuItem, element); loadStylename(element, menuItem); loadDescription(element, menuItem);
nextToItem = findItem(nextTo, rootItem); if (nextToItem != null) { if (nextToItem.getParent() != null) menuItem.setMenu(true); menuItem.setDescriptor(element); loadIcon(element, menuItem); loadShortcut(menuItem, element); loadStylename(element, menuItem); loadExpanded(element, menuItem); loadDescription(element, menuItem); loadMenuItems(element, menuItem); } else if ("item".equals(element.getName())) { menuItem = createMenuItem(element, currentParentItem); addItem(currentParentItem.getChildren(), menuItem, nextToItem, before); } else { addItem(rootItems, menuItem, nextToItem, before);
protected void initDefaultScreenField() { boolean screenSelectionEnabled = webConfig.getUserCanChooseDefaultScreen(); if (!screenSelectionEnabled) { defaultScreenField.setEditable(false); defaultScreenField.setDescription(getMessage("defaultScreenSelectionDisabled")); } Map<String, String> map = new LinkedHashMap<>(); for (MenuItem item : collectPermittedScreens(menuConfig.getRootItems())) { map.put(menuConfig.getItemCaption(item.getId()), item.getScreen()); } defaultScreenField.setOptionsMap(map); String defaultScreen = userSettingService.loadSetting(ClientType.WEB, "userDefaultScreen"); if (StringUtils.isEmpty(defaultScreen) || !screenSelectionEnabled) { defaultScreen = webConfig.getDefaultScreenId(); } defaultScreenField.setValue(defaultScreen); }
/** * Main menu root items */ public List<MenuItem> getRootItems() { lock.readLock().lock(); try { checkInitialized(); return Collections.unmodifiableList(rootItems); } finally { lock.readLock().unlock(); } }
protected void checkInitialized() { if (!initialized) { lock.readLock().unlock(); lock.writeLock().lock(); try { if (!initialized) { init(); initialized = true; } } finally { lock.readLock().lock(); lock.writeLock().unlock(); } } }
protected void loadIcon(Element element, MenuItem menuItem) { String icon = element.attributeValue("icon"); if (StringUtils.isNotEmpty(icon)) { menuItem.setIcon(getIconPath(icon)); } }
protected MenuItem findItem(String id, MenuItem item) { if (id.equals(item.getId())) return item; else if (!item.getChildren().isEmpty()) { for (MenuItem child : item.getChildren()) { MenuItem menuItem = findItem(id, child); if (menuItem != null) return menuItem; } } return null; }
String caption = menuConfig.getItemCaption(screen);
public void build(SideMenu menu) { build(menu, menuConfig.getRootItems()); }
private void walkMenu(MenuItem info, Node<BasicPermissionTarget> node) { String id = info.getId(); String caption = menuConfig.getItemCaption(id) .replaceAll("<.+?>", "") .replaceAll(">", ""); caption = StringEscapeUtils.unescapeHtml4(caption); if (info.getChildren() != null && !info.getChildren().isEmpty()) { Node<BasicPermissionTarget> n = new Node<>(new BasicPermissionTarget("category:" + id, caption, id)); node.addChild(n); for (MenuItem item : info.getChildren()) { walkMenu(item, n); } } else { if (!info.isSeparator()) { Node<BasicPermissionTarget> n = new Node<>(new BasicPermissionTarget("item:" + id, caption, id)); node.addChild(n); } } }
public void build(AppMenu appMenu) { build(appMenu, menuConfig.getRootItems()); }
protected void createMenuBarItem(Window webWindow, MenuItem item) { if (item.isPermitted(session)) { AppMenu.MenuItem menuItem = appMenu.createMenuItem(item.getId(), menuConfig.getItemCaption(item.getId()), null, createMenuBarCommand(item)); assignShortcut(webWindow, menuItem, item); assignStyleName(menuItem, item); assignIcon(menuItem, item); assignDescription(menuItem, item); createSubMenu(webWindow, menuItem, item, session); if (!isMenuItemEmpty(menuItem)) { appMenu.addMenuItem(menuItem); } } }
protected void createMenuBarItem(Window webWindow, SideMenu menu, MenuItem item) { if (item.isPermitted(session)) { SideMenu.MenuItem menuItem = menu.createMenuItem(item.getId(), menuConfig.getItemCaption(item.getId()), null, createMenuBarCommand(item)); createSubMenu(webWindow, menu, menuItem, item, session); assignStyleName(menuItem, item); assignIcon(menuItem, item); assignDescription(menuItem, item); assignExpanded(menuItem, item); assignShortcut(webWindow, menuItem, item); if (!isMenuItemEmpty(menuItem)) { menu.addMenuItem(menuItem); } } }
menuConfig.getItemCaption(child.getId()), null, createMenuBarCommand(child)); if (child.isPermitted(session)) { AppMenu.MenuItem menuItem = appMenu.createMenuItem(child.getId(), menuConfig.getItemCaption(child.getId()), null, null);
protected void createSubMenu(Window webWindow, SideMenu menu, SideMenu.MenuItem vItem, MenuItem parentItem, UserSession session) { if (parentItem.isPermitted(session)) { for (MenuItem child : parentItem.getChildren()) { if (child.isSeparator()) { continue; } if (child.isPermitted(session)) { SideMenu.MenuItem menuItem = menu.createMenuItem(child.getId(), menuConfig.getItemCaption(child.getId())); assignDescription(menuItem, child); assignIcon(menuItem, child); assignStyleName(menuItem, child); if (child.getChildren().isEmpty()) { menuItem.setCommand(createMenuBarCommand(child)); assignShortcut(webWindow, menuItem, child); vItem.addChildItem(menuItem); } else { createSubMenu(webWindow, menu, menuItem, child, session); assignExpanded(menuItem, child); if (!isMenuItemEmpty(menuItem)) { vItem.addChildItem(menuItem); } } } } } }