Interface HasMenuItems

All Known Subinterfaces:
HasActionMenuItems, HasComponentMenuItems, HasTextMenuItems, HasViewMenuItems, UserMenuItem.HasSubMenu.SubMenu
All Known Implementing Classes:
JmixUserMenu, JmixUserMenu.JmixUserMenuSubMenu, JmixUserMenuItemsDelegate, UserMenu, UserMenu.UserMenuSubMenu, UserMenuItemsDelegate

public interface HasMenuItems
Represents a contract for managing menu items in user menu components.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a separator to the menu.
    void
    Adds a separator to the menu at the specified index.
    findItem(String itemId)
    Searches for a user menu item with the specified unique identifier.
    getItem(String itemId)
    Retrieves a user menu item with the specified unique identifier.
    Returns a list of all items currently present in the user menu component.
    void
    remove(UserMenuItem menuItem)
    Removes the specified menu item from the user menu.
    void
    remove(String itemId)
    Removes a menu item identified by the specified unique identifier from the menu.
    void
    Removes all menu items from the user menu.
  • Method Details

    • addSeparator

      void addSeparator()
      Adds a separator to the menu. A separator is used to visually divide groups of menu items, enabling better organization and readability.
    • addSeparatorAtIndex

      void addSeparatorAtIndex(int index)
      Adds a separator to the menu at the specified index. A separator is used to visually divide groups of menu items, enhancing organization and readability. The given index determines the position where the separator is inserted.
      Parameters:
      index - the position in the menu where the separator will be added. The index must be within the valid range of current menu items.
    • findItem

      Optional<UserMenuItem> findItem(String itemId)
      Searches for a user menu item with the specified unique identifier.
      Parameters:
      itemId - the unique identifier of the menu item to find
      Returns:
      an Optional containing the UserMenuItem if found, or an empty Optional if the item does not exist
    • getItem

      UserMenuItem getItem(String itemId)
      Retrieves a user menu item with the specified unique identifier.
      Parameters:
      itemId - the unique identifier of the menu item to retrieve
      Returns:
      the UserMenuItem associated with the given identifier
      Throws:
      IllegalArgumentException - if the item with the given identifier does not exist
    • getItems

      List<UserMenuItem> getItems()
      Returns a list of all items currently present in the user menu component.
      Returns:
      a list of all items currently present in the user menu component
    • remove

      void remove(String itemId)
      Removes a menu item identified by the specified unique identifier from the menu.
      Parameters:
      itemId - the unique identifier of the menu item to be removed
    • remove

      void remove(UserMenuItem menuItem)
      Removes the specified menu item from the user menu.
      Parameters:
      menuItem - the UserMenuItem to be removed from the menu
    • removeAll

      void removeAll()
      Removes all menu items from the user menu.