Class EditorBuilder<E>

java.lang.Object
io.jmix.ui.builder.EditorBuilder<E>
Direct Known Subclasses:
EditorClassBuilder

public class EditorBuilder<E> extends Object
Editor screen builder that is not aware of concrete screen class. It's build() method returns Screen.
  • Field Details

  • Constructor Details

  • Method Details

    • newEntity

      public EditorBuilder<E> newEntity()
      Sets EditMode to CREATE and returns the builder for chaining.

      A new entity instance will be created automatically. It can be initialized by code passed to the withInitializer(Consumer) method.

      See Also:
    • newEntity

      public EditorBuilder<E> newEntity(@Nullable E entity)
      Sets EditMode to CREATE and returns the builder for chaining.

      The new entity instance is accepted as the parameter. It can be initialized by code passed to the withInitializer(Consumer) method.

      Parameters:
      entity - new entity instance to be passed to the editor screen
      See Also:
    • editEntity

      public EditorBuilder<E> editEntity(@Nullable E entity)
      Sets EditMode to EDIT and returns the builder for chaining.
      Parameters:
      entity - entity instance to be passed to the editor screen
      See Also:
    • withContainer

      public EditorBuilder<E> withContainer(CollectionContainer<E> container)
      Sets CollectionContainer and returns the builder for chaining.

      The container is updated after the editor screen is committed. If the container is Nested, the framework automatically initializes the reference to the parent entity and sets up data contexts for editing compositions.

    • withInitializer

      public EditorBuilder<E> withInitializer(Consumer<E> initializer)
      Sets code to initialize a new entity instance and returns the builder for chaining.

      The initializer is invoked only when EditMode is CREATE, i.e. when newEntity() or newEntity(Object) methods are invoked on the builder.

    • withTransformation

      public EditorBuilder<E> withTransformation(@Nullable Function<E,E> transformation)
      Sets code to transform the edited entity after editor commit and returns the builder for chaining.
      Applied only if either field or container or listComponent is assigned.
      Parameters:
      transformation - edited entity transformation
      See Also:
    • withOpenMode

      public EditorBuilder<E> withOpenMode(OpenMode openMode)
      Sets OpenMode for the editor screen and returns the builder for chaining.

      For example: builder.withOpenMode(OpenMode.DIALOG).build();

    • withAddFirst

      public EditorBuilder<E> withAddFirst(boolean addFirst)
      Defines whether a new item will be added to the beginning or to the end of collection. Affects only standalone containers, for nested containers new items are always added to the end.
    • withParentDataContext

      public EditorBuilder<E> withParentDataContext(@Nullable DataContext parentDataContext)
      Sets parent DataContext for the editor screen and returns the builder for chaining.

      The screen will commit data to the parent context instead of directly to DataManager.

    • withOptions

      public EditorBuilder<E> withOptions(ScreenOptions options)
      Sets ScreenOptions for the editor screen and returns the builder for chaining.
    • withListComponent

      public EditorBuilder<E> withListComponent(ListComponent<E> listComponent)
      Sets list component and returns the builder for chaining.

      The component is used to get the container if it is not set explicitly by withContainer(CollectionContainer) method. Usually, the list component is a Table or DataGrid displaying the list of entities.

    • withScreenId

      public EditorBuilder<E> withScreenId(String screenId)
      Sets screen id and returns the builder for chaining.
      Parameters:
      screenId - identifier of the editor screen as specified in the UiController annotation or screens.xml.
    • withScreenClass

      public <S extends Screen & EditorScreen<E>> EditorClassBuilder<E,S> withScreenClass(Class<S> screenClass)
      Sets screen class and returns the EditorClassBuilder for chaining.
      Parameters:
      screenClass - class of the screen controller
    • withField

      public <T extends HasValue<E>> EditorBuilder<E> withField(T field)
      Sets the field component and returns the builder for chaining.

      If the field is set, the framework sets the committed entity to the field after successful editor commit.

    • getField

      @Nullable public HasValue<E> getField()
      Returns the field component set by withField(HasValue).
    • getScreenId

      @Nullable public String getScreenId()
      Returns screen id set by withScreenId(String).
    • getParentDataContext

      @Nullable public DataContext getParentDataContext()
      Returns parent data context set by withParentDataContext(DataContext).
    • getEntityClass

      public Class<E> getEntityClass()
      Returns edited entity class.
    • getNewEntity

      @Nullable public E getNewEntity()
      Returns new entity set by newEntity(Object).
    • getEditedEntity

      public E getEditedEntity()
      Returns entity set by editEntity(Object).
    • getContainer

      @Nullable public CollectionContainer<E> getContainer()
      Returns container set by withContainer(CollectionContainer).
    • getInitializer

      @Nullable public Consumer<E> getInitializer()
      Returns initializer set by withInitializer(Consumer).
    • getOpenMode

      public OpenMode getOpenMode()
      Returns launch mode set by withOpenMode(OpenMode).
    • getOrigin

      public FrameOwner getOrigin()
      Returns invoking screen.
    • getOptions

      public ScreenOptions getOptions()
      Returns screen options set by withOptions(ScreenOptions).
    • getAddFirst

      @Nullable public Boolean getAddFirst()
      Returns if a new item will be added to the beginning or to the end of collection. Affects only standalone containers, for nested containers new items are always added to the end.
    • getListComponent

      @Nullable public ListComponent<E> getListComponent()
      Returns list component set by withListComponent(ListComponent).
    • getMode

      public EditMode getMode()
      Returns builder mode derived from previous calls to newEntity() or editEntity(Object).
    • getTransformation

      @Nullable public Function<E,E> getTransformation()
      Returns edited entity transformation.
    • build

      public Screen build()
      Builds the editor screen. Screen should be shown using Screen.show().
    • show

      public Screen show()
      Builds and shows the editor screen.