Package io.jmix.flowui.facet
Interface SettingsFacet<S extends UiComponentSettings<S>>
- All Superinterfaces:
Facet
- All Known Subinterfaces:
FragmentSettingsFacet,ViewSettingsFacet
- All Known Implementing Classes:
AbstractSettingsFacet,FragmentSettingsFacetImpl,ViewSettingsFacetImpl
Provides an ability to save component states when
FacetOwner 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 a component.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classSettingsFacet.SettingsContext<S extends UiComponentSettings<S>>Provides information about a source component and components that facet should manage. -
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 the default facet's logic for applying data loading settings.voidSets handler that should be invoked instead of the 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 the 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
- Returns:
UiComponentSettingsornullif facet is not attached to theFacetOwner
-
applySettings
void applySettings()Restores settings for components. Facet applies settings onOwner'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
Owner'sView.BeforeShowEvent. -
saveSettings
void saveSettings()Persists settings to store. Facet saves settings onOwner'sDetachEvent. -
addComponentIds
Adds component ids that should be managed whenisAuto()returnsfalse.Note, component must be attached to the
Owner's, 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, a collection will be filled byOwner'scomponents, otherwise a 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 the 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<S>> delegate) Sets handler that should be invoked instead of the 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 the 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
-