com.vaadin.flow.component.contextmenu.
Class MenuManager<C extends Component,I extends MenuItemBase<?,I,S>,S extends SubMenuBase<?,I,S>>
Type Parameters:
C
- the context menu type
I
- the menu item type
S
- the sub menu type
All Implemented Interfaces:
Common management logic for context menus and sub menus. Maintains the list of components to stamp into one overlay.
Author:
Vaadin Ltd.
See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMenuManager
(C menu, SerializableRunnable contentReset, SerializableBiFunction<C, SerializableRunnable, I> itemGenerator, Class<I> itemType, I parentMenuItem) Creates a new manager instance.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds components to the (sub)menu.
void
addComponentAtIndex
(int index, Component component) Inserts component to the (sub)menu using the
index
.Adds a component as a menu item.
addItem
(Component component, ComponentEventListener<ClickEvent<I>> clickListener) Adds a component as a menu item with a click listener.
Adds a text as a menu item.
addItem
(String text, ComponentEventListener<ClickEvent<I>> clickListener) Adds a text as a menu item with a click listener.
Gets all (sub)menu children.
getItems()
Gets all children items.
void
Removes components to the (sub)menu.
void
Remove all components and items from (sub)menu.
-
Constructor Details
-
MenuManager
public MenuManager(C menu, SerializableRunnable contentReset, SerializableBiFunction<C, SerializableRunnable, I> itemGenerator, Class<I> itemType, I parentMenuItem) Creates a new manager instance.
Parameters:
menu
- the context menucontentReset
- callback to reset the context menuitemGenerator
- the item generator/factoryitemType
- the item typeparentMenuItem
- the parent menu item of the submenu
-
-
Method Details
-
addItem
Adds a text as a menu item.
Parameters:
text
- the text for the menu itemReturns:
a new menu item
-
addItem
Adds a component as a menu item.
Parameters:
component
- the component for the menu itemReturns:
a new menu item
-
addItem
Adds a text as a menu item with a click listener.
Parameters:
text
- the text for the menu itemclickListener
- a click listenerReturns:
a new menu item
-
addItem
Adds a component as a menu item with a click listener.
Parameters:
component
- the component for the menu itemclickListener
- a click listenerReturns:
a new menu item
-
add
Adds components to the (sub)menu.
The components are added into the content as is, they are not wrapped as menu items.
Parameters:
components
- components to addSee Also:
-
remove
Removes components to the (sub)menu.
Parameters:
components
- components to removeSee Also:
-
removeAll
public void removeAll()Remove all components and items from (sub)menu.
See Also:
-
addComponentAtIndex
Inserts component to the (sub)menu using the
index
.The component is inserted into the content as is, it is not wrapped as a menu item.
Parameters:
index
- index to insert, not negativecomponent
- component to insertSee Also:
-
getChildren
Gets all (sub)menu children.
Children consist of components and items.
Returns:
the children components
See Also:
-
getItems
Gets all children items.
The items are filtered using the provided item type in the constructor.
Returns:
all children items
See Also:
-