Package org.apache.log4j.chainsaw.prefs
Class SettingsManager
- java.lang.Object
-
- org.apache.log4j.chainsaw.prefs.SettingsManager
-
public final class SettingsManager extends java.lang.Object
SettingManager allows components to register interest in Saving/Loading of general application preferences/settings.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Properties
defaultProperties
private static java.lang.String
GLOBAL_SETTINGS_FILE_NAME
private static java.lang.String
HEADER
private static SettingsManager
instance
private javax.swing.event.EventListenerList
listenerList
-
Constructor Summary
Constructors Modifier Constructor Description private
SettingsManager()
Initialises the SettingsManager by loading the default Properties from a resource
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSettingsListener(SettingsListener listener)
Registers the listener with the managervoid
configure(SettingsListener listener)
private LoadSettingsEvent
createProfilebleEvent(Profileable p)
java.util.Properties
getDefaultSettings()
Returns the loaded default settings, which can be used by other classes within this package.static SettingsManager
getInstance()
Returns the singleton instance of the SettingsManagerjava.io.File
getSettingsDirectory()
private java.util.Properties
loadGlobalProperties()
Returns the current Properties settings for this user by merging the default Properties with the ones we find in their directory.private void
loadGlobalSettings()
private void
loadProfileableSettings()
private void
loadProfileble(Profileable p)
private java.util.Properties
loadProperties(Profileable p)
void
loadSettings()
Requests that the settings be loaded, all listeners will be notified of this call, and configure themselves according to the values found in the loaded settingsprivate void
saveGlobalSettings(java.io.File settingsDir)
private void
saveProfileableSetting(java.io.File settingsDir)
Looks up all the Profileable's that have been registered and creates a new event for each of them, and ensures that they are saved within a separate external storevoid
saveSettings()
Creates a SaveSettingsEvent and calls all the SettingsListeners to populate the properties with configuration information
-
-
-
Field Detail
-
instance
private static final SettingsManager instance
-
GLOBAL_SETTINGS_FILE_NAME
private static final java.lang.String GLOBAL_SETTINGS_FILE_NAME
- See Also:
- Constant Field Values
-
HEADER
private static final java.lang.String HEADER
- See Also:
- Constant Field Values
-
listenerList
private javax.swing.event.EventListenerList listenerList
-
defaultProperties
private java.util.Properties defaultProperties
-
-
Method Detail
-
getInstance
public static SettingsManager getInstance()
Returns the singleton instance of the SettingsManager- Returns:
- settings manager
-
addSettingsListener
public void addSettingsListener(SettingsListener listener)
Registers the listener with the manager- Parameters:
listener
-
-
loadSettings
public void loadSettings()
Requests that the settings be loaded, all listeners will be notified of this call, and configure themselves according to the values found in the loaded settings
-
loadProfileableSettings
private void loadProfileableSettings()
-
loadProfileble
private void loadProfileble(Profileable p)
-
createProfilebleEvent
private LoadSettingsEvent createProfilebleEvent(Profileable p)
-
loadProperties
private java.util.Properties loadProperties(Profileable p)
- Parameters:
p
-- Returns:
-
loadGlobalSettings
private void loadGlobalSettings()
-
saveSettings
public void saveSettings()
Creates a SaveSettingsEvent and calls all the SettingsListeners to populate the properties with configuration information
-
saveProfileableSetting
private void saveProfileableSetting(java.io.File settingsDir)
Looks up all the Profileable's that have been registered and creates a new event for each of them, and ensures that they are saved within a separate external store- Parameters:
settingsDir
-
-
saveGlobalSettings
private void saveGlobalSettings(java.io.File settingsDir)
-
getSettingsDirectory
public java.io.File getSettingsDirectory()
-
configure
public void configure(SettingsListener listener)
-
loadGlobalProperties
private java.util.Properties loadGlobalProperties()
Returns the current Properties settings for this user by merging the default Properties with the ones we find in their directory.- Returns:
-
getDefaultSettings
public java.util.Properties getDefaultSettings()
Returns the loaded default settings, which can be used by other classes within this package.- Returns:
- Properties defaults
-
-