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 TypeMethodDescriptionvoidAdds a separator to the menu.voidaddSeparatorAtIndex(int index) Adds a separator to the menu at the specified index.Searches for a user menu item with the specified unique identifier.Retrieves a user menu item with the specified unique identifier.getItems()Returns a list of all items currently present in the user menu component.voidremove(UserMenuItem menuItem) Removes the specified menu item from the user menu.voidRemoves a menu item identified by the specified unique identifier from the menu.voidRemoves 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
Searches for a user menu item with the specified unique identifier.- Parameters:
itemId- the unique identifier of the menu item to find- Returns:
- an
Optionalcontaining theUserMenuItemif found, or an emptyOptionalif the item does not exist
-
getItem
Retrieves a user menu item with the specified unique identifier.- Parameters:
itemId- the unique identifier of the menu item to retrieve- Returns:
- the
UserMenuItemassociated 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
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
-
removeAll
void removeAll()Removes all menu items from the user menu.
-