List of usage examples for com.google.gwt.user.client.ui MenuItem getParentMenu
public MenuBar getParentMenu()
From source file:com.vaadin.client.ui.menubar.MenuBar.java
License:Apache License
protected void doItemAction(final MenuItem item, boolean fireCommand) { // If the given item is already showing its menu, we're done. if ((shownChildMenu != null) && (item.getSubMenu() == shownChildMenu)) { return;/*from w w w .j a v a 2 s . c o m*/ } // If another item is showing its menu, then hide it. if (shownChildMenu != null) { shownChildMenu.onHide(); popup.hide(); } // If the item has no popup, optionally fire its command. if (item.getSubMenu() == null) { if (fireCommand) { // Close this menu and all of its parents. closeAllParents(); // Fire the item's command. final Command cmd = item.getCommand(); if (cmd != null) { Scheduler.get().scheduleDeferred(cmd); } } return; } // Ensure that the item is selected. selectItem(item); // Create a new popup for this item, and position it next to // the item (below if this is a horizontal menu bar, to the // right if it's a vertical bar). popup = new VOverlay(true) { { setWidget(item.getSubMenu()); item.getSubMenu().onShow(); setOwner(MenuBar.this); } @Override public boolean onEventPreview(Event event) { // Hook the popup panel's event preview. We use this to keep it // from // auto-hiding when the parent menu is clicked. switch (DOM.eventGetType(event)) { case Event.ONCLICK: // If the event target is part of the parent menu, suppress // the // event altogether. final Element target = DOM.eventGetTarget(event); final Element parentMenuElement = item.getParentMenu().getElement(); if (DOM.isOrHasChild(parentMenuElement, target)) { return false; } break; } return super.onEventPreview(event); } }; popup.addPopupListener(this); if (vertical) { popup.setPopupPosition(item.getAbsoluteLeft() + item.getOffsetWidth(), item.getAbsoluteTop()); } else { popup.setPopupPosition(item.getAbsoluteLeft(), item.getAbsoluteTop() + item.getOffsetHeight()); } shownChildMenu = item.getSubMenu(); item.getSubMenu().parentMenu = this; // Show the popup, ensuring that the menubar's event preview remains on // top // of the popup's. popup.show(); }
From source file:com.vaadin.terminal.gwt.client.ui.MenuBar.java
License:Open Source License
void doItemAction(final MenuItem item, boolean fireCommand) { // If the given item is already showing its menu, we're done. if ((shownChildMenu != null) && (item.getSubMenu() == shownChildMenu)) { return;// w w w.ja va 2s. co m } // If another item is showing its menu, then hide it. if (shownChildMenu != null) { shownChildMenu.onHide(); popup.hide(); } // If the item has no popup, optionally fire its command. if (item.getSubMenu() == null) { if (fireCommand) { // Close this menu and all of its parents. closeAllParents(); // Fire the item's command. final Command cmd = item.getCommand(); if (cmd != null) { Scheduler.get().scheduleDeferred(cmd); } } return; } // Ensure that the item is selected. selectItem(item); // Create a new popup for this item, and position it next to // the item (below if this is a horizontal menu bar, to the // right if it's a vertical bar). popup = new VOverlay(true) { { setWidget(item.getSubMenu()); item.getSubMenu().onShow(); } @Override public boolean onEventPreview(Event event) { // Hook the popup panel's event preview. We use this to keep it // from // auto-hiding when the parent menu is clicked. switch (DOM.eventGetType(event)) { case Event.ONCLICK: // If the event target is part of the parent menu, suppress // the // event altogether. final Element target = DOM.eventGetTarget(event); final Element parentMenuElement = item.getParentMenu().getElement(); if (DOM.isOrHasChild(parentMenuElement, target)) { return false; } break; } return super.onEventPreview(event); } }; popup.addPopupListener(this); if (vertical) { popup.setPopupPosition(item.getAbsoluteLeft() + item.getOffsetWidth(), item.getAbsoluteTop()); } else { popup.setPopupPosition(item.getAbsoluteLeft(), item.getAbsoluteTop() + item.getOffsetHeight()); } shownChildMenu = item.getSubMenu(); item.getSubMenu().parentMenu = this; // Show the popup, ensuring that the menubar's event preview remains on // top // of the popup's. popup.show(); }
From source file:net.sf.mmm.client.ui.impl.gwt.widget.menu.adapter.UiWidgetAdapterGwtMenuItemBase.java
License:Apache License
/** * {@inheritDoc}//from w ww. j av a 2s. c om */ @Override public void removeFromParent() { // not supported by GWT MenuItem item = getToplevelWidget(); MenuBar menu = item.getParentMenu(); if (menu != null) { menu.removeItem(item); } }
From source file:org.pentaho.mantle.client.MantleMenuBar.java
License:Open Source License
private void hidePDFFrames(MenuItem item) { Frame frame = getActiveBrowserPerspectiveFrame(); if (frame == null) { return;//from w ww. j a va 2s. c om } if (item.getSubMenu() != null && item.getSubMenu().isVisible()) { if (ElementUtils.elementsOverlap(item.getSubMenu().getElement(), getActiveBrowserPerspectiveFrame().getElement())) { FrameUtils.setEmbedVisibility(getActiveBrowserPerspectiveFrame(), false); } } else if (item.getParentMenu() != null) { // popups if (ElementUtils.elementsOverlap(item.getParentMenu().getElement(), getActiveBrowserPerspectiveFrame().getElement())) { FrameUtils.setEmbedVisibility(getActiveBrowserPerspectiveFrame(), false); } } }