Package io.jmix.ui.builder
Class LookupBuilder<E>
java.lang.Object
io.jmix.ui.builder.LookupBuilder<E>
- Direct Known Subclasses:
LookupClassBuilder
-
Field Summary
Modifier and TypeFieldDescriptionprotected CollectionContainer<E>
protected HasValue
protected final Function<LookupBuilder<E>,
Screen> protected boolean
protected ListComponent<E>
protected OpenMode
protected ScreenOptions
protected final FrameOwner
protected String
protected Consumer<Collection<E>>
protected Predicate<LookupScreen.ValidationContext<E>>
protected Function<Collection<E>,
Collection<E>> -
Constructor Summary
ConstructorDescriptionLookupBuilder
(LookupBuilder<E> builder) LookupBuilder
(FrameOwner origin, Class<E> entityClass, Function<LookupBuilder<E>, Screen> handler) -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds the lookup screen.Returns container set bywithContainer(CollectionContainer)
.Returns class of the entity to lookup.getField()
Returns the field component set bywithField(HasValue)
.Returns list component set bywithListComponent(ListComponent)
.Returns launch mode set bywithOpenMode(OpenMode)
.Returns screen options set bywithOptions(ScreenOptions)
.Returns invoking screen.Returns screen id set bywithScreenId(String)
.Returns selection handler set bywithSelectHandler(Consumer)
.Returns selection validator set bywithSelectValidator(Predicate)
.protected boolean
show()
Builds and shows the lookup screen.withContainer
(CollectionContainer<E> container) SetsCollectionContainer
and returns the builder for chaining.<T extends HasValue<E>>
LookupBuilder<E>withField
(T field) Sets the field component and returns the builder for chaining.withListComponent
(ListComponent<E> target) Sets list component and returns the builder for chaining.withOpenMode
(OpenMode openMode) SetsOpenMode
for the lookup screen and returns the builder for chaining.withOptions
(ScreenOptions options) SetsScreenOptions
for the lookup screen and returns the builder for chaining.<S extends Screen & LookupScreen<E>>
LookupClassBuilder<E,S> withScreenClass
(Class<S> screenClass) Sets screen class and returns theLookupClassBuilder
for chaining.withScreenId
(String screenId) Sets screen id and returns the builder for chaining.withSelectHandler
(Consumer<Collection<E>> selectHandler) Sets selection handler for the lookup screen and returns the builder for chaining.withSelectValidator
(Predicate<LookupScreen.ValidationContext<E>> selectValidator) Sets selection validator for the lookup screen and returns the builder for chaining.withTransformation
(Function<Collection<E>, Collection<E>> transformation) Sets code to transform entities after selection and returns the builder for chaining.<T extends HasValue<Collection<E>>>
LookupBuilder<E>withValuesField
(T field) Sets the field component with collection value type.
-
Field Details
-
origin
-
entityClass
-
handler
-
selectValidator
-
transformation
-
selectHandler
-
openMode
-
options
-
container
-
screenId
-
listComponent
-
field
-
isFieldCollectionValue
protected boolean isFieldCollectionValue
-
-
Constructor Details
-
LookupBuilder
-
LookupBuilder
public LookupBuilder(FrameOwner origin, Class<E> entityClass, Function<LookupBuilder<E>, Screen> handler)
-
-
Method Details
-
withOpenMode
SetsOpenMode
for the lookup screen and returns the builder for chaining.For example:
builder.withOpenMode(OpenMode.DIALOG).build();
-
withOptions
SetsScreenOptions
for the lookup screen and returns the builder for chaining. -
withSelectValidator
public LookupBuilder<E> withSelectValidator(Predicate<LookupScreen.ValidationContext<E>> selectValidator) Sets selection validator for the lookup screen and returns the builder for chaining. -
withSelectHandler
Sets selection handler for the lookup screen and returns the builder for chaining. -
withField
Sets the field component and returns the builder for chaining.If the field is set, the framework sets the selected entity to the field after successful lookup.
-
withValuesField
Sets the field component with collection value type.If the field is set, the framework sets the selected entity to the field after successful lookup.
- Type Parameters:
T
- type of field- Parameters:
field
- field to set- Returns:
- the builder for chaining
-
withScreenClass
public <S extends Screen & LookupScreen<E>> LookupClassBuilder<E,S> withScreenClass(Class<S> screenClass) Sets screen class and returns theLookupClassBuilder
for chaining.- Parameters:
screenClass
- class of the screen controller
-
withScreenId
Sets screen id and returns the builder for chaining.- Parameters:
screenId
- identifier of the lookup screen as specified in theUiController
annotation orscreens.xml
.
-
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. -
withContainer
SetsCollectionContainer
and returns the builder for chaining.The container is updated after the lookup screen is closed. If the container is
Nested
, the framework automatically initializes the reference to the parent entity and sets up data contexts for added One-To-Many and Many-To-Many relations. -
withTransformation
Sets code to transform entities after selection and returns the builder for chaining.
Applied only if either field or container or listComponent is assigned.- Parameters:
transformation
- edited entity transformation- See Also:
-
getScreenId
Returns screen id set bywithScreenId(String)
. -
getOpenMode
Returns launch mode set bywithOpenMode(OpenMode)
. -
getOptions
Returns screen options set bywithOptions(ScreenOptions)
. -
getOrigin
Returns invoking screen. -
getEntityClass
Returns class of the entity to lookup. -
getSelectHandler
Returns selection handler set bywithSelectHandler(Consumer)
. -
getSelectValidator
Returns selection validator set bywithSelectValidator(Predicate)
. -
getField
Returns the field component set bywithField(HasValue)
. -
getContainer
Returns container set bywithContainer(CollectionContainer)
. -
getListComponent
Returns list component set bywithListComponent(ListComponent)
. -
getTransformation
-
build
Builds the lookup screen. Screen should be shown usingScreen.show()
. -
show
Builds and shows the lookup screen. -
isFieldCollectionValue
protected boolean isFieldCollectionValue()
-