public class EditorBuilder<E extends Entity>
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 Screens.LaunchMode |
launchMode |
protected ListComponent<E> |
listComponent |
protected EditMode |
mode |
protected E |
newEntity |
protected ScreenOptions |
options |
protected FrameOwner |
origin |
protected DataContext |
parentDataContext |
protected java.lang.String |
screenId |
protected java.util.function.Function<E,E> |
transformation |
Modifier | Constructor and Description |
---|---|
protected |
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(Entity) . |
java.lang.Class<E> |
getEntityClass()
Returns edited entity class.
|
HasValue<E> |
getField()
Returns the field component set by
withField(com.haulmont.cuba.gui.components.HasValue) . |
java.util.function.Consumer<E> |
getInitializer()
Returns initializer set by
withInitializer(Consumer) . |
Screens.LaunchMode |
getLaunchMode()
Returns launch mode set by
withLaunchMode(Screens.LaunchMode) . |
ListComponent<E> |
getListComponent()
Returns list component set by
withListComponent(ListComponent) . |
EditMode |
getMode()
Returns builder mode derived from previous calls to
newEntity() or editEntity(Entity) . |
E |
getNewEntity()
Returns new entity set by
newEntity(Entity) . |
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> |
withLaunchMode(Screens.LaunchMode launchMode)
Sets
Screens.LaunchMode for the editor screen 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.util.function.Function<EditorBuilder<E extends Entity>,Screen> handler
protected CollectionContainer<E extends Entity> container
protected java.util.function.Function<E extends Entity,E extends Entity> transformation
protected Screens.LaunchMode launchMode
protected ScreenOptions options
protected ListComponent<E extends Entity> listComponent
protected java.lang.String screenId
protected DataContext parentDataContext
protected EditMode mode
protected java.lang.Boolean addFirst
protected 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(Entity)
public EditorBuilder<E> newEntity(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(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(Entity)
methods are invoked on the builder.
public EditorBuilder<E> withTransformation(java.util.function.Function<E,E> transformation)
transformation
- edited entity transformationwithContainer(CollectionContainer)
,
withField(HasValue)
,
withListComponent(ListComponent)
public EditorBuilder<E> withLaunchMode(Screens.LaunchMode launchMode)
Screens.LaunchMode
for the editor screen and returns the builder for chaining.
For example: builder.withLaunchMode(OpenMode.DIALOG).build();
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(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.
public HasValue<E> getField()
withField(com.haulmont.cuba.gui.components.HasValue)
.public java.lang.String getScreenId()
withScreenId(String)
.public DataContext getParentDataContext()
withParentDataContext(DataContext)
.public java.lang.Class<E> getEntityClass()
public E getNewEntity()
newEntity(Entity)
.public E getEditedEntity()
editEntity(Entity)
.public CollectionContainer<E> getContainer()
withContainer(CollectionContainer)
.public java.util.function.Consumer<E> getInitializer()
withInitializer(Consumer)
.public Screens.LaunchMode getLaunchMode()
withLaunchMode(Screens.LaunchMode)
.public FrameOwner getOrigin()
public ScreenOptions getOptions()
withOptions(ScreenOptions)
.public java.lang.Boolean getAddFirst()
public ListComponent<E> getListComponent()
withListComponent(ListComponent)
.public EditMode getMode()
newEntity()
or editEntity(Entity)
.public java.util.function.Function<E,E> getTransformation()
public Screen build()
Screen.show()
.public Screen show()