Interface SettingsFacet

All Superinterfaces:
Facet
All Known Implementing Classes:
SettingsFacetImpl

public interface SettingsFacet extends Facet
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.

  • Method Details

    • isAuto

      boolean isAuto()
      Returns:
      the mode in which facet is worked. true if facet includes all components and false if only specified components by addComponentIds(String...) will be managed.
    • setAuto

      void setAuto(boolean auto)
      Defines in which mode facet will work. If 'auto' is set to true it means that all components that contain an id and have ComponentSettingsBinder will be managed by facet.

      If 'auto' mode is disabled (set to false), only specified components by addComponentIds(String...) will be managed.

      The default value is false.

      Parameters:
      auto - whether facet should include all components
    • getSettings

      @Nullable ViewSettings getSettings()
      Returns:
      View settings or null if facet is not attached to the View
    • applySettings

      void applySettings()
      Restores settings for components. Facet applies settings on View's View.ReadyEvent.
    • applyDataLoadingSettings

      void applyDataLoadingSettings()
      Restores settings that related with data loading. For instance, it applies sort columns and its direction in DataGrid before data loading.

      Facet applies data loading settings on View's View.BeforeShowEvent.

    • saveSettings

      void saveSettings()
      Persists settings to store. Facet saves settings on View's DetachEvent.
    • addComponentIds

      void addComponentIds(String... ids)
      Adds component ids that should be managed when isAuto() returns false.

      Note, component must be attached to the View, otherwise it will be ignored.

      Parameters:
      ids - component ids
    • getComponentIds

      Set<String> getComponentIds()
      Returns:
      set of component ids that should be handled when isAuto() returns false
    • addExcludedComponentIds

      void addExcludedComponentIds(String... ids)
      Adds component ids that should be excluded from applying and saving settings. Excluding is applied despite isAuto() mode and has priority over explicitly added component ids addComponentIds(String...).
      Parameters:
      ids - component ids to exclude
    • getExcludedComponentIds

      Set<String> 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 on isAuto() property. If isAuto() returns true, collection will be filled by View's components, otherwise collection will be filled by components that explicitly added by addComponentIds(String...).
      Returns:
      components collection that is used for applying and saving settings
    • getApplySettingsDelegate

      @Nullable Consumer<SettingsFacet.SettingsContext> getApplySettingsDelegate()
      Returns:
      apply settings delegate or null if not set
    • setApplySettingsDelegate

      void setApplySettingsDelegate(@Nullable Consumer<SettingsFacet.SettingsContext> delegate)
      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

      @Nullable Consumer<SettingsFacet.SettingsContext> 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

      @Nullable Consumer<SettingsFacet.SettingsContext> getSaveSettingsDelegate()
      Returns:
      save settings delegate or null if not set
    • setSaveSettingsDelegate

      void setSaveSettingsDelegate(@Nullable Consumer<SettingsFacet.SettingsContext> delegate)
      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