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:
  • Field Details

    • applicationContext

      protected org.springframework.context.ApplicationContext applicationContext
    • listeners

      protected final Map<Class<?>,List<?>> listeners
    • editItemRequest

      protected com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.internal.ExecutionContext> editItemRequest
    • defaultComponentStatusHandler

      protected Consumer<SupportsStatusChangeHandler.StatusContext<?>> defaultComponentStatusHandler
    • validationErrorsHandler

      protected Consumer<ValidationErrors> validationErrorsHandler
    • edited

      protected T edited
    • buffered

      protected boolean buffered
    • saving

      protected boolean saving
    • itemValueSourceProviders

      protected Map<T,DataGridEditorValueSourceProvider<T>> itemValueSourceProviders
    • columnEditorComponents

      protected Map<com.vaadin.flow.component.grid.Grid.Column<T>,com.vaadin.flow.component.Component> columnEditorComponents
  • Constructor Details

    • DataGridEditorImpl

      public DataGridEditorImpl(com.vaadin.flow.component.grid.Grid<T> grid, org.springframework.context.ApplicationContext applicationContext)
  • Method Details

    • getEventBus

      protected EventBus getEventBus()
    • initGrid

      protected void initGrid(com.vaadin.flow.component.grid.Grid<T> grid)
    • setBinder

      public com.vaadin.flow.component.grid.editor.Editor<T> setBinder(com.vaadin.flow.data.binder.Binder<T> binder)
      Specified by:
      setBinder in interface com.vaadin.flow.component.grid.editor.Editor<T>
    • getBinder

      public com.vaadin.flow.data.binder.Binder<T> getBinder()
      Specified by:
      getBinder in interface com.vaadin.flow.component.grid.editor.Editor<T>
    • setBuffered

      public DataGridEditor<T> setBuffered(boolean buffered)
      Specified by:
      setBuffered in interface com.vaadin.flow.component.grid.editor.Editor<T>
    • closeIfOpen

      protected void closeIfOpen()
    • isBuffered

      public boolean isBuffered()
      Specified by:
      isBuffered in interface com.vaadin.flow.component.grid.editor.Editor<T>
    • isSaving

      public boolean isSaving()
      Specified by:
      isSaving in interface DataGridEditor<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 interface com.vaadin.flow.component.grid.editor.Editor<T>
    • save

      public boolean save()
      Specified by:
      save in interface com.vaadin.flow.component.grid.editor.Editor<T>
    • isEditorEditComponentsValid

      protected boolean isEditorEditComponentsValid()
    • validateEditor

      protected ValidationErrors validateEditor()
    • writeEditComponents

      protected void writeEditComponents()
    • writeComponent

      protected void writeComponent(com.vaadin.flow.component.Component component)
    • cancel

      public void cancel()
      Specified by:
      cancel in interface com.vaadin.flow.component.grid.editor.Editor<T>
    • closeEditor

      public void closeEditor()
      Specified by:
      closeEditor in interface com.vaadin.flow.component.grid.editor.Editor<T>
    • editItem

      public void editItem(T item)
      Specified by:
      editItem in interface com.vaadin.flow.component.grid.editor.Editor<T>
    • requestEditItem

      protected void requestEditItem(T item)
    • refresh

      public void refresh()
      Specified by:
      refresh in interface com.vaadin.flow.component.grid.editor.Editor<T>
    • getItem

      public T getItem()
      Specified by:
      getItem in interface DataGridEditor<T>
      Specified by:
      getItem in interface com.vaadin.flow.component.grid.editor.Editor<T>
    • getGrid

      public com.vaadin.flow.component.grid.Grid<T> getGrid()
      Specified by:
      getGrid in interface com.vaadin.flow.component.grid.editor.Editor<T>
      Overrides:
      getGrid in class com.vaadin.flow.component.grid.Grid.AbstractGridExtension<T>
    • generateData

      public void generateData(@Nullable T item, elemental.json.JsonObject jsonObject)
      Specified by:
      generateData in interface com.vaadin.flow.data.provider.DataGenerator<T>
    • closeInternal

      protected void closeInternal()
    • handleItemClick

      protected void handleItemClick(com.vaadin.flow.component.grid.ItemClickEvent<T> event)
    • validateCanEdit

      protected void validateCanEdit(T item)
    • createValueSourceProvider

      protected ValueSourceProvider createValueSourceProvider(T item)
    • createInstanceContainer

      protected InstanceContainer<T> createInstanceContainer(T item)
    • clearItemValueSourceProviders

      protected void clearItemValueSourceProviders(@Nullable T item)
    • detachItemContainer

      protected void detachItemContainer(DataGridEditorValueSourceProvider<T> valueSourceProvider)
    • clearEditorComponents

      protected void clearEditorComponents()
    • dataProviderChanged

      public void dataProviderChanged()
      Specified by:
      dataProviderChanged in interface DataGridDataProviderChangeObserver
    • getEntityMetaClass

      protected MetaClass getEntityMetaClass()
    • initColumnDefaultEditorComponent

      public void initColumnDefaultEditorComponent(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. To find the column it's assumed that the column key is equal to the property.
      Specified by:
      initColumnDefaultEditorComponent in interface DataGridEditor<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 use EditComponentGenerationContext.getValueSourceProvider() to obtain an instance of ValueSource. To find the column it's assumed that the column key is equal to the property.
      Specified by:
      setColumnEditorComponent in interface DataGridEditor<T>
      Parameters:
      property - an entity attribute for which the edit component is created
      generator - 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 interface DataGridEditor<T>
      Parameters:
      column - a grid column for which to set editor component
      property - 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 use EditComponentGenerationContext.getValueSourceProvider() to obtain an instance of ValueSource.
      Specified by:
      setColumnEditorComponent in interface DataGridEditor<T>
      Parameters:
      column - a grid column for which to set editor component
      property - an entity attribute for which the edit component is created
      generator - a callback function that is used to create an edit component
      See Also:
    • defaultComponentStatusHandler

      protected void defaultComponentStatusHandler(SupportsStatusChangeHandler.StatusContext<?> statusContext)
    • handleComponentStatus

      protected void handleComponentStatus(SupportsStatusChangeHandler.StatusContext<?> statusContext)
    • setDefaultComponentStatusHandler

      public void setDefaultComponentStatusHandler(@Nullable Consumer<SupportsStatusChangeHandler.StatusContext<?>> handler)
      Description copied from interface: DataGridEditor
      Sets a callback that is set to editor components which implement SupportsStatusChangeHandler. If a custom component generator is used, this status handler can be obtained from EditComponentGenerationContext.getStatusHandler().
      Specified by:
      setDefaultComponentStatusHandler in interface DataGridEditor<T>
      Parameters:
      handler - a callback that is set to editor components which implement SupportsStatusChangeHandler
    • 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. when Editor.save() is invoked.

      Note! This handler can be called only if editor is in buffered mode.

      Specified by:
      setValidationErrorsHandler in interface DataGridEditor<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 interface com.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 interface com.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 interface com.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 interface com.vaadin.flow.component.grid.editor.Editor<T>
    • addListener

      protected <L> com.vaadin.flow.shared.Registration addListener(Class<L> listenerType, L listener)
    • fireOpenEvent

      protected void fireOpenEvent(com.vaadin.flow.component.grid.editor.EditorOpenEvent<T> event)
    • fireCancelEvent

      protected void fireCancelEvent(com.vaadin.flow.component.grid.editor.EditorCancelEvent<T> event)
    • fireSaveEvent

      protected void fireSaveEvent(com.vaadin.flow.component.grid.editor.EditorSaveEvent<T> event)
    • fireCloseEvent

      protected void fireCloseEvent(com.vaadin.flow.component.grid.editor.EditorCloseEvent<T> event)
    • getDataComponents

      protected DataComponents getDataComponents()
    • getUiComponentsGenerator

      protected UiComponentsGenerator getUiComponentsGenerator()
    • getViewValidation

      protected ViewValidation getViewValidation()