Class JmixUserMenuItemsDelegate
java.lang.Object
io.jmix.flowui.kit.component.usermenu.JmixUserMenuItemsDelegate
- All Implemented Interfaces:
HasActionMenuItems,HasComponentMenuItems,HasMenuItems,HasTextMenuItems
- Direct Known Subclasses:
UserMenuItemsDelegate
public class JmixUserMenuItemsDelegate
extends Object
implements HasTextMenuItems, HasActionMenuItems, HasComponentMenuItems
Delegate class for managing
UserMenuItem collection.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classBlank item needed for correct insertion by index. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<UserMenuItem>protected Map<UserMenuItem,com.vaadin.flow.shared.Registration> protected final JmixSubMenuprotected final JmixUserMenu<?> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddActionItem(String id, Action action) Adds a new menu item with the specified identifier and associated action.addActionItem(String id, Action action, int index) Adds a new menu item with the specified identifier, associated action, and specified index where the item should be inserted.addComponentItem(String id, com.vaadin.flow.component.Component content) Adds a new menu item with a unique identifier and a custom UIComponentas its content.addComponentItem(String id, com.vaadin.flow.component.Component content, int index) Adds a new menu item with a unique identifier, a custom UIComponentas its content, and inserts it at a specific position in the menu.addComponentItem(String id, com.vaadin.flow.component.Component content, Consumer<UserMenuItem.HasClickListener.ClickEvent<ComponentUserMenuItem>> listener) Adds a new menu item with a unique identifier, a custom UIComponentas its content, and a click listener to handle click events for the menu item.addComponentItem(String id, com.vaadin.flow.component.Component content, Consumer<UserMenuItem.HasClickListener.ClickEvent<ComponentUserMenuItem>> listener, int index) Adds a new menu item with a unique identifier, a custom UIComponentas its content, a click listener to handle click events for the menu item, and inserts it at a specific position in the menu.protected voidaddItemInternal(UserMenuItem item, int index) protected ComponentUserMenuItemaddItemInternal(String id, com.vaadin.flow.component.Component content, Consumer<UserMenuItem.HasClickListener.ClickEvent<ComponentUserMenuItem>> listener, int index) protected TextUserMenuItemaddItemInternal(String id, String text, com.vaadin.flow.component.Component icon, Consumer<UserMenuItem.HasClickListener.ClickEvent<TextUserMenuItem>> listener, int index) voidAdds a separator to the menu.voidaddSeparatorAtIndex(int index) Adds a separator to the menu at the specified index.addTextItem(String id, String text) Adds a new menu item with the specified ID and text.addTextItem(String id, String text, int index) Adds a new menu item with the specified ID and text at the given index.addTextItem(String id, String text, com.vaadin.flow.component.Component icon) Adds a new menu item with the specified ID, text and icon.addTextItem(String id, String text, com.vaadin.flow.component.Component icon, int index) Adds a new menu item with the specified ID, text and icon at the given index.addTextItem(String id, String text, com.vaadin.flow.component.Component icon, Consumer<UserMenuItem.HasClickListener.ClickEvent<TextUserMenuItem>> listener) Adds a new menu item with the specified ID, text, icon and click listener.addTextItem(String id, String text, com.vaadin.flow.component.Component icon, Consumer<UserMenuItem.HasClickListener.ClickEvent<TextUserMenuItem>> listener, int index) Adds a new menu item with the specified ID, text, icon and click listener at the given index.addTextItem(String id, String text, Consumer<UserMenuItem.HasClickListener.ClickEvent<TextUserMenuItem>> listener) Adds a new menu item with the specified ID, text and click listener.addTextItem(String id, String text, Consumer<UserMenuItem.HasClickListener.ClickEvent<TextUserMenuItem>> listener, int index) Adds a new menu item with the specified ID, text and click listener at the given index.protected intadjustPhysicalIndex(int index) protected voidattachItem(UserMenuItem item) protected JmixMenuItemcreateMenuItem(String id, com.vaadin.flow.component.Component content, int index) protected voiddetachItem(UserMenuItem item) 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.protected voidonItemPropertyChange(PropertyChangeEvent propertyChangeEvent) 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.voidUpdates the visibility of menu items based on their properties and position.
-
Field Details
-
userMenu
-
subMenu
-
items
-
propertyChangeRegistrations
-
-
Constructor Details
-
Method Details
-
addTextItem
Description copied from interface:HasTextMenuItemsAdds a new menu item with the specified ID and text.- Specified by:
addTextItemin interfaceHasTextMenuItems- Parameters:
id- unique identifier for the menu itemtext- text to be displayed in the menu item- Returns:
- newly created menu item
-
addTextItem
Description copied from interface:HasTextMenuItemsAdds a new menu item with the specified ID and text at the given index.- Specified by:
addTextItemin interfaceHasTextMenuItems- Parameters:
id- unique identifier for the menu itemtext- text to be displayed in the menu itemindex- position at which to insert the menu item- Returns:
- newly created menu item
-
addTextItem
public TextUserMenuItem addTextItem(String id, String text, Consumer<UserMenuItem.HasClickListener.ClickEvent<TextUserMenuItem>> listener) Description copied from interface:HasTextMenuItemsAdds a new menu item with the specified ID, text and click listener.- Specified by:
addTextItemin interfaceHasTextMenuItems- Parameters:
id- unique identifier for the menu itemtext- text to be displayed in the menu itemlistener- callback to be invoked when the menu item is clicked- Returns:
- newly created menu item
-
addTextItem
public TextUserMenuItem addTextItem(String id, String text, Consumer<UserMenuItem.HasClickListener.ClickEvent<TextUserMenuItem>> listener, int index) Description copied from interface:HasTextMenuItemsAdds a new menu item with the specified ID, text and click listener at the given index.- Specified by:
addTextItemin interfaceHasTextMenuItems- Parameters:
id- unique identifier for the menu itemtext- text to be displayed in the menu itemlistener- callback to be invoked when the menu item is clickedindex- position at which to insert the menu item- Returns:
- newly created menu item
-
addTextItem
public TextUserMenuItem addTextItem(String id, String text, com.vaadin.flow.component.Component icon) Description copied from interface:HasTextMenuItemsAdds a new menu item with the specified ID, text and icon.- Specified by:
addTextItemin interfaceHasTextMenuItems- Parameters:
id- unique identifier for the menu itemtext- text to be displayed in the menu itemicon- icon component to be displayed in the menu item- Returns:
- newly created menu item
-
addTextItem
public TextUserMenuItem addTextItem(String id, String text, com.vaadin.flow.component.Component icon, int index) Description copied from interface:HasTextMenuItemsAdds a new menu item with the specified ID, text and icon at the given index.- Specified by:
addTextItemin interfaceHasTextMenuItems- Parameters:
id- unique identifier for the menu itemtext- text to be displayed in the menu itemicon- icon component to be displayed in the menu itemindex- position at which to insert the menu item- Returns:
- newly created menu item
-
addTextItem
public TextUserMenuItem addTextItem(String id, String text, com.vaadin.flow.component.Component icon, Consumer<UserMenuItem.HasClickListener.ClickEvent<TextUserMenuItem>> listener) Description copied from interface:HasTextMenuItemsAdds a new menu item with the specified ID, text, icon and click listener.- Specified by:
addTextItemin interfaceHasTextMenuItems- Parameters:
id- unique identifier for the menu itemtext- text to be displayed in the menu itemicon- icon component to be displayed in the menu itemlistener- callback to be invoked when the menu item is clicked- Returns:
- newly created menu item
-
addTextItem
public TextUserMenuItem addTextItem(String id, String text, com.vaadin.flow.component.Component icon, Consumer<UserMenuItem.HasClickListener.ClickEvent<TextUserMenuItem>> listener, int index) Description copied from interface:HasTextMenuItemsAdds a new menu item with the specified ID, text, icon and click listener at the given index.- Specified by:
addTextItemin interfaceHasTextMenuItems- Parameters:
id- unique identifier for the menu itemtext- text to be displayed in the menu itemicon- icon component to be displayed in the menu itemlistener- callback to be invoked when the menu item is clickedindex- position at which to insert the menu item- Returns:
- newly created menu item
-
addItemInternal
protected TextUserMenuItem addItemInternal(String id, String text, @Nullable com.vaadin.flow.component.Component icon, @Nullable Consumer<UserMenuItem.HasClickListener.ClickEvent<TextUserMenuItem>> listener, int index) -
addActionItem
Description copied from interface:HasActionMenuItemsAdds a new menu item with the specified identifier and associated action.- Specified by:
addActionItemin interfaceHasActionMenuItems- Parameters:
id- the unique identifier of the menu itemaction- theActionto associate with the menu item- Returns:
- the created
ActionUserMenuIteminstance
-
addActionItem
Description copied from interface:HasActionMenuItemsAdds a new menu item with the specified identifier, associated action, and specified index where the item should be inserted.- Specified by:
addActionItemin interfaceHasActionMenuItems- Parameters:
id- the unique identifier of the menu itemaction- theActionto associate with the menu itemindex- the position at which the menu item should be inserted- Returns:
- the created
ActionUserMenuIteminstance
-
addComponentItem
public ComponentUserMenuItem addComponentItem(String id, com.vaadin.flow.component.Component content) Description copied from interface:HasComponentMenuItemsAdds a new menu item with a unique identifier and a custom UIComponentas its content.- Specified by:
addComponentItemin interfaceHasComponentMenuItems- Parameters:
id- the unique identifier of the menu itemcontent- theComponentto be set as the content of the menu item- Returns:
- the created
ComponentUserMenuIteminstance
-
addComponentItem
public ComponentUserMenuItem addComponentItem(String id, com.vaadin.flow.component.Component content, int index) Description copied from interface:HasComponentMenuItemsAdds a new menu item with a unique identifier, a custom UIComponentas its content, and inserts it at a specific position in the menu.- Specified by:
addComponentItemin interfaceHasComponentMenuItems- Parameters:
id- the unique identifier of the menu itemcontent- theComponentto be set as the content of the menu itemindex- the position at which the menu item will be inserted- Returns:
- the created
ComponentUserMenuIteminstance
-
addComponentItem
public ComponentUserMenuItem addComponentItem(String id, com.vaadin.flow.component.Component content, Consumer<UserMenuItem.HasClickListener.ClickEvent<ComponentUserMenuItem>> listener) Description copied from interface:HasComponentMenuItemsAdds a new menu item with a unique identifier, a custom UIComponentas its content, and a click listener to handle click events for the menu item.- Specified by:
addComponentItemin interfaceHasComponentMenuItems- Parameters:
id- the unique identifier of the menu itemcontent- theComponentto be set as the content of the menu itemlistener- theConsumerthat handles the click events triggered by the menu item- Returns:
- the created
ComponentUserMenuIteminstance
-
addComponentItem
public ComponentUserMenuItem addComponentItem(String id, com.vaadin.flow.component.Component content, Consumer<UserMenuItem.HasClickListener.ClickEvent<ComponentUserMenuItem>> listener, int index) Description copied from interface:HasComponentMenuItemsAdds a new menu item with a unique identifier, a custom UIComponentas its content, a click listener to handle click events for the menu item, and inserts it at a specific position in the menu.- Specified by:
addComponentItemin interfaceHasComponentMenuItems- Parameters:
id- the unique identifier of the menu itemcontent- theComponentto be set as the content of the menu itemlistener- theConsumerthat handles the click events triggered by the menu itemindex- the position at which the menu item will be inserted- Returns:
- the created
ComponentUserMenuIteminstance
-
addItemInternal
protected ComponentUserMenuItem addItemInternal(String id, com.vaadin.flow.component.Component content, @Nullable Consumer<UserMenuItem.HasClickListener.ClickEvent<ComponentUserMenuItem>> listener, int index) -
addSeparator
public void addSeparator()Description copied from interface:HasMenuItemsAdds a separator to the menu. A separator is used to visually divide groups of menu items, enabling better organization and readability.- Specified by:
addSeparatorin interfaceHasMenuItems
-
addSeparatorAtIndex
public void addSeparatorAtIndex(int index) Description copied from interface:HasMenuItemsAdds 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.- Specified by:
addSeparatorAtIndexin interfaceHasMenuItems- 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.
-
onItemPropertyChange
-
updateItemsVisibility
public void updateItemsVisibility()Updates the visibility of menu items based on their properties and position. -
createMenuItem
protected JmixMenuItem createMenuItem(String id, com.vaadin.flow.component.Component content, int index) -
findItem
Description copied from interface:HasMenuItemsSearches for a user menu item with the specified unique identifier.- Specified by:
findItemin interfaceHasMenuItems- 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
Description copied from interface:HasMenuItemsRetrieves a user menu item with the specified unique identifier.- Specified by:
getItemin interfaceHasMenuItems- Parameters:
itemId- the unique identifier of the menu item to retrieve- Returns:
- the
UserMenuItemassociated with the given identifier
-
getItems
Description copied from interface:HasMenuItemsReturns a list of all items currently present in the user menu component.- Specified by:
getItemsin interfaceHasMenuItems- Returns:
- a list of all items currently present in the user menu component
-
remove
Description copied from interface:HasMenuItemsRemoves a menu item identified by the specified unique identifier from the menu.- Specified by:
removein interfaceHasMenuItems- Parameters:
itemId- the unique identifier of the menu item to be removed
-
removeAll
public void removeAll()Description copied from interface:HasMenuItemsRemoves all menu items from the user menu.- Specified by:
removeAllin interfaceHasMenuItems
-
adjustPhysicalIndex
protected int adjustPhysicalIndex(int index)
-