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
Modifier and Type | Class and Description |
---|---|
static class |
VMenuBar.CustomMenuItem
A class to hold information on menu items.
|
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
Modifier and Type | Field and Description |
---|---|
static String |
CLASSNAME
Set the CSS class name to allow styling.
|
ApplicationConnection |
client
For internal use only.
|
VMenuBar |
collapsedRootItems
For internal use only.
|
protected com.google.gwt.dom.client.Element |
containerElement |
static com.google.gwt.user.client.Command |
emptyCommand
An empty command to be used when the item has no command associated
|
boolean |
enabled
For internal use only.
|
VMenuBar |
hostReference
For internal use only.
|
boolean |
htmlContentAllowed
For internal use only.
|
protected List<VMenuBar.CustomMenuItem> |
items |
protected boolean |
menuVisible |
VMenuBar.CustomMenuItem |
moreItem
For internal use only.
|
boolean |
openRootOnHover
For internal use only.
|
protected VMenuBar |
parentMenu |
protected VOverlay |
popup |
protected VMenuBar.CustomMenuItem |
selected |
protected boolean |
subMenu |
static String |
SUBMENU_CLASSNAME_PREFIX |
String |
uidlId
For server connections.
|
protected VMenuBar |
visibleChildMenu |
Constructor and Description |
---|
VMenuBar() |
VMenuBar(boolean subMenu,
VMenuBar parentMenu) |
Modifier and Type | Method and Description |
---|---|
VMenuBar.CustomMenuItem |
addItem(String html,
com.google.gwt.user.client.Command cmd)
Add a new item to this menu.
|
void |
addItem(VMenuBar.CustomMenuItem item)
Add a new item to this menu.
|
void |
addItem(VMenuBar.CustomMenuItem item,
int index) |
com.google.web.bindery.event.shared.HandlerRegistration |
addTrigger(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.
|
String |
buildItemHTML(boolean separator,
boolean subMenu,
String iconUrl,
String text)
Build the HTML content for a menu item.
|
String |
buildItemHTML(UIDL item)
Build the HTML content for a menu item.
|
void |
clearItems()
Remove all the items in this menu.
|
protected void |
close(com.google.gwt.event.logical.shared.CloseEvent<com.google.gwt.user.client.ui.PopupPanel> event,
boolean animated) |
protected VOverlay |
createOverlay()
Create an overlay for the menu bar.
|
protected int |
getCloseMenuKey()
Get the key that closes the menu.
|
List<VMenuBar.CustomMenuItem> |
getItems()
Returns a list of items in this menu.
|
VMenuBar.CustomMenuItem |
getMenuItemWithElement(com.google.gwt.user.client.Element element)
Deprecated.
As of 7.2, call or override
getMenuItemWithElement(Element) instead |
VMenuBar.CustomMenuItem |
getMenuItemWithElement(com.google.gwt.dom.client.Element element)
Get menu item with given DOM element.
|
protected int |
getNavigationDownKey()
Get the key that moves the selection downwards.
|
protected int |
getNavigationLeftKey()
Get the key that moves the selection left.
|
protected int |
getNavigationRightKey()
Get the key that moves the selection right.
|
protected int |
getNavigationSelectKey()
Deprecated.
use
isNavigationSelectKey(int) instead |
protected int |
getNavigationUpKey()
Get the key that moves the selection upwards.
|
VMenuBar |
getParentMenu()
Returns the parent menu of this menu, or null if this is the top-level
menu.
|
protected VMenuBar |
getRoot() |
VMenuBar.CustomMenuItem |
getSelected()
Returns the currently selected item of this menu, or null if nothing is
selected.
|
com.google.gwt.user.client.Element |
getSubPartElement(String subPart)
Locates an element inside a component using the identifier provided in
subPart . |
String |
getSubPartName(com.google.gwt.user.client.Element subElement)
Provides an identifier that identifies the element within the component.
|
boolean |
handleNavigation(int keycode,
boolean ctrl,
boolean shift)
Handles the keyboard events handled by the MenuBar.
|
void |
hideChildMenu(VMenuBar.CustomMenuItem item)
Hides the submenu of an item.
|
void |
hideChildren()
Recursively hide all child menus.
|
void |
hideChildren(boolean animateIn,
boolean animateOut)
Recursively hide all child menus.
|
void |
hideParents(boolean autoClosed)
Recursively hide all parent menus.
|
void |
hideParents(boolean autoClosed,
boolean animated) |
void |
iLayout() |
void |
iLayout(boolean iconLoadEvent) |
protected boolean |
isNavigationSelectKey(int keycode)
Checks whether key code selects a menu item.
|
void |
itemClick(VMenuBar.CustomMenuItem item)
When an item is clicked.
|
void |
itemOut(VMenuBar.CustomMenuItem item)
When the mouse is moved away from an item.
|
void |
itemOver(VMenuBar.CustomMenuItem item)
When the user hovers the mouse over the item.
|
void |
onBrowserEvent(com.google.gwt.user.client.Event e) |
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.
|
protected void |
onDetach() |
void |
onFocus(com.google.gwt.event.dom.client.FocusEvent event) |
void |
onKeyDown(com.google.gwt.event.dom.client.KeyDownEvent event) |
void |
onKeyPress(com.google.gwt.event.dom.client.KeyPressEvent event) |
void |
onMenuClick(int clickedItemId)
This is called by the items in the menu and it communicates the
information to the server.
|
void |
onMouseOut(com.google.gwt.event.dom.client.MouseOutEvent event) |
void |
onMouseOver(com.google.gwt.event.dom.client.MouseOverEvent event) |
void |
onShow()
When the menu is shown.
|
void |
removeItem(VMenuBar.CustomMenuItem item)
Remove the given item from this menu.
|
void |
setParentMenu(VMenuBar parent)
Set the parent menu of this menu.
|
void |
setSelected(VMenuBar.CustomMenuItem item)
Set the currently selected item of this menu.
|
void |
setStyleName(String style) |
void |
setStylePrimaryName(String style) |
void |
showChildMenu(VMenuBar.CustomMenuItem item)
Shows the child menu of an item.
|
protected void |
showChildMenuAt(VMenuBar.CustomMenuItem item,
int top,
int left) |
protected void |
updateStyleNames() |
addBlurHandler, addFocusHandler, addKeyDownHandler, addKeyPressHandler, focus, setFocus
add, add, adjustIndex, checkIndexBoundsForAccess, checkIndexBoundsForInsertion, getChildren, getWidget, getWidgetCount, getWidgetIndex, getWidgetIndex, insert, insert, iterator, remove, remove
add, adopt, doAttachChildren, doDetachChildren, orphan, remove
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getWidgetIndex
getWidget, getWidgetCount, getWidgetIndex, remove
forEach, spliterator
public static final String CLASSNAME
public static final String SUBMENU_CLASSNAME_PREFIX
public String uidlId
For internal use only. May be removed or replaced in the future.
public ApplicationConnection client
public final VMenuBar hostReference
public VMenuBar.CustomMenuItem moreItem
public VMenuBar collapsedRootItems
public static final com.google.gwt.user.client.Command emptyCommand
For internal use only. May be removed or replaced in the future.
protected boolean subMenu
protected List<VMenuBar.CustomMenuItem> items
protected com.google.gwt.dom.client.Element containerElement
protected VOverlay popup
protected VMenuBar visibleChildMenu
protected boolean menuVisible
protected VMenuBar parentMenu
protected VMenuBar.CustomMenuItem selected
public boolean enabled
public boolean openRootOnHover
public boolean htmlContentAllowed
public VMenuBar()
public VMenuBar(boolean subMenu, VMenuBar parentMenu)
public void setStyleName(String style)
setStyleName
in class com.google.gwt.user.client.ui.UIObject
public void setStylePrimaryName(String style)
setStylePrimaryName
in class com.google.gwt.user.client.ui.UIObject
protected void updateStyleNames()
protected void onDetach()
onDetach
in class com.google.gwt.user.client.ui.Widget
public String buildItemHTML(UIDL item)
For internal use only. May be removed or replaced in the future.
public String buildItemHTML(boolean separator, boolean subMenu, String iconUrl, String text)
For internal use only. May be removed or replaced in the future.
separator
- the menu item is separatorsubMenu
- the menu item contains submenuiconUrl
- the menu item icon URL or null
text
- the menu item text. May not be null
public void onMenuClick(int clickedItemId)
clickedItemId
- id of the item that was clickedpublic List<VMenuBar.CustomMenuItem> getItems()
public void clearItems()
public VMenuBar.CustomMenuItem addItem(String html, com.google.gwt.user.client.Command cmd)
html
- items textcmd
- items commandpublic void addItem(VMenuBar.CustomMenuItem item)
item
- public void addItem(VMenuBar.CustomMenuItem item, int index)
public void removeItem(VMenuBar.CustomMenuItem item)
item
- public void onBrowserEvent(com.google.gwt.user.client.Event e)
onBrowserEvent
in interface com.google.gwt.user.client.EventListener
onBrowserEvent
in class com.google.gwt.user.client.ui.Widget
public void itemClick(VMenuBar.CustomMenuItem item)
item
- public void itemOver(VMenuBar.CustomMenuItem item)
item
- public void itemOut(VMenuBar.CustomMenuItem item)
item
- public void showChildMenu(VMenuBar.CustomMenuItem item)
item
- protected void showChildMenuAt(VMenuBar.CustomMenuItem item, int top, int left)
protected VOverlay createOverlay()
public void hideChildMenu(VMenuBar.CustomMenuItem item)
item
- public void onShow()
public void onClose(com.google.gwt.event.logical.shared.CloseEvent<com.google.gwt.user.client.ui.PopupPanel> event)
onClose
in interface com.google.gwt.event.logical.shared.CloseHandler<com.google.gwt.user.client.ui.PopupPanel>
protected void close(com.google.gwt.event.logical.shared.CloseEvent<com.google.gwt.user.client.ui.PopupPanel> event, boolean animated)
public void hideChildren()
public void hideChildren(boolean animateIn, boolean animateOut)
animateIn
- enable/disable animate-in animation when hide popupanimateOut
- enable/disable animate-out animation when hide popuppublic void hideParents(boolean autoClosed)
public void hideParents(boolean autoClosed, boolean animated)
public VMenuBar getParentMenu()
public void setParentMenu(VMenuBar parent)
parent
- public VMenuBar.CustomMenuItem getSelected()
public void setSelected(VMenuBar.CustomMenuItem item)
item
- public void iLayout()
public void iLayout(boolean iconLoadEvent)
public void onKeyPress(com.google.gwt.event.dom.client.KeyPressEvent event)
onKeyPress
in interface com.google.gwt.event.dom.client.KeyPressHandler
public void onKeyDown(com.google.gwt.event.dom.client.KeyDownEvent event)
onKeyDown
in interface com.google.gwt.event.dom.client.KeyDownHandler
protected int getNavigationUpKey()
protected int getNavigationDownKey()
protected int getNavigationLeftKey()
protected int getNavigationRightKey()
@Deprecated protected int getNavigationSelectKey()
isNavigationSelectKey(int)
insteadprotected boolean isNavigationSelectKey(int keycode)
keycode
- protected int getCloseMenuKey()
public boolean handleNavigation(int keycode, boolean ctrl, boolean shift)
keycode
- The key code receivedctrl
- Whether CTRL
was pressedshift
- Whether SHIFT
was pressedpublic void onFocus(com.google.gwt.event.dom.client.FocusEvent event)
onFocus
in interface com.google.gwt.event.dom.client.FocusHandler
public com.google.gwt.user.client.Element getSubPartElement(String subPart)
SubPartAware
subPart
. The subPart
identifier is component specific and
may be any string of characters, numbers, space characters and brackets.getSubPartElement
in interface SubPartAware
subPart
- The identifier for the element inside the componentpublic String getSubPartName(com.google.gwt.user.client.Element subElement)
SubPartAware
subElement
is a part of the component and must never be null.
Note!
getSubPartElement(getSubPartName(element)) == element
is not
always true. A component can choose to provide a more generic
identifier for any given element if the results of all interactions with
subElement
are 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 as subElement
because interactions with the DIV and the
root button element produce the same result.
getSubPartName
in interface SubPartAware
subElement
- The element the identifier string should uniquely identifysubElement
or null
if no identifier could be provided.@Deprecated public VMenuBar.CustomMenuItem getMenuItemWithElement(com.google.gwt.user.client.Element element)
getMenuItemWithElement(Element)
insteadelement
- Element used in searchpublic VMenuBar.CustomMenuItem getMenuItemWithElement(com.google.gwt.dom.client.Element element)
element
- Element used in searchpublic void onMouseOver(com.google.gwt.event.dom.client.MouseOverEvent event)
onMouseOver
in interface com.google.gwt.event.dom.client.MouseOverHandler
public void onMouseOut(com.google.gwt.event.dom.client.MouseOutEvent event)
onMouseOut
in interface com.google.gwt.event.dom.client.MouseOutHandler
protected VMenuBar getRoot()
public com.google.web.bindery.event.shared.HandlerRegistration addTrigger(com.google.gwt.user.client.Command command, String partInformation)
EventTrigger
addTrigger
in interface EventTrigger
command
- The command to execute when the event occurspartInformation
- Information passed from the server, typically telling which
element to attach the DOM handler toCopyright © 2018 Vaadin Ltd. All rights reserved.