Package com.vaadin.client.widget.grid
Class DefaultEditorEventHandler<T>
- java.lang.Object
-
- com.vaadin.client.widget.grid.DefaultEditorEventHandler<T>
-
- All Implemented Interfaces:
Grid.Editor.EventHandler<T>
public class DefaultEditorEventHandler<T> extends Object implements Grid.Editor.EventHandler<T>
The default handler for Grid editor events. Offers several overridable protected methods for easier customization.- Since:
- 7.6
- Author:
- Vaadin Ltd
-
-
Field Summary
Fields Modifier and Type Field Description static int
KEYCODE_BUFFERED_SAVE
static int
KEYCODE_CLOSE
static int
KEYCODE_MOVE_HORIZONTAL
static int
KEYCODE_MOVE_VERTICAL
static int
KEYCODE_OPEN
-
Constructor Summary
Constructors Constructor Description DefaultEditorEventHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
editRow(Grid.EditorDomEvent<T> event, int rowIndex, int colIndex)
protected boolean
handleBufferedMoveEvent(Grid.EditorDomEvent<T> event)
Moves the editor to another column if the received event is a move event.protected boolean
handleCloseEvent(Grid.EditorDomEvent<T> event)
Closes the editor if the received event is a close event.boolean
handleEvent(Grid.EditorDomEvent<T> event)
Handles editor-related events in an appropriate way.protected boolean
handleMoveEvent(Grid.EditorDomEvent<T> event)
Moves the editor to another row or another column if the received event is a move event.protected boolean
handleOpenEvent(Grid.EditorDomEvent<T> event)
Opens the editor on the appropriate row if the received event is an open event.protected boolean
isCloseEvent(Grid.EditorDomEvent<T> event)
Returns whether the given event should close the editor.protected boolean
isOpenEvent(Grid.EditorDomEvent<T> event)
Returns whether the given event should open the editor.protected boolean
isTouchOpenEvent(Grid.EditorDomEvent<T> event)
Returns whether the given event is a touch event that should open the editor.
-
-
-
Field Detail
-
KEYCODE_OPEN
public static final int KEYCODE_OPEN
- See Also:
- Constant Field Values
-
KEYCODE_MOVE_VERTICAL
public static final int KEYCODE_MOVE_VERTICAL
- See Also:
- Constant Field Values
-
KEYCODE_CLOSE
public static final int KEYCODE_CLOSE
- See Also:
- Constant Field Values
-
KEYCODE_MOVE_HORIZONTAL
public static final int KEYCODE_MOVE_HORIZONTAL
- See Also:
- Constant Field Values
-
KEYCODE_BUFFERED_SAVE
public static final int KEYCODE_BUFFERED_SAVE
- See Also:
- Constant Field Values
-
-
Method Detail
-
isTouchOpenEvent
protected boolean isTouchOpenEvent(Grid.EditorDomEvent<T> event)
Returns whether the given event is a touch event that should open the editor.- Parameters:
event
- the received event- Returns:
- whether the event is a touch open event
-
isOpenEvent
protected boolean isOpenEvent(Grid.EditorDomEvent<T> event)
Returns whether the given event should open the editor. The default implementation returns true if and only if the event is a doubleclick or if it is a keydown event and the keycode isKEYCODE_OPEN
.- Parameters:
event
- the received event- Returns:
- true if the event is an open event, false otherwise
-
handleOpenEvent
protected boolean handleOpenEvent(Grid.EditorDomEvent<T> event)
Opens the editor on the appropriate row if the received event is an open event. The default implementation usesisOpenEvent
.- Parameters:
event
- the received event- Returns:
- true if this method handled the event and nothing else should be done, false otherwise
-
handleMoveEvent
protected boolean handleMoveEvent(Grid.EditorDomEvent<T> event)
Moves the editor to another row or another column if the received event is a move event. The default implementation moves the editor to the clicked row if the event is a click; otherwise, if the event is a keydown and the keycode isKEYCODE_MOVE_VERTICAL
, moves the editor one row up or down if the shift key is pressed or not, respectively. Keydown event with keycodeKEYCODE_MOVE_HORIZONTAL
moves the editor left or right if shift key is pressed or not, respectively.- Parameters:
event
- the received event- Returns:
- true if this method handled the event and nothing else should be done, false otherwise
-
handleBufferedMoveEvent
protected boolean handleBufferedMoveEvent(Grid.EditorDomEvent<T> event)
Moves the editor to another column if the received event is a move event. By default the editor is moved on a keydown event with keycodeKEYCODE_MOVE_HORIZONTAL
. This moves the editor left or right if shift key is pressed or not, respectively.- Parameters:
event
- the received event- Returns:
- true if this method handled the event and nothing else should be done, false otherwise
-
isCloseEvent
protected boolean isCloseEvent(Grid.EditorDomEvent<T> event)
Returns whether the given event should close the editor. The default implementation returns true if and only if the event is a keydown event and the keycode isKEYCODE_CLOSE
.- Parameters:
event
- the received event- Returns:
- true if the event is a close event, false otherwise
-
handleCloseEvent
protected boolean handleCloseEvent(Grid.EditorDomEvent<T> event)
Closes the editor if the received event is a close event. The default implementation usesisCloseEvent
.- Parameters:
event
- the received event- Returns:
- true if this method handled the event and nothing else should be done, false otherwise
-
editRow
protected void editRow(Grid.EditorDomEvent<T> event, int rowIndex, int colIndex)
-
handleEvent
public boolean handleEvent(Grid.EditorDomEvent<T> event)
Description copied from interface:Grid.Editor.EventHandler
Handles editor-related events in an appropriate way. Opens, moves, or closes the editor based on the given event.- Specified by:
handleEvent
in interfaceGrid.Editor.EventHandler<T>
- Parameters:
event
- the received event- Returns:
- true if the event was handled and nothing else should be done, false otherwise
-
-