WrapperStyle (install4j API)
Description: declaration: package: com.install4j.api.styles, class: WrapperStyle

# Class WrapperStyle

java.lang.Object
com.install4j.api.beans.AbstractBean
com.install4j.api.styles.AbstractStyle
com.install4j.api.styles.WrapperStyle

All Implemented Interfaces:
  `Bean, VisualContainerBean, ControlButtonContainer, NestedStyleContainer, Style, StyleContextReceiver`

public abstract class WrapperStyle extends AbstractStyle implements NestedStyleContainer
Abstract base class for a screen style that wraps a single user-selectable style.

When you use this base class, you do not have to handle any life-cycle aspects of the nested style. See `NestedStyleContainer` for more information on nesting styles in general.

The "customCode" sample project contains the class `SunnySkyBackgroundStyle` and its associated `BeanInfo` that show you an example of wrapping a user-selected screen style with a graphical decoration. For more complex use cases, the source code of `WrapperStyle` can be used as a starting point.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `WrapperStyle()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `activated()`
  This method is called by the framework just after a screen with this screen style has been activated.
  `final JComponent`
  `createComponent()`
  Create the UI component for the style.
  `protected abstract JComponent`
  `createComponent(JComponent styleComponent)`
  Create the UI component for the style.
  `void`
  `deactivated()`
  This method is called by the framework just after a screen with this screen style has been deactivated.
  `void`
  `focusControlButton(ControlButtonType controlButtonType)`
  Called when a control button is focused.
  `protected abstract String`
  `getNestedStyleId()`
  Returns the ID of the nested style.
  `Collection<String>`
  `getNestedStyleIds()`
  Return the IDs of all nested styles.
  `boolean`
  `isFillHorizontal()`
  Returns whether the visual component wants to grow in the horizontal direction.
  `boolean`
  `isFillVertical()`
  Returns whether the visual component wants to grow in the vertical direction.
  `void`
  `setControlButtonEnabled(ControlButtonType controlButtonType, boolean enabled)`
  Called when the enabled state of a control button is changed.
  `void`
  `setControlButtonText(ControlButtonType controlButtonType, String text)`
  Called when a control button text is changed.
  `void`
  `setControlButtonVisible(ControlButtonType controlButtonType, boolean visible)`
  Called when the visibility of a control button is changed.
  `void`
  `setStyleContext(StyleContext styleContext)`
  Called by the framework when the current screen changes.
  `void`
  `willActivate()`
  This method is called by the framework just before a screen with this screen style is activated.

  ### Methods inherited from class AbstractStyle

  `getAnchor, getContext, getStyleManager, isStandalone, setContext`

  ### Methods inherited from class AbstractBean

  `executeActionListAsync, executeActionListSync, getTextOverrideValue, replaceVariables, replaceVariables, replaceVariables, replaceVariables, replaceVariables, replaceVariables, replaceVariables, replaceVariables, replaceWithTextOverride, replaceWithTextOverride, replaceWithTextOverride, replaceWithTextOverride, replaceWithTextOverride, replaceWithTextOverride, replaceWithTextOverride, replaceWithTextOverride, replaceWithTextOverride, replaceWithTextOverride, rollbackActionList`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### WrapperStyle

    public WrapperStyle()

- ## Method Details

  - ### getNestedStyleId

    protected abstract String getNestedStyleId()
    Returns the ID of the nested style. This method must be implemented by derived classes. To make a `String` property user-selectable in the IDE, register it in the `BeanInfo` with the special context `Install4JPropertyDescriptor.CONTEXT_STYLE_ID`.
    Returns:
      the ID

  - ### createComponent

    protected abstract JComponent createComponent(JComponent styleComponent)
    Create the UI component for the style. Has the same responsibility as `createComponent()`, only that the UI component of the nested screen style is passed as a parameter.
    Returns:
      the UI component

  - ### setStyleContext

    public void setStyleContext(StyleContext styleContext)
    Description copied from interface: `StyleContextReceiver`
    Called by the framework when the current screen changes. This method is called before `Style.createComponent()` where the `StyleContext` may be required for constructing the screen style component.

    You have to delegate this method call to any nested styles, see `NestedStyleContainer` for more information.

    Specified by:
      `setStyleContext` in interface `StyleContextReceiver`
    Parameters:
      `styleContext` - the screen style context

  - ### setControlButtonEnabled

    public void setControlButtonEnabled(ControlButtonType controlButtonType, boolean enabled)
    Description copied from interface: `ControlButtonContainer`
    Called when the enabled state of a control button is changed. This is called by the framework as required, but it can also be triggered programatically by a call to `WizardContext.setControlButtonEnabled(ControlButtonType, boolean)`.
    Specified by:
      `setControlButtonEnabled` in interface `ControlButtonContainer`
    Parameters:
      `controlButtonType` - the control button type
      `enabled` - `true` or `false`

  - ### setControlButtonVisible

    public void setControlButtonVisible(ControlButtonType controlButtonType, boolean visible)
    Description copied from interface: `ControlButtonContainer`
    Called when the visibility of a control button is changed. This is called by the framework as required, but it can also be triggered programatically by a call to `WizardContext.setControlButtonVisible(ControlButtonType, boolean)`.
    Specified by:
      `setControlButtonVisible` in interface `ControlButtonContainer`
    Parameters:
      `controlButtonType` - the control button type
      `visible` - `true` or `false`

  - ### setControlButtonText

    public void setControlButtonText(ControlButtonType controlButtonType, String text)
    Description copied from interface: `ControlButtonContainer`
    Called when a control button text is changed. This is called for all control button types each time when a screen is activated, but it can also be triggered programatically by a call to `WizardContext.setControlButtonText(ControlButtonType, String)`.
    Specified by:
      `setControlButtonText` in interface `ControlButtonContainer`
    Parameters:
      `controlButtonType` - the control button type
      `text` - the text for the button

  - ### focusControlButton

    public void focusControlButton(ControlButtonType controlButtonType)
    Description copied from interface: `ControlButtonContainer`
    Called when a control button is focused. This is triggered programatically by a call to `WizardContext.focusControlButton(ControlButtonType)`.
    Specified by:
      `focusControlButton` in interface `ControlButtonContainer`

  - ### createComponent

    public final JComponent createComponent()
    Description copied from interface: `Style`
    Create the UI component for the style. Depending on the return value of the `VisualContainerBean.isFillHorizontal()` and the `VisualContainerBean.isFillVertical()` methods, the component grows to fill all available horizontal or vertical space. The method must not return `null`.

    Never call this method yourself. For nested styles, call `StyleManager.createStyleComponent(Style)` instead.

    Each screen style is only instantiated once, and this method is called multiple times for each screen that uses the style. In console or unattended mode, this method is never called.

    Specified by:
      `createComponent` in interface `Style`
    Returns:
      the UI component
    See Also:
      - `VisualContainerBean.isFillHorizontal()`
      - `VisualContainerBean.isFillVertical()`
      - `NestedStyleContainer`

  - ### isFillHorizontal

    public boolean isFillHorizontal()
    Description copied from interface: `VisualContainerBean`
    Returns whether the visual component wants to grow in the horizontal direction. If not, the visual component will be aligned at the left of the available space and be sized at its preferred horizontal size. If, for example, you have text fields in your layout that should use as much horizontal space as possible, you should return `true` here. If all your components are fixed-size components, return `false`.

    In console or unattended mode, this method is never called.

    Specified by:
      `isFillHorizontal` in interface `VisualContainerBean`
    Returns:
      `true` or `false`.
    See Also:
      - `VisualContainerBean.isFillVertical()`

  - ### isFillVertical

    public boolean isFillVertical()
    Description copied from interface: `VisualContainerBean`
    Returns whether the visual component wants to grow in the vertical direction. If not, the visual component will be aligned at the top of the available space and be sized at its preferred vertical size. If, for example, you have a list in your layout that should use as much vertical space as possible, you should return `true` here. In that case you would also want to return `true` in `isFillHorizontal`. If all your components are fixed-size components, return `false`.

    In console or unattended mode, this method is never called.

    Specified by:
      `isFillVertical` in interface `VisualContainerBean`
    Returns:
      `true` or `false`.
    See Also:
      - `VisualContainerBean.isFillHorizontal()`

  - ### getNestedStyleIds

    public Collection<String> getNestedStyleIds()
    Description copied from interface: `NestedStyleContainer`
    Return the IDs of all nested styles. This allows the install4j IDE to collect all overridable properties.
    Specified by:
      `getNestedStyleIds` in interface `NestedStyleContainer`
    Returns:
      the IDs

  - ### willActivate

    public void willActivate()
    Description copied from interface: `Style`
    This method is called by the framework just before a screen with this screen style is activated. This call has to be delegated to nested styles by using `StyleManager.willActivate(Style)`.
    Specified by:
      `willActivate` in interface `Style`
    Overrides:
      `willActivate` in class `AbstractStyle`
    See Also:
      - `Screen.willActivate()`

  - ### activated

    public void activated()
    Description copied from interface: `Style`
    This method is called by the framework just after a screen with this screen style has been activated. This call has to be delegated to nested styles by using `StyleManager.activated(Style)`
    Specified by:
      `activated` in interface `Style`
    Overrides:
      `activated` in class `AbstractStyle`
    See Also:
      - `Screen.activated()`

  - ### deactivated

    public void deactivated()
    Description copied from interface: `Style`
    This method is called by the framework just after a screen with this screen style has been deactivated. This call has to be delegated to nested styles by using `StyleManager.deactivated(Style)`
    Specified by:
      `deactivated` in interface `Style`
    Overrides:
      `deactivated` in class `AbstractStyle`