Class Preferences
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringTheAPPLICATION_PREFERENCES_FILENAMEis the default name for the user preferences file.static final StringPreference name for the export directory that was last accessed.static final StringPreference name for the import directory that was last accessed for domain files.static final StringPreference name for directory last selected for creating a new project.static final StringPreference name for the last opened archive directory.static final StringPreference name for the last chosen directory for path related items.static final StringPreference name for export directory that was last accessed for tools.static final StringPreference name for import directory that was last accessed for tools.static final StringPreference name for the project directory. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear()Clears all properties in this Preferences object.static StringGet the filename that will be used in the store() method.static String[]Return the paths in the UserPluginPath property.static StringgetProperty(String name) Get the property with the given name.static StringgetProperty(String name, String defaultValue) Get the property with the given name; if there is no property, return the defaultValue.static StringgetProperty(String name, String defaultValue, boolean useHistoricalValue) Get the property with the given name; if there is no property, return the defaultValue.Get an array of known property names.static StringremoveProperty(String name) Removes the given preference from this preferences object.static voidsetFilename(String name) Set the filename so that when the store() method is called, the preferences are written to this file.static voidsetPluginPaths(String[] paths) Set the paths to be used as the UserPluginPath property.static voidsetProperty(String name, String value) Set the property value.static booleanstore()Store the preferences in a file for the current filename.
-
Field Details
-
APPLICATION_PREFERENCES_FILENAME
TheAPPLICATION_PREFERENCES_FILENAMEis the default name for the user preferences file.- See Also:
-
LAST_OPENED_ARCHIVE_DIRECTORY
Preference name for the last opened archive directory.- See Also:
-
PROJECT_DIRECTORY
Preference name for the project directory.- See Also:
-
LAST_TOOL_IMPORT_DIRECTORY
Preference name for import directory that was last accessed for tools.- See Also:
-
LAST_TOOL_EXPORT_DIRECTORY
Preference name for export directory that was last accessed for tools.- See Also:
-
LAST_NEW_PROJECT_DIRECTORY
Preference name for directory last selected for creating a new project.- See Also:
-
LAST_PATH_DIRECTORY
Preference name for the last chosen directory for path related items.- See Also:
-
LAST_IMPORT_FILE
Preference name for the import directory that was last accessed for domain files.- See Also:
-
LAST_EXPORT_DIRECTORY
Preference name for the export directory that was last accessed.- See Also:
-
-
Method Details
-
clear
public static void clear()Clears all properties in this Preferences object.Warning: Save any changes pending before calling this method, as this call will erase any changes not written do disk via
store() -
removeProperty
Removes the given preference from this preferences object.- Parameters:
name- the name of the preference key to remove.- Returns:
- the value that was stored with the given key.
-
getProperty
Get the property with the given name.Note: all
getProperty(...)methods will checkSystem.getProperty(String)for a value first. This allows users to override preferences from the command-line.- Parameters:
name- the property name- Returns:
- the current property value; null if not set
-
getProperty
Get the property with the given name; if there is no property, return the defaultValue.Note: all
getProperty(...)methods will checkSystem.getProperty(String)for a value first. This allows users to override preferences from the command-line.- Parameters:
name- the property namedefaultValue- the default value- Returns:
- the property value; default value if not set
- See Also:
-
getProperty
Get the property with the given name; if there is no property, return the defaultValue.This version of
getPropertywill, whenuseHistoricalValueis true, look for the given preference value in the last used installation of the application.Note: all
getProperty(...)methods will checkSystem.getProperty(String)for a value first. This allows users to override preferences from the command-line.- Parameters:
name- The name of the property for which to get a valuedefaultValue- The value to use if there is no value yet set for the given nameuseHistoricalValue- True signals to check the last used application installation for a value for the given name if that value has not yet been set.- Returns:
- the property with the given name; if there is no property, return the defaultValue.
- See Also:
-
setProperty
Set the property value. If a null value is passed, then the property is removed from this collection of preferences.- Parameters:
name- property namevalue- value for property
-
getPropertyNames
Get an array of known property names.- Returns:
- if there are no properties, return a zero-length array
-
getFilename
Get the filename that will be used in the store() method.- Returns:
- the filename
-
setFilename
Set the filename so that when the store() method is called, the preferences are written to this file.- Parameters:
name- the filename
-
store
public static boolean store()Store the preferences in a file for the current filename.- Returns:
- true if the file was written
- Throws:
RuntimeException- if the preferences filename was not set
-
getPluginPaths
Return the paths in the UserPluginPath property. Return zero length array if this property is not set.- Returns:
- the paths
-
setPluginPaths
Set the paths to be used as the UserPluginPath property.- Parameters:
paths- the paths
-