de.caff.util.settings.swing

## Class SwingRecentFilesPreferenceProperty

- java.lang.Object
- - de.caff.util.settings.AbstractBasicChangeableItem
  - - de.caff.util.settings.AbstractBasicLocalizableChangeableItem
    - - de.caff.util.settings.swing.SwingRecentFilesPreferenceProperty

- All Implemented Interfaces:
    ChangeableItem, PreferenceProperty, StringListPreferenceProperty, java.io.Serializable

      public class SwingRecentFilesPreferenceProperty
      extends AbstractBasicLocalizableChangeableItem
      implements StringListPreferenceProperty

  Hold a list of recently opened files.
  Author:
    Rammi
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `SwingRecentFilesPreferenceProperty.RecentFileLoader` Interface for loaders of recent files.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `MAXIMUM_STORE_SIZE` The maximum number of allowd entries.

    - ### Fields inherited from interface de.caff.util.settings.PreferenceProperty

      `PROPERTY_VALUE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SwingRecentFilesPreferenceProperty(java.lang.String basicName, java.lang.String baseTag)` Constructor.
    `SwingRecentFilesPreferenceProperty(java.lang.String basicName, java.lang.String baseTag, int maxSize)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addEntry(java.lang.String filepath)` Add a file path which becomes the most recent entry.
    `java.lang.String` | `getLatestEntry()` Return the entry which was added most recently.
    `javax.swing.JMenuItem` | `getMenuItem(SwingRecentFilesPreferenceProperty.RecentFileLoader loader, java.util.Locale l)` Get a menu item representing the list of recent files.
    `java.util.List<java.lang.String>` | `getStringList()` Get the collection of strings.
    `void` | `readFrom(java.util.prefs.Preferences preferences)` Read the property value from the preferences.
    `void` | `storeTo(java.util.prefs.Preferences preferences)` Store the current property value in the preferences.

    - ### 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.ChangeableItem

      `addValueChangeListener, addValueChangeListenerWeakly, removeValueChangeListener, removeValueChangeListenerWeakly`

- - ### Field Detail

    - #### MAXIMUM_STORE_SIZE

          public static final int MAXIMUM_STORE_SIZE

      The maximum number of allowd entries.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SwingRecentFilesPreferenceProperty

          public SwingRecentFilesPreferenceProperty(@NotNull
                                                    java.lang.String basicName,
                                                    @NotNull
                                                    java.lang.String baseTag)

      Constructor. Uses `MAXIMUM_STORE_SIZE` as allowed size for list.
      Parameters:
        `basicName` - basic name (prefix)
        `baseTag` - basic i18n tag

    - #### SwingRecentFilesPreferenceProperty

          public SwingRecentFilesPreferenceProperty(@NotNull
                                                    java.lang.String basicName,
                                                    @NotNull
                                                    java.lang.String baseTag,
                                                    int maxSize)

      Constructor.
      Parameters:
        `basicName` - basic name (prefix)
        `baseTag` - basic i18n tag
        `maxSize` - maximum number of recent files stored, must be not more than `MAXIMUM_STORE_SIZE`

  - ### Method Detail

    - #### addEntry

          public void addEntry(@NotNull
                               java.lang.String filepath)

      Add a file path which becomes the most recent entry.
      Parameters:
        `filepath` - filepath to add

    - #### readFrom

          public void readFrom(@NotNull
                               java.util.prefs.Preferences preferences)

      Read the property value from the preferences.
      Specified by:
        `readFrom` in interface `PreferenceProperty`
      Parameters:
        `preferences` - preferences from where to read the property value

    - #### storeTo

          public void storeTo(@NotNull
                              java.util.prefs.Preferences preferences)

      Store the current property value in the preferences.
      Specified by:
        `storeTo` in interface `PreferenceProperty`
      Parameters:
        `preferences` - preferences where to store the property value

    - #### getStringList

          @NotNull
          public java.util.List<java.lang.String> getStringList()

      Get the collection of strings.
      Specified by:
        `getStringList` in interface `StringListPreferenceProperty`
      Returns:
        String list

    - #### getLatestEntry

          @Nullable
          public java.lang.String getLatestEntry()

      Return the entry which was added most recently.
      Returns:
        latest entry or `null` if no entry was saved

    - #### getMenuItem

          @NotNull
          public javax.swing.JMenuItem getMenuItem(SwingRecentFilesPreferenceProperty.RecentFileLoader loader,
                                                            java.util.Locale l)

      Get a menu item representing the list of recent files.
      Parameters:
        `loader` - loader which loads the files if one is selected
        `l` - locale
      Returns:
        menu item