de.caff.util.settings.swing

## Class SwingEnumProperty<E>

- java.lang.Object
- - de.caff.util.settings.AbstractBasicChangeableItem
  - - de.caff.util.settings.AbstractBasicLocalizableChangeableItem
    - - de.caff.util.settings.swing.AbstractBasicSimpleEditableChangeableItem
      - - de.caff.util.settings.swing.SwingEnumProperty<E>

- All Implemented Interfaces:
    ChangeableItem, EnumProperty<E>, EditableProperty, java.io.Serializable
  Direct Known Subclasses:
    SwingEnumPreferenceProperty

      public class SwingEnumProperty<E>
      extends AbstractBasicSimpleEditableChangeableItem
      implements EnumProperty<E>

  An enum preference property. This is one value out of a set of values.
  Author:
    Rammi
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `SwingEnumProperty.EnumValueComparator<T>` Comparator used for enum value sorting.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SwingEnumProperty(EnumValue<E> startValue, boolean autoSave, java.lang.String basicName, java.lang.String baseTag, java.util.Collection<EnumValue<E>> values)` Constructor.
    `SwingEnumProperty(EnumValue<E> startValue, boolean autoSave, java.lang.String basicName, java.lang.String baseTag, EnumValue<E>... values)` Constructor.
    `SwingEnumProperty(EnumValue<E> startValue, boolean autoSave, java.lang.String basicName, java.lang.String baseTag, SwingEnumProperty.EnumValueComparator<E> enumValueComparator, java.util.Collection<EnumValue<E>> values)` Constructor.
    `SwingEnumProperty(EnumValue<E> startValue, boolean autoSave, java.lang.String basicName, java.lang.String baseTag, SwingEnumProperty.EnumValueComparator<E> enumValueComparator, EnumValue<E>... values)` Constructor.
    `SwingEnumProperty(EnumValue<E> startValue, java.lang.String basicName, java.lang.String baseTag, java.util.Collection<EnumValue<E>> values)` Constructor.
    `SwingEnumProperty(EnumValue<E> startValue, java.lang.String basicName, java.lang.String baseTag, EnumValue<E>... values)` Constructor.
    `SwingEnumProperty(EnumValue<E> startValue, java.lang.String basicName, java.lang.String baseTag, SwingEnumProperty.EnumValueComparator<E> enumValueComparator, java.util.Collection<EnumValue<E>> values)` Constructor.
    `SwingEnumProperty(EnumValue<E> startValue, java.lang.String basicName, java.lang.String baseTag, SwingEnumProperty.EnumValueComparator<E> enumValueComparator, EnumValue<E>... values)` Constructor.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `javax.swing.JMenuItem` | `createMenuItem(java.util.Locale l)` Create a menu item for this boolean property.
    `EditorProvider` | `getEditorProvider(java.util.Locale l)` Get the editor provider which provides editor components for editing this preference property.
    `(package private) SwingEnumProperty.EnumValueComparator<E>` | `getEnumValueComparator()` Get the enum value comparator.
    `protected java.util.List<EnumValue<E>>` | `getEnumValues()` Get the enum values.
    `java.util.List<EnumValue<E>>` | `getEnumValues(java.util.Locale l)` Get the possible values.
    `static <T> SwingEnumProperty.EnumValueComparator<T>` | `getShortNameEnumValueComparator()` Get an enum value comparator suitable to be used in the `SwingEnumProperty(de.caff.util.settings.EnumValue, String, String, de.caff.util.settings.swing.SwingEnumProperty.EnumValueComparator, de.caff.util.settings.EnumValue[])` constructor, which sorts the enum values by their short names.
    `EnumValue<E>` | `getValue()` Get the current value.
    `void` | `setValue(EnumValue<E> value)` Set a new value.

    - ### Methods inherited from class de.caff.util.settings.AbstractBasicLocalizableChangeableItem

      `getBaseTag, getLabelString, getMenuString, getName, getString`

    - ### Methods inherited from class de.caff.util.settings.AbstractBasicChangeableItem

      `addValueChangeListener, addValueChangeListenerWeakly, firePropertyChange, fireValueChange, fireValueChange, fireValueChange, getBasicName, getPropertyName, removeValueChangeListener, removeValueChangeListenerWeakly`

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

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

    - ### Methods inherited from interface de.caff.util.settings.swing.EditableProperty

      `getName`

    - ### Methods inherited from interface de.caff.util.settings.ChangeableItem

      `addValueChangeListener, addValueChangeListenerWeakly, removeValueChangeListener, removeValueChangeListenerWeakly`

- - ### Constructor Detail

    - #### SwingEnumProperty

          public SwingEnumProperty(@NotNull
                                   EnumValue<E> startValue,
                                   @NotNull
                                   java.lang.String basicName,
                                   @NotNull
                                   java.lang.String baseTag,
                                   @NotNull
                                   EnumValue<E>... values)

      Constructor. No auto saving.
      Parameters:
        `startValue` - the start value of this property
        `basicName` - the name of this property
        `baseTag` - the basic i18n tag of this property
        `values` - the possible values of this property

    - #### SwingEnumProperty

          public SwingEnumProperty(@NotNull
                                   EnumValue<E> startValue,
                                   boolean autoSave,
                                   @NotNull
                                   java.lang.String basicName,
                                   @NotNull
                                   java.lang.String baseTag,
                                   @NotNull
                                   EnumValue<E>... values)

      Constructor.
      Parameters:
        `startValue` - the start value of this property
        `autoSave` - auto save changes?
        `basicName` - the name of this property
        `baseTag` - the basic i18n tag of this property
        `values` - the possible values of this property

    - #### SwingEnumProperty

          public SwingEnumProperty(@NotNull
                                   EnumValue<E> startValue,
                                   @NotNull
                                   java.lang.String basicName,
                                   @NotNull
                                   java.lang.String baseTag,
                                   @NotNull
                                   java.util.Collection<EnumValue<E>> values)

      Constructor. No auto saving.
      Parameters:
        `startValue` - the start value of this property
        `basicName` - the name of this property
        `baseTag` - the basic i18n tag of this property
        `values` - the possible values of this property

    - #### SwingEnumProperty

          public SwingEnumProperty(@NotNull
                                   EnumValue<E> startValue,
                                   boolean autoSave,
                                   @NotNull
                                   java.lang.String basicName,
                                   @NotNull
                                   java.lang.String baseTag,
                                   @NotNull
                                   java.util.Collection<EnumValue<E>> values)

      Constructor.
      Parameters:
        `startValue` - the start value of this property
        `autoSave` - auto save changes?
        `basicName` - the name of this property
        `baseTag` - the basic i18n tag of this property
        `values` - the possible values of this property

    - #### SwingEnumProperty

          public SwingEnumProperty(@NotNull
                                   EnumValue<E> startValue,
                                   @NotNull
                                   java.lang.String basicName,
                                   @NotNull
                                   java.lang.String baseTag,
                                   @NotNull
                                   SwingEnumProperty.EnumValueComparator<E> enumValueComparator,
                                   @NotNull
                                   EnumValue<E>... values)

      Constructor. No auto save.
      Parameters:
        `startValue` - the start value of this property
        `basicName` - the name of this property
        `baseTag` - the basic i18n tag of this property
        `enumValueComparator` - comparator for `EnumValue`s used to sort the values for display
        `values` - the possible values of this property

    - #### SwingEnumProperty

          public SwingEnumProperty(@NotNull
                                   EnumValue<E> startValue,
                                   boolean autoSave,
                                   @NotNull
                                   java.lang.String basicName,
                                   @NotNull
                                   java.lang.String baseTag,
                                   @NotNull
                                   SwingEnumProperty.EnumValueComparator<E> enumValueComparator,
                                   @NotNull
                                   EnumValue<E>... values)

      Constructor.
      Parameters:
        `startValue` - the start value of this property
        `autoSave` - auto save values?
        `basicName` - the name of this property
        `baseTag` - the basic i18n tag of this property
        `enumValueComparator` - comparator for `EnumValue`s used to sort the values for display
        `values` - the possible values of this property

    - #### SwingEnumProperty

          public SwingEnumProperty(@NotNull
                                   EnumValue<E> startValue,
                                   @NotNull
                                   java.lang.String basicName,
                                   @NotNull
                                   java.lang.String baseTag,
                                   @NotNull
                                   SwingEnumProperty.EnumValueComparator<E> enumValueComparator,
                                   @NotNull
                                   java.util.Collection<EnumValue<E>> values)

      Constructor.
      Parameters:
        `startValue` - the start value of this property
        `basicName` - the name of this property
        `baseTag` - the basic i18n tag of this property
        `enumValueComparator` - comparator for `EnumValue`s used to sort the values for display
        `values` - the possible values of this property

    - #### SwingEnumProperty

          public SwingEnumProperty(@NotNull
                                   EnumValue<E> startValue,
                                   boolean autoSave,
                                   @NotNull
                                   java.lang.String basicName,
                                   @NotNull
                                   java.lang.String baseTag,
                                   @NotNull
                                   SwingEnumProperty.EnumValueComparator<E> enumValueComparator,
                                   @NotNull
                                   java.util.Collection<EnumValue<E>> values)

      Constructor.
      Parameters:
        `startValue` - the start value of this property
        `autoSave` - auto save values?
        `basicName` - the name of this property
        `baseTag` - the basic i18n tag of this property
        `enumValueComparator` - comparator for `EnumValue`s used to sort the values for display
        `values` - the possible values of this property

  - ### Method Detail

    - #### getEditorProvider

          @NotNull
          public EditorProvider getEditorProvider(@Nullable
                                                           java.util.Locale l)

      Get the editor provider which provides editor components for editing this preference property.
      Specified by:
        `getEditorProvider` in interface `EditableProperty`
      Parameters:
        `l` - locale used for i18n
      Returns:
        editor provider

    - #### getValue

          @NotNull
          public EnumValue<E> getValue()

      Get the current value.
      Specified by:
        `getValue` in interface `EnumProperty<E>`
      Returns:
        the value

    - #### setValue

          public void setValue(EnumValue<E> value)

      Set a new value.
      Parameters:
        `value` - new value

    - #### getEnumValues

          @NotNull
          public java.util.List<EnumValue<E>> getEnumValues(java.util.Locale l)

      Get the possible values.
      Specified by:
        `getEnumValues` in interface `EnumProperty<E>`
      Parameters:
        `l` - locale to use
      Returns:
        possible values

    - #### getEnumValues

          @NotNull
          protected java.util.List<EnumValue<E>> getEnumValues()

      Get the enum values.
      Returns:
        enum values

    - #### getEnumValueComparator

          SwingEnumProperty.EnumValueComparator<E> getEnumValueComparator()

      Get the enum value comparator.
      Returns:
        enum value comparator used to sort the enum values for display, or `null` if they are displayed in their natural order

    - #### createMenuItem

          public javax.swing.JMenuItem createMenuItem(java.util.Locale l)

      Create a menu item for this boolean property.
      Parameters:
        `l` - locale
      Returns:
        menu item

    - #### getShortNameEnumValueComparator

          public static <T> SwingEnumProperty.EnumValueComparator<T> getShortNameEnumValueComparator()

      Get an enum value comparator suitable to be used in the `SwingEnumProperty(de.caff.util.settings.EnumValue, String, String, de.caff.util.settings.swing.SwingEnumProperty.EnumValueComparator, de.caff.util.settings.EnumValue[])` constructor, which sorts the enum values by their short names.
      Type Parameters:
        `T` - enum type
      Returns:
        comparator comparing short names (case insensitive)