Class VMenuBar
- java.lang.Object
-
- com.google.gwt.user.client.ui.UIObject
-
- com.google.gwt.user.client.ui.Widget
-
- com.google.gwt.user.client.ui.Panel
-
- com.google.gwt.user.client.ui.ComplexPanel
-
- com.google.gwt.user.client.ui.FlowPanel
-
- com.vaadin.client.ui.FocusableFlowPanel
-
- com.vaadin.client.ui.VMenuBar
-
- All Implemented Interfaces:
com.google.gwt.event.dom.client.FocusHandler,com.google.gwt.event.dom.client.HasBlurHandlers,com.google.gwt.event.dom.client.HasFocusHandlers,com.google.gwt.event.dom.client.HasKeyDownHandlers,com.google.gwt.event.dom.client.HasKeyPressHandlers,com.google.gwt.event.dom.client.KeyDownHandler,com.google.gwt.event.dom.client.KeyPressHandler,com.google.gwt.event.dom.client.MouseOutHandler,com.google.gwt.event.dom.client.MouseOverHandler,com.google.gwt.event.logical.shared.CloseHandler<com.google.gwt.user.client.ui.PopupPanel>,com.google.gwt.event.logical.shared.HasAttachHandlers,com.google.gwt.event.shared.EventHandler,com.google.gwt.event.shared.HasHandlers,com.google.gwt.user.client.EventListener,com.google.gwt.user.client.ui.HasVisibility,com.google.gwt.user.client.ui.HasWidgets,com.google.gwt.user.client.ui.HasWidgets.ForIsWidget,com.google.gwt.user.client.ui.IndexedPanel,com.google.gwt.user.client.ui.IndexedPanel.ForIsWidget,com.google.gwt.user.client.ui.InsertPanel,com.google.gwt.user.client.ui.InsertPanel.ForIsWidget,com.google.gwt.user.client.ui.IsWidget,EventTrigger,Focusable,SubPartAware,Iterable<com.google.gwt.user.client.ui.Widget>
public class VMenuBar extends FocusableFlowPanel implements com.google.gwt.event.logical.shared.CloseHandler<com.google.gwt.user.client.ui.PopupPanel>, com.google.gwt.event.dom.client.KeyPressHandler, com.google.gwt.event.dom.client.KeyDownHandler, com.google.gwt.event.dom.client.FocusHandler, SubPartAware, com.google.gwt.event.dom.client.MouseOutHandler, com.google.gwt.event.dom.client.MouseOverHandler, EventTrigger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classVMenuBar.CustomMenuItemA class to hold information on menu items.-
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
-
Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasWidgets
com.google.gwt.user.client.ui.HasWidgets.ForIsWidget
-
-
Field Summary
Fields Modifier and Type Field Description static StringCLASSNAMESet the CSS class name to allow styling.ApplicationConnectionclientFor internal use only.VMenuBarcollapsedRootItemsFor internal use only.protected com.google.gwt.dom.client.ElementcontainerElementstatic com.google.gwt.user.client.CommandemptyCommandAn empty command to be used when the item has no command associatedbooleanenabledFor internal use only.VMenuBarhostReferenceFor internal use only.booleanhtmlContentAllowedFor internal use only.protected List<VMenuBar.CustomMenuItem>itemsprotected booleanmenuVisibleVMenuBar.CustomMenuItemmoreItemFor internal use only.booleanmouseDownPressedbooleanopenRootOnHoverFor internal use only.protected VMenuBarparentMenuprotected VOverlaypopupprotected VMenuBar.CustomMenuItemselectedprotected booleansubMenustatic StringSUBMENU_CLASSNAME_PREFIXStringuidlIdFor server connections.protected VMenuBarvisibleChildMenu
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddItem(VMenuBar.CustomMenuItem item)Add a new item to this menu.voidaddItem(VMenuBar.CustomMenuItem item, int index)VMenuBar.CustomMenuItemaddItem(String html, com.google.gwt.user.client.Command cmd)Add a new item to this menu.com.google.web.bindery.event.shared.HandlerRegistrationaddTrigger(com.google.gwt.user.client.Command command, String partInformation)Adds an appropriate event handler on the correct element inside the widget and invokes the given file downloader when the event occurs.StringbuildItemHTML(boolean separator, boolean subMenu, String iconUrl, String text)Build the HTML content for a menu item.StringbuildItemHTML(UIDL item)Build the HTML content for a menu item.voidclearItems()Remove all the items in this menu.protected voidclose(com.google.gwt.event.logical.shared.CloseEvent<com.google.gwt.user.client.ui.PopupPanel> event, boolean animated)protected VOverlaycreateOverlay()Create an overlay for the menu bar.protected intgetCloseMenuKey()Get the key that closes the menu.List<VMenuBar.CustomMenuItem>getItems()Returns a list of items in this menu.VMenuBar.CustomMenuItemgetMenuItemWithElement(com.google.gwt.dom.client.Element element)Get menu item with given DOM element.VMenuBar.CustomMenuItemgetMenuItemWithElement(com.google.gwt.user.client.Element element)Deprecated.As of 7.2, call or overridegetMenuItemWithElement(Element)insteadprotected intgetNavigationDownKey()Get the key that moves the selection downwards.protected intgetNavigationLeftKey()Get the key that moves the selection left.protected intgetNavigationRightKey()Get the key that moves the selection right.protected intgetNavigationSelectKey()Deprecated.useisNavigationSelectKey(int)insteadprotected intgetNavigationUpKey()Get the key that moves the selection upwards.VMenuBargetParentMenu()Returns the parent menu of this menu, or null if this is the top-level menu.protected VMenuBargetRoot()VMenuBar.CustomMenuItemgetSelected()Returns the currently selected item of this menu, or null if nothing is selected.com.google.gwt.user.client.ElementgetSubPartElement(String subPart)Locates an element inside a component using the identifier provided insubPart.StringgetSubPartName(com.google.gwt.user.client.Element subElement)Provides an identifier that identifies the element within the component.booleanhandleNavigation(int keycode, boolean ctrl, boolean shift)Handles the keyboard events handled by the MenuBar.voidhideChildMenu(VMenuBar.CustomMenuItem item)Hides the submenu of an item.voidhideChildren()Recursively hide all child menus.voidhideChildren(boolean animateIn, boolean animateOut)Recursively hide all child menus.voidhideParents(boolean autoClosed)Recursively hide all parent menus.voidhideParents(boolean autoClosed, boolean animated)voidiLayout()voidiLayout(boolean iconLoadEvent)protected booleanisNavigationSelectKey(int keycode)Checks whether key code selects a menu item.voiditemClick(VMenuBar.CustomMenuItem item)When an item is clicked.voiditemOut(VMenuBar.CustomMenuItem item)When the mouse is moved away from an item.voiditemOver(VMenuBar.CustomMenuItem item)When the user hovers the mouse over the item.voidonBrowserEvent(com.google.gwt.user.client.Event e)voidonClose(com.google.gwt.event.logical.shared.CloseEvent<com.google.gwt.user.client.ui.PopupPanel> event)Listener method, fired when this menu is closed.protected voidonDetach()voidonFocus(com.google.gwt.event.dom.client.FocusEvent event)voidonKeyDown(com.google.gwt.event.dom.client.KeyDownEvent event)voidonKeyPress(com.google.gwt.event.dom.client.KeyPressEvent event)voidonMenuClick(int clickedItemId)This is called by the items in the menu and it communicates the information to the server.voidonMouseOut(com.google.gwt.event.dom.client.MouseOutEvent event)voidonMouseOver(com.google.gwt.event.dom.client.MouseOverEvent event)voidonShow()When the menu is shown.voidremoveItem(VMenuBar.CustomMenuItem item)Remove the given item from this menu.voidsetParentMenu(VMenuBar parent)Set the parent menu of this menu.voidsetSelected(VMenuBar.CustomMenuItem item)Set the currently selected item of this menu.voidsetStyleName(String style)voidsetStylePrimaryName(String style)voidshowChildMenu(VMenuBar.CustomMenuItem item)Shows the child menu of an item.protected voidshowChildMenuAt(VMenuBar.CustomMenuItem item, int top, int left)protected voidupdateStyleNames()-
Methods inherited from class com.vaadin.client.ui.FocusableFlowPanel
addBlurHandler, addFocusHandler, addKeyDownHandler, addKeyPressHandler, focus, setFocus
-
Methods inherited from class com.google.gwt.user.client.ui.ComplexPanel
add, add, adjustIndex, checkIndexBoundsForAccess, checkIndexBoundsForInsertion, getChildren, getWidget, getWidgetCount, getWidgetIndex, getWidgetIndex, insert, insert, iterator, remove, remove
-
Methods inherited from class com.google.gwt.user.client.ui.Panel
add, adopt, doAttachChildren, doDetachChildren, orphan, remove
-
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
-
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.google.gwt.user.client.ui.IndexedPanel
getWidget, getWidgetCount, getWidgetIndex, remove
-
Methods inherited from interface com.google.gwt.user.client.ui.IndexedPanel.ForIsWidget
getWidgetIndex
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
CLASSNAME
public static final String CLASSNAME
Set the CSS class name to allow styling.- See Also:
- Constant Field Values
-
SUBMENU_CLASSNAME_PREFIX
public static final String SUBMENU_CLASSNAME_PREFIX
- See Also:
- Constant Field Values
-
uidlId
public String uidlId
For server connections.For internal use only. May be removed or replaced in the future.
-
client
public ApplicationConnection client
For internal use only. May be removed or replaced in the future.
-
hostReference
public final VMenuBar hostReference
For internal use only. May be removed or replaced in the future.
-
moreItem
public VMenuBar.CustomMenuItem moreItem
For internal use only. May be removed or replaced in the future.
-
collapsedRootItems
public VMenuBar collapsedRootItems
For internal use only. May be removed or replaced in the future.
-
emptyCommand
public static final com.google.gwt.user.client.Command emptyCommand
An empty command to be used when the item has no command associatedFor internal use only. May be removed or replaced in the future.
-
subMenu
protected boolean subMenu
-
items
protected List<VMenuBar.CustomMenuItem> items
-
containerElement
protected com.google.gwt.dom.client.Element containerElement
-
popup
protected VOverlay popup
-
visibleChildMenu
protected VMenuBar visibleChildMenu
-
menuVisible
protected boolean menuVisible
-
parentMenu
protected VMenuBar parentMenu
-
selected
protected VMenuBar.CustomMenuItem selected
-
enabled
public boolean enabled
For internal use only. May be removed or replaced in the future.
-
openRootOnHover
public boolean openRootOnHover
For internal use only. May be removed or replaced in the future.
-
htmlContentAllowed
public boolean htmlContentAllowed
For internal use only. May be removed or replaced in the future.
-
mouseDownPressed
public boolean mouseDownPressed
-
-
Constructor Detail
-
VMenuBar
public VMenuBar()
-
VMenuBar
public VMenuBar(boolean subMenu, VMenuBar parentMenu)
-
-
Method Detail
-
setStyleName
public void setStyleName(String style)
- Overrides:
setStyleNamein classcom.google.gwt.user.client.ui.UIObject
-
setStylePrimaryName
public void setStylePrimaryName(String style)
- Overrides:
setStylePrimaryNamein classcom.google.gwt.user.client.ui.UIObject
-
updateStyleNames
protected void updateStyleNames()
-
onDetach
protected void onDetach()
- Overrides:
onDetachin classcom.google.gwt.user.client.ui.Widget
-
buildItemHTML
public String buildItemHTML(UIDL item)
Build the HTML content for a menu item.For internal use only. May be removed or replaced in the future.
-
buildItemHTML
public String buildItemHTML(boolean separator, boolean subMenu, String iconUrl, String text)
Build the HTML content for a menu item.For internal use only. May be removed or replaced in the future.
- Parameters:
separator- the menu item is separatorsubMenu- the menu item contains submenuiconUrl- the menu item icon URL ornulltext- the menu item text. May not benull
-
onMenuClick
public void onMenuClick(int clickedItemId)
This is called by the items in the menu and it communicates the information to the server.- Parameters:
clickedItemId- id of the item that was clicked
-
getItems
public List<VMenuBar.CustomMenuItem> getItems()
Returns a list of items in this menu.
-
clearItems
public void clearItems()
Remove all the items in this menu.
-
addItem
public VMenuBar.CustomMenuItem addItem(String html, com.google.gwt.user.client.Command cmd)
Add a new item to this menu.- Parameters:
html- items textcmd- items command- Returns:
- the item created
-
addItem
public void addItem(VMenuBar.CustomMenuItem item)
Add a new item to this menu.- Parameters:
item-
-
addItem
public void addItem(VMenuBar.CustomMenuItem item, int index)
-
removeItem
public void removeItem(VMenuBar.CustomMenuItem item)
Remove the given item from this menu.- Parameters:
item-
-
onBrowserEvent
public void onBrowserEvent(com.google.gwt.user.client.Event e)
- Specified by:
onBrowserEventin interfacecom.google.gwt.user.client.EventListener- Overrides:
onBrowserEventin classcom.google.gwt.user.client.ui.Widget
-
itemClick
public void itemClick(VMenuBar.CustomMenuItem item)
When an item is clicked.- Parameters:
item-
-
itemOver
public void itemOver(VMenuBar.CustomMenuItem item)
When the user hovers the mouse over the item.- Parameters:
item-
-
itemOut
public void itemOut(VMenuBar.CustomMenuItem item)
When the mouse is moved away from an item.- Parameters:
item-
-
showChildMenu
public void showChildMenu(VMenuBar.CustomMenuItem item)
Shows the child menu of an item. The caller must ensure that the item has a submenu.- Parameters:
item-
-
showChildMenuAt
protected void showChildMenuAt(VMenuBar.CustomMenuItem item, int top, int left)
-
createOverlay
protected VOverlay createOverlay()
Create an overlay for the menu bar. This method can be overridden to use a custom overlay.- Returns:
- overlay to use
- Since:
- 7.6
-
hideChildMenu
public void hideChildMenu(VMenuBar.CustomMenuItem item)
Hides the submenu of an item.- Parameters:
item-
-
onShow
public void onShow()
When the menu is shown.
-
onClose
public void onClose(com.google.gwt.event.logical.shared.CloseEvent<com.google.gwt.user.client.ui.PopupPanel> event)
Listener method, fired when this menu is closed.- Specified by:
onClosein interfacecom.google.gwt.event.logical.shared.CloseHandler<com.google.gwt.user.client.ui.PopupPanel>
-
close
protected void close(com.google.gwt.event.logical.shared.CloseEvent<com.google.gwt.user.client.ui.PopupPanel> event, boolean animated)
-
hideChildren
public void hideChildren()
Recursively hide all child menus.
-
hideChildren
public void hideChildren(boolean animateIn, boolean animateOut)Recursively hide all child menus.- Parameters:
animateIn- enable/disable animate-in animation when hide popupanimateOut- enable/disable animate-out animation when hide popup- Since:
- 7.3.7
-
hideParents
public void hideParents(boolean autoClosed)
Recursively hide all parent menus.
-
hideParents
public void hideParents(boolean autoClosed, boolean animated)
-
getParentMenu
public VMenuBar getParentMenu()
Returns the parent menu of this menu, or null if this is the top-level menu.- Returns:
-
setParentMenu
public void setParentMenu(VMenuBar parent)
Set the parent menu of this menu.- Parameters:
parent-
-
getSelected
public VMenuBar.CustomMenuItem getSelected()
Returns the currently selected item of this menu, or null if nothing is selected.- Returns:
-
setSelected
public void setSelected(VMenuBar.CustomMenuItem item)
Set the currently selected item of this menu.- Parameters:
item-
-
iLayout
public void iLayout()
-
iLayout
public void iLayout(boolean iconLoadEvent)
-
onKeyPress
public void onKeyPress(com.google.gwt.event.dom.client.KeyPressEvent event)
- Specified by:
onKeyPressin interfacecom.google.gwt.event.dom.client.KeyPressHandler
-
onKeyDown
public void onKeyDown(com.google.gwt.event.dom.client.KeyDownEvent event)
- Specified by:
onKeyDownin interfacecom.google.gwt.event.dom.client.KeyDownHandler
-
getNavigationUpKey
protected int getNavigationUpKey()
Get the key that moves the selection upwards. By default it is the up arrow key but by overriding this you can change the key to whatever you want.- Returns:
- The keycode of the key
-
getNavigationDownKey
protected int getNavigationDownKey()
Get the key that moves the selection downwards. By default it is the down arrow key but by overriding this you can change the key to whatever you want.- Returns:
- The keycode of the key
-
getNavigationLeftKey
protected int getNavigationLeftKey()
Get the key that moves the selection left. By default it is the left arrow key but by overriding this you can change the key to whatever you want.- Returns:
- The keycode of the key
-
getNavigationRightKey
protected int getNavigationRightKey()
Get the key that moves the selection right. By default it is the right arrow key but by overriding this you can change the key to whatever you want.- Returns:
- The keycode of the key
-
getNavigationSelectKey
@Deprecated protected int getNavigationSelectKey()
Deprecated.useisNavigationSelectKey(int)insteadGet the key that selects a menu item. By default it is the Enter key but by overriding this you can change the key to whatever you want.- Returns:
-
isNavigationSelectKey
protected boolean isNavigationSelectKey(int keycode)
Checks whether key code selects a menu item. By default it is the Enter and Space keys but by overriding this you can change the keys to whatever you want.- Parameters:
keycode-- Returns:
- true if key selects menu item
- Since:
- 7.2
-
getCloseMenuKey
protected int getCloseMenuKey()
Get the key that closes the menu. By default it is the escape key but by overriding this yoy can change the key to whatever you want.- Returns:
-
handleNavigation
public boolean handleNavigation(int keycode, boolean ctrl, boolean shift)Handles the keyboard events handled by the MenuBar.- Parameters:
keycode- The key code receivedctrl- WhetherCTRLwas pressedshift- WhetherSHIFTwas pressed- Returns:
- true if the navigation event was handled
-
onFocus
public void onFocus(com.google.gwt.event.dom.client.FocusEvent event)
- Specified by:
onFocusin interfacecom.google.gwt.event.dom.client.FocusHandler
-
getSubPartElement
public com.google.gwt.user.client.Element getSubPartElement(String subPart)
Description copied from interface:SubPartAwareLocates an element inside a component using the identifier provided insubPart. ThesubPartidentifier is component specific and may be any string of characters, numbers, space characters and brackets.- Specified by:
getSubPartElementin interfaceSubPartAware- Parameters:
subPart- The identifier for the element inside the component- Returns:
- The element identified by subPart or null if the element could not be found.
-
getSubPartName
public String getSubPartName(com.google.gwt.user.client.Element subElement)
Description copied from interface:SubPartAwareProvides an identifier that identifies the element within the component. ThesubElementis a part of the component and must never be null.Note!
getSubPartElement(getSubPartName(element)) == elementis not always true. A component can choose to provide a more generic identifier for any given element if the results of all interactions withsubElementare the same as interactions with the element identified by the return value. For example a button can return an identifier for the root element even though a DIV inside the button was passed assubElementbecause interactions with the DIV and the root button element produce the same result.- Specified by:
getSubPartNamein interfaceSubPartAware- Parameters:
subElement- The element the identifier string should uniquely identify- Returns:
- An identifier that uniquely identifies
subElementor null if no identifier could be provided.
-
getMenuItemWithElement
@Deprecated public VMenuBar.CustomMenuItem getMenuItemWithElement(com.google.gwt.user.client.Element element)
Deprecated.As of 7.2, call or overridegetMenuItemWithElement(Element)insteadGet menu item with given DOM element.- Parameters:
element- Element used in search- Returns:
- Menu item or null if not found
-
getMenuItemWithElement
public VMenuBar.CustomMenuItem getMenuItemWithElement(com.google.gwt.dom.client.Element element)
Get menu item with given DOM element.- Parameters:
element- Element used in search- Returns:
- Menu item or null if not found
- Since:
- 7.2
-
onMouseOver
public void onMouseOver(com.google.gwt.event.dom.client.MouseOverEvent event)
- Specified by:
onMouseOverin interfacecom.google.gwt.event.dom.client.MouseOverHandler
-
onMouseOut
public void onMouseOut(com.google.gwt.event.dom.client.MouseOutEvent event)
- Specified by:
onMouseOutin interfacecom.google.gwt.event.dom.client.MouseOutHandler
-
getRoot
protected VMenuBar getRoot()
-
addTrigger
public com.google.web.bindery.event.shared.HandlerRegistration addTrigger(com.google.gwt.user.client.Command command, String partInformation)Description copied from interface:EventTriggerAdds an appropriate event handler on the correct element inside the widget and invokes the given file downloader when the event occurs.- Specified by:
addTriggerin interfaceEventTrigger- Parameters:
command- The command to execute when the event occurspartInformation- Information passed from the server, typically telling which element to attach the DOM handler to- Returns:
- a registration handler which can be used to remove the handler
-
-