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
,HasActions
,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, HasActions, 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
Modifier and TypeClassDescriptionstatic class
Event sent when theConfiguration
is changed.static class
Event sent when theConfiguration
is updated.static class
Nested classes/interfaces inherited from interface io.jmix.flowui.component.SupportsResponsiveSteps
SupportsResponsiveSteps.ResponsiveStep
-
Field Summary
Modifier and TypeFieldDescriptionprotected Actions
protected JmixButton
protected org.springframework.context.ApplicationContext
protected ComboButton
protected String
protected boolean
protected static final String
protected List<FilterComponent>
protected boolean
protected List<Configuration>
protected com.vaadin.flow.component.orderedlayout.VerticalLayout
protected com.vaadin.flow.component.orderedlayout.HorizontalLayout
protected CurrentAuthentication
protected Configuration
protected DataLoader
protected DialogWindows
protected Configuration
protected static final String
protected static final String
protected static final String
protected GenericFilterSupport
protected static final String
protected GroupFilterSupport
protected Condition
protected Messages
protected Metadata
protected com.vaadin.flow.shared.Registration
protected Predicate<MetaPropertyPath>
protected int
protected List<SupportsResponsiveSteps.ResponsiveStep>
protected LogicalFilterComponent<?>
protected DropdownButton
protected UiComponents
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
addCondition
(FilterComponent filterComponent) Adds a condition to the filter.void
addConfiguration
(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.Registration
addConfigurationChangeListener
(com.vaadin.flow.component.ComponentEventListener<GenericFilter.ConfigurationChangeEvent> listener) com.vaadin.flow.shared.Registration
addConfigurationRefreshListener
(com.vaadin.flow.component.ComponentEventListener<GenericFilter.ConfigurationRefreshEvent> listener) com.vaadin.flow.shared.Registration
addOpenedChangeListener
(com.vaadin.flow.component.ComponentEventListener<GenericFilter.OpenedChangeEvent> listener) Adds a listener foropened-changed
events fired by the component.void
addPropertyFiltersPredicate
(Predicate<MetaPropertyPath> propertyFiltersPredicate) Adds a predicate to the current properties filter predicate.protected void
addSelectConfigurationAction
(Configuration configuration) void
void
apply()
Applies the current configuration.protected void
protected void
protected Condition
protected JmixButton
protected ComboButton
protected com.vaadin.flow.component.Component
createConditionRemoveButton
(FilterComponent filterComponent, String removeButtonId) protected Action
createConfigurationAction
(Configuration configuration) protected LogicalFilterComponent<?>
protected com.vaadin.flow.component.orderedlayout.VerticalLayout
protected com.vaadin.flow.component.orderedlayout.HorizontalLayout
protected Action
protected DropdownButton
Gets a configuration by id.protected String
getConfigurationName
(Configuration configuration) com.vaadin.flow.component.HasComponents
Gets 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.int
Get the list ofSupportsResponsiveSteps.ResponsiveStep
s used to configure this layout.protected void
initAddConditionButton
(JmixButton addConditionButton) protected void
initApplyButton
(ComboButton applyButton) protected void
protected JmixDetails
protected void
initContentWrapper
(com.vaadin.flow.component.orderedlayout.VerticalLayout contentWrapper) protected void
initControlsLayout
(com.vaadin.flow.component.orderedlayout.HorizontalLayout controlsLayout) protected void
protected void
protected void
protected void
protected void
initSettingsButton
(DropdownButton settingsButton) boolean
boolean
isOpened()
void
protected void
onApplyButtonClick
(com.vaadin.flow.component.ClickEvent<com.vaadin.flow.component.contextmenu.MenuItem> clickEvent) protected void
onOpenedChanged
(com.vaadin.flow.component.details.Details.OpenedChangeEvent openedChangeEvent) protected void
void
removeAction
(Action action) void
removeAction
(String id) void
void
removeCondition
(FilterComponent filterComponent) Removes a condition from filter.void
removeConfiguration
(Configuration configuration) Removes a configuration from filter.protected void
removeFilterComponent
(FilterComponent filterComponent) protected void
removeOpenedChangeListener
(com.vaadin.flow.shared.Registration registration) protected void
resetFilterComponentDefaultValue
(PropertyFilter<?> propertyFilter) void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) void
setApplyShortcut
(String applyShortcut) Sets a newKeyCombination
to apply the filter.void
setAutoApply
(boolean autoApply) Sets whether the filter should be automatically applied to theDataLoader
when the value component value is changed.void
setCurrentConfiguration
(Configuration currentConfiguration) Sets the given configuration as current and displays filter components from the current configuration.protected void
setCurrentConfigurationInternal
(Configuration currentConfiguration, boolean fromClient) void
setDataLoader
(DataLoader dataLoader) Sets aDataLoader
related to the filter.void
setOpened
(boolean opened) Sets whether this component is expanded or collapsedvoid
setPropertyFiltersPredicate
(Predicate<MetaPropertyPath> propertyFiltersPredicate) Sets a predicate that tests whether a property with the given path should be available for filtering.void
setPropertyHierarchyDepth
(int propertyHierarchyDepth) Sets hierarchy depth of entity properties available for filtering.void
Configure the responsive steps used in this layout.void
setSummaryText
(String summary) Sets this component summary textprotected void
protected void
updateApplyButtonText
(boolean autoApply) protected void
updateCurrentConfigurationAutoApply
(boolean autoApply) protected void
protected void
updateDataLoaderInitialCondition
(Condition condition) protected void
updateGroupConditionButtons
(GroupFilter groupFilter) protected void
protected void
updateRootLogicalFilterComponent
(LogicalFilterComponent<?> logicalFilterComponent) protected void
protected void
updateSingleConditionRemoveButton
(SingleFilterComponentBase<?> singleFilter) Methods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElement
Methods 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, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods inherited from interface io.jmix.flowui.kit.component.HasActions
addAction
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
Methods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabled
Methods 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, setWidthFull
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
Methods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
Methods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipText
Methods 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:
-
GLOBAL_CONFIGURATION_NAME_POSTFIX
- See Also:
-
applicationContext
protected org.springframework.context.ApplicationContext applicationContext -
currentAuthentication
-
uiComponents
-
actions
-
messages
-
metadata
-
dialogWindows
-
genericFilterSupport
-
groupFilterSupport
-
autoApply
protected boolean autoApply -
applyShortcut
-
propertyHierarchyDepth
protected int propertyHierarchyDepth -
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:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in 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:
initContent
in 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
LogicalCondition
related to the configuration
-
getDataLoader
- Returns:
- a
DataLoader
related to the filter
-
setDataLoader
Sets aDataLoader
related to the filter.- Parameters:
dataLoader
- aDataLoader
to set
-
updateDataLoaderInitialCondition
-
isAutoApply
public boolean isAutoApply()- Returns:
true
if the filter should be automatically applied to theDataLoader
when the value component value is changed
-
setAutoApply
public void setAutoApply(boolean autoApply) Sets whether the filter should be automatically applied to theDataLoader
when the value component value is changed.- Parameters:
autoApply
-true
if the filter should be automatically applied to theDataLoader
when the value component value is changed
-
getApplyShortcut
- Returns:
KeyCombination
that is used to apply the filter
-
setApplyShortcut
Sets a newKeyCombination
to apply the filter.- Parameters:
applyShortcut
- string representation of aKeyCombination
-
updateCurrentConfigurationAutoApply
protected void updateCurrentConfigurationAutoApply(boolean autoApply) -
apply
public void apply()Applies the current configuration. -
setupLoaderFirstResult
protected void setupLoaderFirstResult() -
getResponsiveSteps
Description copied from interface:SupportsResponsiveSteps
Get the list ofSupportsResponsiveSteps.ResponsiveStep
s used to configure this layout.- Specified by:
getResponsiveSteps
in interfaceSupportsResponsiveSteps
- Returns:
- the list of
SupportsResponsiveSteps.ResponsiveStep
s used to configure this layout - See Also:
-
setResponsiveSteps
Description copied from interface:SupportsResponsiveSteps
Configure the responsive steps used in this layout.- Specified by:
setResponsiveSteps
in interfaceSupportsResponsiveSteps
- Parameters:
steps
- list ofSupportsResponsiveSteps.ResponsiveStep
s 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-changed
events fired by the component.- Parameters:
listener
- the listener to set- Returns:
- a
Registration
for removing the event listener
-
onOpenedChanged
protected void onOpenedChanged(com.vaadin.flow.component.details.Details.OpenedChangeEvent openedChangeEvent) -
addAction
- Specified by:
addAction
in interfaceHasActions
-
removeAction
- Specified by:
removeAction
in interfaceHasActions
-
removeAction
- Specified by:
removeAction
in interfaceHasActions
-
removeAllActions
public void removeAllActions()- Specified by:
removeAllActions
in interfaceHasActions
-
getActions
- Specified by:
getActions
in interfaceHasActions
-
getAction
- Specified by:
getAction
in interfaceHasActions
-
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
-
updateSingleConditionRemoveButton
-
updateGroupConditionButtons
-
createConditionRemoveButton
protected com.vaadin.flow.component.Component createConditionRemoveButton(FilterComponent filterComponent, 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
null
if 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 ofFilterComponent
s. The configuration does not store a reference to all components, but stores a reference only to the root elementLogicalFilterComponent
from which the restFilterComponent
s can be obtained. The rootLogicalFilterComponent
is generated with aLogicalFilterComponent.Operation.AND
operation.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 ofFilterComponent
s. The configuration does not store a reference to all components, but stores a reference only to the root elementLogicalFilterComponent
from which the restFilterComponent
s can be obtained. The rootLogicalFilterComponent
is 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 aFilterComponent
that is not initially added to any of the configurations, but the user can select this component in theAddConditionView
in theConditions
section 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) -
addConfigurationRefreshListener
public com.vaadin.flow.shared.Registration addConfigurationRefreshListener(com.vaadin.flow.component.ComponentEventListener<GenericFilter.ConfigurationRefreshEvent> listener) -
loadConfigurationsAndApplyDefault
public void loadConfigurationsAndApplyDefault() -
clearValues
protected void clearValues() -
copy
-
getPropertyHierarchyDepth
public int getPropertyHierarchyDepth()- Returns:
- hierarchy depth of entity properties available for filtering.
- See Also:
-
setPropertyHierarchyDepth
public void setPropertyHierarchyDepth(int propertyHierarchyDepth) Sets hierarchy depth of entity properties available for filtering. This property is used in the 'Add Condition' editor of the filter. For example, if the depth value is 2, then you can select an entity attributecontractor.city.country
, if the value is 3, thencontractor.city.country.name
.- Parameters:
propertyHierarchyDepth
- hierarchy depth of entity properties available for filtering
-