Package com.vaadin.featurepack.ui
Class FMenuBar
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.menubar.MenuBar
com.vaadin.featurepack.ui.FMenuBar
- All Implemented Interfaces:
ClientConnector,FAbstractClientConnector,FSizeable,HasSizeable,FAbstractComponent,com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.BlurNotifier<FMenuBar>,com.vaadin.flow.component.contextmenu.HasMenuItems,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.Focusable<FMenuBar>,com.vaadin.flow.component.FocusNotifier<FMenuBar>,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasTheme,com.vaadin.flow.component.shared.HasThemeVariant<com.vaadin.flow.component.menubar.MenuBarVariant>,Serializable
@JsModule("./menu-bar-styles.js")
public class FMenuBar
extends com.vaadin.flow.component.menubar.MenuBar
implements FAbstractComponent, com.vaadin.flow.component.Focusable<FMenuBar>, HasSizeable
A class representing a Vaadin 7/8 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.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThis interface contains the layer for menu commands of theFMenuBarclass.classNested classes/interfaces inherited from class com.vaadin.flow.component.menubar.MenuBar
com.vaadin.flow.component.menubar.MenuBar.MenuBarI18nNested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.featurepack.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.DetachEvent, ClientConnector.DetachListenerNested classes/interfaces inherited from interface com.vaadin.featurepack.server.FAbstractClientConnector
FAbstractClientConnector.LegacyMethodEventNested classes/interfaces inherited from interface com.vaadin.featurepack.ui.FAbstractComponent
FAbstractComponent.DataKeyNested classes/interfaces inherited from interface com.vaadin.flow.component.Focusable
com.vaadin.flow.component.Focusable.FocusJsNested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddItem(String caption, Resource icon, FMenuBar.Command command) Add a new item to the menu bar.addItem(String caption, FMenuBar.Command command) Add a new item to the menu bar.addItem(String caption, com.vaadin.flow.component.icon.Icon icon, FMenuBar.Command command) Add a new item to the menu bar.addItemBefore(String caption, Resource icon, FMenuBar.Command command, FMenuBar.MenuItem itemToAddBefore) Add an item before some item.voidbeforeClientResponse(boolean initial) Called before the response is written to client side.protected voidfireEvent(com.vaadin.flow.component.ComponentEvent<?> componentEvent) Returns a list with all the MenuItem objects in the menu barGet the MenuItem used as the collapse menu item.intgetSize()Returns the size of the menu.booleanDetects whether the menubar is in a mode where top level menus are automatically opened when the mouse cursor is moved over the menu.booleanChecks whether item captions are interpreted as html or plain text.protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) protected voidonDetach(com.vaadin.flow.component.DetachEvent detachEvent) voidremoveItem(FMenuBar.MenuItem item) Remove first occurrence the specified item from the main menuvoidEmpty the menu barvoidsetAutoOpen(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.voidsetHtmlContentAllowed(boolean htmlContentAllowed) Sets whether html is allowed in the item captions.voidsetLabelComponent(com.vaadin.flow.component.Component labelComponent) Sets the component's label component.voidSet the item that is used when collapsing the top level menu.Methods inherited from class com.vaadin.flow.component.menubar.MenuBar
addItem, addItem, addItem, addItem, addItem, addItem, addItem, addItem, close, getChildren, getI18n, getItems, isOpenOnHover, isReverseCollapseOrder, isTabNavigation, remove, removeAll, setI18n, setOpenOnHover, setReverseCollapseOrder, setTabNavigation, setTooltipTextMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, findAncestor, from, get, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, getUIOrThrow, hasListener, isAttached, isTemplateMapped, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible, whenAttachedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.featurepack.server.FAbstractClientConnector
addLegacyAttachListener, addLegacyDetachListener, addListener, addListener, attach, detach, doConnectorOnAttach, doConnectorOnDetach, fireEvent, fireEvent, getAllChildrenIterable, getFListeners, getFlowComponent, getResource, hasListeners, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeListener, removeListener, setResourceMethods inherited from interface com.vaadin.featurepack.ui.FAbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, addStyleNames, getCaption, getComponentError, getData, getDescription, getFErrorIndicator, getFErrorMessage, getFId, getFParent, getIcon, getIconResource, getPrimaryStyleName, getStyleName, isCaptionAsHtml, isImmediate, isResponsive, notifyParentAboutStyleChanges, removeContextClickListener, removeShortcutListener, removeStyleName, removeStyleNames, setCaption, setCaptionAsHtml, setComponentError, setData, setDescription, setDescription, setIcon, setIcon, setIconResource, setImmediate, setLocale, setPrimaryStyleName, setResponsive, setStyleName, setStyleNameMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasSize
bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.featurepack.server.HasSizeable
getFHeight, getFWidth, getHeightUnits, getWidthUnits, setHeight, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefinedMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, bindThemeName, bindThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, bindThemeVariant, bindThemeVariants, removeThemeVariants, setThemeVariant, setThemeVariants, setThemeVariants
-
Constructor Details
-
FMenuBar
public FMenuBar()
-
-
Method Details
-
fireEvent
protected void fireEvent(com.vaadin.flow.component.ComponentEvent<?> componentEvent) - Overrides:
fireEventin classcom.vaadin.flow.component.Component
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
onDetach
protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent) - Overrides:
onDetachin classcom.vaadin.flow.component.Component
-
beforeClientResponse
public void beforeClientResponse(boolean initial) Description copied from interface:ClientConnectorCalled before the response is written to client side. Gives the legacy connector an opportunity to set computed/dynamic state values.This is implemented for the legacy components to keep consistent behavior and e.g. legaze size calculations working.
NOTE: the parameter
initialisfalsewhen the component is attached again to a newUIwhenPreserveOnRefreshis used.- Specified by:
beforeClientResponsein interfaceClientConnector- Specified by:
beforeClientResponsein interfaceFAbstractClientConnector- Specified by:
beforeClientResponsein interfaceFAbstractComponent- Parameters:
initial-trueif the client-side connector will be created and initialized after this method has been invoked.falseif there is already an initialized client-side connector.
-
setLabelComponent
public void setLabelComponent(com.vaadin.flow.component.Component labelComponent) Description copied from interface:FAbstractComponentSets the component's label component. Flow components that support caption component usually overrides this.- Specified by:
setLabelComponentin interfaceFAbstractComponent- Parameters:
labelComponent- the new label component for the component.
-
addItem
Add a new item to the menu bar. Command can be null, but a caption must be given.- Parameters:
caption- the text for the menu itemcommand- the command for the menu item- Throws:
IllegalArgumentException
-
addItem
public FMenuBar.MenuItem addItem(String caption, com.vaadin.flow.component.icon.Icon icon, FMenuBar.Command command) Add a new item to the menu bar. Icon and command can be null, but a caption must be given.- Parameters:
caption- the text for the menu itemicon- the icon component for the menu itemcommand- the command for the menu item- Throws:
IllegalArgumentException
-
addItem
Add a new item to the menu bar. Icon and command can be null, but a caption must be given.- Parameters:
caption- the text for the menu itemicon- the icon for the menu itemcommand- the command for the menu item- Throws:
IllegalArgumentException
-
addItemBefore
public FMenuBar.MenuItem addItemBefore(String caption, Resource icon, FMenuBar.Command command, FMenuBar.MenuItem itemToAddBefore) Add an item before some item. If the given item does not exist the item is added at the end of the menu. Icon and command can be null, but a caption must be given.- Parameters:
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 item- Throws:
IllegalArgumentException
-
getFItems
Returns a list with all the MenuItem objects in the menu bar- Returns:
- a list containing the MenuItem objects in the menu bar
-
removeItem
Remove first occurrence the specified item from the main menu- Parameters:
item- The item to be removed
-
removeItems
public void removeItems()Empty the menu bar -
getSize
public int getSize()Returns the size of the menu.- Returns:
- The size of the menu
-
setMoreMenuItem
Set the item that is used when collapsing the top level menu. All "overflowing" items will be added below this. The item command will be ignored. If set to null, the default item with a downwards arrow is used. The item command (if specified) is ignored.- Parameters:
item-
-
getMoreMenuItem
Get the MenuItem used as the collapse menu item.- Returns:
-
setAutoOpen
public 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. In this mode the menu also closes itself if the mouse is moved out of the opened menu.Note, that on touch devices the menu still opens on a click event.
- Parameters:
autoOpenTopLevelMenu- true if menus should be opened without click, the default is false
-
isAutoOpen
public 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. Normally root menu opens only by clicking on the menu. Submenus always open automatically.- Returns:
- true if the root menus open without click, the default is false
-
setHtmlContentAllowed
public void setHtmlContentAllowed(boolean htmlContentAllowed) Sets whether html is allowed in the item captions. If set to true, the captions are passed to the browser as html and the developer is responsible for ensuring no harmful html is used. If set to false, the content is passed to the browser as plain text.- Parameters:
htmlContentAllowed- true if the captions are used as html, false if used as plain text
-
isHtmlContentAllowed
public boolean isHtmlContentAllowed()Checks whether item captions are interpreted as html or plain text.- Returns:
- true if the captions are used as html, false if used as plain text
- See Also:
-