com.vaadin.flow.component.contextmenu.

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 type

I - the menu-item type

S - 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 Details

    • SubMenuBase

      public SubMenuBase(I parentMenuItem)
  • Method Details

    • addItem

      public I addItem(String text)

      Creates a new menu item with the given text content and adds it to the sub menu overlay.

      Parameters:

      text - the text content for the created menu item

      Returns:

      the created menu item

      See Also:

    • addItem

      public I addItem(Component component)

      Creates a new menu item with the given component content and adds it to the sub menu overlay.

      Parameters:

      component - the component to add to the created menu item

      Returns:

      the created menu item

      See Also:

    • add

      @Deprecated(since="24.8") public void add(Component... components)
      Deprecated.
      Since 24.8, use addComponent(Component...) instead

      Adds the given components into the sub menu overlay.

      For the common use case of having a list of high-lightable items inside the overlay, use addItem(String) and its overload methods instead.

      The added elements will be inserted into an overlay that is attached into the <body>.

      Parameters:

      components - the components to add

      See Also:

    • addComponent

      public void addComponent(Component... components)

      Adds the given components into the sub menu overlay.

      For the common use case of having a list of high-lightable items inside the overlay, use addItem(String) and its overload methods instead.

      The added elements will be inserted into an overlay that is attached into the <body>.

      Parameters:

      components - the components to add

      See Also:

    • remove

      public void remove(Component... components)

      Removes the given components from the sub menu overlay.

      Parameters:

      components - the components to remove

      See Also:

    • removeAll

      public void removeAll()

      Removes all components inside the sub menu overlay.

      See Also:

    • addComponentAtIndex

      public void addComponentAtIndex(int index, Component component)

      Adds the given component into the sub menu overlay at the given index.

      For the common use case of having a list of high-lightable items inside the overlay, use addItem(String) and its overload methods instead.

      The added elements will be inserted into an overlay that is attached into the <body>.

      Parameters:

      index - the index, where the component will be added

      component - the component to add

      See Also:

    • getChildren

      public Stream<Component> getChildren()

      Gets the child components of this sub menu. This includes components added with add(Component...) and the MenuItem components created with addItem(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

      public List<I> getItems()

      Gets the items added to this sub menu (the children of this component that are instances of MenuItem).

      Returns:

      the MenuItem components in this sub menu

      See Also:

    • getParentMenuItem

      public I getParentMenuItem()

      Gets the menu item component that opens this sub menu overlay.

      Returns:

      the parent menu item of this sub menu

    • addSeparator

      public void addSeparator()

      Adds a separator between items.

    • getMenuManager

      protected MenuManager<C,I,S> getMenuManager()

      Gets a (sub) menu manager.

      Returns:

    • createMenuManager

      protected abstract MenuManager<C,I,S> createMenuManager()

      Creates a (sub) menu manager instance which contains logic to control the (sub) menu content.

      Returns:

      a new menu manager instance