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
Modifier and TypeClassDescriptionstatic class
Event sent when theConfiguration
is changed.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 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 Condition
protected Messages
protected Metadata
protected com.vaadin.flow.shared.Registration
protected Predicate<MetaPropertyPath>
protected List<SupportsResponsiveSteps.ResponsiveStep>
protected LogicalFilterComponent<?>
protected DropdownButton
protected UiComponents
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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
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 JmixButton
protected ComboButton
protected com.vaadin.flow.component.Component
createConditionRemoveButton
(SingleFilterComponent<?> singleFilter, 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.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()
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
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
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
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
updateConditionRemoveButton
(SingleFilterComponentBase<?> singleFilter) protected void
updateCurrentConfigurationAutoApply
(boolean autoApply) protected void
protected void
protected void
updateRootLogicalFilterComponent
(LogicalFilterComponent<?> logicalFilterComponent) protected void
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, 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 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:
-
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:
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
-
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
-
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) -
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
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) -
clearValues
protected void clearValues()
-