if (found && tmpItem.isEnabled()) { if (tmpItem.isCheckable()) { tmpItem.setChecked(!tmpItem.isChecked());
if (!item.isEnabled()) { target.addAttribute(MenuBarConstants.ATTRIBUTE_ITEM_DISABLED, true);
menuItemState.descriptionContentMode = item .getDescriptionContentMode(); menuItemState.enabled = item.isEnabled(); menuItemState.separator = item.isSeparator(); menuItemState.icon = ResourceReference.create(item.getIcon(), this,
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); } } }