com.vaadin.flow.component.grid.contextmenu.
Class GridContextMenu<T>
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- com.vaadin.flow.component.contextmenu.GeneratedVaadinContextMenu<C>
-
- com.vaadin.flow.component.contextmenu.ContextMenuBase<GridContextMenu<T>,GridMenuItem<T>,GridSubMenu<T>>
-
- com.vaadin.flow.component.grid.contextmenu.GridContextMenu<T>
-
All Implemented Interfaces:
AttachNotifier, ClickNotifier<GridContextMenu<T>>, DetachNotifier, HasComponents, HasElement, HasEnabled, HasStyle, Serializable
public class GridContextMenu<T> extends ContextMenuBase<GridContextMenu<T>,GridMenuItem<T>,GridSubMenu<T>>
Server-side component for
<vaadin-context-menu>
to be used withGrid
.Author:
Vaadin Ltd.
See Also:
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static class
GridContextMenu.GridContextMenuItemClickEvent<T>
Event that is fired when a
GridMenuItem
is clicked inside aGridContextMenu
.-
Nested classes/interfaces inherited from class com.vaadin.flow.component.contextmenu.GeneratedVaadinContextMenu
GeneratedVaadinContextMenu.OpenedChangeEvent<R extends GeneratedVaadinContextMenu<R>>
-
-
Constructor Summary
Constructors Constructor and Description GridContextMenu()
Creates an empty context menu to be used with a Grid.
GridContextMenu(Grid<T> target)
Creates an empty context menu with the given target component.
-
Method Summary
All Methods Modifier and Type Method and Description GridMenuItem<T>
addItem(Component component, ComponentEventListener<GridContextMenu.GridContextMenuItemClickEvent<T>> clickListener)
Adds a new item component with the given component and click listener to the context menu overlay.
GridMenuItem<T>
addItem(String text, ComponentEventListener<GridContextMenu.GridContextMenuItemClickEvent<T>> clickListener)
Adds a new item component with the given text content and click listener to the context menu overlay.
protected MenuManager<GridContextMenu<T>,GridMenuItem<T>,GridSubMenu<T>>
createMenuManager(SerializableRunnable contentReset)
Creates a menu manager instance which contains logic to control the menu content.
void
setTarget(Component target)
Sets the target component for this context menu.
-
Methods inherited from class com.vaadin.flow.component.contextmenu.ContextMenuBase
add, addComponentAtIndex, addItem, addItem, addOpenedChangeListener, close, getChildren, getItems, getMenuManager, getTarget, isOpened, isOpenOnClick, remove, removeAll, setOpenOnClick
-
Methods inherited from class com.vaadin.flow.component.contextmenu.GeneratedVaadinContextMenu
getCloseOnString, getListenOnJsonObject, getOpenOnString, getSelectorString, isOpenedBoolean, open, setCloseOn, setListenOn, setOpenOn, setSelector
-
Methods inherited from class com.vaadin.flow.component.Component
addListener, fireEvent, from, get, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getUI, hasListener, 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, addComponentAsFirst
-
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.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Methods inherited from interface com.vaadin.flow.component.ClickNotifier
addClickListener, addClickShortcut
-
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
-
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
-
-
-
-
Constructor Detail
-
GridContextMenu
public GridContextMenu()
Creates an empty context menu to be used with a Grid.
-
-
Method Detail
-
setTarget
public void setTarget(Component target)
Sets the target component for this context menu.
By default, the context menu can be opened with a right click or a long touch on the target component.
Overrides:
setTarget
in classContextMenuBase<GridContextMenu<T>,GridMenuItem<T>,GridSubMenu<T>>
Parameters:
target
- the target component for this context menu, can benull
to remove the targetThrows:
IllegalArgumentException
- if the given target is not an instance ofGrid
-
addItem
public GridMenuItem<T> addItem(String text, ComponentEventListener<GridContextMenu.GridContextMenuItemClickEvent<T>> clickListener)
Adds a new item component with the given text content and click listener to the context menu overlay.
This is a convenience method for the use case where you have a list of highlightable
GridMenuItem
s inside the overlay. If you want to configure the contents of the overlay without wrapping them insideGridMenuItem
s, or if you just want to add some non-highlightable components between the items, use theContextMenuBase.add(Component...)
method.Parameters:
text
- the text content for the new itemclickListener
- the handler for clicking the new item, can benull
to not add listenerReturns:
the added
GridMenuItem
componentSee Also:
addItem(Component, ComponentEventListener)
,ContextMenuBase.add(Component...)
,SubMenuBase.add(Component...)
-
addItem
public GridMenuItem<T> addItem(Component component, ComponentEventListener<GridContextMenu.GridContextMenuItemClickEvent<T>> clickListener)
Adds a new item component with the given component and click listener to the context menu overlay.
This is a convenience method for the use case where you have a list of highlightable
GridMenuItem
s inside the overlay. If you want to configure the contents of the overlay without wrapping them insideGridMenuItem
s, or if you just want to add some non-highlightable components between the items, use theContextMenuBase.add(Component...)
method.Parameters:
component
- the component inside the new itemclickListener
- the handler for clicking the new item, can benull
to not add listenerReturns:
the added
GridMenuItem
componentSee Also:
addItem(String, ComponentEventListener)
,ContextMenuBase.add(Component...)
,SubMenuBase.add(Component...)
-
createMenuManager
protected MenuManager<GridContextMenu<T>,GridMenuItem<T>,GridSubMenu<T>> createMenuManager(SerializableRunnable contentReset)
Description copied from class:
ContextMenuBase
Creates a menu manager instance which contains logic to control the menu content.
Specified by:
createMenuManager
in classContextMenuBase<GridContextMenu<T>,GridMenuItem<T>,GridSubMenu<T>>
Returns:
a new menu manager instance
-
-