Package com.vaadin.ui.components.grid
Interface Editor<T>
-
- Type Parameters:
T-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
EditorImpl
public interface Editor<T> extends Serializable
An editor in a Grid.- Since:
- 8.0
- Author:
- Vaadin Ltd
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description RegistrationaddCancelListener(EditorCancelListener<T> listener)Adds an editor cancellistener.RegistrationaddOpenListener(EditorOpenListener<T> listener)Adds an editor openlistener.RegistrationaddSaveListener(EditorSaveListener<T> listener)Adds an editor savelistener.voidcancel()Close the editor discarding any unsaved changes.voideditRow(int rowNumber)Opens the editor interface for the provided row.Binder<T>getBinder()Returns the underlying Binder from Editor.StringgetCancelCaption()Gets the caption of the cancel button in buffered mode.EditorErrorGenerator<T>getErrorGenerator()Gets the error message generator of this editor.Grid<T>getGrid()Gets the Grid instance which this editor belongs to.StringgetSaveCaption()Gets the caption of the save button in buffered mode.booleanisBuffered()Returns whether Editor is buffered or not.booleanisEnabled()Returns whether Editor is enabled or not.booleanisOpen()Returns whether Editor is open or not.booleansave()Saves any changes from the Editor fields to the edited bean.Editor<T>setBinder(Binder<T> binder)Sets the underlying Binder to this Editor.Editor<T>setBuffered(boolean buffered)Sets the Editor buffered mode.Editor<T>setCancelCaption(String cancelCaption)Sets the caption of the cancel button in buffered mode.Editor<T>setEnabled(boolean enabled)Enables or disabled the Editor.Editor<T>setErrorGenerator(EditorErrorGenerator<T> errorGenerator)Sets the error message generator for this editor.Editor<T>setSaveCaption(String saveCaption)Sets the caption of the save button in buffered mode.
-
-
-
Method Detail
-
setBinder
Editor<T> setBinder(Binder<T> binder)
Sets the underlying Binder to this Editor.- Parameters:
binder- the binder for updating editor fields; notnull- Returns:
- this editor
-
getBinder
Binder<T> getBinder()
Returns the underlying Binder from Editor.- Returns:
- the binder; not
null
-
setBuffered
Editor<T> setBuffered(boolean buffered)
Sets the Editor buffered mode. When the editor is in buffered mode, edits are only committed when the user clicks the save button. In unbuffered mode valid changes are automatically committed.- Parameters:
buffered-trueif editor should be buffered;falseif not- Returns:
- this editor
-
setEnabled
Editor<T> setEnabled(boolean enabled)
Enables or disabled the Editor. A disabled editor cannot be opened.- Parameters:
enabled-trueif editor should be enabled;falseif not- Returns:
- this editor
-
isBuffered
boolean isBuffered()
Returns whether Editor is buffered or not.- Returns:
trueif editor is buffered;falseif not- See Also:
setBuffered(boolean)
-
isEnabled
boolean isEnabled()
Returns whether Editor is enabled or not.- Returns:
trueif editor is enabled;falseif not
-
isOpen
boolean isOpen()
Returns whether Editor is open or not.- Returns:
trueif editor is open;falseif not
-
save
boolean save()
Saves any changes from the Editor fields to the edited bean.- Returns:
trueif save succeeded;falseif not
-
cancel
void cancel()
Close the editor discarding any unsaved changes.
-
editRow
void editRow(int rowNumber)
Opens the editor interface for the provided row. Scrolls the Grid to bring the row to view if it is not already visible. Note that any cell content rendered by a WidgetRenderer will not be visible in the editor row.- Parameters:
rowNumber- the row number of the edited item- Throws:
IllegalStateException- if the editor is not enabled, Grid is read-only, or already editing a different item in buffered modeIllegalArgumentException- if therowNumberis not in the backing data provider- Since:
- 8.2
- See Also:
setEnabled(boolean)
-
setSaveCaption
Editor<T> setSaveCaption(String saveCaption)
Sets the caption of the save button in buffered mode.- Parameters:
saveCaption- the save button caption- Returns:
- this editor
-
setCancelCaption
Editor<T> setCancelCaption(String cancelCaption)
Sets the caption of the cancel button in buffered mode.- Parameters:
cancelCaption- the cancel button caption- Returns:
- this editor
-
getSaveCaption
String getSaveCaption()
Gets the caption of the save button in buffered mode.- Returns:
- the save button caption
-
getCancelCaption
String getCancelCaption()
Gets the caption of the cancel button in buffered mode.- Returns:
- the cancel button caption
-
setErrorGenerator
Editor<T> setErrorGenerator(EditorErrorGenerator<T> errorGenerator)
Sets the error message generator for this editor.The default message is a concatenation of column field validation failures and bean validation failures.
- Parameters:
errorGenerator- the function to generate error messages; notnull- Returns:
- this editor
- See Also:
EditorErrorGenerator
-
getErrorGenerator
EditorErrorGenerator<T> getErrorGenerator()
Gets the error message generator of this editor.- Returns:
- the function that generates error messages; not
null - See Also:
EditorErrorGenerator
-
addSaveListener
Registration addSaveListener(EditorSaveListener<T> listener)
Adds an editor savelistener.- Parameters:
listener- save listener- Returns:
- a registration object for removing the listener
-
addCancelListener
Registration addCancelListener(EditorCancelListener<T> listener)
Adds an editor cancellistener.- Parameters:
listener- cancel listener- Returns:
- a registration object for removing the listener
-
addOpenListener
Registration addOpenListener(EditorOpenListener<T> listener)
Adds an editor openlistener.- Parameters:
listener- open listener- Returns:
- a registration object for removing the listener
- Since:
- 8.1
-
-