Class EditorBuilder<E>
- Direct Known Subclasses:
EditorClassBuilder
-
Field Summary
Modifier and TypeFieldDescriptionprotected Boolean
protected CollectionContainer<E>
protected E
protected final Function<EditorBuilder<E>,
Screen> protected ListComponent<E>
protected EditMode
protected E
protected OpenMode
protected ScreenOptions
protected final FrameOwner
protected DataContext
protected String
-
Constructor Summary
ConstructorDescriptionEditorBuilder
(EditorBuilder<E> builder) EditorBuilder
(FrameOwner origin, Class<E> entityClass, Function<EditorBuilder<E>, Screen> handler) -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds the editor screen.editEntity
(E entity) SetsEditMode
toEDIT
and returns the builder for chaining.Returns if a new item will be added to the beginning or to the end of collection.Returns container set bywithContainer(CollectionContainer)
.Returns entity set byeditEntity(Object)
.Returns edited entity class.getField()
Returns the field component set bywithField(HasValue)
.Returns initializer set bywithInitializer(Consumer)
.Returns list component set bywithListComponent(ListComponent)
.getMode()
Returns builder mode derived from previous calls tonewEntity()
oreditEntity(Object)
.Returns new entity set bynewEntity(Object)
.Returns launch mode set bywithOpenMode(OpenMode)
.Returns screen options set bywithOptions(ScreenOptions)
.Returns invoking screen.Returns parent data context set bywithParentDataContext(DataContext)
.Returns screen id set bywithScreenId(String)
.Returns edited entity transformation.SetsEditMode
toCREATE
and returns the builder for chaining.SetsEditMode
toCREATE
and returns the builder for chaining.show()
Builds and shows the editor screen.withAddFirst
(boolean addFirst) Defines whether a new item will be added to the beginning or to the end of collection.withContainer
(CollectionContainer<E> container) SetsCollectionContainer
and returns the builder for chaining.<T extends HasValue<E>>
EditorBuilder<E>withField
(T field) Sets the field component and returns the builder for chaining.withInitializer
(Consumer<E> initializer) Sets code to initialize a new entity instance and returns the builder for chaining.withListComponent
(ListComponent<E> listComponent) Sets list component and returns the builder for chaining.withOpenMode
(OpenMode openMode) SetsOpenMode
for the editor screen and returns the builder for chaining.withOptions
(ScreenOptions options) SetsScreenOptions
for the editor screen and returns the builder for chaining.withParentDataContext
(DataContext parentDataContext) Sets parentDataContext
for the editor screen and returns the builder for chaining.<S extends Screen & EditorScreen<E>>
EditorClassBuilder<E,S> withScreenClass
(Class<S> screenClass) Sets screen class and returns theEditorClassBuilder
for chaining.withScreenId
(String screenId) Sets screen id and returns the builder for chaining.withTransformation
(Function<E, E> transformation) Sets code to transform the edited entity after editor commit and returns the builder for chaining.
-
Field Details
-
origin
-
entityClass
-
handler
-
newEntity
-
editedEntity
-
container
-
initializer
-
transformation
-
openMode
-
options
-
listComponent
-
field
-
screenId
-
parentDataContext
-
mode
-
addFirst
-
-
Constructor Details
-
EditorBuilder
-
EditorBuilder
public EditorBuilder(FrameOwner origin, Class<E> entityClass, Function<EditorBuilder<E>, Screen> handler)
-
-
Method Details
-
newEntity
SetsEditMode
toCREATE
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
SetsEditMode
toCREATE
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
SetsEditMode
toEDIT
and returns the builder for chaining.- Parameters:
entity
- entity instance to be passed to the editor screen- See Also:
-
withContainer
SetsCollectionContainer
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
Sets code to initialize a new entity instance and returns the builder for chaining.The initializer is invoked only when
EditMode
isCREATE
, i.e. whennewEntity()
ornewEntity(Object)
methods are invoked on the builder. -
withTransformation
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
SetsOpenMode
for the editor screen and returns the builder for chaining.For example:
builder.withOpenMode(OpenMode.DIALOG).build();
-
withAddFirst
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
Sets parentDataContext
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
SetsScreenOptions
for the editor screen and returns the builder for chaining. -
withListComponent
Sets list component and returns the builder for chaining.The component is used to get the
container
if it is not set explicitly bywithContainer(CollectionContainer)
method. Usually, the list component is aTable
orDataGrid
displaying the list of entities. -
withScreenId
Sets screen id and returns the builder for chaining.- Parameters:
screenId
- identifier of the editor screen as specified in theUiController
annotation orscreens.xml
.
-
withScreenClass
public <S extends Screen & EditorScreen<E>> EditorClassBuilder<E,S> withScreenClass(Class<S> screenClass) Sets screen class and returns theEditorClassBuilder
for chaining.- Parameters:
screenClass
- class of the screen controller
-
withField
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
Returns the field component set bywithField(HasValue)
. -
getScreenId
Returns screen id set bywithScreenId(String)
. -
getParentDataContext
Returns parent data context set bywithParentDataContext(DataContext)
. -
getEntityClass
Returns edited entity class. -
getNewEntity
Returns new entity set bynewEntity(Object)
. -
getEditedEntity
Returns entity set byeditEntity(Object)
. -
getContainer
Returns container set bywithContainer(CollectionContainer)
. -
getInitializer
Returns initializer set bywithInitializer(Consumer)
. -
getOpenMode
Returns launch mode set bywithOpenMode(OpenMode)
. -
getOrigin
Returns invoking screen. -
getOptions
Returns screen options set bywithOptions(ScreenOptions)
. -
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
Returns list component set bywithListComponent(ListComponent)
. -
getMode
Returns builder mode derived from previous calls tonewEntity()
oreditEntity(Object)
. -
getTransformation
Returns edited entity transformation. -
build
Builds the editor screen. Screen should be shown usingScreen.show()
. -
show
Builds and shows the editor screen.
-