public class EditorBuilder<E>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.Boolean |
addFirst |
protected CollectionContainer<E> |
container |
protected E |
editedEntity |
protected java.lang.Class<E> |
entityClass |
protected HasValue<E> |
field |
protected java.util.function.Function<EditorBuilder<E>,Screen> |
handler |
protected java.util.function.Consumer<E> |
initializer |
protected ListComponent<E> |
listComponent |
protected EditMode |
mode |
protected E |
newEntity |
protected OpenMode |
openMode |
protected ScreenOptions |
options |
protected FrameOwner |
origin |
protected DataContext |
parentDataContext |
protected java.lang.String |
screenId |
protected java.util.function.Function<E,E> |
transformation |
| Constructor and Description |
|---|
EditorBuilder(EditorBuilder<E> builder) |
EditorBuilder(FrameOwner origin,
java.lang.Class<E> entityClass,
java.util.function.Function<EditorBuilder<E>,Screen> handler) |
| Modifier and Type | Method and Description |
|---|---|
Screen |
build()
Builds the editor screen.
|
EditorBuilder<E> |
editEntity(E entity)
Sets
EditMode to EDIT and returns the builder for chaining. |
java.lang.Boolean |
getAddFirst()
Returns if a new item will be added to the beginning or to the end of collection.
|
CollectionContainer<E> |
getContainer()
Returns container set by
withContainer(CollectionContainer). |
E |
getEditedEntity()
Returns entity set by
editEntity(Object). |
java.lang.Class<E> |
getEntityClass()
Returns edited entity class.
|
HasValue<E> |
getField()
Returns the field component set by
withField(HasValue). |
java.util.function.Consumer<E> |
getInitializer()
Returns initializer set by
withInitializer(Consumer). |
ListComponent<E> |
getListComponent()
Returns list component set by
withListComponent(ListComponent). |
EditMode |
getMode()
Returns builder mode derived from previous calls to
newEntity() or editEntity(Object). |
E |
getNewEntity()
Returns new entity set by
newEntity(Object). |
OpenMode |
getOpenMode()
Returns launch mode set by
withOpenMode(OpenMode). |
ScreenOptions |
getOptions()
Returns screen options set by
withOptions(ScreenOptions). |
FrameOwner |
getOrigin()
Returns invoking screen.
|
DataContext |
getParentDataContext()
Returns parent data context set by
withParentDataContext(DataContext). |
java.lang.String |
getScreenId()
Returns screen id set by
withScreenId(String). |
java.util.function.Function<E,E> |
getTransformation()
Returns edited entity transformation.
|
EditorBuilder<E> |
newEntity()
Sets
EditMode to CREATE and returns the builder for chaining. |
EditorBuilder<E> |
newEntity(E entity)
Sets
EditMode to CREATE and returns the builder for chaining. |
Screen |
show()
Builds and shows the editor screen.
|
EditorBuilder<E> |
withAddFirst(boolean addFirst)
Defines whether a new item will be added to the beginning or to the end of collection.
|
EditorBuilder<E> |
withContainer(CollectionContainer<E> container)
Sets
CollectionContainer and returns the builder for chaining. |
<T extends HasValue<E>> |
withField(T field)
Sets the field component and returns the builder for chaining.
|
EditorBuilder<E> |
withInitializer(java.util.function.Consumer<E> initializer)
Sets code to initialize a new entity instance and returns the builder for chaining.
|
EditorBuilder<E> |
withListComponent(ListComponent<E> listComponent)
Sets list component and returns the builder for chaining.
|
EditorBuilder<E> |
withOpenMode(OpenMode openMode)
Sets
OpenMode for the editor screen and returns the builder for chaining. |
EditorBuilder<E> |
withOptions(ScreenOptions options)
Sets
ScreenOptions for the editor screen and returns the builder for chaining. |
EditorBuilder<E> |
withParentDataContext(DataContext parentDataContext)
Sets parent
DataContext for the editor screen and returns the builder for chaining. |
<S extends Screen & EditorScreen<E>> |
withScreenClass(java.lang.Class<S> screenClass)
Sets screen class and returns the
EditorClassBuilder for chaining. |
EditorBuilder<E> |
withScreenId(java.lang.String screenId)
Sets screen id and returns the builder for chaining.
|
EditorBuilder<E> |
withTransformation(java.util.function.Function<E,E> transformation)
Sets code to transform the edited entity after editor commit and returns the builder for chaining.
|
protected final FrameOwner origin
protected final java.lang.Class<E> entityClass
protected final java.util.function.Function<EditorBuilder<E>,Screen> handler
protected E newEntity
protected E editedEntity
protected CollectionContainer<E> container
protected java.util.function.Consumer<E> initializer
protected OpenMode openMode
protected ScreenOptions options
protected ListComponent<E> listComponent
protected java.lang.String screenId
protected DataContext parentDataContext
protected EditMode mode
protected java.lang.Boolean addFirst
public EditorBuilder(EditorBuilder<E> builder)
public EditorBuilder(FrameOwner origin, java.lang.Class<E> entityClass, java.util.function.Function<EditorBuilder<E>,Screen> handler)
public EditorBuilder<E> newEntity()
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.
newEntity(Object)public EditorBuilder<E> newEntity(@Nullable E entity)
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.
entity - new entity instance to be passed to the editor screennewEntity()public EditorBuilder<E> editEntity(@Nullable E entity)
EditMode to EDIT and returns the builder for chaining.entity - entity instance to be passed to the editor screennewEntity()public EditorBuilder<E> withContainer(CollectionContainer<E> container)
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.
public EditorBuilder<E> withInitializer(java.util.function.Consumer<E> initializer)
The initializer is invoked only when EditMode is CREATE, i.e. when newEntity() or
newEntity(Object) methods are invoked on the builder.
public EditorBuilder<E> withTransformation(@Nullable java.util.function.Function<E,E> transformation)
transformation - edited entity transformationwithContainer(CollectionContainer),
withField(HasValue),
withListComponent(ListComponent)public EditorBuilder<E> withOpenMode(OpenMode openMode)
OpenMode for the editor screen and returns the builder for chaining.
For example: builder.withOpenMode(OpenMode.DIALOG).build();
public EditorBuilder<E> withAddFirst(boolean addFirst)
public EditorBuilder<E> withParentDataContext(@Nullable DataContext parentDataContext)
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.
public EditorBuilder<E> withOptions(ScreenOptions options)
ScreenOptions for the editor screen and returns the builder for chaining.public EditorBuilder<E> withListComponent(ListComponent<E> listComponent)
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.
public EditorBuilder<E> withScreenId(java.lang.String screenId)
screenId - identifier of the editor screen as specified in the UiController annotation
or screens.xml.public <S extends Screen & EditorScreen<E>> EditorClassBuilder<E,S> withScreenClass(java.lang.Class<S> screenClass)
EditorClassBuilder for chaining.screenClass - class of the screen controllerpublic <T extends HasValue<E>> EditorBuilder<E> withField(T field)
If the field is set, the framework sets the committed entity to the field after successful editor commit.
@Nullable public HasValue<E> getField()
withField(HasValue).@Nullable public java.lang.String getScreenId()
withScreenId(String).@Nullable public DataContext getParentDataContext()
withParentDataContext(DataContext).public java.lang.Class<E> getEntityClass()
@Nullable public E getNewEntity()
newEntity(Object).public E getEditedEntity()
editEntity(Object).@Nullable public CollectionContainer<E> getContainer()
withContainer(CollectionContainer).@Nullable public java.util.function.Consumer<E> getInitializer()
withInitializer(Consumer).public OpenMode getOpenMode()
withOpenMode(OpenMode).public FrameOwner getOrigin()
public ScreenOptions getOptions()
withOptions(ScreenOptions).@Nullable public java.lang.Boolean getAddFirst()
@Nullable public ListComponent<E> getListComponent()
withListComponent(ListComponent).public EditMode getMode()
newEntity() or editEntity(Object).@Nullable public java.util.function.Function<E,E> getTransformation()
public Screen build()
Screen.show().public Screen show()