List of usage examples for com.google.gwt.user.client.ui MenuBar MenuBar
public MenuBar(boolean vertical, Resources resources)
From source file:cc.kune.common.client.actions.gwtui.AbstractGwtMenuGui.java
License:GNU Affero Public License
@Override public AbstractGuiItem create(final GuiActionDescrip descriptor) { super.create(descriptor); menu = new MenuBar((Boolean) descriptor.getValue(MenuDescriptor.MENU_VERTICAL), SubMenuResources.INSTANCE); menu.setAutoOpen(true);//from w w w .j a va 2s. c o m menu.setFocusOnHoverEnabled(true); menu.setAnimationEnabled(true); descriptor.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(final PropertyChangeEvent event) { if (event.getPropertyName().equals(MenuDescriptor.MENU_HIDE)) { if (popup != null && popup.isShowing()) { popup.hide(); } } else if (event.getPropertyName().equals(MenuDescriptor.MENU_SHOW)) { show(); } else if (event.getPropertyName().equals(MenuDescriptor.MENU_SELECTION_DOWN)) { menu.moveSelectionDown(); } else if (event.getPropertyName().equals(MenuDescriptor.MENU_SELECTION_UP)) { menu.moveSelectionUp(); } else if (event.getPropertyName().equals(MenuDescriptor.MENU_SELECT_ITEM)) { final HasMenuItem item = (HasMenuItem) ((MenuItemDescriptor) descriptor .getValue(MenuDescriptor.MENU_SELECT_ITEM)).getValue(MenuItemDescriptor.UI); menu.selectItem((MenuItem) item.getMenuItem()); } } }); return this; }
From source file:org.jrydberg.ui.client.PopupMenu.java
License:Apache License
public PopupMenu(Resources resources) { super(true);// www . j a va2 s . co m menu = new MenuBar(true, resources) { @Override @SuppressWarnings("deprecation") public void onPopupClosed(PopupPanel sender, boolean autoClosed) { super.onPopupClosed(sender, autoClosed); // If the menu popup was not auto-closed, close popup menu.. if (!autoClosed) { if (canClose) { PopupMenu.this.hide(); } } } private boolean canClose = true; public void onBrowserEvent(Event event) { switch (DOM.eventGetType(event)) { case Event.ONMOUSEOVER: { canClose = false; break; } case Event.ONMOUSEOUT: { canClose = true; break; } } super.onBrowserEvent(event); } }; resources.popupMenuCss().ensureInjected(); menu.setAutoOpen(true); add(menu); setAnimationEnabled(false); sinkEvents(Event.ONCLICK); setStyleName(resources.popupMenuCss().menu()); DOM.setIntStyleAttribute(getElement(), "zIndex", Integer.MAX_VALUE); }