T
- the grid bean typepublic class EditorImpl<T> extends Grid.AbstractGridExtension<T> implements Editor<T>
Editor
interface.ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
Constructor and Description |
---|
EditorImpl(PropertySet<T> propertySet)
Constructor for internal implementation of the Editor.
|
Modifier and Type | Method and 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.
|
addComponentToGrid, extend, getInternalIdForColumn, getParent, removeComponentFromGrid
getData, refresh, remove
extend, getSupportedParentType, setParent
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
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
destroyAllData, destroyData, refreshData
addAttachListener, addDetachListener, attach, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, getUI, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
getConnectorId
public EditorImpl(PropertySet<T> propertySet)
propertySet
- the property set to use for configuring the default binderpublic void generateData(T item, elemental.json.JsonObject jsonObject)
DataGenerator
JsonObject
representation. This JSON object will be sent to client-side
DataProvider.generateData
in interface DataGenerator<T>
item
- the data item being serializedjsonObject
- the JSON object being sent to the clientpublic Editor<T> setBinder(Binder<T> binder)
Editor
public Binder<T> getBinder()
Editor
public Editor<T> setBuffered(boolean buffered)
Editor
setBuffered
in interface Editor<T>
buffered
- true
if editor should be buffered; false
if
notpublic Editor<T> setEnabled(boolean enabled)
Editor
setEnabled
in interface Editor<T>
enabled
- true
if editor should be enabled; false
if notpublic boolean isBuffered()
Editor
isBuffered
in interface Editor<T>
true
if editor is buffered; false
if notEditor.setBuffered(boolean)
public boolean isEnabled()
Editor
protected void doEdit(T bean)
bean
- the edited item; can't be null
public boolean save()
Editor
public boolean isOpen()
Editor
public void cancel()
Editor
public void editRow(int rowNumber) throws IllegalStateException, IllegalArgumentException
Editor
editRow
in interface Editor<T>
rowNumber
- the row number of the edited itemIllegalStateException
- if the editor is not enabled or already editing a different
item in buffered modeIllegalArgumentException
- if the rowNumber
is not in the backing data providerEditor.setEnabled(boolean)
protected void doClose()
public Editor<T> setSaveCaption(String saveCaption)
Editor
setSaveCaption
in interface Editor<T>
saveCaption
- the save button captionpublic Editor<T> setCancelCaption(String cancelCaption)
Editor
setCancelCaption
in interface Editor<T>
cancelCaption
- the cancel button captionpublic String getSaveCaption()
Editor
getSaveCaption
in interface Editor<T>
public String getCancelCaption()
Editor
getCancelCaption
in interface Editor<T>
protected EditorState getState()
AbstractClientConnector
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.
getState
in class Grid.AbstractGridExtension<T>
protected EditorState getState(boolean markAsDirty)
AbstractClientConnector
getState
in class Grid.AbstractGridExtension<T>
markAsDirty
- true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()
public Editor<T> setErrorGenerator(EditorErrorGenerator<T> errorGenerator)
Editor
The default message is a concatenation of column field validation failures and bean validation failures.
setErrorGenerator
in interface Editor<T>
errorGenerator
- the function to generate error messages; not null
EditorErrorGenerator
public EditorErrorGenerator<T> getErrorGenerator()
Editor
getErrorGenerator
in interface Editor<T>
null
EditorErrorGenerator
public Registration addSaveListener(EditorSaveListener<T> listener)
Editor
listener
.addSaveListener
in interface Editor<T>
listener
- save listenerpublic Registration addCancelListener(EditorCancelListener<T> listener)
Editor
listener
.addCancelListener
in interface Editor<T>
listener
- cancel listenerpublic Registration addOpenListener(EditorOpenListener<T> listener)
Editor
listener
.addOpenListener
in interface Editor<T>
listener
- open listenerCopyright © 2022 Vaadin Ltd. All rights reserved.