Package com.vaadin.client.widgets
Class Grid.Editor<T>
- java.lang.Object
-
- com.vaadin.client.widgets.Grid.Editor<T>
-
- Type Parameters:
T
- the row type of the grid
- All Implemented Interfaces:
DeferredWorker
public static class Grid.Editor<T> extends Object implements DeferredWorker
An editor UI for Grid rows. A single Grid row at a time can be opened for editing.- Since:
- 7.6
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Grid.Editor.EventHandler<T>
A handler for events related to the Grid editor.protected static class
Grid.Editor.State
-
Field Summary
Fields Modifier and Type Field Description static int
KEYCODE_HIDE
static int
KEYCODE_SHOW
-
Constructor Summary
Constructors Constructor Description Editor()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
cancel()
Cancels the currently active edit and hides the editor.void
clearEditorColumnErrors()
protected com.google.gwt.dom.client.Element
createCell(com.google.gwt.dom.client.TableCellElement td)
Creates an editor cell corresponding to the given table cell.void
editRow(int rowIndex)
If a cell of this Grid had focus once this editRow call was triggered, the editor component at the previously focused column index will be focused.void
editRow(int rowIndex, int columnIndexDOM)
Opens the editor over the row with the given index and attempts to focus the editor widget in the given column index.String
getCancelCaption()
protected int
getElementColumn(com.google.gwt.dom.client.Element e)
Grid.Editor.EventHandler<T>
getEventHandler()
Returns the event handler of this Editor.EditorHandler<T>
getHandler()
Returns the handler responsible for binding data and editor widgets to this editor.int
getRow()
String
getSaveCaption()
protected Grid.Editor.State
getState()
protected com.google.gwt.user.client.ui.Widget
getWidget(Grid.Column<?,T> column)
Returns the editor widget associated with the given column.protected void
hideOverlay()
boolean
isBuffered()
boolean
isEditorColumnError(Grid.Column<?,T> column)
boolean
isEnabled()
boolean
isWorkPending()
Checks whether there are operations pending for this widget or connector that must be executed before reaching a steady state.void
save()
Saves any unsaved changes to the data source and hides the editor.void
setBuffered(boolean buffered)
void
setCancelCaption(String cancelCaption)
void
setEditorColumnError(Grid.Column<?,T> column, boolean hasError)
void
setEditorError(String errorMessage, Collection<Grid.Column<?,T>> errorColumns)
void
setEnabled(boolean enabled)
Sets the enabled state of this editor.void
setEventHandler(Grid.Editor.EventHandler<T> handler)
Sets the event handler for this Editor.protected void
setGrid(Grid<T> grid)
protected void
setGridEnabled(boolean enabled)
void
setHandler(EditorHandler<T> rowHandler)
Sets the handler responsible for binding data and editor widgets to this editor.void
setSaveCaption(String saveCaption)
protected void
setState(Grid.Editor.State state)
protected void
setStylePrimaryName(String primaryName)
protected void
show(int rowIndex, int columnIndex)
protected void
showOverlay()
Opens the editor overlay over the table row indicated bygetRow()
.protected void
showOverlay(com.google.gwt.dom.client.TableRowElement unused)
Deprecated.As of 7.5, useshowOverlay()
instead.
-
-
-
Field Detail
-
KEYCODE_SHOW
public static final int KEYCODE_SHOW
- See Also:
- Constant Field Values
-
KEYCODE_HIDE
public static final int KEYCODE_HIDE
- See Also:
- Constant Field Values
-
-
Method Detail
-
setEditorError
public void setEditorError(String errorMessage, Collection<Grid.Column<?,T>> errorColumns)
-
getRow
public int getRow()
-
editRow
public void editRow(int rowIndex)
If a cell of this Grid had focus once this editRow call was triggered, the editor component at the previously focused column index will be focused. If a Grid cell was not focused prior to calling this method, it will be equivalent toeditRow(rowIndex, -1)
.- See Also:
editRow(int, int)
-
editRow
public void editRow(int rowIndex, int columnIndexDOM)
Opens the editor over the row with the given index and attempts to focus the editor widget in the given column index. Does not move focus if the widget is not focusable or if the column index is -1.- Parameters:
rowIndex
- the index of the row to be editedcolumnIndexDOM
- the column index (excluding hidden columns) of the editor widget that should be initially focused or -1 to not set focus- Throws:
IllegalStateException
- if this editor is not enabledIllegalStateException
- if this editor is already in edit mode and in buffered mode- Since:
- 7.5
-
cancel
public void cancel()
Cancels the currently active edit and hides the editor. Any changes that are notsaved
are lost.- Throws:
IllegalStateException
- if this editor is not enabledIllegalStateException
- if this editor is not in edit mode
-
save
public void save()
Saves any unsaved changes to the data source and hides the editor.- Throws:
IllegalStateException
- if this editor is not enabledIllegalStateException
- if this editor is not in edit mode
-
getHandler
public EditorHandler<T> getHandler()
Returns the handler responsible for binding data and editor widgets to this editor.- Returns:
- the editor handler or null if not set
-
setHandler
public void setHandler(EditorHandler<T> rowHandler)
Sets the handler responsible for binding data and editor widgets to this editor.- Parameters:
rowHandler
- the new editor handler- Throws:
IllegalStateException
- if this editor is currently in edit mode
-
isEnabled
public boolean isEnabled()
-
setEnabled
public void setEnabled(boolean enabled)
Sets the enabled state of this editor.- Parameters:
enabled
- true if enabled, false otherwise- Throws:
IllegalStateException
- if in edit mode and trying to disableIllegalStateException
- if the editor handler is not set
-
show
protected void show(int rowIndex, int columnIndex)
-
getState
protected Grid.Editor.State getState()
-
setState
protected void setState(Grid.Editor.State state)
-
getWidget
protected com.google.gwt.user.client.ui.Widget getWidget(Grid.Column<?,T> column)
Returns the editor widget associated with the given column. If the editor is not active or the column is noteditable
, returns null.- Parameters:
column
- the column- Returns:
- the widget if the editor is open and the column is editable, null otherwise
-
showOverlay
@Deprecated protected void showOverlay(com.google.gwt.dom.client.TableRowElement unused)
Deprecated.As of 7.5, useshowOverlay()
instead.Equivalent toshowOverlay()
. The argument is ignored.- Parameters:
unused
- ignored argument
-
showOverlay
protected void showOverlay()
Opens the editor overlay over the table row indicated bygetRow()
.- Since:
- 7.5
-
hideOverlay
protected void hideOverlay()
-
setStylePrimaryName
protected void setStylePrimaryName(String primaryName)
-
createCell
protected com.google.gwt.dom.client.Element createCell(com.google.gwt.dom.client.TableCellElement td)
Creates an editor cell corresponding to the given table cell. The returned element is empty and has the same dimensions and position as the table cell.- Parameters:
td
- the table cell used as a reference- Returns:
- an editor cell corresponding to the given cell
-
setGridEnabled
protected void setGridEnabled(boolean enabled)
-
setSaveCaption
public void setSaveCaption(String saveCaption) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
getSaveCaption
public String getSaveCaption()
-
setCancelCaption
public void setCancelCaption(String cancelCaption) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
getCancelCaption
public String getCancelCaption()
-
setEditorColumnError
public void setEditorColumnError(Grid.Column<?,T> column, boolean hasError)
-
clearEditorColumnErrors
public void clearEditorColumnErrors()
-
isEditorColumnError
public boolean isEditorColumnError(Grid.Column<?,T> column)
-
setBuffered
public void setBuffered(boolean buffered)
-
isBuffered
public boolean isBuffered()
-
setEventHandler
public void setEventHandler(Grid.Editor.EventHandler<T> handler)
Sets the event handler for this Editor.- Parameters:
handler
- the new event handler- Since:
- 7.6
-
getEventHandler
public Grid.Editor.EventHandler<T> getEventHandler()
Returns the event handler of this Editor.- Returns:
- the current event handler
- Since:
- 7.6
-
isWorkPending
public boolean isWorkPending()
Description copied from interface:DeferredWorker
Checks whether there are operations pending for this widget or connector that must be executed before reaching a steady state.- Specified by:
isWorkPending
in interfaceDeferredWorker
-
getElementColumn
protected int getElementColumn(com.google.gwt.dom.client.Element e)
-
-