C - the context menu typeI - the menu item typeS - the sub menu typepublic class MenuManager<C extends com.vaadin.flow.component.Component,I extends MenuItemBase<?,I,S>,S extends SubMenuBase<?,I,S>> extends Object implements Serializable
| Constructor and Description |
|---|
MenuManager(C menu,
com.vaadin.flow.function.SerializableRunnable contentReset,
com.vaadin.flow.function.SerializableBiFunction<C,com.vaadin.flow.function.SerializableRunnable,I> itemGenerator,
Class<I> itemType,
I parentMenuItem)
Creates a new manager instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(com.vaadin.flow.component.Component... components)
Adds components to the (sub)menu.
|
void |
addComponentAtIndex(int index,
com.vaadin.flow.component.Component component)
Inserts component to the (sub)menu using the
index. |
I |
addItem(com.vaadin.flow.component.Component component)
Adds a component as a menu item.
|
I |
addItem(com.vaadin.flow.component.Component component,
com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.ClickEvent<I>> clickListener)
Adds a component as a menu item with a click listener.
|
I |
addItem(String text)
Adds a text as a menu item.
|
I |
addItem(String text,
com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.ClickEvent<I>> clickListener)
Adds a text as a menu item with a click listener.
|
Stream<com.vaadin.flow.component.Component> |
getChildren()
Gets all (sub)menu children.
|
List<I> |
getItems()
Gets all children items.
|
void |
remove(com.vaadin.flow.component.Component... components)
Removes components to the (sub)menu.
|
void |
removeAll()
Remove all components and items from (sub)menu.
|
public MenuManager(C menu, com.vaadin.flow.function.SerializableRunnable contentReset, com.vaadin.flow.function.SerializableBiFunction<C,com.vaadin.flow.function.SerializableRunnable,I> itemGenerator, Class<I> itemType, I parentMenuItem)
menu - the context menucontentReset - callback to reset the context menuitemGenerator - the item generator/factoryitemType - the item typeparentMenuItem - the parent menu item of the submenupublic I addItem(String text)
text - the text for the menu itempublic I addItem(com.vaadin.flow.component.Component component)
component - the component for the menu itempublic I addItem(String text, com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.ClickEvent<I>> clickListener)
text - the text for the menu itemclickListener - a click listenerpublic I addItem(com.vaadin.flow.component.Component component, com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.ClickEvent<I>> clickListener)
component - the component for the menu itemclickListener - a click listenerpublic void add(com.vaadin.flow.component.Component... components)
The components are added into the content as is, they are not wrapped as menu items.
components - components to addremove(Component...),
addComponentAtIndex(int, Component)public void remove(com.vaadin.flow.component.Component... components)
components - components to removeadd(Component...)public void removeAll()
remove(Component...)public void addComponentAtIndex(int index,
com.vaadin.flow.component.Component component)
index.
The component is inserted into the content as is, it is not wrapped as a menu item.
index - index to insert, not negativecomponent - component to insertadd(Component...),
remove(Component...)public Stream<com.vaadin.flow.component.Component> getChildren()
Children consist of components and items.
add(Component...),
addItem(Component),
getItems()public List<I> getItems()
The items are filtered using the provided item type in the constructor.
getChildren()Copyright © 2025. All rights reserved.