Class AbstractDropdownButton
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<JmixMenuBar>
io.jmix.flowui.kit.component.dropdownbutton.AbstractDropdownButton
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier
,com.vaadin.flow.component.BlurNotifier<AbstractDropdownButton>
,com.vaadin.flow.component.DetachNotifier
,com.vaadin.flow.component.Focusable<AbstractDropdownButton>
,com.vaadin.flow.component.FocusNotifier<AbstractDropdownButton>
,com.vaadin.flow.component.HasElement
,com.vaadin.flow.component.HasEnabled
,com.vaadin.flow.component.HasSize
,com.vaadin.flow.component.HasStyle
,com.vaadin.flow.component.HasText
,com.vaadin.flow.component.HasTheme
,com.vaadin.flow.component.shared.HasOverlayClassName
,DropdownButtonComponent
,HasSubParts
,HasTitle
,Serializable
- Direct Known Subclasses:
ComboButton
,DropdownButton
public abstract class AbstractDropdownButton
extends com.vaadin.flow.component.Composite<JmixMenuBar>
implements DropdownButtonComponent, com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, HasTitle, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasTheme, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.shared.HasOverlayClassName, com.vaadin.flow.component.HasText, com.vaadin.flow.component.Focusable<AbstractDropdownButton>
An abstract base class for dropdown button components, providing functionality for managing dropdown items,
icons, styles, and various component behaviors. It serves as a customizable foundation for components such
as dropdown buttons and combo buttons.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
protected static class
protected static class
protected static interface
protected static interface
protected static class
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>
Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasText
com.vaadin.flow.component.HasText.WhiteSpace
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
protected JmixMenuItem
protected com.vaadin.flow.component.icon.Icon
protected List<AbstractDropdownButton.HasMenuItem>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.Registration
addAttachListener
(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.AttachEvent> listener) void
addClassName
(String className) void
addClassNames
(String... classNames) com.vaadin.flow.shared.Registration
addDetachListener
(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.DetachEvent> listener) com.vaadin.flow.component.ShortcutRegistration
addFocusShortcut
(com.vaadin.flow.component.Key key, com.vaadin.flow.component.KeyModifier... keyModifiers) Adds a new dropdown item with the specified identifier and component content.Adds a new dropdown item with the specified identifier, component content, and position index.addItem
(String id, com.vaadin.flow.component.Component component, Consumer<DropdownButtonItem.ClickEvent> componentEventListener) Adds a new dropdown item with the specified identifier, content component, and a click event listener.addItem
(String id, com.vaadin.flow.component.Component component, Consumer<DropdownButtonItem.ClickEvent> componentEventListener, int index) Adds a new dropdown item with the specified identifier, component content, click event listener, and position index.Adds a new dropdown item with the specified identifier and action.Adds a new dropdown item with the specified identifier, action, and index.Adds a new dropdown item with the specified identifier and text.Adds a new dropdown item with the specified identifier, text, and index.addItem
(String id, String text, Consumer<DropdownButtonItem.ClickEvent> componentEventListener) Adds a new dropdown item with the specified identifier, text, and a click event listener.addItem
(String id, String text, Consumer<DropdownButtonItem.ClickEvent> componentEventListener, int index) Adds a new dropdown item with the specified identifier, text, click event listener, and position index.protected void
addItemInternal
(AbstractDropdownButton.HasMenuItem item, int index) void
Adds a visual separator to the dropdown menu.void
addSeparatorAtIndex
(int index) Adds a visual separator at the specified index in the dropdown menu.void
addThemeName
(String themeName) void
addThemeNames
(String... themeNames) void
blur()
protected com.vaadin.flow.component.contextmenu.MenuItem
createComponentMenuItem
(String id, com.vaadin.flow.component.Component content, int index) protected com.vaadin.flow.component.contextmenu.MenuItem
createTextMenuItem
(String id, String text, int index) void
focus()
com.vaadin.flow.dom.ClassList
protected abstract JmixMenuItem
Optional<com.vaadin.flow.component.Unit>
com.vaadin.flow.component.icon.Icon
getIcon()
Returns the icon associated with the dropdown button item, if present.Returns the dropdown item with the specified identifier.getItems()
Returns a list of all items currently present in the dropdown button component.int
com.vaadin.flow.dom.ThemeList
getWidth()
Optional<com.vaadin.flow.component.Unit>
boolean
hasClassName
(String className) boolean
hasThemeName
(String themeName) boolean
boolean
boolean
Determines whether the dropdown menu is configured to open when the user hovers over the component.void
remove
(DropdownButtonItem item) Removes the specified item from the collection or list.void
remove
(DropdownButtonItem... items) Removes the specified items from the dropdown button's list of items.void
Removes the specified item identified by the given item ID.void
Removes all items from the dropdown button component.boolean
removeClassName
(String className) void
removeClassNames
(String... classNames) boolean
removeThemeName
(String themeName) void
removeThemeNames
(String... themeNames) void
setClassName
(String className) void
setClassName
(String className, boolean set) void
setEnabled
(boolean enabled) void
setHeight
(float height, com.vaadin.flow.component.Unit unit) void
void
void
setMaxHeight
(float maxHeight, com.vaadin.flow.component.Unit unit) void
setMaxHeight
(String maxHeight) void
setMaxWidth
(float maxWidth, com.vaadin.flow.component.Unit unit) void
setMaxWidth
(String maxWidth) void
setMinHeight
(float minHeight, com.vaadin.flow.component.Unit unit) void
setMinHeight
(String minHeight) void
setMinWidth
(float minWidth, com.vaadin.flow.component.Unit unit) void
setMinWidth
(String minWidth) void
setOpenOnHover
(boolean openOnHover) Configures whether the dropdown menu opens when the user hovers over the button.void
setOverlayClassName
(String overlayClassName) void
void
void
setTabIndex
(int tabIndex) void
setThemeName
(String themeName) void
setThemeName
(String themeName, boolean set) void
setWidth
(float width, com.vaadin.flow.component.Unit unit) void
void
Methods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElement, initContent
Methods 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, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListener
Methods inherited from interface io.jmix.flowui.kit.component.dropdownbutton.DropdownButtonComponent
getSubPart, setIcon
Methods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListener
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
Methods inherited from interface com.vaadin.flow.component.HasStyle
getStyle
Methods inherited from interface com.vaadin.flow.component.HasText
getText, getWhiteSpace, setText, setWhiteSpace
-
Field Details
-
ATTRIBUTE_JMIX_ROLE_NAME
- See Also:
-
items
-
dropdownItem
-
iconComponent
protected com.vaadin.flow.component.icon.Icon iconComponent
-
-
Constructor Details
-
AbstractDropdownButton
public AbstractDropdownButton()
-
-
Method Details
-
getDropdownItem
-
addItem
Description copied from interface:DropdownButtonComponent
Adds a new dropdown item with the specified identifier and action.- Specified by:
addItem
in interfaceDropdownButtonComponent
- Parameters:
id
- the identifier for the dropdown itemaction
- the action to associate with the dropdown item- Returns:
- the created dropdown item
-
addItem
Description copied from interface:DropdownButtonComponent
Adds a new dropdown item with the specified identifier, action, and index.- Specified by:
addItem
in interfaceDropdownButtonComponent
- Parameters:
id
- the identifier for the dropdown itemaction
- the action to associate with the dropdown itemindex
- the position at which the dropdown item will be added- Returns:
- the created dropdown item
-
addItem
Description copied from interface:DropdownButtonComponent
Adds a new dropdown item with the specified identifier and text.- Specified by:
addItem
in interfaceDropdownButtonComponent
- Parameters:
id
- the identifier for the dropdown itemtext
- the text to display for the dropdown item- Returns:
- the created dropdown item
-
addItem
Description copied from interface:DropdownButtonComponent
Adds a new dropdown item with the specified identifier, text, and index.- Specified by:
addItem
in interfaceDropdownButtonComponent
- Parameters:
id
- the identifier for the dropdown itemtext
- the text to display for the dropdown itemindex
- the position at which the dropdown item will be added- Returns:
- the created dropdown item
-
addItem
public DropdownButtonItem addItem(String id, String text, Consumer<DropdownButtonItem.ClickEvent> componentEventListener) Description copied from interface:DropdownButtonComponent
Adds a new dropdown item with the specified identifier, text, and a click event listener.- Specified by:
addItem
in interfaceDropdownButtonComponent
- Parameters:
id
- the unique identifier for the dropdown itemtext
- the text displayed for the dropdown itemcomponentEventListener
- the listener to handle click events for the dropdown item- Returns:
- the created dropdown item instance
-
addItem
public DropdownButtonItem addItem(String id, String text, Consumer<DropdownButtonItem.ClickEvent> componentEventListener, int index) Description copied from interface:DropdownButtonComponent
Adds a new dropdown item with the specified identifier, text, click event listener, and position index.- Specified by:
addItem
in interfaceDropdownButtonComponent
- Parameters:
id
- the unique identifier for the dropdown itemtext
- the text to display for the dropdown itemcomponentEventListener
- the listener to handle click events for the dropdown itemindex
- the position at which the dropdown item will be added- Returns:
- the created dropdown item instance
-
addItem
Description copied from interface:DropdownButtonComponent
Adds a new dropdown item with the specified identifier and component content.- Specified by:
addItem
in interfaceDropdownButtonComponent
- Parameters:
id
- the unique identifier for the dropdown itemcomponent
- the component to be used as content for the dropdown item- Returns:
- the created dropdown item instance
-
addItem
public DropdownButtonItem addItem(String id, com.vaadin.flow.component.Component component, int index) Description copied from interface:DropdownButtonComponent
Adds a new dropdown item with the specified identifier, component content, and position index.- Specified by:
addItem
in interfaceDropdownButtonComponent
- Parameters:
id
- the unique identifier for the dropdown itemcomponent
- the component to be used as content for the dropdown itemindex
- the position at which the dropdown item will be added- Returns:
- the created dropdown item instance
-
addItem
public DropdownButtonItem addItem(String id, com.vaadin.flow.component.Component component, Consumer<DropdownButtonItem.ClickEvent> componentEventListener) Description copied from interface:DropdownButtonComponent
Adds a new dropdown item with the specified identifier, content component, and a click event listener.- Specified by:
addItem
in interfaceDropdownButtonComponent
- Parameters:
id
- the unique identifier for the dropdown itemcomponent
- the component to be used as content for the dropdown itemcomponentEventListener
- the listener to handle click events for the dropdown item- Returns:
- the created dropdown item instance
-
addItem
public DropdownButtonItem addItem(String id, com.vaadin.flow.component.Component component, Consumer<DropdownButtonItem.ClickEvent> componentEventListener, int index) Description copied from interface:DropdownButtonComponent
Adds a new dropdown item with the specified identifier, component content, click event listener, and position index.- Specified by:
addItem
in interfaceDropdownButtonComponent
- Parameters:
id
- the unique identifier for the dropdown itemcomponent
- the component to be used as content for the dropdown itemcomponentEventListener
- the listener to handle click events for the dropdown itemindex
- the position at which the dropdown item will be added- Returns:
- the created dropdown item instance
-
createComponentMenuItem
protected com.vaadin.flow.component.contextmenu.MenuItem createComponentMenuItem(String id, com.vaadin.flow.component.Component content, int index) -
createTextMenuItem
-
addItemInternal
-
getItem
Description copied from interface:DropdownButtonComponent
Returns the dropdown item with the specified identifier.- Specified by:
getItem
in interfaceDropdownButtonComponent
- Parameters:
itemId
- the unique identifier of the dropdown item to retrieve- Returns:
- the item with the given identifier, or
null
if no item with the specified ID is found
-
getItems
Description copied from interface:DropdownButtonComponent
Returns a list of all items currently present in the dropdown button component.- Specified by:
getItems
in interfaceDropdownButtonComponent
- Returns:
- a list of
DropdownButtonItem
instances representing all items in the dropdown.
-
remove
Description copied from interface:DropdownButtonComponent
Removes the specified item identified by the given item ID.- Specified by:
remove
in interfaceDropdownButtonComponent
- Parameters:
itemId
- the unique identifier of the item to be removed
-
remove
Description copied from interface:DropdownButtonComponent
Removes the specified item from the collection or list.- Specified by:
remove
in interfaceDropdownButtonComponent
- Parameters:
item
- the item to be removed
-
remove
Description copied from interface:DropdownButtonComponent
Removes the specified items from the dropdown button's list of items.- Specified by:
remove
in interfaceDropdownButtonComponent
- Parameters:
items
- the items to be removed from the dropdown button. Each item represents a DropdownButtonItem object to be excluded from the list.
-
removeAll
public void removeAll()Description copied from interface:DropdownButtonComponent
Removes all items from the dropdown button component.- Specified by:
removeAll
in interfaceDropdownButtonComponent
-
addSeparator
public void addSeparator()Description copied from interface:DropdownButtonComponent
Adds a visual separator to the dropdown menu. Separators are used to group related items visually.- Specified by:
addSeparator
in interfaceDropdownButtonComponent
-
addSeparatorAtIndex
public void addSeparatorAtIndex(int index) Description copied from interface:DropdownButtonComponent
Adds a visual separator at the specified index in the dropdown menu. Separators are used to visually group related items within the menu.- Specified by:
addSeparatorAtIndex
in interfaceDropdownButtonComponent
- Parameters:
index
- the position at which the separator will be added. The index must be a non-negative integer less than or equal to the current number of items.
-
addAttachListener
public com.vaadin.flow.shared.Registration addAttachListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.AttachEvent> listener) - Specified by:
addAttachListener
in interfacecom.vaadin.flow.component.AttachNotifier
-
isAttached
public boolean isAttached()- Overrides:
isAttached
in classcom.vaadin.flow.component.Component
-
addDetachListener
public com.vaadin.flow.shared.Registration addDetachListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.DetachEvent> listener) - Specified by:
addDetachListener
in interfacecom.vaadin.flow.component.DetachNotifier
-
getIcon
@Nullable public com.vaadin.flow.component.icon.Icon getIcon()Description copied from interface:DropdownButtonComponent
Returns the icon associated with the dropdown button item, if present.- Specified by:
getIcon
in interfaceDropdownButtonComponent
- Returns:
- the icon of the dropdown button item, or
null
if no icon is set
-
setClassName
- Specified by:
setClassName
in interfacecom.vaadin.flow.component.HasStyle
-
setClassName
- Specified by:
setClassName
in interfacecom.vaadin.flow.component.HasStyle
-
getClassName
- Specified by:
getClassName
in interfacecom.vaadin.flow.component.HasStyle
-
addClassName
- Specified by:
addClassName
in interfacecom.vaadin.flow.component.HasStyle
-
removeClassName
- Specified by:
removeClassName
in interfacecom.vaadin.flow.component.HasStyle
-
getClassNames
public com.vaadin.flow.dom.ClassList getClassNames()- Specified by:
getClassNames
in interfacecom.vaadin.flow.component.HasStyle
-
addClassNames
- Specified by:
addClassNames
in interfacecom.vaadin.flow.component.HasStyle
-
removeClassNames
- Specified by:
removeClassNames
in interfacecom.vaadin.flow.component.HasStyle
-
hasClassName
- Specified by:
hasClassName
in interfacecom.vaadin.flow.component.HasStyle
-
getOverlayClassName
- Specified by:
getOverlayClassName
in interfacecom.vaadin.flow.component.shared.HasOverlayClassName
-
setOverlayClassName
- Specified by:
setOverlayClassName
in interfacecom.vaadin.flow.component.shared.HasOverlayClassName
-
setThemeName
- Specified by:
setThemeName
in interfacecom.vaadin.flow.component.HasTheme
-
setThemeName
- Specified by:
setThemeName
in interfacecom.vaadin.flow.component.HasTheme
-
getThemeName
- Specified by:
getThemeName
in interfacecom.vaadin.flow.component.HasTheme
-
addThemeName
- Specified by:
addThemeName
in interfacecom.vaadin.flow.component.HasTheme
-
removeThemeName
- Specified by:
removeThemeName
in interfacecom.vaadin.flow.component.HasTheme
-
hasThemeName
- Specified by:
hasThemeName
in interfacecom.vaadin.flow.component.HasTheme
-
getThemeNames
public com.vaadin.flow.dom.ThemeList getThemeNames()- Specified by:
getThemeNames
in interfacecom.vaadin.flow.component.HasTheme
-
addThemeNames
- Specified by:
addThemeNames
in interfacecom.vaadin.flow.component.HasTheme
-
removeThemeNames
- Specified by:
removeThemeNames
in interfacecom.vaadin.flow.component.HasTheme
-
setOpenOnHover
public void setOpenOnHover(boolean openOnHover) Description copied from interface:DropdownButtonComponent
Configures whether the dropdown menu opens when the user hovers over the button.- Specified by:
setOpenOnHover
in interfaceDropdownButtonComponent
- Parameters:
openOnHover
- iftrue
, the dropdown menu will open on hover; iffalse
, it will only open on click
-
isOpenOnHover
public boolean isOpenOnHover()Description copied from interface:DropdownButtonComponent
Determines whether the dropdown menu is configured to open when the user hovers over the component.- Specified by:
isOpenOnHover
in interfaceDropdownButtonComponent
- Returns:
true
if the dropdown opens on hover,false
otherwise
-
setEnabled
public void setEnabled(boolean enabled) - Specified by:
setEnabled
in interfacecom.vaadin.flow.component.HasEnabled
-
isEnabled
public boolean isEnabled()- Specified by:
isEnabled
in interfacecom.vaadin.flow.component.HasEnabled
-
setTabIndex
public void setTabIndex(int tabIndex) - Specified by:
setTabIndex
in interfacecom.vaadin.flow.component.Focusable<AbstractDropdownButton>
-
getTabIndex
public int getTabIndex()- Specified by:
getTabIndex
in interfacecom.vaadin.flow.component.Focusable<AbstractDropdownButton>
-
focus
public void focus()- Specified by:
focus
in interfacecom.vaadin.flow.component.Focusable<AbstractDropdownButton>
-
blur
public void blur()- Specified by:
blur
in interfacecom.vaadin.flow.component.Focusable<AbstractDropdownButton>
-
addFocusShortcut
public com.vaadin.flow.component.ShortcutRegistration addFocusShortcut(com.vaadin.flow.component.Key key, com.vaadin.flow.component.KeyModifier... keyModifiers) - Specified by:
addFocusShortcut
in interfacecom.vaadin.flow.component.Focusable<AbstractDropdownButton>
-
setWidth
- Specified by:
setWidth
in interfacecom.vaadin.flow.component.HasSize
-
setWidth
public void setWidth(float width, com.vaadin.flow.component.Unit unit) - Specified by:
setWidth
in interfacecom.vaadin.flow.component.HasSize
-
setMinWidth
- Specified by:
setMinWidth
in interfacecom.vaadin.flow.component.HasSize
-
setMinWidth
public void setMinWidth(float minWidth, com.vaadin.flow.component.Unit unit) - Specified by:
setMinWidth
in interfacecom.vaadin.flow.component.HasSize
-
setMaxWidth
- Specified by:
setMaxWidth
in interfacecom.vaadin.flow.component.HasSize
-
setMaxWidth
public void setMaxWidth(float maxWidth, com.vaadin.flow.component.Unit unit) - Specified by:
setMaxWidth
in interfacecom.vaadin.flow.component.HasSize
-
getWidth
- Specified by:
getWidth
in interfacecom.vaadin.flow.component.HasSize
-
getMinWidth
- Specified by:
getMinWidth
in interfacecom.vaadin.flow.component.HasSize
-
getMaxWidth
- Specified by:
getMaxWidth
in interfacecom.vaadin.flow.component.HasSize
-
getWidthUnit
- Specified by:
getWidthUnit
in interfacecom.vaadin.flow.component.HasSize
-
setHeight
- Specified by:
setHeight
in interfacecom.vaadin.flow.component.HasSize
-
setHeight
public void setHeight(float height, com.vaadin.flow.component.Unit unit) - Specified by:
setHeight
in interfacecom.vaadin.flow.component.HasSize
-
setMinHeight
- Specified by:
setMinHeight
in interfacecom.vaadin.flow.component.HasSize
-
setMinHeight
public void setMinHeight(float minHeight, com.vaadin.flow.component.Unit unit) - Specified by:
setMinHeight
in interfacecom.vaadin.flow.component.HasSize
-
setMaxHeight
- Specified by:
setMaxHeight
in interfacecom.vaadin.flow.component.HasSize
-
setMaxHeight
public void setMaxHeight(float maxHeight, com.vaadin.flow.component.Unit unit) - Specified by:
setMaxHeight
in interfacecom.vaadin.flow.component.HasSize
-
getHeight
- Specified by:
getHeight
in interfacecom.vaadin.flow.component.HasSize
-
getMinHeight
- Specified by:
getMinHeight
in interfacecom.vaadin.flow.component.HasSize
-
getMaxHeight
- Specified by:
getMaxHeight
in interfacecom.vaadin.flow.component.HasSize
-
getHeightUnit
- Specified by:
getHeightUnit
in interfacecom.vaadin.flow.component.HasSize
-
setSizeFull
public void setSizeFull()- Specified by:
setSizeFull
in interfacecom.vaadin.flow.component.HasSize
-
setWidthFull
public void setWidthFull()- Specified by:
setWidthFull
in interfacecom.vaadin.flow.component.HasSize
-
setHeightFull
public void setHeightFull()- Specified by:
setHeightFull
in interfacecom.vaadin.flow.component.HasSize
-
setSizeUndefined
public void setSizeUndefined()- Specified by:
setSizeUndefined
in interfacecom.vaadin.flow.component.HasSize
-