Resource icon = item.getIcon(); if (icon != null) { target.addAttribute(MenuBarConstants.ATTRIBUTE_ITEM_ICON, icon);
menuItemState.enabled = item.isEnabled(); menuItemState.separator = item.isSeparator(); menuItemState.icon = ResourceReference.create(item.getIcon(), this, ""); menuItemState.styleName = item.getStyleName();
private void addItems(ItemAddBehaviour<com.vaadin.contextmenu.MenuItem> behaviour, MenuBar.MenuItem child) { com.vaadin.contextmenu.MenuItem contextMenuItem = behaviour.addItem(); contextMenuItem.setEnabled(child.isEnabled()); if (child.isSeparator()) { contextMenuItem.addSeparator(); } if (child.getCommand() != null) { contextMenuItem.setCommand((Command) contextMenuItemClickEvent -> child.getCommand().menuSelected(child)); } if (child.hasChildren()) { for (MenuBar.MenuItem eachChild : child.getChildren()) { addItems(() -> contextMenuItem.addItem( eachChild.getText(), eachChild.getIcon(), (Command) selectedItem -> { if (eachChild.getCommand() != null) { eachChild.getCommand().menuSelected(eachChild); } }), eachChild); } } }
private void addItems(ItemAddBehaviour<ContextMenuItem> behaviour, MenuBar.MenuItem child) { ContextMenuItem contextMenuItem = behaviour.addItem(); contextMenuItem.setEnabled(child.isEnabled()); contextMenuItem.setSeparatorVisible(child.isSeparator()); if (child.getCommand() != null) { contextMenuItem.addItemClickListener(contextMenuItemClickEvent -> child.getCommand().menuSelected(child)); } if (child.hasChildren()) { for (MenuBar.MenuItem eachChild : child.getChildren()) { addItems(() -> contextMenuItem.addItem(eachChild.getText(), eachChild.getIcon()), eachChild); } } }
private void addItems(MenuBar menuBar) { for (MenuBar.MenuItem eachItem : menuBar.getItems()) { addItems(() -> this.addItem( eachItem.getText(), eachItem.getIcon(), (Command) selectedItem -> { if (eachItem.getCommand() != null) { eachItem.getCommand().menuSelected(eachItem); } }), eachItem); } }
private void addItems(MenuBar menuBar) { for (MenuBar.MenuItem eachItem : menuBar.getItems()) { addItems(() -> this.addItem(eachItem.getText(), eachItem.getIcon()), eachItem); } }
/** Paint (serialize) the component for the client. */ @Override public void paintContent(PaintTarget target) throws PaintException { target.addAttribute(MenuBarConstants.OPEN_ROOT_MENU_ON_HOWER, openRootOnHover); if (isHtmlContentAllowed()) { target.addAttribute(MenuBarConstants.HTML_CONTENT_ALLOWED, true); } target.startTag("options"); if (getWidth() > -1) { target.startTag("moreItem"); target.addAttribute("text", moreItem.getText()); if (moreItem.getIcon() != null) { target.addAttribute("icon", moreItem.getIcon()); } target.endTag("moreItem"); } target.endTag("options"); target.startTag("items"); // This generates the tree from the contents of the menu for (MenuItem item : menuItems) { paintItem(target, item); } target.endTag("items"); }