com.vaadin.client.ui.VMenuBar Java Examples
The following examples show how to use
com.vaadin.client.ui.VMenuBar.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContextMenuConnector.java From consulo with Apache License 2.0 | 6 votes |
private void addMenuItemsFromState(VMenuBar menuToAddTo, List<MenuItemState> menuItems) { if (menuItems == null) return; for (MenuItemState menuItemState : menuItems) { CustomMenuItem newItem = addMenuItemToMenu(menuToAddTo, menuItemState); if (menuItemState.childItems != null && menuItemState.childItems.size() > 0) { VMenuBar subMenu = new MyVMenuBar(true, menuToAddTo); addMenuItemsFromState(subMenu, menuItemState.childItems); newItem.setSubMenu(subMenu); } } }
Example #2
Source File: ContextMenuConnector.java From consulo with Apache License 2.0 | 6 votes |
private CustomMenuItem addMenuItemToMenu(VMenuBar menuToAddTo, final MenuItemState menuItemState) { String itemText = buildItemHTML(menuItemState, getState().htmlContentAllowed, getConnection()); CustomMenuItem item = menuToAddTo.addItem(itemText, new Command() { @Override public void execute() { if (contextMenuWidget.isAttached()) { dummyRootMenuBar.hideChildren(); itemSelected(menuItemState.id); } } }); updateMenuItemFromState(item, menuItemState); return item; }
Example #3
Source File: CubaMenuBarConnector.java From cuba with Apache License 2.0 | 5 votes |
@Override protected void assignAdditionalMenuStyles(VMenuBar currentMenu, UIDL item) { String icon = item.getStringAttribute("icon"); if (icon != null) { currentMenu.addStyleDependentName("has-icons"); } }
Example #4
Source File: ContextMenuConnector.java From cuba with Apache License 2.0 | 5 votes |
private void updateItemFromState(VMenuBar.CustomMenuItem currentItem, ContextMenuItemState menuItemState) { currentItem.setSeparator(menuItemState.separator); currentItem.setEnabled(menuItemState.enabled); if (!menuItemState.separator && menuItemState.checked) { // if the selected attribute is present (either true or false), // the item is selectable currentItem.setCheckable(true); currentItem.setChecked(menuItemState.checked); } else { currentItem.setCheckable(false); } currentItem.setStyleName(menuItemState.styleName); currentItem.setDescription(menuItemState.description); currentItem.setDescriptionContentMode( menuItemState.descriptionContentMode); if (menuItemState.description != null) { currentItem.getElement().setAttribute("title", menuItemState.description); } currentItem.updateStyleNames(); }
Example #5
Source File: VContextMenu.java From cuba with Apache License 2.0 | 5 votes |
@Override protected VOverlay createOverlay() { VOverlay overlay = super.createOverlay(); for (VMenuBar current = this; current != null; current = current .getParentMenu()) { if (current.client != null) { overlay.setApplicationConnection(current.client); break; } } return overlay; }
Example #6
Source File: VContextMenu.java From cuba with Apache License 2.0 | 5 votes |
@Override protected VMenuBar getRoot() { VMenuBar root = this; while (root.getParentMenu() != null && root.getParentMenu().getParentMenu() != null) { root = root.getParentMenu(); } return root; }
Example #7
Source File: ContextMenuConnector.java From context-menu with Apache License 2.0 | 5 votes |
private void updateItemFromState(VMenuBar.CustomMenuItem currentItem, ContextMenuItemState menuItemState) { currentItem.setSeparator(menuItemState.separator); currentItem.setEnabled(menuItemState.enabled); if (!menuItemState.separator && menuItemState.checked) { // if the selected attribute is present (either true or false), // the item is selectable currentItem.setCheckable(true); currentItem.setChecked(menuItemState.checked); } else { currentItem.setCheckable(false); } currentItem.setStyleName(menuItemState.styleName); currentItem.setDescription(menuItemState.description); currentItem.setDescriptionContentMode( menuItemState.descriptionContentMode); if (menuItemState.description != null) { currentItem.getElement().setAttribute("title", menuItemState.description); } currentItem.updateStyleNames(); }
Example #8
Source File: VContextMenu.java From context-menu with Apache License 2.0 | 5 votes |
@Override protected VOverlay createOverlay() { VOverlay overlay = super.createOverlay(); for (VMenuBar current = this; current != null; current = current .getParentMenu()) { if (current.client != null) { overlay.setApplicationConnection(current.client); break; } } return overlay; }
Example #9
Source File: VContextMenu.java From context-menu with Apache License 2.0 | 5 votes |
@Override protected VMenuBar getRoot() { VMenuBar root = this; while (root.getParentMenu() != null && root.getParentMenu().getParentMenu() != null) { root = root.getParentMenu(); } return root; }
Example #10
Source File: CubaMenuBarConnector.java From cuba with Apache License 2.0 | 4 votes |
@Override protected void assignAdditionalAttributes(VMenuBar.CustomMenuItem currentItem, UIDL item) { if (item.hasAttribute("cid")) { currentItem.getElement().setAttribute("cuba-id", item.getStringAttribute("cid")); } }
Example #11
Source File: ContextMenuConnector.java From cuba with Apache License 2.0 | 4 votes |
protected void updateFromState(ContextMenuState state) { contextMenu.enabled = state.enabled; contextMenu.htmlContentAllowed = state.htmlContentAllowed; Stack<Iterator<ContextMenuItemState>> iteratorStack = new Stack<>(); Stack<VMenuBar> menuStack = new Stack<>(); VMenuBar currentMenu = contextMenuRoot.getSubMenu(); currentMenu.clearItems(); if (state.menuItems != null && !state.menuItems.isEmpty()) { Iterator<ContextMenuItemState> itr = state.menuItems.iterator(); while (itr.hasNext()) { ContextMenuItemState menuItemState = itr.next(); VMenuBar.CustomMenuItem currentItem; boolean itemHasCommand = menuItemState.command; boolean itemIsCheckable = menuItemState.checkable; String iconUrl = menuItemState.icon == null ? null : menuItemState.icon.getURL(); boolean subMenu = menuItemState.childItems != null && !menuItemState.childItems.isEmpty(); String itemHTML = contextMenu.buildItemHTML( menuItemState.separator, subMenu, iconUrl, menuItemState.text); Command cmd = null; if (!menuItemState.separator) { if (itemHasCommand || itemIsCheckable) { // Construct a command that fires onMenuClick(int) with // the // item's id-number cmd = () -> contextMenu.onMenuClick(menuItemState.id); } } currentItem = currentMenu.addItem(itemHTML, cmd); currentItem.setId("" + menuItemState.id); updateItemFromState(currentItem, menuItemState); if (subMenu) { menuStack.push(currentMenu); iteratorStack.push(itr); itr = menuItemState.childItems.iterator(); currentMenu = new VContextMenu(true, currentMenu); getConnection().getVTooltip() .connectHandlersToWidget(currentMenu); // this is the top-level style that also propagates to items // - // any item specific styles are set above in // currentItem.updateFromUIDL(item, client) if (ComponentStateUtil.hasStyles(getState())) { for (String style : getState().styles) { currentMenu.addStyleDependentName(style); } } currentItem.setSubMenu(currentMenu); } while (!itr.hasNext() && !iteratorStack.empty()) { boolean hasCheckableItem = false; for (VMenuBar.CustomMenuItem menuItem : currentMenu .getItems()) { hasCheckableItem = hasCheckableItem || menuItem.isCheckable(); } if (hasCheckableItem) { currentMenu.addStyleDependentName("check-column"); } else { currentMenu.removeStyleDependentName("check-column"); } itr = iteratorStack.pop(); currentMenu = menuStack.pop(); } } } }
Example #12
Source File: VContextMenu.java From cuba with Apache License 2.0 | 4 votes |
public VContextMenu(boolean subMenu, VMenuBar parentMenu) { super(subMenu, parentMenu); }
Example #13
Source File: ContextMenuConnector.java From context-menu with Apache License 2.0 | 4 votes |
protected void updateFromState(ContextMenuState state) { contextMenu.enabled = state.enabled; contextMenu.htmlContentAllowed = state.htmlContentAllowed; Stack<Iterator<ContextMenuItemState>> iteratorStack = new Stack<>(); Stack<VMenuBar> menuStack = new Stack<>(); VMenuBar currentMenu = contextMenuRoot.getSubMenu(); currentMenu.clearItems(); if (state.menuItems != null && !state.menuItems.isEmpty()) { Iterator<ContextMenuItemState> itr = state.menuItems.iterator(); while (itr.hasNext()) { ContextMenuItemState menuItemState = itr.next(); VMenuBar.CustomMenuItem currentItem; boolean itemHasCommand = menuItemState.command; boolean itemIsCheckable = menuItemState.checkable; String iconUrl = menuItemState.icon == null ? null : menuItemState.icon.getURL(); boolean subMenu = menuItemState.childItems != null && !menuItemState.childItems.isEmpty(); String itemHTML = contextMenu.buildItemHTML( menuItemState.separator, subMenu, iconUrl, menuItemState.text); Command cmd = null; if (!menuItemState.separator) { if (itemHasCommand || itemIsCheckable) { // Construct a command that fires onMenuClick(int) with // the // item's id-number cmd = () -> contextMenu.onMenuClick(menuItemState.id); } } currentItem = currentMenu.addItem(itemHTML, cmd); currentItem.setId("" + menuItemState.id); updateItemFromState(currentItem, menuItemState); if (subMenu) { menuStack.push(currentMenu); iteratorStack.push(itr); itr = menuItemState.childItems.iterator(); currentMenu = new VContextMenu(true, currentMenu); getConnection().getVTooltip() .connectHandlersToWidget(currentMenu); // this is the top-level style that also propagates to items // - // any item specific styles are set above in // currentItem.updateFromUIDL(item, client) if (ComponentStateUtil.hasStyles(getState())) { for (String style : getState().styles) { currentMenu.addStyleDependentName(style); } } currentItem.setSubMenu(currentMenu); } while (!itr.hasNext() && !iteratorStack.empty()) { boolean hasCheckableItem = false; for (VMenuBar.CustomMenuItem menuItem : currentMenu .getItems()) { hasCheckableItem = hasCheckableItem || menuItem.isCheckable(); } if (hasCheckableItem) { currentMenu.addStyleDependentName("check-column"); } else { currentMenu.removeStyleDependentName("check-column"); } itr = iteratorStack.pop(); currentMenu = menuStack.pop(); } } } }
Example #14
Source File: VContextMenu.java From context-menu with Apache License 2.0 | 4 votes |
public VContextMenu(boolean subMenu, VMenuBar parentMenu) { super(subMenu, parentMenu); }
Example #15
Source File: MyVMenuBar.java From consulo with Apache License 2.0 | 4 votes |
public MyVMenuBar(boolean subMenu, VMenuBar parentMenu) { super(subMenu, parentMenu); }