Class TLcyPreferencesManager
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 Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addPropertyChangeListener
(PropertyChangeListener aListener) Deprecated.Add the listener to #getCurrentUserPreferences instead.void
addPropertyChangeListener
(String aPropertyName, PropertyChangeListener aListener) Deprecated.Add the listener to #getCurrentUserPreferences instead.Returns the user preferences of thisTLcyPreferencesManager
.Returns the system preferences of thisTLcyPreferencesManager
.Returns theILcyPropertiesDecoder
that addons can use to decode their initial system configuration.Deprecated.Use #getCurrentUserPreferences instead.Returns theILcyPropertiesDecoder
that addons can use to decode their initial user configuration.void
Deprecated.Remove the listener to #getCurrentUserPreferences instead.void
removePropertyChangeListener
(String aPropertyName, PropertyChangeListener aListener) Deprecated.Remove the listener from #getCurrentUserPreferences instead.void
setSystemPreferencesPropertiesDecoder
(ILcyPropertiesDecoder aSystemPreferencesPropertiesDecoder) Sets theILcyPropertiesDecoder
that addons should use to decode their initial system configuration.void
setUserPreferencesPropertiesDecoder
(ILcyPropertiesDecoder aUserPreferencesPropertiesDecoder) Sets theILcyPropertiesDecoder
that addons should use to decode their initial user configuration.
-
Field Details
-
DATA_DIRECTORY_KEY
Property name for the data directory in the preference manager. The corresponding property value is of typejava.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
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
Returns the
ILcyPropertiesDecoder
that addons can use to decode their initial system configuration. The defaultILcyPropertiesDecoder
interprets the given source name as a file relative to the classpath or current working directory and expects the file to contain properties in thejava.util.Properties
format.- Returns:
- The
ILcyPropertiesDecoder
to decode initial system configuration. Nevernull
.
-
setSystemPreferencesPropertiesDecoder
public void setSystemPreferencesPropertiesDecoder(ILcyPropertiesDecoder aSystemPreferencesPropertiesDecoder) Sets the
ILcyPropertiesDecoder
that addons should use to decode their initial system configuration.- Parameters:
aSystemPreferencesPropertiesDecoder
- TheILcyPropertiesDecoder
that should be used to decode initial system configuration. Must not benull
.- See Also:
-
getUserPreferencesPropertiesDecoder
Returns the
ILcyPropertiesDecoder
that addons can use to decode their initial user configuration. The defaultILcyPropertiesDecoder
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 thejava.util.Properties
format.For instance,
getUserPreferencesPropertiesDecoder().decode( "sourceName.cfg" )
will look for thesourceName.userPrefs.cfg
file relative to the classpath or working directory.- Returns:
- The
ILcyPropertiesDecoder
to decode initial user configuration. Nevernull
.
-
setUserPreferencesPropertiesDecoder
public void setUserPreferencesPropertiesDecoder(ILcyPropertiesDecoder aUserPreferencesPropertiesDecoder) Sets the
ILcyPropertiesDecoder
that addons should use to decode their initial user configuration.- Parameters:
aUserPreferencesPropertiesDecoder
- TheILcyPropertiesDecoder
that should be used to decode initial user configuration. Must not benull
.- See Also:
-
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 ofTLcyPersistentPreferencesAddOn
).Preferences can be added to and retrieved from this
TLcyStringProperties
object by using the variousput
andget
methods. Note that onlyString
values are allowed to be stored; the simple types such as int, double, etc. are automatically converted toString
s byTLcyStringProperties
. 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
Returns the user preferences of thisTLcyPreferencesManager
. 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 (seeTLcyPersistentPreferencesAddOn
) to fulfill this task. Preferences can be added to and retrieved from thisTLcyStringProperties
object by using the variousput
andget
methods. Note that onlyString
values are allowed to be stored; the simple types such as int, double, etc. are automatically converted toString
s byTLcyStringProperties
. 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.Use #getCurrentUserPreferences instead.Returns the user preferences of this
Preferences can be added to thisTLcyPreferencesManager
. 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 (seeTLcyPersistentPreferencesAddOn
) to fulfill this task.Properties
object by usingProperties.setProperty(String, String)
, they can be retrieved by usingProperties.getProperty(String)
. OnlyString
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.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.ggetUserPreferences()
). 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.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.
-