Package 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 type
- All Implemented Interfaces:
DataGenerator<T>,MethodEventSource,ClientConnector,Extension,Connector,Editor<T>,Serializable
public class EditorImpl<T> extends Grid.AbstractGridExtension<T> implements Editor<T>
Implementation ofEditorinterface.- Since:
- 8.0
- See Also:
- Serialized Form
-
-
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 Instance Methods Concrete 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.protected voiddoClose()Handles clean up for closing the Editor.protected voiddoEdit(T bean)Handles editor component generation and adding them to the hierarchy of the Grid.voideditRow(int rowNumber)Opens the editor interface for the provided row.voidgenerateData(T item, elemental.json.JsonObject jsonObject)Adds custom data for the given item to its serializedJsonObjectrepresentation.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.protected EditorStategetState()Returns the shared state for this connector.protected EditorStategetState(boolean markAsDirty)Returns the shared state for this connector.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.-
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:DataGeneratorAdds custom data for the given item to its serializedJsonObjectrepresentation. This JSON object will be sent to client-side DataProvider.- Specified by:
generateDatain 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:EditorSets the underlying Binder to this Editor.
-
getBinder
public Binder<T> getBinder()
Description copied from interface:EditorReturns the underlying Binder from Editor.
-
setBuffered
public Editor<T> setBuffered(boolean buffered)
Description copied from interface:EditorSets 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:
setBufferedin interfaceEditor<T>- Parameters:
buffered-trueif editor should be buffered;falseif not- Returns:
- this editor
-
setEnabled
public Editor<T> setEnabled(boolean enabled)
Description copied from interface:EditorEnables or disabled the Editor. A disabled editor cannot be opened.- Specified by:
setEnabledin interfaceEditor<T>- Parameters:
enabled-trueif editor should be enabled;falseif not- Returns:
- this editor
-
isBuffered
public boolean isBuffered()
Description copied from interface:EditorReturns whether Editor is buffered or not.- Specified by:
isBufferedin interfaceEditor<T>- Returns:
trueif editor is buffered;falseif not- See Also:
Editor.setBuffered(boolean)
-
isEnabled
public boolean isEnabled()
Description copied from interface:EditorReturns 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:EditorSaves any changes from the Editor fields to the edited bean.
-
isOpen
public boolean isOpen()
Description copied from interface:EditorReturns whether Editor is open or not.
-
cancel
public void cancel()
Description copied from interface:EditorClose the editor discarding any unsaved changes.
-
editRow
public void editRow(int rowNumber) throws IllegalStateException, IllegalArgumentExceptionDescription copied from interface:EditorOpens 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:
editRowin interfaceEditor<T>- 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- See Also:
Editor.setEnabled(boolean)
-
doClose
protected void doClose()
Handles clean up for closing the Editor.
-
setSaveCaption
public Editor<T> setSaveCaption(String saveCaption)
Description copied from interface:EditorSets the caption of the save button in buffered mode.- Specified by:
setSaveCaptionin interfaceEditor<T>- Parameters:
saveCaption- the save button caption- Returns:
- this editor
-
setCancelCaption
public Editor<T> setCancelCaption(String cancelCaption)
Description copied from interface:EditorSets the caption of the cancel button in buffered mode.- Specified by:
setCancelCaptionin interfaceEditor<T>- Parameters:
cancelCaption- the cancel button caption- Returns:
- this editor
-
getSaveCaption
public String getSaveCaption()
Description copied from interface:EditorGets the caption of the save button in buffered mode.- Specified by:
getSaveCaptionin interfaceEditor<T>- Returns:
- the save button caption
-
getCancelCaption
public String getCancelCaption()
Description copied from interface:EditorGets the caption of the cancel button in buffered mode.- Specified by:
getCancelCaptionin interfaceEditor<T>- Returns:
- the cancel button caption
-
getState
protected EditorState getState()
Description copied from class:AbstractClientConnectorReturns 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:
getStatein classGrid.AbstractGridExtension<T>- Returns:
- The shared state for this connector. Never null.
-
getState
protected EditorState getState(boolean markAsDirty)
Description copied from class:AbstractClientConnectorReturns the shared state for this connector.- Overrides:
getStatein classGrid.AbstractGridExtension<T>- Parameters:
markAsDirty- true if the connector should automatically be marked dirty, false otherwise- Returns:
- The shared state for this connector. Never null.
- See Also:
AbstractClientConnector.getState()
-
setErrorGenerator
public Editor<T> setErrorGenerator(EditorErrorGenerator<T> errorGenerator)
Description copied from interface:EditorSets the error message generator for this editor.The default message is a concatenation of column field validation failures and bean validation failures.
- Specified by:
setErrorGeneratorin interfaceEditor<T>- Parameters:
errorGenerator- the function to generate error messages; notnull- Returns:
- this editor
- See Also:
EditorErrorGenerator
-
getErrorGenerator
public EditorErrorGenerator<T> getErrorGenerator()
Description copied from interface:EditorGets the error message generator of this editor.- Specified by:
getErrorGeneratorin interfaceEditor<T>- Returns:
- the function that generates error messages; not
null - See Also:
EditorErrorGenerator
-
addSaveListener
public Registration addSaveListener(EditorSaveListener<T> listener)
Description copied from interface:EditorAdds an editor savelistener.- Specified by:
addSaveListenerin interfaceEditor<T>- Parameters:
listener- save listener- Returns:
- a registration object for removing the listener
-
addCancelListener
public Registration addCancelListener(EditorCancelListener<T> listener)
Description copied from interface:EditorAdds an editor cancellistener.- Specified by:
addCancelListenerin interfaceEditor<T>- Parameters:
listener- cancel listener- Returns:
- a registration object for removing the listener
-
addOpenListener
public Registration addOpenListener(EditorOpenListener<T> listener)
Description copied from interface:EditorAdds an editor openlistener.- Specified by:
addOpenListenerin interfaceEditor<T>- Parameters:
listener- open listener- Returns:
- a registration object for removing the listener
-
-