Interface Editor<T>

  • Type Parameters:
    T -
    All Superinterfaces:
    Serializable
    All Known Implementing Classes:
    EditorImpl

    public interface Editor<T>
    extends Serializable
    An editor in a Grid.
    Since:
    8.0
    Author:
    Vaadin Ltd
    • Method Detail

      • setBinder

        Editor<T> setBinder​(Binder<T> binder)
        Sets the underlying Binder to this Editor.
        Parameters:
        binder - the binder for updating editor fields; not null
        Returns:
        this editor
      • getBinder

        Binder<T> getBinder()
        Returns the underlying Binder from Editor.
        Returns:
        the binder; not null
      • setBuffered

        Editor<T> setBuffered​(boolean buffered)
        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.
        Parameters:
        buffered - true if editor should be buffered; false if not
        Returns:
        this editor
      • setEnabled

        Editor<T> setEnabled​(boolean enabled)
        Enables or disabled the Editor. A disabled editor cannot be opened.
        Parameters:
        enabled - true if editor should be enabled; false if not
        Returns:
        this editor
      • isBuffered

        boolean isBuffered()
        Returns whether Editor is buffered or not.
        Returns:
        true if editor is buffered; false if not
        See Also:
        setBuffered(boolean)
      • isEnabled

        boolean isEnabled()
        Returns whether Editor is enabled or not.
        Returns:
        true if editor is enabled; false if not
      • isOpen

        boolean isOpen()
        Returns whether Editor is open or not.
        Returns:
        true if editor is open; false if not
      • save

        boolean save()
        Saves any changes from the Editor fields to the edited bean.
        Returns:
        true if save succeeded; false if not
      • cancel

        void cancel()
        Close the editor discarding any unsaved changes.
      • editRow

        void editRow​(int rowNumber)
        Opens the editor interface for the provided row. Scrolls the Grid to bring the row to view if it is not already visible. Note that any cell content rendered by a WidgetRenderer will not be visible in the editor row.
        Parameters:
        rowNumber - the row number of the edited item
        Throws:
        IllegalStateException - if the editor is not enabled, Grid is read-only, or already editing a different item in buffered mode
        IllegalArgumentException - if the rowNumber is not in the backing data provider
        Since:
        8.2
        See Also:
        setEnabled(boolean)
      • setSaveCaption

        Editor<T> setSaveCaption​(String saveCaption)
        Sets the caption of the save button in buffered mode.
        Parameters:
        saveCaption - the save button caption
        Returns:
        this editor
      • setCancelCaption

        Editor<T> setCancelCaption​(String cancelCaption)
        Sets the caption of the cancel button in buffered mode.
        Parameters:
        cancelCaption - the cancel button caption
        Returns:
        this editor
      • getSaveCaption

        String getSaveCaption()
        Gets the caption of the save button in buffered mode.
        Returns:
        the save button caption
      • getCancelCaption

        String getCancelCaption()
        Gets the caption of the cancel button in buffered mode.
        Returns:
        the cancel button caption
      • setErrorGenerator

        Editor<T> setErrorGenerator​(EditorErrorGenerator<T> errorGenerator)
        Sets the error message generator for this editor.

        The default message is a concatenation of column field validation failures and bean validation failures.

        Parameters:
        errorGenerator - the function to generate error messages; not null
        Returns:
        this editor
        See Also:
        EditorErrorGenerator
      • getErrorGenerator

        EditorErrorGenerator<T> getErrorGenerator()
        Gets the error message generator of this editor.
        Returns:
        the function that generates error messages; not null
        See Also:
        EditorErrorGenerator
      • addSaveListener

        Registration addSaveListener​(EditorSaveListener<T> listener)
        Adds an editor save listener.
        Parameters:
        listener - save listener
        Returns:
        a registration object for removing the listener
      • addCancelListener

        Registration addCancelListener​(EditorCancelListener<T> listener)
        Adds an editor cancel listener.
        Parameters:
        listener - cancel listener
        Returns:
        a registration object for removing the listener
      • addOpenListener

        Registration addOpenListener​(EditorOpenListener<T> listener)
        Adds an editor open listener.
        Parameters:
        listener - open listener
        Returns:
        a registration object for removing the listener
        Since:
        8.1
      • getGrid

        Grid<T> getGrid()
        Gets the Grid instance which this editor belongs to.
        Returns:
        the grid which owns the editor