com.vaadin.flow.component.contextmenu.
Class MenuItemBase<C extends ContextMenuBase<C,I,S>,I extends MenuItemBase<C,I,S>,S extends SubMenuBase<C,I,S>>
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- com.vaadin.flow.component.contextmenu.MenuItemBase<C,I,S>
-
Type Parameters:
C
- the context menu typeI
- the menu item typeS
- the sub menu typeAll Implemented Interfaces:
AttachNotifier, DetachNotifier, HasComponents, HasElement, HasEnabled, HasText, Serializable
Direct Known Subclasses:
@Tag(value="vaadin-context-menu-item") public abstract class MenuItemBase<C extends ContextMenuBase<C,I,S>,I extends MenuItemBase<C,I,S>,S extends SubMenuBase<C,I,S>> extends Component implements HasText, HasComponents, HasEnabled
Base class for item component used inside
ContextMenu
s.Author:
Vaadin Ltd.
See Also:
-
-
Constructor Summary
Constructors Constructor and Description MenuItemBase(C contextMenu)
Default constructor
-
Method Summary
All Methods Modifier and Type Method and Description protected abstract S
createSubMenu()
C
getContextMenu()
Gets the context menu component that this item belongs to.
S
getSubMenu()
Gets the sub menu API for this menu item.
boolean
isCheckable()
Gets whether this item toggles a checkmark icon when clicked.
boolean
isChecked()
Gets the checked state of this item.
boolean
isParentItem()
Gets whether this item has a sub menu attached to it or not.
void
setCheckable(boolean checkable)
Sets the checkable state of this menu item.
void
setChecked(boolean checked)
Sets the checked state of this item.
-
Methods inherited from class com.vaadin.flow.component.Component
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, 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.HasComponents
add, add, addComponentAsFirst, addComponentAtIndex, remove, removeAll
-
Methods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabled
-
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
-
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
-
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
-
-
-
-
Constructor Detail
-
MenuItemBase
public MenuItemBase(C contextMenu)
Default constructor
Parameters:
contextMenu
- the context menu to which this item belongs to
-
-
Method Detail
-
getContextMenu
public C getContextMenu()
Gets the context menu component that this item belongs to.
Returns:
the context-menu component
-
getSubMenu
public S getSubMenu()
Gets the sub menu API for this menu item. Adding content to the returned sub menu makes this component a parent item which opens the sub menu overlay. When the sub menu has no content, it won't be rendered.
Returns:
the sub menu that can be opened via this item
-
isParentItem
public boolean isParentItem()
Gets whether this item has a sub menu attached to it or not.
Returns:
true
if this component has a sub menu with content inside it,false
otherwiseSee Also:
-
setCheckable
public void setCheckable(boolean checkable)
Sets the checkable state of this menu item. A checkable item toggles a checkmark icon when clicked. Changes in the checked state can be handled in the item's click handler with
isChecked()
.Setting a checked item un-checkable also makes it un-checked.
Parameters:
checkable
-true
to enable toggling the checked-state of this menu item by clicking,false
to disable it.Throws:
IllegalStateException
- if setting a parent item checkable
-
isCheckable
public boolean isCheckable()
Gets whether this item toggles a checkmark icon when clicked.
Returns:
the checkable state of the item
See Also:
-
setChecked
public void setChecked(boolean checked)
Sets the checked state of this item. A checked item displays a checkmark icon next to it. The checked state is also toggled by clicking the item.
Note that the item needs to be explicitly set as checkable via
setCheckable(boolean)
in order to check it.Parameters:
checked
-true
to check this item,false
to un-check itThrows:
IllegalStateException
- if trying to check the item when it's checkable
-
isChecked
public boolean isChecked()
Gets the checked state of this item. The item can be checked and un-checked with
setChecked(boolean)
or by clicking it when it is checkable. A checked item displays a checkmark icon inside it.Returns:
true
if the item is checked,false
otherwiseSee Also:
-
createSubMenu
protected abstract S createSubMenu()
-
-