public class MenuBar extends com.vaadin.ui.AbstractComponent implements Menu, com.vaadin.ui.LegacyComponent, com.vaadin.ui.Component.Focusable
A class representing a horizontal menu bar. The menu can contain MenuItem objects, which in turn can contain more MenuBars. These sub-level MenuBars are represented as vertical menu.
Menu.Command
com.vaadin.ui.Component.ErrorEvent, com.vaadin.ui.Component.Event, com.vaadin.ui.Component.Focusable, com.vaadin.ui.Component.Listener
com.vaadin.server.ClientConnector.AttachEvent, com.vaadin.server.ClientConnector.AttachListener, com.vaadin.server.ClientConnector.ConnectorErrorEvent, com.vaadin.server.ClientConnector.DetachEvent, com.vaadin.server.ClientConnector.DetachListener
Constructor and Description |
---|
MenuBar()
Constructs an empty, horizontal menu
|
Modifier and Type | Method and Description |
---|---|
MenuItem |
addItem(String caption,
Menu.Command command)
Add a new item to the menu bar.
|
MenuItem |
addItem(String caption,
com.vaadin.server.Resource icon,
Menu.Command command)
Add a new item to the menu bar.
|
MenuItem |
addItemBefore(String caption,
com.vaadin.server.Resource icon,
Menu.Command command,
MenuItem itemToAddBefore)
Add an item before some item.
|
void |
changeVariables(Object source,
Map<String,Object> variables)
Deserialize changes received from client.
|
protected org.jsoup.nodes.Element |
createMenuElement(MenuItem item,
com.vaadin.ui.declarative.DesignContext designContext) |
void |
focus() |
protected Collection<String> |
getCustomAttributes() |
List<MenuItem> |
getItems()
Returns a list with all the MenuItem objects in the menu bar
|
MenuItem |
getMoreMenuItem()
Get the MenuItem used as the collapse menu item.
|
int |
getSize()
Returns the size of the menu.
|
protected com.vaadin.shared.ui.menubar.MenuBarState |
getState() |
protected com.vaadin.shared.ui.menubar.MenuBarState |
getState(boolean markAsDirty) |
int |
getTabIndex() |
boolean |
isAutoOpen()
Detects whether the menubar is in a mode where top level menus are
automatically opened when the mouse cursor is moved over the menu.
|
boolean |
isHtmlContentAllowed()
Checks whether item captions are interpreted as html or plain text.
|
void |
paintContent(com.vaadin.server.PaintTarget target)
Paint (serialise) the component for the client.
|
void |
readDesign(org.jsoup.nodes.Element design,
com.vaadin.ui.declarative.DesignContext designContext) |
protected MenuItem |
readMenuElement(org.jsoup.nodes.Element menuElement,
MenuItem parent) |
void |
removeItem(MenuItem item)
Remove first occurrence the specified item from the main menu
|
void |
removeItems()
Empty the menu bar
|
void |
setAutoOpen(boolean autoOpenTopLevelMenu)
Using this method menubar can be put into a special mode where top level
menus opens without clicking on the menu, but automatically when mouse
cursor is moved over the menu.
|
void |
setHtmlContentAllowed(boolean htmlContentAllowed)
Sets whether html is allowed in the item captions.
|
void |
setMoreMenuItem(MenuItem item)
Set the item that is used when collapsing the top level menu.
|
void |
setTabIndex(int tabIndex) |
void |
writeDesign(org.jsoup.nodes.Element design,
com.vaadin.ui.declarative.DesignContext designContext) |
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isReadOnly, isRequiredIndicatorVisible, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeight, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setReadOnly, setRequiredIndicatorVisible, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setStyleName, setVisible, setWidth, setWidth, setWidthUndefined
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
addListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setVisible
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
protected com.vaadin.shared.ui.menubar.MenuBarState getState()
getState
in class com.vaadin.ui.AbstractComponent
protected com.vaadin.shared.ui.menubar.MenuBarState getState(boolean markAsDirty)
getState
in class com.vaadin.ui.AbstractComponent
public void paintContent(com.vaadin.server.PaintTarget target) throws com.vaadin.server.PaintException
paintContent
in interface com.vaadin.ui.LegacyComponent
com.vaadin.server.PaintException
public void changeVariables(Object source, Map<String,Object> variables)
changeVariables
in interface com.vaadin.server.VariableOwner
public int getTabIndex()
getTabIndex
in interface com.vaadin.ui.Component.Focusable
public void setTabIndex(int tabIndex)
setTabIndex
in interface com.vaadin.ui.Component.Focusable
public void focus()
focus
in interface com.vaadin.ui.Component.Focusable
focus
in class com.vaadin.ui.AbstractComponent
public void writeDesign(org.jsoup.nodes.Element design, com.vaadin.ui.declarative.DesignContext designContext)
writeDesign
in interface com.vaadin.ui.Component
writeDesign
in class com.vaadin.ui.AbstractComponent
protected org.jsoup.nodes.Element createMenuElement(MenuItem item, com.vaadin.ui.declarative.DesignContext designContext)
protected MenuItem readMenuElement(org.jsoup.nodes.Element menuElement, MenuItem parent)
public void setMoreMenuItem(MenuItem item)
item
- public MenuItem getMoreMenuItem()
public void setAutoOpen(boolean autoOpenTopLevelMenu)
Note, that on touch devices the menu still opens on a click event.
autoOpenTopLevelMenu
- true if menus should be opened without click, the default is
falsepublic boolean isAutoOpen()
public void readDesign(org.jsoup.nodes.Element design, com.vaadin.ui.declarative.DesignContext designContext)
readDesign
in interface com.vaadin.ui.Component
readDesign
in class com.vaadin.ui.AbstractComponent
protected Collection<String> getCustomAttributes()
getCustomAttributes
in class com.vaadin.ui.AbstractComponent
public MenuItem addItem(String caption, Menu.Command command)
Menu
public MenuItem addItem(String caption, com.vaadin.server.Resource icon, Menu.Command command)
Menu
public MenuItem addItemBefore(String caption, com.vaadin.server.Resource icon, Menu.Command command, MenuItem itemToAddBefore)
Menu
addItemBefore
in interface Menu
caption
- the text for the menu itemicon
- the icon for the menu itemcommand
- the command for the menu itemitemToAddBefore
- the item that will be after the new itempublic List<MenuItem> getItems()
Menu
public void removeItem(MenuItem item)
Menu
removeItem
in interface Menu
item
- The item to be removedpublic void removeItems()
Menu
removeItems
in interface Menu
public int getSize()
Menu
public void setHtmlContentAllowed(boolean htmlContentAllowed)
Menu
setHtmlContentAllowed
in interface Menu
htmlContentAllowed
- true if the captions are used as html, false if used as plain
textpublic boolean isHtmlContentAllowed()
Menu
isHtmlContentAllowed
in interface Menu
Menu.setHtmlContentAllowed(boolean)
Copyright © 2017 Magnolia International Ltd.. All rights reserved.