Package io.jmix.flowui.facet
Interface SettingsFacet
- All Superinterfaces:
Facet
- All Known Implementing Classes:
SettingsFacetImpl
Provides ability to save component states when
View
is closed and restore them
when it's opened again.
For instance, it can be 'opened' state from JmixDetails
or columns order in DataGrid
.
Note, facet works with components that contain an id and have ComponentSettingsBinder
.
Otherwise, it cannot match saved settings with component.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
Provides information about source component and components that should be managed by facet. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addComponentIds
(String... ids) Adds component ids that should be managed whenisAuto()
returnsfalse
.void
addExcludedComponentIds
(String... ids) Adds component ids that should be excluded from applying and saving settings.void
Restores settings that related with data loading.void
Restores settings for components.Collection<com.vaadin.flow.component.Component>
Collection depends onisAuto()
property.boolean
isAuto()
void
Persists settings to store.void
Sets handler that should be invoked instead of default facet's logic for applying data loading settings.void
Sets handler that should be invoked instead of default facet's logic for applying settings.void
setAuto
(boolean auto) Defines in which mode facet will work.void
Sets handler that should be invoked instead of default facet's logic for saving settings.
-
Method Details
-
isAuto
boolean isAuto()- Returns:
- the mode in which facet is worked.
true
if facet includes all components andfalse
if only specified components byaddComponentIds(String...)
will be managed.
-
setAuto
void setAuto(boolean auto) Defines in which mode facet will work. If 'auto' is set totrue
it means that all components that contain an id and haveComponentSettingsBinder
will be managed by facet.If 'auto' mode is disabled (set to
false
), only specified components byaddComponentIds(String...)
will be managed.The default value is
false
.- Parameters:
auto
- whether facet should include all components
-
getSettings
-
applySettings
void applySettings()Restores settings for components. Facet applies settings onView
'sView.ReadyEvent
. -
applyDataLoadingSettings
void applyDataLoadingSettings()Restores settings that related with data loading. For instance, it applies sort columns and its direction inDataGrid
before data loading.Facet applies data loading settings on
View
'sView.BeforeShowEvent
. -
saveSettings
void saveSettings()Persists settings to store. Facet saves settings onView
'sDetachEvent
. -
addComponentIds
Adds component ids that should be managed whenisAuto()
returnsfalse
.Note, component must be attached to the
View
, otherwise it will be ignored.- Parameters:
ids
- component ids
-
getComponentIds
- Returns:
- set of component ids that should be handled when
isAuto()
returnsfalse
-
addExcludedComponentIds
Adds component ids that should be excluded from applying and saving settings. Excluding is applied despiteisAuto()
mode and has priority over explicitly added component idsaddComponentIds(String...)
.- Parameters:
ids
- component ids to exclude
-
getExcludedComponentIds
- Returns:
- set of component ids that should be excluded from applying and saving settings
-
getManagedComponents
Collection<com.vaadin.flow.component.Component> getManagedComponents()Collection depends onisAuto()
property. IfisAuto()
returnstrue
, collection will be filled byView
's components, otherwise collection will be filled by components that explicitly added byaddComponentIds(String...)
.- Returns:
- components collection that is used for applying and saving settings
-
getApplySettingsDelegate
- Returns:
- apply settings delegate or
null
if not set
-
setApplySettingsDelegate
Sets handler that should be invoked instead of default facet's logic for applying settings.For instance:
@Install(to = "settingsFacet", subject = "applySettingsDelegate") private void onApplySettings(SettingsFacet.SettingsContext settingsContext) { settingsFacet.applySettings(); }
- Parameters:
delegate
- handler to set
-
getApplyDataLoadingSettingsDelegate
- Returns:
- apply data loading settings delegate or
null
if not set
-
setApplyDataLoadingSettingsDelegate
void setApplyDataLoadingSettingsDelegate(@Nullable Consumer<SettingsFacet.SettingsContext> delegate) Sets handler that should be invoked instead of default facet's logic for applying data loading settings.For instance:
@Install(to = "settingsFacet", subject = "applyDataLoadingSettingsDelegate") private void onApplyDataLoadingSettings(SettingsFacet.SettingsContext settingsContext) { settingsFacet.applyDataLoadingSettings(); }
- Parameters:
delegate
- handler to set
-
getSaveSettingsDelegate
- Returns:
- save settings delegate or
null
if not set
-
setSaveSettingsDelegate
Sets handler that should be invoked instead of default facet's logic for saving settings.For instance:
@Install(to = "settingsFacet", subject = "saveSettingsDelegate") private void onSaveSettings(SettingsFacet.SettingsContext settingsContext) { settingsFacet.saveSettings(); }
- Parameters:
delegate
- handler to set
-