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
Nested ClassesModifier and TypeInterfaceDescriptionstatic classProvides information about source component and components that should be managed by facet. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddComponentIds(String... ids) Adds component ids that should be managed whenisAuto()returnsfalse.voidaddExcludedComponentIds(String... ids) Adds component ids that should be excluded from applying and saving settings.voidRestores settings that related with data loading.voidRestores settings for components.Collection<com.vaadin.flow.component.Component>Collection depends onisAuto()property.booleanisAuto()voidPersists settings to store.voidSets handler that should be invoked instead of default facet's logic for applying data loading settings.voidSets handler that should be invoked instead of default facet's logic for applying settings.voidsetAuto(boolean auto) Defines in which mode facet will work.voidSets 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.
trueif facet includes all components andfalseif only specified components byaddComponentIds(String...)will be managed.
-
setAuto
void setAuto(boolean auto) Defines in which mode facet will work. If 'auto' is set totrueit means that all components that contain an id and haveComponentSettingsBinderwill 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 inDataGridbefore 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
nullif 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
nullif 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
nullif 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
-