Class JmixUserMenu<USER>
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<JmixMenuBar>
io.jmix.flowui.kit.component.usermenu.JmixUserMenu<USER>
- Type Parameters:
USER- the type of the user associated with the menu
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.BlurNotifier<JmixUserMenu<USER>>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.Focusable<JmixUserMenu<USER>>,com.vaadin.flow.component.FocusNotifier<JmixUserMenu<USER>>,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasTheme,com.vaadin.flow.component.shared.HasOverlayClassName,com.vaadin.flow.component.shared.HasThemeVariant<UserMenuVariant>,HasSubParts,HasTitle,HasActionMenuItems,HasComponentMenuItems,HasMenuItems,HasTextMenuItems,Serializable
- Direct Known Subclasses:
UserMenu
public class JmixUserMenu<USER>
extends com.vaadin.flow.component.Composite<JmixMenuBar>
implements HasTextMenuItems, HasActionMenuItems, HasComponentMenuItems, com.vaadin.flow.component.HasEnabled, HasTitle, com.vaadin.flow.component.shared.HasOverlayClassName, HasSubParts, com.vaadin.flow.component.shared.HasThemeVariant<UserMenuVariant>, com.vaadin.flow.component.Focusable<JmixUserMenu<USER>>
A component that displays a user menu as a dropdown.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classprotected static classprotected static classprotected static classprotected static interfaceRepresents a component that has an associatedMenuItem.protected static classstatic interfaceA functional interface representing a renderer that generates aComponentbased on a provided item.protected static classstatic classRepresents an event that is triggered when the user associated with theJmixUserMenucomponent changes.Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected static final Stringprotected JmixUserMenu.Renderer<USER>protected JmixUserMenu.Renderer<USER>protected com.vaadin.flow.component.HasComponentsprotected JmixUserMenuItemsDelegateprotected static final Stringprotected USERprotected JmixMenuItem -
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.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.com.vaadin.flow.shared.RegistrationaddUserChangedListener(com.vaadin.flow.component.ComponentEventListener<JmixUserMenu.UserChangedEvent<USER>> listener) protected com.vaadin.flow.component.HasComponentsprotected UserMenuItem.HasSubMenu.SubMenucreateSubMenu(JmixSubMenu subMenu) protected JmixUserMenuItemsDelegatecreateUserMenuItemsDelegate(JmixSubMenu subMenu) 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 JmixUserMenuItemsDelegateprotected JmixSubMenugetSubPart(String name) Returns a sub part object by its name.getUser()Returns the current user associated with the user menu.protected JmixMenuBarprotected voidbooleanDetermines whether the user menu opens on hover.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.voidsetButtonRenderer(JmixUserMenu.Renderer<USER> buttonRenderer) Sets the function to generate the button's content based on the current user.voidsetHeaderRenderer(JmixUserMenu.Renderer<USER> headerRenderer) Sets the function to generate the header's content based on the current user.voidsetOpenOnHover(boolean openOnHover) Sets whether the user menu should open when hovered.voidsetOverlayClassName(String overlayClassName) voidSets the user for the user menu.protected voidprotected voidprotected voidMethods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElementMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.shared.HasOverlayClassName
getOverlayClassNameMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, removeThemeVariants
-
Field Details
-
ATTRIBUTE_JMIX_ROLE_NAME
- See Also:
-
ATTRIBUTE_JMIX_ROLE_VALUE
- See Also:
-
BASE_CLASS_NAME
- See Also:
-
OVERLAY_CLASS_NAME
- See Also:
-
userMenuItem
-
headerWrapper
protected com.vaadin.flow.component.HasComponents headerWrapper -
buttonRenderer
-
headerRenderer
-
user
-
itemsDelegate
-
-
Constructor Details
-
JmixUserMenu
public JmixUserMenu()
-
-
Method Details
-
initUserMenuItem
protected void initUserMenuItem() -
initContent
- Overrides:
initContentin classcom.vaadin.flow.component.Composite<JmixMenuBar>
-
getSubMenu
-
getUser
Returns the current user associated with the user menu.- Returns:
- the current user, or
nullif no user is set
-
setUser
Sets the user for the user menu. If the given user is different from the currently set user, the change is applied, an internal user change handler is called, and aJmixUserMenu.UserChangedEventis fired.- Parameters:
user- the user to be set; can benullto clear the current user
-
userChangedInternal
protected void userChangedInternal() -
updateButton
protected void updateButton() -
updateHeader
protected void updateHeader() -
createHeaderWrapper
protected com.vaadin.flow.component.HasComponents createHeaderWrapper() -
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
-
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
-
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.
-
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
-
getSubPart
Description copied from interface:HasSubPartsReturns a sub part object by its name.- Specified by:
getSubPartin interfaceHasSubParts- Parameters:
name- sub part name, e.g. component id- Returns:
- a sub part object by its name, or
nullif not found
-
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
-
isOpenOnHover
public boolean isOpenOnHover()Determines whether the user menu opens on hover.- Returns:
trueif the menu opens on hover,falseotherwise
-
setOpenOnHover
public void setOpenOnHover(boolean openOnHover) Sets whether the user menu should open when hovered.- Parameters:
openOnHover-trueto make the menu open on hover,falseto disable this behavior
-
setOverlayClassName
- Specified by:
setOverlayClassNamein interfacecom.vaadin.flow.component.shared.HasOverlayClassName
-
addUserChangedListener
public com.vaadin.flow.shared.Registration addUserChangedListener(com.vaadin.flow.component.ComponentEventListener<JmixUserMenu.UserChangedEvent<USER>> listener) -
getItemsDelegate
-