com.vaadin.terminal.gwt.client.ui.
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.SimplePanel
com.vaadin.terminal.gwt.client.ui.SimpleFocusablePanel
com.vaadin.terminal.gwt.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.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.AcceptsOneWidget, com.google.gwt.user.client.ui.HasOneWidget, com.google.gwt.user.client.ui.HasWidgets, com.google.gwt.user.client.ui.HasWidgets.ForIsWidget, com.google.gwt.user.client.ui.IsWidget, ContainerResizedListener, Focusable, Paintable, SubPartAware, Iterable<com.google.gwt.user.client.ui.Widget>
- extends SimpleFocusablePanel
- implements Paintable, com.google.gwt.event.logical.shared.CloseHandler<com.google.gwt.user.client.ui.PopupPanel>, ContainerResizedListener, com.google.gwt.event.dom.client.KeyPressHandler, com.google.gwt.event.dom.client.KeyDownHandler, com.google.gwt.event.dom.client.FocusHandler, SubPartAware
public class VMenuBar
Nested Class Summary | |
---|---|
protected static class |
VMenuBar.CustomMenuItem
A 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 | |
---|---|
static String |
ATTRIBUTE_CHECKED
|
static String |
CLASSNAME
Set the CSS class name to allow styling. |
protected ApplicationConnection |
client
|
protected VMenuBar |
collapsedRootItems
|
protected com.google.gwt.user.client.Element |
containerElement
|
protected static com.google.gwt.user.client.Command |
emptyCommand
|
protected VMenuBar |
hostReference
|
static String |
HTML_CONTENT_ALLOWED
|
protected ArrayList<VMenuBar.CustomMenuItem> |
items
|
protected boolean |
menuVisible
|
protected VMenuBar.CustomMenuItem |
moreItem
|
static String |
OPEN_ROOT_MENU_ON_HOWER
|
protected VMenuBar |
parentMenu
|
protected VOverlay |
popup
|
protected VMenuBar.CustomMenuItem |
selected
|
protected boolean |
subMenu
Widget fields |
protected String |
submenuIcon
|
protected String |
uidlId
For server connections |
protected VMenuBar |
visibleChildMenu
|
Fields inherited from class com.google.gwt.user.client.ui.UIObject |
---|
DEBUG_ID_PREFIX |
Constructor Summary | |
---|---|
VMenuBar()
|
|
VMenuBar(boolean subMenu,
VMenuBar parentMenu)
|
Method Summary | |
---|---|
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)
|
protected String |
buildItemHTML(UIDL item)
Build the HTML content for a menu item. |
void |
clearItems()
Remove all the items in this menu |
protected int |
getCloseMenuKey()
Get the key that closes the menu. |
com.google.gwt.user.client.Element |
getContainerElement()
Returns the containing element of the menu |
List<VMenuBar.CustomMenuItem> |
getItems()
Returns a list of items in this menu |
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()
Get the key that selects a menu item. |
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 |
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 |
hideParents(boolean autoClosed)
Recursively hide all parent menus |
void |
iLayout()
This function is run when container box has been resized. |
void |
iLayout(boolean iconLoadEvent)
|
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)
|
protected void |
onLoad()
|
void |
onMenuClick(int clickedItemId)
This is called by the items in the menu and it communicates the information to the server |
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 |
setWidth(String width)
|
void |
showChildMenu(VMenuBar.CustomMenuItem item)
Shows the child menu of an item. |
protected void |
showChildMenuAt(VMenuBar.CustomMenuItem item,
int top,
int left)
|
void |
updateFromUIDL(UIDL uidl,
ApplicationConnection client)
This method must be implemented to update the client-side component from UIDL data received from server. |
Methods inherited from class com.vaadin.terminal.gwt.client.ui.SimpleFocusablePanel |
---|
addBlurHandler, addFocusHandler, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, focus, setFocus, setTabIndex |
Methods inherited from class com.google.gwt.user.client.ui.SimplePanel |
---|
add, getWidget, iterator, remove, setWidget, setWidget |
Methods inherited from class com.google.gwt.user.client.ui.Panel |
---|
add, adopt, adopt, clear, disown, 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, onUnload, removeFromParent, setLayoutData, sinkEvents |
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, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, sinkBitlessEvent, toString, unsinkEvents |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.google.gwt.event.shared.HasHandlers |
---|
fireEvent |
Methods inherited from interface com.google.gwt.event.shared.HasHandlers |
---|
fireEvent |
Methods inherited from interface com.google.gwt.event.shared.HasHandlers |
---|
fireEvent |
Methods inherited from interface com.google.gwt.event.shared.HasHandlers |
---|
fireEvent |
Field Detail |
---|
CLASSNAME
public static final String CLASSNAME
- See Also:
- Constant Field Values
Set the CSS class name to allow styling.
uidlId
protected String uidlId
For server connections
client
protected ApplicationConnection client
hostReference
protected final VMenuBar hostReference
submenuIcon
protected String submenuIcon
moreItem
protected VMenuBar.CustomMenuItem moreItem
collapsedRootItems
protected VMenuBar collapsedRootItems
emptyCommand
protected static final com.google.gwt.user.client.Command emptyCommand
OPEN_ROOT_MENU_ON_HOWER
public static final String OPEN_ROOT_MENU_ON_HOWER
See Also:
ATTRIBUTE_CHECKED
public static final String ATTRIBUTE_CHECKED
See Also:
HTML_CONTENT_ALLOWED
public static final String HTML_CONTENT_ALLOWED
See Also:
subMenu
protected boolean subMenu
Widget fields
items
protected ArrayList<VMenuBar.CustomMenuItem> items
containerElement
protected com.google.gwt.user.client.Element containerElement
popup
protected VOverlay popup
visibleChildMenu
protected VMenuBar visibleChildMenu
menuVisible
protected boolean menuVisible
parentMenu
protected VMenuBar parentMenu
selected
protected VMenuBar.CustomMenuItem selected
Constructor Detail |
---|
VMenuBar
public VMenuBar()
VMenuBar
public VMenuBar(boolean subMenu,
VMenuBar parentMenu)
Method Detail |
---|
onDetach
protected void onDetach()
- Overrides:
onDetach
in classcom.google.gwt.user.client.ui.Widget
setWidth
public void setWidth(String width)
- Overrides:
setWidth
in classcom.google.gwt.user.client.ui.UIObject
updateFromUIDL
public void updateFromUIDL(UIDL uidl,
ApplicationConnection client)
- Specified by:
updateFromUIDL
in interfacePaintable
This method must be implemented to update the client-side component from UIDL data received from server. This method is called when the page is loaded for the first time, and every time UI changes in the component are received from the server.
buildItemHTML
protected String buildItemHTML(UIDL item)
- Parameters:
item
-- Returns:
Build the HTML content for a menu item.
onMenuClick
public void onMenuClick(int clickedItemId)
- Parameters:
clickedItemId
- id of the item that was clicked
This is called by the items in the menu and it communicates the information to the server
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
getContainerElement
public com.google.gwt.user.client.Element getContainerElement()
- Overrides:
getContainerElement
in classcom.google.gwt.user.client.ui.SimplePanel
- Returns:
Returns the containing element of the menu
addItem
public VMenuBar.CustomMenuItem addItem(String html,
com.google.gwt.user.client.Command cmd)
- Parameters:
html
- items textcmd
- items command- Returns:
- the item created
Add a new item to this menu
addItem
public void addItem(VMenuBar.CustomMenuItem item)
- Parameters:
item
-
Add a new item to this menu
addItem
public void addItem(VMenuBar.CustomMenuItem item,
int index)
removeItem
public void removeItem(VMenuBar.CustomMenuItem item)
- Parameters:
item
-
Remove the given item from this menu
onBrowserEvent
public void onBrowserEvent(com.google.gwt.user.client.Event e)
- Specified by:
onBrowserEvent
in interfacecom.google.gwt.user.client.EventListener
- Overrides:
onBrowserEvent
in classcom.google.gwt.user.client.ui.Widget
itemClick
public void itemClick(VMenuBar.CustomMenuItem item)
- Parameters:
item
-
When an item is clicked
itemOver
public void itemOver(VMenuBar.CustomMenuItem item)
- Parameters:
item
-
When the user hovers the mouse over the item
itemOut
public void itemOut(VMenuBar.CustomMenuItem item)
- Parameters:
item
-
When the mouse is moved away from an item
showChildMenu
public void showChildMenu(VMenuBar.CustomMenuItem item)
- Parameters:
item
-
Shows the child menu of an item. The caller must ensure that the item has a submenu.
showChildMenuAt
protected void showChildMenuAt(VMenuBar.CustomMenuItem item,
int top,
int left)
hideChildMenu
public void hideChildMenu(VMenuBar.CustomMenuItem item)
- Parameters:
item
-
Hides the submenu of an 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)
- Specified by:
onClose
in interfacecom.google.gwt.event.logical.shared.CloseHandler<com.google.gwt.user.client.ui.PopupPanel>
Listener method, fired when this menu is closed
hideChildren
public void hideChildren()
Recursively hide all child menus
hideParents
public void hideParents(boolean autoClosed)
Recursively hide all parent menus
getParentMenu
public VMenuBar getParentMenu()
- Returns:
Returns the parent menu of this menu, or null if this is the top-level menu
setParentMenu
public void setParentMenu(VMenuBar parent)
- Parameters:
parent
-
Set the parent menu of this menu
getSelected
public VMenuBar.CustomMenuItem getSelected()
- Returns:
Returns the currently selected item of this menu, or null if nothing is selected
setSelected
public void setSelected(VMenuBar.CustomMenuItem item)
- Parameters:
item
-
Set the currently selected item of this menu
iLayout
public void iLayout()
- Specified by:
iLayout
in interfaceContainerResizedListener
Description copied from interface: ContainerResizedListener
This function is run when container box has been resized. Object implementing ContainerResizedListener is responsible to call the same function on its ancestors that implement NeedsLayout in case their container has resized. runAnchestorsLayout(HasWidgets parent) function from Util class may be a good helper for this.
iLayout
public void iLayout(boolean iconLoadEvent)
onKeyPress
public void onKeyPress(com.google.gwt.event.dom.client.KeyPressEvent event)
- Specified by:
onKeyPress
in interfacecom.google.gwt.event.dom.client.KeyPressHandler
onKeyDown
public void onKeyDown(com.google.gwt.event.dom.client.KeyDownEvent event)
- Specified by:
onKeyDown
in interfacecom.google.gwt.event.dom.client.KeyDownHandler
getNavigationUpKey
protected int getNavigationUpKey()
- Returns:
- The keycode of the key
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.
getNavigationDownKey
protected int getNavigationDownKey()
- Returns:
- The keycode of the key
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.
getNavigationLeftKey
protected int getNavigationLeftKey()
- Returns:
- The keycode of the key
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.
getNavigationRightKey
protected int getNavigationRightKey()
- Returns:
- The keycode of the key
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.
getNavigationSelectKey
protected int getNavigationSelectKey()
- Returns:
Get 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.
getCloseMenuKey
protected int getCloseMenuKey()
- Returns:
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.
handleNavigation
public boolean handleNavigation(int keycode,
boolean ctrl,
boolean shift)
- Parameters:
event
- The keyboard event received- Returns:
- true iff the navigation event was handled
Handles the keyboard events handled by the MenuBar
onFocus
public void onFocus(com.google.gwt.event.dom.client.FocusEvent event)
- Specified by:
onFocus
in interfacecom.google.gwt.event.dom.client.FocusHandler
getSubPartElement
public com.google.gwt.user.client.Element getSubPartElement(String subPart)
- Specified by:
getSubPartElement
in 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.
Description copied from interface: SubPartAware
Locates an element inside a component using the identifier provided in
subPart
. The subPart
identifier is component specific and
may be any string of characters, numbers, space characters and brackets.
getSubPartName
public String getSubPartName(com.google.gwt.user.client.Element subElement)
- Specified by:
getSubPartName
in interfaceSubPartAware
- Parameters:
subElement
- The element the identifier string should uniquely identify- Returns:
- An identifier that uniquely identifies
subElement
or null if no identifier could be provided.
Description copied from interface: SubPartAware
Provides an identifier that identifies the element within the component.
The 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.
onLoad
protected void onLoad()
- Overrides:
onLoad
in classcom.google.gwt.user.client.ui.Widget