Class RunTimeConfigurationBuilder
RunTimeConfiguration.
Use this builder when you need a dynamic configuration whose filter components can be added or removed at runtime (e.g. via the per-condition remove button).
Encapsulates all required steps:
- Creating and configuring the root
GroupFilter - Adding filter components and recording their default values in the configuration
- Marking all added components as modified so remove buttons appear immediately
- Registering the configuration via
GenericFilter.addConfiguration(Configuration) - Optionally activating the configuration via
GenericFilter.setCurrentConfiguration(Configuration)
Obtain an instance via GenericFilter.runtimeConfigurationBuilder():
filter.runtimeConfigurationBuilder()
.id("dynamicSearch")
.name("Dynamic Search")
.add(nameFilter)
.add(statusFilter, "NEW")
.makeCurrent()
.buildAndRegister();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected booleanprotected final List<RunTimeConfigurationBuilder.ComponentEntry> protected final GenericFilterprotected Stringprotected booleanprotected Stringprotected LogicalFilterComponent.Operationprotected final UiComponents -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRunTimeConfigurationBuilder(GenericFilter filter, UiComponents uiComponents) -
Method Summary
Modifier and TypeMethodDescriptionadd(FilterComponent filterComponent) Adds a filter component using the component's current value (if any) as the default.add(SingleFilterComponentBase<V> filterComponent, @Nullable V defaultValue) Adds a filter component, overriding its default value.addAll(FilterComponent... filterComponents) Adds several filter components at once, each using its current value (if any) as the default.Allows the user to delete this configuration through the UI.allowDeletion(boolean allowDeletion) Controls whether the user can delete this configuration through the UI.Builds theRunTimeConfiguration, registers it with the filter, and optionally activates it.Sets the configuration id.Makes this configuration the current (active) one immediately after it is registered.Sets the configuration display name.operation(LogicalFilterComponent.Operation operation) Sets the logical operation of the root filter component.
-
Field Details
-
filter
-
uiComponents
-
id
-
name
-
operation
-
makeCurrent
protected boolean makeCurrent -
allowDeletion
protected boolean allowDeletion -
built
protected boolean built -
entries
-
-
Constructor Details
-
RunTimeConfigurationBuilder
-
-
Method Details
-
id
Sets the configuration id. Required.- Parameters:
id- unique configuration identifier within this filter
-
name
Sets the configuration display name.- Parameters:
name- display name shown in the configuration selector
-
operation
Sets the logical operation of the root filter component. Defaults toAND.- Parameters:
operation- logical operation
-
add
Adds a filter component using the component's current value (if any) as the default.- Parameters:
filterComponent- filter component to add
-
addAll
Adds several filter components at once, each using its current value (if any) as the default.- Parameters:
filterComponents- filter components to add
-
add
public <V> RunTimeConfigurationBuilder add(SingleFilterComponentBase<V> filterComponent, @Nullable V defaultValue) Adds a filter component, overriding its default value.The type parameter
Vensures thedefaultValuematches the component's own value type at compile time.- Type Parameters:
V- the value type of the filter component- Parameters:
filterComponent- filter component to adddefaultValue- value to apply and record as the configuration default
-
makeCurrent
Makes this configuration the current (active) one immediately after it is registered.This is not the persistent default configuration marker (set via the
genericFilter_makeDefaultaction and stored per user): it simply activates this configuration now, equivalent toGenericFilter.setCurrentConfiguration(Configuration). -
allowDeletion
Controls whether the user can delete this configuration through the UI.By default, configurations created via this builder are protected from user deletion (
RunTimeConfiguration.setProtectedFromUserDeletion(boolean)).- Parameters:
allowDeletion-trueto allow the user to remove the configuration,false(default) to protect it
-
allowDeletion
Allows the user to delete this configuration through the UI. Convenience alias forallowDeletion(true). -
buildAndRegister
Builds theRunTimeConfiguration, registers it with the filter, and optionally activates it.Automatically:
- Creates the root
GroupFilterwithsetConditionModificationDelegated(true)andsetDataLoader(filter.getDataLoader()) - Adds each filter component to the root
- Calls
setFilterComponentDefaultValuefor every component with a value - Registers the configuration via
GenericFilter.addConfiguration(Configuration), and activates it viaGenericFilter.setCurrentConfiguration(Configuration)ifmakeCurrent()was requested
- Returns:
- the newly created and registered
RunTimeConfiguration - Throws:
IllegalStateException- if this builder instance has already been used, ifidwas not set, if a configuration with the same id is already registered in the filter, or if the filter has no DataLoader
- Creates the root
-