Class TLcyPreferencesManager

java.lang.Object
com.luciad.lucy.TLcyPreferencesManager

public class TLcyPreferencesManager extends Object

Manager of preferences. Users of the API shouldn't create a TLcyPreferencesManager themselves, instead the TLcyPreferencesManager can be retrieved using ILcyLucyEnv.getPreferencesManager().

The preferences are divided in two categories: user preferences and system preferences. Both are represented as ALcyProperties and can be retrieved with getCurrentUserPreferences() and getSystemPreferences() respectively. User preferences concern the user, and can be different per user of the system. System preferences are application wide preferences, that should only differ per system. Changes in the preferences can be observed by adding a PropertyChangeListener to the ALcyProperties instances.

Additionally, this manager offers ILcyPropertiesDecoder decoders to addons so they can decode their initial configuration. The default ILcyPropertiesDecoder decodes the configuration files specified by the source name, but alternative implementations can be set using the setUserPreferencesPropertiesDecoder(ILcyPropertiesDecoder) and setSystemPreferencesPropertiesDecoder(ILcyPropertiesDecoder) methods. These could for instance retrieve the initial configuration from a database.

This class does not take care of making the preferences persistent so that they are available the next time the application is started. This is done by the TLcyPersistentPreferencesAddOn. If this addon is not loaded, the preferences will not be persistent.

  • Field Details

    • DATA_DIRECTORY_KEY

      public static final String DATA_DIRECTORY_KEY
      Property name for the data directory in the preference manager. The corresponding property value is of type java.lang.String. This property is, for example, used in the Open and Save dialogs to represent the current directory.
      See Also:
    • SCROLL_UP_ZOOM_OUT_KEY

      public static final String SCROLL_UP_ZOOM_OUT_KEY
      Defines the zoom direction of the scroll wheel. True means when the scroll wheel is scrolled up (pushed away), the map zooms out. If set to false, scrolling up means zooming in. This property works application wide: all scroll behavior will follow this property.
      See Also:
  • Constructor Details

    • TLcyPreferencesManager

      public TLcyPreferencesManager()

      Creates a new preferences manager. Clients should not use this constructor but rather retrieve a preferences manager from the Lucy backend. See ILcyLucyEnv.getPreferencesManager()

  • Method Details

    • getSystemPreferencesPropertiesDecoder

      public ILcyPropertiesDecoder getSystemPreferencesPropertiesDecoder()

      Returns the ILcyPropertiesDecoder that addons can use to decode their initial system configuration. The default ILcyPropertiesDecoder interprets the given source name as a file relative to the classpath or current working directory and expects the file to contain properties in the java.util.Properties format.

      Returns:
      The ILcyPropertiesDecoder to decode initial system configuration. Never null.
    • setSystemPreferencesPropertiesDecoder

      public void setSystemPreferencesPropertiesDecoder(ILcyPropertiesDecoder aSystemPreferencesPropertiesDecoder)

      Sets the ILcyPropertiesDecoder that addons should use to decode their initial system configuration.

      Parameters:
      aSystemPreferencesPropertiesDecoder - The ILcyPropertiesDecoder that should be used to decode initial system configuration. Must not be null.
      See Also:
    • getUserPreferencesPropertiesDecoder

      public ILcyPropertiesDecoder getUserPreferencesPropertiesDecoder()

      Returns the ILcyPropertiesDecoder that addons can use to decode their initial user configuration. The default ILcyPropertiesDecoder adds '.userPrefs' before the extension of the the given source name and interprets that result as a file relative to the classpath or current working directory and expects the file to contain properties in the java.util.Properties format.

      For instance, getUserPreferencesPropertiesDecoder().decode( "sourceName.cfg" ) will look for the sourceName.userPrefs.cfg file relative to the classpath or working directory.

      Returns:
      The ILcyPropertiesDecoder to decode initial user configuration. Never null.
    • setUserPreferencesPropertiesDecoder

      public void setUserPreferencesPropertiesDecoder(ILcyPropertiesDecoder aUserPreferencesPropertiesDecoder)

      Sets the ILcyPropertiesDecoder that addons should use to decode their initial user configuration.

      Parameters:
      aUserPreferencesPropertiesDecoder - The ILcyPropertiesDecoder that should be used to decode initial user configuration. Must not be null.
      See Also:
    • getSystemPreferences

      public TLcyStringProperties getSystemPreferences()

      Returns the system preferences of this TLcyPreferencesManager. The intention is to have system wide preferences, so they should be identical for all users in a system, but it is up to the addon that makes the preferences persistent to fulfill this task. Note that changes to these system preferences currently aren't made persistent. This is a known limitation of TLcyPersistentPreferencesAddOn).

      Preferences can be added to and retrieved from this TLcyStringProperties object by using the various put and get methods. Note that only String values are allowed to be stored; the simple types such as int, double, etc. are automatically converted to Strings by TLcyStringProperties. Note that the keys should be unique (application wide) and it is therefore advised to use the package name as a prefix for the names of the keys.

      Returns:
      the user preferences of this TLcyPreferencesManager.
    • getCurrentUserPreferences

      public TLcyStringProperties getCurrentUserPreferences()
      Returns the user preferences of this TLcyPreferencesManager. The intention is to have separate preferences for every user in a system, but it is up to the addon that makes the preferences persistent (see TLcyPersistentPreferencesAddOn) to fulfill this task.

      Preferences can be added to and retrieved from this TLcyStringProperties object by using the various put and get methods. Note that only String values are allowed to be stored; the simple types such as int, double, etc. are automatically converted to Strings by TLcyStringProperties. Note that the keys should be unique (application wide) and it is therefore advised to use the package name as a prefix for the names of the keys.

      Returns:
      the user preferences of this TLcyPreferencesManager.
    • getUserPreferences

      @Deprecated public Properties getUserPreferences()
      Deprecated.
      Use #getCurrentUserPreferences instead.

      Returns the user preferences of this TLcyPreferencesManager. The intention is to have separate preferences for every user in a system, but it is up to the addon that makes the preferences persistent (see TLcyPersistentPreferencesAddOn) to fulfill this task.

      Preferences can be added to this Properties object by using Properties.setProperty(String, String), they can be retrieved by using Properties.getProperty(String). Only String objects can be used as 'key' and 'value'. Note that the keys should be unique and it is therefore advised to use the package name as a prefix for the names of the keys.

      Returns:
      the user preferences of this TLcyPreferencesManager.
    • addPropertyChangeListener

      @Deprecated public void addPropertyChangeListener(PropertyChangeListener aListener)
      Deprecated.
      Add the listener to #getCurrentUserPreferences instead.

      Adds a listener to listen for changes in all preferences. The source of the event is the Properties object that is involved in the change (e.g getUserPreferences()). The property name is the key of the property that has changed, or null if multiple properties have changed. If the property name is available (not null), the old and new values will be available too.

      Parameters:
      aListener - The listener to add.
    • addPropertyChangeListener

      @Deprecated public void addPropertyChangeListener(String aPropertyName, PropertyChangeListener aListener)
      Deprecated.
      Add the listener to #getCurrentUserPreferences instead.

      Equivalent to addPropertyChangeListener(java.beans.PropertyChangeListener), but only events with respect to the property with name aPropertyName are received by aListener.

      Parameters:
      aPropertyName - The property name to listen for changes.
      aListener - The listener.
    • removePropertyChangeListener

      @Deprecated public void removePropertyChangeListener(PropertyChangeListener aListener)
      Deprecated.
      Remove the listener to #getCurrentUserPreferences instead.

      Removes the listener so that it no longer receives change events.

      Parameters:
      aListener - The listener to remove.
    • removePropertyChangeListener

      @Deprecated public void removePropertyChangeListener(String aPropertyName, PropertyChangeListener aListener)
      Deprecated.
      Remove the listener from #getCurrentUserPreferences instead.

      Removes the listener so that it no longer receives change events for the given aPropertyName.

      Parameters:
      aPropertyName - The property name to stop listening for.
      aListener - The listener to remove.