de.caff.gimmicks.swing

## Class AbstractToggleState

- java.lang.Object
- - de.caff.gimmicks.swing.AbstractState
  - - de.caff.gimmicks.swing.VisibleState
    - - de.caff.gimmicks.swing.AbstractToggleState

- All Implemented Interfaces:
    State, ToolBarElement, Localizable, java.awt.event.ActionListener, java.util.EventListener, javax.swing.Action

      public abstract class AbstractToggleState
      extends VisibleState

  Basic class for a toggle state.
  Author:
    Rammi

- - ### Field Summary

    - ### Fields inherited from class de.caff.gimmicks.swing.AbstractState

      `manager, properties, propertyChangeSupport`

    - ### Fields inherited from interface de.caff.gimmicks.swing.State

      `ACTIVATION_PROPERTY, ACTIVE_ICON_PROPERTY, DISABLED_ICON_PROPERTY, ENABLE_PROPERTY, INACTIVE_ICON_PROPERTY, LABEL_TEXT_PROPERTY, POPUP_PROPERTY, TOOLTIP_TEXT_PROPERTY`

    - ### Fields inherited from interface javax.swing.Action

      `ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractToggleState(java.lang.String baseTag)` Create a visible state from I18n settings.
    `protected` | `AbstractToggleState(java.lang.String labelResourceKey, java.lang.String tooltipResourceKey, javax.swing.Icon activeIcon)` Create a visible state with default icons.
    `protected` | `AbstractToggleState(java.lang.String labelResourceKey, java.lang.String tooltipResourceKey, javax.swing.ImageIcon activeIcon, javax.swing.ImageIcon inactiveIcon, javax.swing.ImageIcon disabledIcon)` Create a visible state.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `actionPerformed(java.awt.event.ActionEvent e)` An action is performed.
    `void` | `deactivate()` Deactivate this state.
    `boolean` | `isToggleEnabled()` Is it possible to switch this state off by clicking on it with the mouse?

    - ### Methods inherited from class de.caff.gimmicks.swing.VisibleState

      `getLocale, setLocale`

    - ### Methods inherited from class de.caff.gimmicks.swing.AbstractState

      `activate, addPropertyChangeListener, addPropertyChangeListener, addToToolBar, addToToolBar, getValue, isActivated, isEnabled, putValue, refresh, removePropertyChangeListener, removePropertyChangeListener, setEnabled, setManager, setProperty, showPopup`

    - ### Methods inherited from class java.lang.Object

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

    - ### Methods inherited from interface de.caff.gimmicks.swing.State

      `hasPopup`

- - ### Constructor Detail

    - #### AbstractToggleState

          protected AbstractToggleState(java.lang.String labelResourceKey,
                                        java.lang.String tooltipResourceKey,
                                        javax.swing.ImageIcon activeIcon,
                                        javax.swing.ImageIcon inactiveIcon,
                                        javax.swing.ImageIcon disabledIcon)

      Create a visible state.
      Parameters:
        `labelResourceKey` - resource key for labels and menu items
        `tooltipResourceKey` - resource key for tooltips
        `activeIcon` - icon to be displayed when state is active
        `inactiveIcon` - icon to be displayed when state is inactive
        `disabledIcon` - icon to be displayed when state is disabled (if `null` the Swing standard is used)

    - #### AbstractToggleState

          protected AbstractToggleState(java.lang.String labelResourceKey,
                                        java.lang.String tooltipResourceKey,
                                        javax.swing.Icon activeIcon)

      Create a visible state with default icons. The inactive icon is the same as the active and the disabled icon is the standard disabled view.
      Parameters:
        `labelResourceKey` - resource key for labels and menu items
        `tooltipResourceKey` - resource key for tooltips
        `activeIcon` - icon to be displayed when state is active

    - #### AbstractToggleState

          protected AbstractToggleState(@NotNull
                                        java.lang.String baseTag)

      Create a visible state from I18n settings.
      Parameters:
        `baseTag` - I18n base tag

  - ### Method Detail

    - #### actionPerformed

          public void actionPerformed(java.awt.event.ActionEvent e)

      An action is performed. This is just toggling the activation.
      Specified by:
        `actionPerformed` in interface `java.awt.event.ActionListener`
      Overrides:
        `actionPerformed` in class `AbstractState`
      Parameters:
        `e` - unused

    - #### deactivate

          public void deactivate()

      Deactivate this state.
      Specified by:
        `deactivate` in interface `State`
      Overrides:
        `deactivate` in class `AbstractState`

    - #### isToggleEnabled

          public boolean isToggleEnabled()

      Is it possible to switch this state off by clicking on it with the mouse?
      Specified by:
        `isToggleEnabled` in interface `State`
      Overrides:
        `isToggleEnabled` in class `AbstractState`
      Returns:
        the answer