Class DataGridEditorImpl<T>
java.lang.Object
com.vaadin.flow.component.grid.Grid.AbstractGridExtension<T>
io.jmix.flowui.component.grid.editor.DataGridEditorImpl<T>
- All Implemented Interfaces:
com.vaadin.flow.component.grid.editor.Editor<T>
,com.vaadin.flow.data.provider.DataGenerator<T>
,DataGridDataProviderChangeObserver
,DataGridEditor<T>
,Serializable
public class DataGridEditorImpl<T>
extends com.vaadin.flow.component.grid.Grid.AbstractGridExtension<T>
implements DataGridEditor<T>, DataGridDataProviderChangeObserver
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.springframework.context.ApplicationContext
protected boolean
protected Consumer<SupportsStatusChangeHandler.StatusContext<?>>
protected T
protected com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.internal.ExecutionContext>
protected Map<T,
DataGridEditorValueSourceProvider<T>> protected boolean
protected Consumer<ValidationErrors>
-
Constructor Summary
ConstructorDescriptionDataGridEditorImpl
(com.vaadin.flow.component.grid.Grid<T> grid, org.springframework.context.ApplicationContext applicationContext) -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.Registration
addCancelListener
(com.vaadin.flow.component.grid.editor.EditorCancelListener<T> listener) com.vaadin.flow.shared.Registration
addCloseListener
(com.vaadin.flow.component.grid.editor.EditorCloseListener<T> listener) protected <L> com.vaadin.flow.shared.Registration
addListener
(Class<L> listenerType, L listener) com.vaadin.flow.shared.Registration
addOpenListener
(com.vaadin.flow.component.grid.editor.EditorOpenListener<T> listener) com.vaadin.flow.shared.Registration
addSaveListener
(com.vaadin.flow.component.grid.editor.EditorSaveListener<T> listener) void
cancel()
protected void
protected void
void
protected void
protected void
protected InstanceContainer<T>
createInstanceContainer
(T item) protected ValueSourceProvider
createValueSourceProvider
(T item) void
protected void
defaultComponentStatusHandler
(SupportsStatusChangeHandler.StatusContext<?> statusContext) protected void
detachItemContainer
(DataGridEditorValueSourceProvider<T> valueSourceProvider) void
protected void
fireCancelEvent
(com.vaadin.flow.component.grid.editor.EditorCancelEvent<T> event) protected void
fireCloseEvent
(com.vaadin.flow.component.grid.editor.EditorCloseEvent<T> event) protected void
fireOpenEvent
(com.vaadin.flow.component.grid.editor.EditorOpenEvent<T> event) protected void
fireSaveEvent
(com.vaadin.flow.component.grid.editor.EditorSaveEvent<T> event) void
generateData
(T item, elemental.json.JsonObject jsonObject) com.vaadin.flow.data.binder.Binder<T>
protected DataComponents
protected MetaClass
protected EventBus
com.vaadin.flow.component.grid.Grid<T>
getGrid()
getItem()
protected UiComponentsGenerator
protected ViewValidation
protected void
handleComponentStatus
(SupportsStatusChangeHandler.StatusContext<?> statusContext) protected void
handleItemClick
(com.vaadin.flow.component.grid.ItemClickEvent<T> event) void
initColumnDefaultEditorComponent
(com.vaadin.flow.component.grid.Grid.Column<T> column, String property) Inits the default function that returns the column editor component that is bound to the passed entity's property.void
initColumnDefaultEditorComponent
(String property) Inits the default function that returns the column editor component that is bound to the passed entity's property.protected void
boolean
protected boolean
boolean
isOpen()
boolean
isSaving()
void
refresh()
protected void
registerEditComponent
(com.vaadin.flow.component.grid.Grid.Column<T> column, com.vaadin.flow.component.Component editComponent) protected void
requestEditItem
(T item) boolean
save()
com.vaadin.flow.component.grid.editor.Editor<T>
setBuffered
(boolean buffered) void
setColumnEditorComponent
(com.vaadin.flow.component.grid.Grid.Column<T> column, String property, Function<EditComponentGenerationContext<T>, com.vaadin.flow.component.Component> generator) Sets a function that returns the column editor component.void
setColumnEditorComponent
(String property, Function<EditComponentGenerationContext<T>, com.vaadin.flow.component.Component> generator) Sets a function that returns the column editor component.void
Sets a callback that is set to editor components which implementSupportsStatusChangeHandler
.void
setValidationErrorsHandler
(Consumer<ValidationErrors> validationErrorsHandler) Sets a callback that is used to handle validation errors when Editor attempts to save the data, i.e.protected void
validateCanEdit
(T item) protected ValidationErrors
protected void
writeComponent
(com.vaadin.flow.component.Component component) protected void
Methods inherited from class com.vaadin.flow.component.grid.Grid.AbstractGridExtension
extend, refresh, remove
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.data.provider.DataGenerator
destroyAllData, destroyData, refreshData
-
Field Details
-
applicationContext
protected org.springframework.context.ApplicationContext applicationContext -
listeners
-
editItemRequest
protected com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.internal.ExecutionContext> editItemRequest -
defaultComponentStatusHandler
-
validationErrorsHandler
-
edited
-
buffered
protected boolean buffered -
saving
protected boolean saving -
itemValueSourceProviders
-
columnEditorComponents
-
-
Constructor Details
-
DataGridEditorImpl
public DataGridEditorImpl(com.vaadin.flow.component.grid.Grid<T> grid, org.springframework.context.ApplicationContext applicationContext)
-
-
Method Details
-
getEventBus
-
initGrid
-
setBinder
public com.vaadin.flow.component.grid.editor.Editor<T> setBinder(com.vaadin.flow.data.binder.Binder<T> binder) - Specified by:
setBinder
in interfacecom.vaadin.flow.component.grid.editor.Editor<T>
-
getBinder
- Specified by:
getBinder
in interfacecom.vaadin.flow.component.grid.editor.Editor<T>
-
setBuffered
- Specified by:
setBuffered
in interfacecom.vaadin.flow.component.grid.editor.Editor<T>
-
closeIfOpen
protected void closeIfOpen() -
isBuffered
public boolean isBuffered()- Specified by:
isBuffered
in interfacecom.vaadin.flow.component.grid.editor.Editor<T>
-
isSaving
public boolean isSaving()- Specified by:
isSaving
in interfaceDataGridEditor<T>
- Returns:
true
if this editor is buffered and is in a process of writing data to an item,false
otherwise
-
isOpen
public boolean isOpen()- Specified by:
isOpen
in interfacecom.vaadin.flow.component.grid.editor.Editor<T>
-
save
public boolean save()- Specified by:
save
in interfacecom.vaadin.flow.component.grid.editor.Editor<T>
-
isEditorEditComponentsValid
protected boolean isEditorEditComponentsValid() -
validateEditor
-
writeEditComponents
protected void writeEditComponents() -
writeComponent
protected void writeComponent(com.vaadin.flow.component.Component component) -
cancel
public void cancel()- Specified by:
cancel
in interfacecom.vaadin.flow.component.grid.editor.Editor<T>
-
closeEditor
public void closeEditor()- Specified by:
closeEditor
in interfacecom.vaadin.flow.component.grid.editor.Editor<T>
-
editItem
- Specified by:
editItem
in interfacecom.vaadin.flow.component.grid.editor.Editor<T>
-
requestEditItem
-
refresh
public void refresh()- Specified by:
refresh
in interfacecom.vaadin.flow.component.grid.editor.Editor<T>
-
getItem
- Specified by:
getItem
in interfaceDataGridEditor<T>
- Specified by:
getItem
in interfacecom.vaadin.flow.component.grid.editor.Editor<T>
-
getGrid
-
generateData
- Specified by:
generateData
in interfacecom.vaadin.flow.data.provider.DataGenerator<T>
-
closeInternal
protected void closeInternal() -
handleItemClick
-
validateCanEdit
-
createValueSourceProvider
-
createInstanceContainer
-
clearItemValueSourceProviders
-
detachItemContainer
-
clearEditorComponents
protected void clearEditorComponents() -
dataProviderChanged
public void dataProviderChanged()- Specified by:
dataProviderChanged
in interfaceDataGridDataProviderChangeObserver
-
getEntityMetaClass
-
initColumnDefaultEditorComponent
Description copied from interface:DataGridEditor
Inits the default function that returns the column editor component that is bound to the passed entity's property. To find the column it's assumed that the column key is equal to the property.- Specified by:
initColumnDefaultEditorComponent
in interfaceDataGridEditor<T>
- Parameters:
property
- an entity attribute for which the edit component is created- See Also:
-
setColumnEditorComponent
public void setColumnEditorComponent(String property, Function<EditComponentGenerationContext<T>, com.vaadin.flow.component.Component> generator) Description copied from interface:DataGridEditor
Sets a function that returns the column editor component. To bound an editor component to the passed entity's property, the function implementation should useEditComponentGenerationContext.getValueSourceProvider()
to obtain an instance ofValueSource
. To find the column it's assumed that the column key is equal to the property.- Specified by:
setColumnEditorComponent
in interfaceDataGridEditor<T>
- Parameters:
property
- an entity attribute for which the edit component is createdgenerator
- a callback function that is used to create an edit component- See Also:
-
initColumnDefaultEditorComponent
public void initColumnDefaultEditorComponent(com.vaadin.flow.component.grid.Grid.Column<T> column, String property) Description copied from interface:DataGridEditor
Inits the default function that returns the column editor component that is bound to the passed entity's property.- Specified by:
initColumnDefaultEditorComponent
in interfaceDataGridEditor<T>
- Parameters:
column
- a grid column for which to set editor componentproperty
- an entity attribute for which an edit component is created- See Also:
-
setColumnEditorComponent
public void setColumnEditorComponent(com.vaadin.flow.component.grid.Grid.Column<T> column, String property, Function<EditComponentGenerationContext<T>, com.vaadin.flow.component.Component> generator) Description copied from interface:DataGridEditor
Sets a function that returns the column editor component. To bound an editor component to the passed entity's property, the function implementation should useEditComponentGenerationContext.getValueSourceProvider()
to obtain an instance ofValueSource
.- Specified by:
setColumnEditorComponent
in interfaceDataGridEditor<T>
- Parameters:
column
- a grid column for which to set editor componentproperty
- an entity attribute for which the edit component is createdgenerator
- a callback function that is used to create an edit component- See Also:
-
defaultComponentStatusHandler
protected void defaultComponentStatusHandler(SupportsStatusChangeHandler.StatusContext<?> statusContext) -
handleComponentStatus
-
setDefaultComponentStatusHandler
public void setDefaultComponentStatusHandler(@Nullable Consumer<SupportsStatusChangeHandler.StatusContext<?>> handler) Description copied from interface:DataGridEditor
Sets a callback that is set to editor components which implementSupportsStatusChangeHandler
. If a custom component generator is used, this status handler can be obtained fromEditComponentGenerationContext.getStatusHandler()
.- Specified by:
setDefaultComponentStatusHandler
in interfaceDataGridEditor<T>
- Parameters:
handler
- a callback that is set to editor components which implementSupportsStatusChangeHandler
-
setValidationErrorsHandler
public void setValidationErrorsHandler(@Nullable Consumer<ValidationErrors> validationErrorsHandler) Description copied from interface:DataGridEditor
Sets a callback that is used to handle validation errors when Editor attempts to save the data, i.e. whenEditor.save()
is invoked.Note! This handler can be called only if editor is in buffered mode.
- Specified by:
setValidationErrorsHandler
in interfaceDataGridEditor<T>
- Parameters:
validationErrorsHandler
- a callback that is used to handle validation errors- See Also:
-
Editor.setBuffered(boolean)
-
registerEditComponent
protected void registerEditComponent(com.vaadin.flow.component.grid.Grid.Column<T> column, com.vaadin.flow.component.Component editComponent) -
addSaveListener
public com.vaadin.flow.shared.Registration addSaveListener(com.vaadin.flow.component.grid.editor.EditorSaveListener<T> listener) - Specified by:
addSaveListener
in interfacecom.vaadin.flow.component.grid.editor.Editor<T>
-
addCancelListener
public com.vaadin.flow.shared.Registration addCancelListener(com.vaadin.flow.component.grid.editor.EditorCancelListener<T> listener) - Specified by:
addCancelListener
in interfacecom.vaadin.flow.component.grid.editor.Editor<T>
-
addOpenListener
public com.vaadin.flow.shared.Registration addOpenListener(com.vaadin.flow.component.grid.editor.EditorOpenListener<T> listener) - Specified by:
addOpenListener
in interfacecom.vaadin.flow.component.grid.editor.Editor<T>
-
addCloseListener
public com.vaadin.flow.shared.Registration addCloseListener(com.vaadin.flow.component.grid.editor.EditorCloseListener<T> listener) - Specified by:
addCloseListener
in interfacecom.vaadin.flow.component.grid.editor.Editor<T>
-
addListener
-
fireOpenEvent
-
fireCancelEvent
-
fireSaveEvent
-
fireCloseEvent
-
getDataComponents
-
getUiComponentsGenerator
-
getViewValidation
-