public class EditorClassBuilder<E extends Entity,S extends Screen & EditorScreen<E>> extends EditorBuilder<E>
build()
method returns that class.Modifier and Type | Field and Description |
---|---|
protected java.util.function.Consumer<AfterScreenCloseEvent<S>> |
closeListener |
protected java.lang.Class<S> |
screenClass |
addFirst, container, editedEntity, entityClass, field, handler, initializer, launchMode, listComponent, mode, newEntity, options, origin, parentDataContext, screenId, transformation
Constructor and Description |
---|
EditorClassBuilder(EditorBuilder<E> builder,
java.lang.Class<S> screenClass) |
Modifier and Type | Method and Description |
---|---|
S |
build()
Builds the editor screen.
|
EditorClassBuilder<E,S> |
editEntity(E entity)
Sets
EditMode to EDIT and returns the builder for chaining. |
java.util.function.Consumer<AfterScreenCloseEvent<S>> |
getCloseListener()
Returns screen close listener.
|
java.lang.Class<S> |
getScreenClass()
Returns editor screen class.
|
EditorClassBuilder<E,S> |
newEntity()
Sets
EditMode to CREATE and returns the builder for chaining. |
EditorClassBuilder<E,S> |
newEntity(E entity)
Sets
EditMode to CREATE and returns the builder for chaining. |
S |
show()
Builds and shows the editor screen.
|
EditorClassBuilder<E,S> |
withAddFirst(boolean addFirst)
Defines whether a new item will be added to the beginning or to the end of collection.
|
EditorClassBuilder<E,S> |
withAfterCloseListener(java.util.function.Consumer<AfterScreenCloseEvent<S>> listener)
Adds
Screen.AfterCloseEvent listener to the screen. |
EditorClassBuilder<E,S> |
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.
|
EditorClassBuilder<E,S> |
withInitializer(java.util.function.Consumer<E> initializer)
Sets code to initialize a new entity instance and returns the builder for chaining.
|
EditorClassBuilder<E,S> |
withLaunchMode(Screens.LaunchMode launchMode)
Sets
Screens.LaunchMode for the editor screen and returns the builder for chaining. |
EditorClassBuilder<E,S> |
withListComponent(ListComponent<E> listComponent)
Sets list component and returns the builder for chaining.
|
EditorClassBuilder<E,S> |
withOpenMode(OpenMode openMode)
Sets
OpenMode for the editor screen and returns the builder for chaining. |
EditorClassBuilder<E,S> |
withOptions(ScreenOptions options)
Sets
ScreenOptions for the editor screen and returns the builder for chaining. |
EditorClassBuilder<E,S> |
withParentDataContext(DataContext parentDataContext)
Sets parent
DataContext for the editor screen and returns the builder for chaining. |
EditorBuilder<E> |
withScreenId(java.lang.String screenId)
Sets screen id and returns the builder for chaining.
|
EditorClassBuilder<E,S> |
withTransformation(java.util.function.Function<E,E> transformation)
Sets code to transform the edited entity after editor commit and returns the builder for chaining.
|
getAddFirst, getContainer, getEditedEntity, getEntityClass, getField, getInitializer, getLaunchMode, getListComponent, getMode, getNewEntity, getOptions, getOrigin, getParentDataContext, getScreenId, getTransformation, withScreenClass
protected java.lang.Class<S extends Screen & EditorScreen<E>> screenClass
protected java.util.function.Consumer<AfterScreenCloseEvent<S extends Screen & EditorScreen<E>>> closeListener
public EditorClassBuilder(EditorBuilder<E> builder, java.lang.Class<S> screenClass)
public EditorClassBuilder<E,S> newEntity()
EditorBuilder
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 EditorBuilder.withInitializer(Consumer)
method.
newEntity
in class EditorBuilder<E extends Entity>
EditorBuilder.newEntity(Entity)
public EditorClassBuilder<E,S> editEntity(E entity)
EditorBuilder
EditMode
to EDIT
and returns the builder for chaining.editEntity
in class EditorBuilder<E extends Entity>
entity
- entity instance to be passed to the editor screenEditorBuilder.newEntity()
public EditorClassBuilder<E,S> newEntity(E entity)
EditorBuilder
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 EditorBuilder.withInitializer(Consumer)
method.
newEntity
in class EditorBuilder<E extends Entity>
entity
- new entity instance to be passed to the editor screenEditorBuilder.newEntity()
public EditorClassBuilder<E,S> withContainer(CollectionContainer<E> container)
EditorBuilder
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.
withContainer
in class EditorBuilder<E extends Entity>
public EditorClassBuilder<E,S> withInitializer(java.util.function.Consumer<E> initializer)
EditorBuilder
The initializer is invoked only when EditMode
is CREATE
, i.e. when EditorBuilder.newEntity()
or
EditorBuilder.newEntity(Entity)
methods are invoked on the builder.
withInitializer
in class EditorBuilder<E extends Entity>
public EditorClassBuilder<E,S> withAddFirst(boolean addFirst)
EditorBuilder
withAddFirst
in class EditorBuilder<E extends Entity>
public EditorClassBuilder<E,S> withLaunchMode(Screens.LaunchMode launchMode)
EditorBuilder
Screens.LaunchMode
for the editor screen and returns the builder for chaining.
For example: builder.withLaunchMode(OpenMode.DIALOG).build();
withLaunchMode
in class EditorBuilder<E extends Entity>
public EditorClassBuilder<E,S> withOpenMode(OpenMode openMode)
EditorBuilder
OpenMode
for the editor screen and returns the builder for chaining.
For example: builder.withOpenMode(OpenMode.DIALOG).build();
withOpenMode
in class EditorBuilder<E extends Entity>
public EditorClassBuilder<E,S> withParentDataContext(DataContext parentDataContext)
EditorBuilder
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
.
withParentDataContext
in class EditorBuilder<E extends Entity>
public EditorClassBuilder<E,S> withOptions(ScreenOptions options)
EditorBuilder
ScreenOptions
for the editor screen and returns the builder for chaining.withOptions
in class EditorBuilder<E extends Entity>
public EditorClassBuilder<E,S> withListComponent(ListComponent<E> listComponent)
EditorBuilder
The component is used to get the container
if it is not set explicitly by
EditorBuilder.withContainer(CollectionContainer)
method. Usually, the list component is a Table
or DataGrid
displaying the list of entities.
withListComponent
in class EditorBuilder<E extends Entity>
public EditorBuilder<E> withScreenId(java.lang.String screenId)
EditorBuilder
withScreenId
in class EditorBuilder<E extends Entity>
screenId
- identifier of the editor screen as specified in the UiController
annotation
or screens.xml
.public EditorClassBuilder<E,S> withAfterCloseListener(java.util.function.Consumer<AfterScreenCloseEvent<S>> listener)
Screen.AfterCloseEvent
listener to the screen.listener
- listenerpublic EditorClassBuilder<E,S> withTransformation(java.util.function.Function<E,E> transformation)
EditorBuilder
withTransformation
in class EditorBuilder<E extends Entity>
transformation
- edited entity transformationEditorBuilder.withContainer(CollectionContainer)
,
EditorBuilder.withField(HasValue)
,
EditorBuilder.withListComponent(ListComponent)
public <T extends HasValue<E>> EditorClassBuilder<E,S> withField(T field)
EditorBuilder
If the field is set, the framework sets the committed entity to the field after successful editor commit.
withField
in class EditorBuilder<E extends Entity>
public java.lang.Class<S> getScreenClass()
public java.util.function.Consumer<AfterScreenCloseEvent<S>> getCloseListener()
public S build()
EditorBuilder
Screen.show()
.build
in class EditorBuilder<E extends Entity>
public S show()
EditorBuilder
show
in class EditorBuilder<E extends Entity>