com.vaadin.ui.components.grid.
Class EditorImpl<T>
- java.lang.Object
-
- com.vaadin.server.AbstractClientConnector
-
- com.vaadin.server.AbstractExtension
-
- com.vaadin.ui.AbstractListing.AbstractListingExtension<T>
-
- com.vaadin.ui.Grid.AbstractGridExtension<T>
-
- com.vaadin.ui.components.grid.EditorImpl<T>
-
Type Parameters:
T
- the grid bean typeAll Implemented Interfaces:
DataGenerator<T>
,MethodEventSource
,ClientConnector
,Extension
,Connector
,Editor<T>
,Serializable
public class EditorImpl<T> extends Grid.AbstractGridExtension<T> implements Editor<T>
Implementation of
Editor
interface.Since:
8.0
See Also:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
-
Constructor Summary
Constructors Constructor Description EditorImpl(PropertySet<T> propertySet)
Constructor for internal implementation of the Editor.
-
Method Summary
All Methods Modifier and Type Method Description Registration
addCancelListener(EditorCancelListener<T> listener)
Adds an editor cancel
listener
.Registration
addOpenListener(EditorOpenListener<T> listener)
Adds an editor open
listener
.Registration
addSaveListener(EditorSaveListener<T> listener)
Adds an editor save
listener
.void
cancel()
Close the editor discarding any unsaved changes.
protected void
doClose()
Handles clean up for closing the Editor.
protected void
doEdit(T bean)
Handles editor component generation and adding them to the hierarchy of the Grid.
void
editRow(int rowNumber)
Opens the editor interface for the provided row.
void
generateData(T item, elemental.json.JsonObject jsonObject)
Adds custom data for the given item to its serialized
JsonObject
representation.Binder<T>
getBinder()
Returns the underlying Binder from Editor.
String
getCancelCaption()
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.
String
getSaveCaption()
Gets the caption of the save button in buffered mode.
protected EditorState
getState()
Returns the shared state for this connector.
protected EditorState
getState(boolean markAsDirty)
Returns the shared state for this connector.
boolean
isBuffered()
Returns whether Editor is buffered or not.
boolean
isEnabled()
Returns whether Editor is enabled or not.
boolean
isOpen()
Returns whether Editor is open or not.
boolean
save()
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.
-
Methods inherited from class com.vaadin.ui.Grid.AbstractGridExtension
addComponentToGrid, extend, getInternalIdForColumn, getParent, removeComponentFromGrid
-
Methods inherited from class com.vaadin.ui.AbstractListing.AbstractListingExtension
getData, refresh, remove
-
Methods inherited from class com.vaadin.server.AbstractExtension
extend, getSupportedParentType, setParent
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, attach, beforeClientResponse, createState, detach, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isConnectorEnabled, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, attach, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, getUI, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
Methods inherited from interface com.vaadin.data.provider.DataGenerator
destroyAllData, destroyData, refreshData
-
-
-
-
Constructor Detail
-
EditorImpl
public EditorImpl(PropertySet<T> propertySet)
Constructor for internal implementation of the Editor.
Parameters:
propertySet
- the property set to use for configuring the default binder
-
-
Method Detail
-
generateData
public void generateData(T item, elemental.json.JsonObject jsonObject)
Description copied from interface:
DataGenerator
Adds custom data for the given item to its serialized
JsonObject
representation. This JSON object will be sent to client-side DataProvider.Specified by:
generateData
in interfaceDataGenerator<T>
Parameters:
item
- the data item being serializedjsonObject
- the JSON object being sent to the client
-
setBinder
public Editor<T> setBinder(Binder<T> binder)
Description copied from interface:
Editor
Sets the underlying Binder to this Editor.
-
getBinder
public Binder<T> getBinder()
Description copied from interface:
Editor
Returns the underlying Binder from Editor.
-
setBuffered
public Editor<T> setBuffered(boolean buffered)
Description copied from interface:
Editor
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.
Specified by:
setBuffered
in interfaceEditor<T>
Parameters:
buffered
-true
if editor should be buffered;false
if notReturns:
this editor
-
setEnabled
public Editor<T> setEnabled(boolean enabled)
Description copied from interface:
Editor
Enables or disabled the Editor. A disabled editor cannot be opened.
Specified by:
setEnabled
in interfaceEditor<T>
Parameters:
enabled
-true
if editor should be enabled;false
if notReturns:
this editor
-
isBuffered
public boolean isBuffered()
Description copied from interface:
Editor
Returns whether Editor is buffered or not.
Specified by:
isBuffered
in interfaceEditor<T>
Returns:
true
if editor is buffered;false
if notSee Also:
-
isEnabled
public boolean isEnabled()
Description copied from interface:
Editor
Returns whether Editor is enabled or not.
-
doEdit
protected void doEdit(T bean)
Handles editor component generation and adding them to the hierarchy of the Grid.
Parameters:
bean
- the edited item; can't benull
-
save
public boolean save()
Description copied from interface:
Editor
Saves any changes from the Editor fields to the edited bean.
-
isOpen
public boolean isOpen()
Description copied from interface:
Editor
Returns whether Editor is open or not.
-
cancel
public void cancel()
Description copied from interface:
Editor
Close the editor discarding any unsaved changes.
-
editRow
public void editRow(int rowNumber) throws IllegalStateException, IllegalArgumentException
Description copied from interface:
Editor
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.
Specified by:
editRow
in interfaceEditor<T>
Parameters:
rowNumber
- the row number of the edited itemThrows:
IllegalStateException
- if the editor is not enabled, Grid is read-only, or already editing a different item in buffered modeIllegalArgumentException
- if therowNumber
is not in the backing data providerSee Also:
-
doClose
protected void doClose()
Handles clean up for closing the Editor.
-
setSaveCaption
public Editor<T> setSaveCaption(String saveCaption)
Description copied from interface:
Editor
Sets the caption of the save button in buffered mode.
Specified by:
setSaveCaption
in interfaceEditor<T>
Parameters:
saveCaption
- the save button captionReturns:
this editor
-
setCancelCaption
public Editor<T> setCancelCaption(String cancelCaption)
Description copied from interface:
Editor
Sets the caption of the cancel button in buffered mode.
Specified by:
setCancelCaption
in interfaceEditor<T>
Parameters:
cancelCaption
- the cancel button captionReturns:
this editor
-
getSaveCaption
public String getSaveCaption()
Description copied from interface:
Editor
Gets the caption of the save button in buffered mode.
Specified by:
getSaveCaption
in interfaceEditor<T>
Returns:
the save button caption
-
getCancelCaption
public String getCancelCaption()
Description copied from interface:
Editor
Gets the caption of the cancel button in buffered mode.
Specified by:
getCancelCaption
in interfaceEditor<T>
Returns:
the cancel button caption
-
getState
protected EditorState getState()
Description copied from class:
AbstractClientConnector
Returns the shared state for this connector. The shared state object is shared between the server connector and the client connector. Changes are only communicated from the server to the client and not in the other direction.
As a side effect, marks the connector dirty so any changes done to the state will be sent to the client. Use
getState(false)
to avoid marking the connector as dirty.Overrides:
getState
in classGrid.AbstractGridExtension<T>
Returns:
The shared state for this connector. Never null.
-
getState
protected EditorState getState(boolean markAsDirty)
Description copied from class:
AbstractClientConnector
Returns the shared state for this connector.
Overrides:
getState
in classGrid.AbstractGridExtension<T>
Parameters:
markAsDirty
- true if the connector should automatically be marked dirty, false otherwiseReturns:
The shared state for this connector. Never null.
See Also:
-
setErrorGenerator
public Editor<T> setErrorGenerator(EditorErrorGenerator<T> errorGenerator)
Description copied from interface:
Editor
Sets the error message generator for this editor.
The default message is a concatenation of column field validation failures and bean validation failures.
Specified by:
setErrorGenerator
in interfaceEditor<T>
Parameters:
errorGenerator
- the function to generate error messages; notnull
Returns:
this editor
See Also:
-
getErrorGenerator
public EditorErrorGenerator<T> getErrorGenerator()
Description copied from interface:
Editor
Gets the error message generator of this editor.
Specified by:
getErrorGenerator
in interfaceEditor<T>
Returns:
the function that generates error messages; not
null
See Also:
-
addSaveListener
public Registration addSaveListener(EditorSaveListener<T> listener)
Description copied from interface:
Editor
Adds an editor save
listener
.Specified by:
addSaveListener
in interfaceEditor<T>
Parameters:
listener
- save listenerReturns:
a registration object for removing the listener
-
addCancelListener
public Registration addCancelListener(EditorCancelListener<T> listener)
Description copied from interface:
Editor
Adds an editor cancel
listener
.Specified by:
addCancelListener
in interfaceEditor<T>
Parameters:
listener
- cancel listenerReturns:
a registration object for removing the listener
-
addOpenListener
public Registration addOpenListener(EditorOpenListener<T> listener)
Description copied from interface:
Editor
Adds an editor open
listener
.Specified by:
addOpenListener
in interfaceEditor<T>
Parameters:
listener
- open listenerReturns:
a registration object for removing the listener
-
-