Class SubMenuBase<C extends ContextMenuBase<C,I,S>,I extends MenuItemBase<C,I,S>,S extends SubMenuBase<C,I,S>>
java.lang.Object
com.vaadin.flow.component.contextmenu.SubMenuBase<C,I,S>
- Type Parameters:
C- the context-menu typeI- the menu-item typeS- the sub menu type
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
GridSubMenu,SubMenu
public abstract class SubMenuBase<C extends ContextMenuBase<C,I,S>,I extends MenuItemBase<C,I,S>,S extends SubMenuBase<C,I,S>>
extends Object
implements Serializable
Base class for sub-menus in
ContextMenuBase extensions. Classes
extending this should provide API for adding items and handling events
related to them. For basic example, see SubMenu.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddComponent(Component... components) Adds the given components to the sub menu.voidaddComponentAtIndex(int index, Component component) Adds the given component to the sub menu at the given index.Creates a new menu item with the given component content and adds it to the sub menu.Creates a new menu item with the given text content and adds it to the sub menu.voidAdds a separator between items.protected abstract MenuManager<C, I, S> Creates a (sub) menu manager instance which contains logic to control the (sub) menu content.Gets the child components of this sub menu.getItems()Gets the items added to this sub menu (the children of this component that are instances ofMenuItem).protected MenuManager<C, I, S> Gets a (sub) menu manager.Gets the menu item component that opens this sub menu.voidRemoves the given components from the sub menu.voidRemoves all components from the sub menu.
-
Constructor Details
-
SubMenuBase
-
-
Method Details
-
addItem
Creates a new menu item with the given text content and adds it to the sub menu.- Parameters:
text- the text content for the created menu item- Returns:
- the created menu item
-
addItem
Creates a new menu item with the given component content and adds it to the sub menu.- Parameters:
component- the component to add to the created menu item- Returns:
- the created menu item
-
addComponent
Adds the given components to the sub menu.For the common use case of having a list of high-lightable items inside the menu, use
addItem(String)and its overload methods instead.- Parameters:
components- the components to add- See Also:
-
remove
Removes the given components from the sub menu.- Parameters:
components- the components to remove
-
removeAll
public void removeAll()Removes all components from the sub menu. -
addComponentAtIndex
Adds the given component to the sub menu at the given index.For the common use case of having a list of high-lightable items inside the menu, use
addItem(String)and its overload methods instead.- Parameters:
index- the index, where the component will be addedcomponent- the component to add
-
getChildren
Gets the child components of this sub menu. This includes components added withaddComponent(Component...)and theMenuItemcomponents created withaddItem(String)and its overload methods. This doesn't include the components added to the main context menu or any other sub menus it may have.- Returns:
- the child components of this sub menu
-
getItems
Gets the items added to this sub menu (the children of this component that are instances ofMenuItem).- Returns:
- the
MenuItemcomponents in this sub menu - See Also:
-
getParentMenuItem
Gets the menu item component that opens this sub menu.- Returns:
- the parent menu item of this sub menu
-
addSeparator
public void addSeparator()Adds a separator between items. -
getMenuManager
Gets a (sub) menu manager.- Returns:
-
createMenuManager
Creates a (sub) menu manager instance which contains logic to control the (sub) menu content.- Returns:
- a new menu manager instance
-