Class EditorImpl<T>
- java.lang.Object
-
- com.vaadin.flow.component.grid.Grid.AbstractGridExtension<T>
-
- com.vaadin.flow.component.grid.editor.EditorImpl<T>
-
- Type Parameters:
T- the grid bean type
- All Implemented Interfaces:
Editor<T>,com.vaadin.flow.data.provider.DataGenerator<T>,Serializable
public class EditorImpl<T> extends Grid.AbstractGridExtension<T> implements Editor<T>
Implementation ofEditorinterface.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description EditorImpl(Grid<T> grid, com.vaadin.flow.data.binder.PropertySet<T> propertySet)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.vaadin.flow.shared.RegistrationaddCancelListener(EditorCancelListener<T> listener)Adds an editor cancellistener.com.vaadin.flow.shared.RegistrationaddCloseListener(EditorCloseListener<T> listener)Adds an editor closelistener.com.vaadin.flow.shared.RegistrationaddOpenListener(EditorOpenListener<T> listener)Adds an editor openlistener.com.vaadin.flow.shared.RegistrationaddSaveListener(EditorSaveListener<T> listener)Adds an editor savelistener.voidcancel()Cancel will discard any changes made in editor fields for a buffered editor.voidcloseEditor()Closes the editor when in unbuffered mode and fires anEditorCloseEventif the edited item is notnull.voideditItem(T item)Opens the editor component for the provided item and fires anEditorOpenEvent.voidgenerateData(T item, elemental.json.JsonObject jsonObject)com.vaadin.flow.data.binder.Binder<T>getBinder()Returns the underlying Binder from Editor.Grid<T>getGrid()Gets the Grid this extension extends.TgetItem()Gets the current item being edited, if any.booleanisBuffered()Returns whether Editor is buffered or not.booleanisOpen()Returns whether Editor is open or not.voidrefresh()Refreshes the editor components for the current item being edited.booleansave()In buffered mode calling save will validate bean and will save any changes made to the Editor fields to the edited bean if all validators pass.Editor<T>setBinder(com.vaadin.flow.data.binder.Binder<T> binder)Sets the underlying Binder to this Editor.Editor<T>setBuffered(boolean buffered)Sets the Editor buffered mode.-
Methods inherited from class com.vaadin.flow.component.grid.Grid.AbstractGridExtension
extend, refresh, remove
-
-
-
-
Method Detail
-
setBinder
public Editor<T> setBinder(com.vaadin.flow.data.binder.Binder<T> binder)
Description copied from interface:EditorSets the underlying Binder to this Editor.
-
getBinder
public com.vaadin.flow.data.binder.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
-
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)
-
isOpen
public boolean isOpen()
Description copied from interface:EditorReturns whether Editor is open or not.
-
save
public boolean save()
Description copied from interface:EditorIn buffered mode calling save will validate bean and will save any changes made to the Editor fields to the edited bean if all validators pass.A successful write will fire an
EditorSaveEventand close the editor that will fire anEditorCloseEvent.If the write fails then there will be no events and the editor will stay open.
Note! For an unbuffered editor calling save will have no effect and always return
false.
-
cancel
public void cancel()
Description copied from interface:EditorCancel will discard any changes made in editor fields for a buffered editor.Calling cancel will fire an
EditorCancelEventand close the editor that will fire anEditorCloseEventif the edited item is notnull.
-
closeEditor
public void closeEditor()
Description copied from interface:EditorCloses the editor when in unbuffered mode and fires anEditorCloseEventif the edited item is notnull.For buffered mode calling close editor will throw an
UnsupportedOperationExceptionas eitherEditor.save()orEditor.cancel()should be used.- Specified by:
closeEditorin interfaceEditor<T>
-
editItem
public void editItem(T item)
Description copied from interface:EditorOpens the editor component for the provided item and fires anEditorOpenEvent.In case there is an open editor an
EditorCloseEventwill also be fired.
-
refresh
public void refresh()
Description copied from interface:EditorRefreshes the editor components for the current item being edited. It is a NO-OP if the editor is not opened.This is useful when the state of the item is changed while the editor is open.
- Specified by:
refreshin interfaceEditor<T>- See Also:
Editor.isOpen()
-
getItem
public T getItem()
Description copied from interface:EditorGets the current item being edited, if any.The item being edited is always
nullwhile the editor is closed. The item is notnullduringEditor.save()andEditor.cancel()operations, but becomenullas soon as the editor is closed.- Specified by:
getItemin interfaceEditor<T>- Returns:
- the item being edited, or
nullif none is being edited - See Also:
Editor.editItem(Object)
-
getGrid
public Grid<T> getGrid()
Description copied from class:Grid.AbstractGridExtensionGets the Grid this extension extends.
-
generateData
public void generateData(T item, elemental.json.JsonObject jsonObject)
- Specified by:
generateDatain interfacecom.vaadin.flow.data.provider.DataGenerator<T>
-
addSaveListener
public com.vaadin.flow.shared.Registration addSaveListener(EditorSaveListener<T> listener)
Description copied from interface:Editor- Specified by:
addSaveListenerin interfaceEditor<T>- Parameters:
listener- save listener- Returns:
- a registration object for removing the listener
-
addCancelListener
public com.vaadin.flow.shared.Registration addCancelListener(EditorCancelListener<T> listener)
Description copied from interface:Editor- Specified by:
addCancelListenerin interfaceEditor<T>- Parameters:
listener- cancel listener- Returns:
- a registration object for removing the listener
-
addOpenListener
public com.vaadin.flow.shared.Registration addOpenListener(EditorOpenListener<T> listener)
Description copied from interface:EditorAdds an editor openlistener.EditorOpenEventis fired when the editor is opened throughEditor.editItem(java.lang.Object)- Specified by:
addOpenListenerin interfaceEditor<T>- Parameters:
listener- open listener- Returns:
- a registration object for removing the listener
-
addCloseListener
public com.vaadin.flow.shared.Registration addCloseListener(EditorCloseListener<T> listener)
Description copied from interface:EditorAdds an editor closelistener. Close events are sent every time the editor is closed, no matter if it is due to a close, save or to a cancel operation.When a successful
Editor.save()operation is performed, two listeners are triggered: save and close listeners. Likewise, when aEditor.cancel()operation is performed, two listeners are triggered, cancel and close listeners.- Specified by:
addCloseListenerin interfaceEditor<T>- Parameters:
listener- close listener- Returns:
- a registration object for removing the listener
-
-