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>, DataGenerator<T>, Serializable

public class EditorImpl<T> extends Grid.AbstractGridExtension<T> implements Editor<T>
Implementation of Editor interface.
See Also:
  • Constructor Details

  • Method Details

    • setBinder

      public Editor<T> setBinder(Binder<T> binder)
      Description copied from interface: Editor
      Sets the underlying Binder to this Editor.
      Specified by:
      setBinder in interface Editor<T>
      Parameters:
      binder - the binder for updating editor fields; not null
      Returns:
      this editor
    • getBinder

      public Binder<T> getBinder()
      Description copied from interface: Editor
      Returns the underlying Binder from Editor.
      Specified by:
      getBinder in interface Editor<T>
      Returns:
      the binder; not null
    • setBuffered

      public Editor<T> setBuffered(boolean buffered)
      Description copied from interface: Editor
      Sets 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:
      setBuffered in interface Editor<T>
      Parameters:
      buffered - true if editor should be buffered; false if not
      Returns:
      this editor
    • isBuffered

      public boolean isBuffered()
      Description copied from interface: Editor
      Returns whether Editor is buffered or not.
      Specified by:
      isBuffered in interface Editor<T>
      Returns:
      true if editor is buffered; false if not
      See Also:
    • isOpen

      public boolean isOpen()
      Description copied from interface: Editor
      Returns whether Editor is open or not.
      Specified by:
      isOpen in interface Editor<T>
      Returns:
      true if editor is open; false if not
    • save

      public boolean save()
      Description copied from interface: Editor
      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.

      A successful write will fire an EditorSaveEvent and close the editor that will fire an EditorCloseEvent.

      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.

      Specified by:
      save in interface Editor<T>
      Returns:
      true if save succeeded; false if not
    • cancel

      public void cancel()
      Description copied from interface: Editor
      Cancel will discard any changes made in editor fields for a buffered editor.

      Calling cancel will fire an EditorCancelEvent and close the editor that will fire an EditorCloseEvent if the edited item is not null.

      Specified by:
      cancel in interface Editor<T>
    • closeEditor

      public void closeEditor()
      Description copied from interface: Editor
      Closes the editor when in unbuffered mode and fires an EditorCloseEvent if the edited item is not null.

      For buffered mode calling close editor will throw an UnsupportedOperationException as either Editor.save() or Editor.cancel() should be used.

      Specified by:
      closeEditor in interface Editor<T>
    • editItem

      public void editItem(T item)
      Description copied from interface: Editor
      Opens the editor component for the provided item and fires an EditorOpenEvent.

      In case there is an open editor an EditorCloseEvent will also be fired.

      Specified by:
      editItem in interface Editor<T>
      Parameters:
      item - the edited item
    • refresh

      public void refresh()
      Description copied from interface: Editor
      Refreshes 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:
      refresh in interface Editor<T>
      See Also:
    • getItem

      public T getItem()
      Description copied from interface: Editor
      Gets the current item being edited, if any.

      The item being edited is always null while the editor is closed. The item is not null during Editor.save() and Editor.cancel() operations, but become null as soon as the editor is closed.

      Specified by:
      getItem in interface Editor<T>
      Returns:
      the item being edited, or null if none is being edited
      See Also:
    • getGrid

      public Grid<T> getGrid()
      Description copied from class: Grid.AbstractGridExtension
      Gets the Grid this extension extends.
      Specified by:
      getGrid in interface Editor<T>
      Overrides:
      getGrid in class Grid.AbstractGridExtension<T>
      Returns:
      the grid this extension extends
    • generateData

      public void generateData(T item, elemental.json.JsonObject jsonObject)
      Description copied from interface: DataGenerator
      Adds custom data for the given item to its serialized JsonObject representation. This JSON object will be sent to client-side DataProvider.
      Specified by:
      generateData in interface DataGenerator<T>
      Parameters:
      item - the data item being serialized
      jsonObject - the JSON object being sent to the client
    • addSaveListener

      public Registration addSaveListener(EditorSaveListener<T> listener)
      Description copied from interface: Editor
      Adds an editor save listener. EditorSaveEvent is called when Editor.save() is called.
      Specified by:
      addSaveListener in interface Editor<T>
      Parameters:
      listener - save listener
      Returns:
      a registration object for removing the listener
    • addCancelListener

      public Registration addCancelListener(EditorCancelListener<T> listener)
      Description copied from interface: Editor
      Adds an editor cancel listener. EditorCancelEvent is fired when Editor.cancel() is called.
      Specified by:
      addCancelListener in interface Editor<T>
      Parameters:
      listener - cancel listener
      Returns:
      a registration object for removing the listener
    • addOpenListener

      public Registration addOpenListener(EditorOpenListener<T> listener)
      Description copied from interface: Editor
      Adds an editor open listener. EditorOpenEvent is fired when the editor is opened through Editor.editItem(java.lang.Object)
      Specified by:
      addOpenListener in interface Editor<T>
      Parameters:
      listener - open listener
      Returns:
      a registration object for removing the listener
    • addCloseListener

      public Registration addCloseListener(EditorCloseListener<T> listener)
      Description copied from interface: Editor
      Adds an editor close listener. 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 a Editor.cancel() operation is performed, two listeners are triggered, cancel and close listeners.

      Specified by:
      addCloseListener in interface Editor<T>
      Parameters:
      listener - close listener
      Returns:
      a registration object for removing the listener