Package com.storedobject.ui
Class RightClickMenu<T>
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.contextmenu.ContextMenuBase<com.vaadin.flow.component.grid.contextmenu.GridContextMenu<T>,com.vaadin.flow.component.grid.contextmenu.GridMenuItem<T>,com.vaadin.flow.component.grid.contextmenu.GridSubMenu<T>>
com.vaadin.flow.component.grid.contextmenu.GridContextMenu<T>
com.storedobject.ui.RightClickMenu<T>
- Type Parameters:
T- The type of data associated with the grid rows and menu items.
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasComponents,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasStyle,Serializable
- Direct Known Subclasses:
ItemContextMenu,ItemTypeContextMenu
public class RightClickMenu<T>
extends com.vaadin.flow.component.grid.contextmenu.GridContextMenu<T>
A specialized context menu that appears on right-click actions within a grid. Typically, instances of
RightClickButtons are added to this menu.
This menu dynamically updates its content based on specified predicates and actions of the RightClickButtons.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.grid.contextmenu.GridContextMenu
com.vaadin.flow.component.grid.contextmenu.GridContextMenu.GridContextMenuItemClickEvent<T>, com.vaadin.flow.component.grid.contextmenu.GridContextMenu.GridContextMenuOpenedEvent<T>Nested classes/interfaces inherited from class com.vaadin.flow.component.contextmenu.ContextMenuBase
com.vaadin.flow.component.contextmenu.ContextMenuBase.OpenedChangeEvent<TComponent extends com.vaadin.flow.component.contextmenu.ContextMenuBase<TComponent,?, ?>> -
Field Summary
Fields inherited from class com.vaadin.flow.component.contextmenu.ContextMenuBase
EVENT_DETAIL -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance of the RightClickMenu.RightClickMenu(com.vaadin.flow.component.grid.Grid<T> grid) Creates a new instance of the RightClickMenu and associates it with the specified grid. -
Method Summary
Modifier and TypeMethodDescriptionadd(RightClickButton<T> button) Adds a new button to the right-click menu and configures its behavior.voidaddCustomContentHandler(com.vaadin.flow.function.SerializablePredicate<T> customContentHandler) Adds a custom content handler for the right-click menu.buttons()remove(RightClickButton<T> button) Removes the specified button and its associated menu item from the right-click menu.voidResets the custom content handler for the right-click menu.voidsetDynamicContentHandler(com.vaadin.flow.function.SerializablePredicate<T> dynamicContentHandler) Any call to this method will raise a runtime exception because the menu automatically manages visibility of theRightClickButtons contained in it.final voidsetTarget(com.vaadin.flow.component.Component target) Methods inherited from class com.vaadin.flow.component.grid.contextmenu.GridContextMenu
addGridContextMenuOpenedListener, addItem, addItem, createMenuManager, getDynamicContentHandler, onBeforeOpenMenuMethods inherited from class com.vaadin.flow.component.contextmenu.ContextMenuBase
add, add, add, addComponent, addComponent, addComponentAsFirst, addComponentAtIndex, addItem, addItem, addOpenedChangeListener, addSeparator, close, getChildren, getItems, getMenuManager, getTarget, isOpened, isOpenOnClick, remove, removeAll, setOpenOnClickMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getElement, 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.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasComponents
removeMethods 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.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Constructor Details
-
RightClickMenu
public RightClickMenu()Constructs a new instance of the RightClickMenu. This constructor initializes the context menu with default settings and prepares it to dynamically update its content based on custom predicates associated with menu items. -
RightClickMenu
Creates a new instance of the RightClickMenu and associates it with the specified grid. The menu updates dynamically based on the provided grid's context, showing or hiding menu items based on the logic in their associated predicates.- Parameters:
grid- the grid to which this right-clicks menu will be attached and whose context will drive the menu's dynamic behavior
-
-
Method Details
-
setTarget
public final void setTarget(com.vaadin.flow.component.Component target) - Overrides:
setTargetin classcom.vaadin.flow.component.grid.contextmenu.GridContextMenu<T>
-
setDynamicContentHandler
public void setDynamicContentHandler(com.vaadin.flow.function.SerializablePredicate<T> dynamicContentHandler) Any call to this method will raise a runtime exception because the menu automatically manages visibility of theRightClickButtons contained in it. However, you can add one or more custom content handlers viaaddCustomContentHandler(SerializablePredicate)for handling visibility of the items other thanRightClickButtons.- Overrides:
setDynamicContentHandlerin classcom.vaadin.flow.component.grid.contextmenu.GridContextMenu<T>- Parameters:
dynamicContentHandler- aSerializablePredicateinstance.
-
addCustomContentHandler
public void addCustomContentHandler(com.vaadin.flow.function.SerializablePredicate<T> customContentHandler) Adds a custom content handler for the right-click menu. The custom content handler is a predicate that allows for dynamically determining whether certain menu items should be displayed based on given conditions.- Parameters:
customContentHandler- aSerializablePredicateused to evaluate conditions for the menu's dynamic content. This predicate is invoked to determine which menu items should be displayed based on the current context.
-
resetCustomContentHandler
public void resetCustomContentHandler()Resets the custom content handler for the right-click menu. This method removes any previously set custom content handler by setting the internal reference to null. Once invoked, the menu will no longer use any custom logic to dynamically determine the visibility or behavior of its items based on a custom predicate. -
add
Adds a new button to the right-click menu and configures its behavior.- Parameters:
button- the right-click button to be added to the menu- Returns:
- the instance of the RightClickMenu with the newly added button
-
remove
Removes the specified button and its associated menu item from the right-click menu.- Parameters:
button- the button to be removed from the right-click menu- Returns:
- the current instance of the RightClickMenu after the button has been removed
-
buttons
-