Package com.vaadin.browserless.internal
Class GridContextMenuSupport
java.lang.Object
com.vaadin.browserless.internal.GridContextMenuSupport
Helpers for driving a
GridContextMenu the way the grid's client-side
connector does.
For internal use only.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDOM event the grid fires on its target element to let the menu know that the user asked for it.static final StringGrid element property holding the internal id of the column the context menu was opened on.static final StringGrid element property holding the key of the row the context menu was opened on. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetColumnInternalId(Grid<?> grid, String columnKey) Gets the internal id the grid uses for the column with the given key.static GridContextMenu<?> getContextMenu(Grid<?> grid) Gets the context menu added to the given grid.static <Y> StringgetItemKey(Grid<Y> grid, Y item) Gets the key the grid uses for the given item.static voidsetTargetItem(Grid<?> grid, String itemKey, String columnInternalId) Records the row and column the context menu is about, the way the grid does when the browser reports a context menu gesture.
-
Field Details
-
BEFORE_OPEN_EVENT
DOM event the grid fires on its target element to let the menu know that the user asked for it.- See Also:
-
TARGET_ITEM_KEY_PROPERTY
Grid element property holding the key of the row the context menu was opened on. Read byGridContextMenuItemClickEvent.getItem()andGridContextMenuOpenedEvent.getItem().- See Also:
-
TARGET_COLUMN_ID_PROPERTY
Grid element property holding the internal id of the column the context menu was opened on. Read byGridContextMenuOpenedEvent.getColumnId().- See Also:
-
-
Method Details
-
getContextMenu
Gets the context menu added to the given grid.A grid keeps no reference to its context menu, and the menu is not part of the component tree until it opens, so the only link from the grid back to the menu is the listener the menu registers on the grid element for "vaadin-context-menu-before-open".
- Parameters:
grid- the grid whose context menu to get- Returns:
- the context menu of the grid
- Throws:
IllegalStateException- if the grid has no context menu, if it has several, or if the menu cannot be resolved
-
setTargetItem
Records the row and column the context menu is about, the way the grid does when the browser reports a context menu gesture.- Parameters:
grid- the grid the menu is attached toitemKey- key of the row the menu targets, or null for nonecolumnInternalId- internal id of the column the menu targets, or null for none
-
getItemKey
Gets the key the grid uses for the given item.- Type Parameters:
Y- item type- Parameters:
grid- the grid holding the itemitem- the item to get the key for- Returns:
- the key of the item
-
getColumnInternalId
Gets the internal id the grid uses for the column with the given key.- Parameters:
grid- the grid holding the columncolumnKey- the key of the column, as set withGrid.Column.setKey(String)- Returns:
- the internal id of the column
- Throws:
IllegalArgumentException- if the grid has no column with the given keyIllegalStateException- if the column is not visible
-