Class GenericFilter
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<JmixDetails>
io.jmix.flowui.component.genericfilter.GenericFilter
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasTheme,com.vaadin.flow.component.shared.HasTooltip,SupportsResponsiveSteps,Serializable,org.springframework.beans.factory.Aware,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware
public class GenericFilter
extends com.vaadin.flow.component.Composite<JmixDetails>
implements SupportsResponsiveSteps, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasTheme, com.vaadin.flow.component.shared.HasTooltip, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean
A versatile tool for filtering the data it is bound to. The component enables
quick data filtering by arbitrary conditions, as well as creating configurations
for repeated use.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classEvent sent when theConfigurationis changed.static classNested classes/interfaces inherited from interface io.jmix.flowui.component.SupportsResponsiveSteps
SupportsResponsiveSteps.ResponsiveStep -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Actionsprotected JmixButtonprotected org.springframework.context.ApplicationContextprotected ComboButtonprotected booleanprotected static final Stringprotected List<FilterComponent>protected booleanprotected List<Configuration>protected com.vaadin.flow.component.orderedlayout.VerticalLayoutprotected com.vaadin.flow.component.orderedlayout.HorizontalLayoutprotected CurrentAuthenticationprotected Configurationprotected DataLoaderprotected DialogWindowsprotected Configurationprotected static final Stringprotected static final Stringprotected static final Stringprotected GenericFilterSupportprotected Conditionprotected Messagesprotected Metadataprotected com.vaadin.flow.shared.Registrationprotected Predicate<MetaPropertyPath>protected List<SupportsResponsiveSteps.ResponsiveStep>protected LogicalFilterComponent<?>protected DropdownButtonprotected UiComponents -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCondition(FilterComponent filterComponent) Adds a condition to the filter.voidaddConfiguration(Configuration configuration) Adds a configuration to the filter.addConfiguration(String id, String name) Adds design-time configuration with given id and name.addConfiguration(String id, String name, LogicalFilterComponent.Operation rootOperation) Adds design-time configuration with given id and name.com.vaadin.flow.shared.RegistrationaddConfigurationChangeListener(com.vaadin.flow.component.ComponentEventListener<GenericFilter.ConfigurationChangeEvent> listener) com.vaadin.flow.shared.RegistrationaddOpenedChangeListener(com.vaadin.flow.component.ComponentEventListener<GenericFilter.OpenedChangeEvent> listener) Adds a listener foropened-changedevents fired by the component.voidaddPropertyFiltersPredicate(Predicate<MetaPropertyPath> propertyFiltersPredicate) Adds a predicate to the current properties filter predicate.protected voidaddSelectConfigurationAction(Configuration configuration) voidvoidapply()Applies the current configuration.protected voidprotected voidprotected JmixButtonprotected ComboButtonprotected com.vaadin.flow.component.ComponentcreateConditionRemoveButton(SingleFilterComponent<?> singleFilter, String removeButtonId) protected ActioncreateConfigurationAction(Configuration configuration) protected LogicalFilterComponent<?>protected com.vaadin.flow.component.orderedlayout.VerticalLayoutprotected com.vaadin.flow.component.orderedlayout.HorizontalLayoutprotected Actionprotected DropdownButtonGets a configuration by id.protected StringgetConfigurationName(Configuration configuration) com.vaadin.flow.component.HasComponentsGets the current configuration that is currently displayed inside the filter.Gets an empty configuration that is used when the user has not selected any of the existing configurations.Get the list ofSupportsResponsiveSteps.ResponsiveSteps used to configure this layout.protected voidinitAddConditionButton(JmixButton addConditionButton) protected voidinitApplyButton(ComboButton applyButton) protected voidprotected JmixDetailsprotected voidinitContentWrapper(com.vaadin.flow.component.orderedlayout.VerticalLayout contentWrapper) protected voidinitControlsLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout controlsLayout) protected voidprotected voidprotected voidprotected voidprotected voidinitSettingsButton(DropdownButton settingsButton) booleanbooleanisOpened()protected voidonApplyButtonClick(com.vaadin.flow.component.ClickEvent<com.vaadin.flow.component.contextmenu.MenuItem> clickEvent) protected voidonOpenedChanged(com.vaadin.flow.component.details.Details.OpenedChangeEvent openedChangeEvent) protected voidvoidremoveCondition(FilterComponent filterComponent) Removes a condition from filter.voidremoveConfiguration(Configuration configuration) Removes a configuration from filter.protected voidremoveFilterComponent(FilterComponent filterComponent) protected voidremoveOpenedChangeListener(com.vaadin.flow.shared.Registration registration) protected voidresetFilterComponentDefaultValue(PropertyFilter<?> propertyFilter) voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) voidsetAutoApply(boolean autoApply) Sets whether the filter should be automatically applied to theDataLoaderwhen the value component value is changed.voidsetCurrentConfiguration(Configuration currentConfiguration) Sets the given configuration as current and displays filter components from the current configuration.protected voidsetCurrentConfigurationInternal(Configuration currentConfiguration, boolean fromClient) voidsetDataLoader(DataLoader dataLoader) Sets aDataLoaderrelated to the filter.voidsetOpened(boolean opened) Sets whether this component is expanded or collapsedvoidsetPropertyFiltersPredicate(Predicate<MetaPropertyPath> propertyFiltersPredicate) Sets a predicate that tests whether a property with the given path should be available for filtering.voidConfigure the responsive steps used in this layout.voidsetSummaryText(String summary) Sets this component summary textprotected voidprotected voidupdateApplyButtonText(boolean autoApply) protected voidupdateConditionRemoveButton(SingleFilterComponentBase<?> singleFilter) protected voidupdateCurrentConfigurationAutoApply(boolean autoApply) protected voidprotected voidprotected voidupdateRootLogicalFilterComponent(LogicalFilterComponent<?> logicalFilterComponent) protected voidMethods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElementMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipTextMethods inherited from interface io.jmix.flowui.component.SupportsResponsiveSteps
setResponsiveSteps
-
Field Details
-
CONDITION_REMOVE_BUTTON_ID_SUFFIX
- See Also:
-
FILTER_CLASS_NAME
- See Also:
-
FILTER_CONTENT_WRAPPER_CLASS_NAME
- See Also:
-
FILTER_CONTROLS_LAYOUT_CLASS_NAME
- See Also:
-
applicationContext
protected org.springframework.context.ApplicationContext applicationContext -
currentAuthentication
-
uiComponents
-
actions
-
messages
-
metadata
-
dialogWindows
-
genericFilterSupport
-
autoApply
protected boolean autoApply -
dataLoader
-
initialDataLoaderCondition
-
propertyFiltersPredicate
-
contentWrapper
protected com.vaadin.flow.component.orderedlayout.VerticalLayout contentWrapper -
controlsLayout
protected com.vaadin.flow.component.orderedlayout.HorizontalLayout controlsLayout -
applyButton
-
addConditionButton
-
settingsButton
-
responsiveSteps
-
openedChangeRegistration
protected com.vaadin.flow.shared.Registration openedChangeRegistration -
rootLogicalFilterComponent
-
emptyConfiguration
-
currentConfiguration
-
configurations
-
conditions
-
configurationModifyPermitted
protected boolean configurationModifyPermitted
-
-
Constructor Details
-
GenericFilter
public GenericFilter()
-
-
Method Details
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
autowireDependencies
protected void autowireDependencies() -
initComponent
protected void initComponent() -
initDefaultResponsiveSteps
protected void initDefaultResponsiveSteps() -
initEmptyConfiguration
protected void initEmptyConfiguration() -
createConfigurationRootLogicalFilterComponent
protected LogicalFilterComponent<?> createConfigurationRootLogicalFilterComponent(LogicalFilterComponent.Operation rootOperation) -
initContent
- Overrides:
initContentin classcom.vaadin.flow.component.Composite<JmixDetails>
-
initLayout
protected void initLayout() -
createContentWrapper
protected com.vaadin.flow.component.orderedlayout.VerticalLayout createContentWrapper() -
initContentWrapper
protected void initContentWrapper(com.vaadin.flow.component.orderedlayout.VerticalLayout contentWrapper) -
createControlsLayout
protected com.vaadin.flow.component.orderedlayout.HorizontalLayout createControlsLayout() -
initControlsLayout
protected void initControlsLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout controlsLayout) -
createAddConditionButton
-
initAddConditionButton
-
createApplyButton
-
initApplyButton
-
initSelectConfigurationDropdown
protected void initSelectConfigurationDropdown() -
updateApplyButtonText
protected void updateApplyButtonText(boolean autoApply) -
onApplyButtonClick
protected void onApplyButtonClick(com.vaadin.flow.component.ClickEvent<com.vaadin.flow.component.contextmenu.MenuItem> clickEvent) -
createResetFilterAction
-
createSettingsButton
-
initSettingsButton
-
getControlsLayout
public com.vaadin.flow.component.HasComponents getControlsLayout() -
getQueryCondition
- Returns:
- a
LogicalConditionrelated to the configuration
-
getDataLoader
- Returns:
- a
DataLoaderrelated to the filter
-
setDataLoader
Sets aDataLoaderrelated to the filter.- Parameters:
dataLoader- aDataLoaderto set
-
isAutoApply
public boolean isAutoApply()- Returns:
trueif the filter should be automatically applied to theDataLoaderwhen the value component value is changed
-
setAutoApply
public void setAutoApply(boolean autoApply) Sets whether the filter should be automatically applied to theDataLoaderwhen the value component value is changed.- Parameters:
autoApply-trueif the filter should be automatically applied to theDataLoaderwhen the value component value is changed
-
updateCurrentConfigurationAutoApply
protected void updateCurrentConfigurationAutoApply(boolean autoApply) -
apply
public void apply()Applies the current configuration. -
setupLoaderFirstResult
protected void setupLoaderFirstResult() -
getResponsiveSteps
Description copied from interface:SupportsResponsiveStepsGet the list ofSupportsResponsiveSteps.ResponsiveSteps used to configure this layout.- Specified by:
getResponsiveStepsin interfaceSupportsResponsiveSteps- Returns:
- the list of
SupportsResponsiveSteps.ResponsiveSteps used to configure this layout - See Also:
-
setResponsiveSteps
Description copied from interface:SupportsResponsiveStepsConfigure the responsive steps used in this layout.- Specified by:
setResponsiveStepsin interfaceSupportsResponsiveSteps- Parameters:
steps- list ofSupportsResponsiveSteps.ResponsiveSteps to set- See Also:
-
getSummaryText
- Returns:
- this component summary text
-
setSummaryText
Sets this component summary text- Parameters:
summary- text to set
-
isOpened
public boolean isOpened()- Returns:
- whether this component is expanded or collapsed
-
setOpened
public void setOpened(boolean opened) Sets whether this component is expanded or collapsed- Parameters:
opened- whether this component is expanded or collapsed
-
addOpenedChangeListener
public com.vaadin.flow.shared.Registration addOpenedChangeListener(com.vaadin.flow.component.ComponentEventListener<GenericFilter.OpenedChangeEvent> listener) Adds a listener foropened-changedevents fired by the component.- Parameters:
listener- the listener to set- Returns:
- a
Registrationfor removing the event listener
-
onOpenedChanged
protected void onOpenedChanged(com.vaadin.flow.component.details.Details.OpenedChangeEvent openedChangeEvent) -
getPropertyFiltersPredicate
- Returns:
- a properties filter predicate
-
setPropertyFiltersPredicate
public void setPropertyFiltersPredicate(@Nullable Predicate<MetaPropertyPath> propertyFiltersPredicate) Sets a predicate that tests whether a property with the given path should be available for filtering.- Parameters:
propertyFiltersPredicate- a predicate to set
-
addPropertyFiltersPredicate
Adds a predicate to the current properties filter predicate. The result predicate is a composed predicate that represents a short-circuiting logical AND of given predicate and current properties filter predicate.- Parameters:
propertyFiltersPredicate- a predicate to add
-
getCurrentConfiguration
Gets the current configuration that is currently displayed inside the filter.- Returns:
- a current configuration
-
setCurrentConfiguration
Sets the given configuration as current and displays filter components from the current configuration.- Parameters:
currentConfiguration- a configuration
-
setCurrentConfigurationInternal
protected void setCurrentConfigurationInternal(Configuration currentConfiguration, boolean fromClient) -
refreshCurrentConfigurationLayout
protected void refreshCurrentConfigurationLayout() -
updateRootLogicalFilterComponent
-
resetFilterComponentDefaultValue
-
updateConditionRemoveButton
-
createConditionRemoveButton
protected com.vaadin.flow.component.Component createConditionRemoveButton(SingleFilterComponent<?> singleFilter, String removeButtonId) -
removeFilterComponent
-
updateRootLayoutSummaryText
protected void updateRootLayoutSummaryText() -
getConfigurationName
-
updateDataLoaderCondition
protected void updateDataLoaderCondition() -
getEmptyConfiguration
Gets an empty configuration that is used when the user has not selected any of the existing configurations.- Returns:
- an empty configuration
-
getConfiguration
Gets a configuration by id.- Parameters:
id- the configuration id- Returns:
- the configuration of
nullif not found
-
getConfigurations
- Returns:
- a list of all configurations related to the filter
-
addConfiguration
Adds design-time configuration with given id and name. A configuration is a set ofFilterComponents. The configuration does not store a reference to all components, but stores a reference only to the root elementLogicalFilterComponentfrom which the restFilterComponents can be obtained. The rootLogicalFilterComponentis generated with aLogicalFilterComponent.Operation.ANDoperation.The configuration defined in XML is a
DesignTimeConfiguration.- Parameters:
id- a configuration id. Must be unique within this filtername- a configuration name- Returns:
DesignTimeConfiguration- See Also:
-
addConfiguration
public DesignTimeConfiguration addConfiguration(String id, @Nullable String name, LogicalFilterComponent.Operation rootOperation) Adds design-time configuration with given id and name. A configuration is a set ofFilterComponents. The configuration does not store a reference to all components, but stores a reference only to the root elementLogicalFilterComponentfrom which the restFilterComponents can be obtained. The rootLogicalFilterComponentis generated with a given operation.The configuration defined in XML is a
DesignTimeConfiguration.- Parameters:
id- a configuration id. Must be unique within this filtername- a configuration namerootOperation- an operation of rootLogicalFilterComponent- Returns:
DesignTimeConfiguration
-
addConfiguration
Adds a configuration to the filter.- Parameters:
configuration- configuration to add- See Also:
-
removeConfiguration
Removes a configuration from filter.- Parameters:
configuration- configuration to remove
-
updateSelectConfigurationDropdown
protected void updateSelectConfigurationDropdown() -
addSelectConfigurationAction
-
createConfigurationAction
-
addCondition
Adds a condition to the filter. A condition is aFilterComponentthat is not initially added to any of the configurations, but the user can select this component in theAddConditionViewin theConditionssection and add it to theRunTimeConfiguration.- Parameters:
filterComponent- a filter component to add to conditions- See Also:
-
getConditions
- Returns:
- a list of all conditions related to the filter
-
removeCondition
Removes a condition from filter.- Parameters:
filterComponent- a filter component to remove from conditions
-
addConfigurationChangeListener
public com.vaadin.flow.shared.Registration addConfigurationChangeListener(com.vaadin.flow.component.ComponentEventListener<GenericFilter.ConfigurationChangeEvent> listener) -
clearValues
protected void clearValues()
-