/** Logger for this class. */
private final static ILogger s_log = LoggerController.createLogger(PreferencesManager.class );
/** Name of preferences file. */
private static final String USER_PREFS_FILE_NAME = "prefs.xml";
/** Folder to store user settings in. */
private static File _userSettingsFolder;
private static [[#variable18d45720]] _prefs = null;
private static IPlugin plugin = null;
/**
* Initializes the PreferencesManager
*
* @param thePlugin
* @throws PluginException
*/
public static void initialize(IPlugin thePlugin) throws PluginException {
plugin = thePlugin;
// Folder to store user settings.
try {
_userSettingsFolder = plugin.getPluginUserSettingsFolder();
}
catch (IOException
ex) {
throw new PluginException(ex);
}
loadPrefs();
}
/**
* Returns the preferences holder
*
* @return The bean holding the preferences for the dataimport plugin.
*/
public static [[#variable18d45720]] getPreferences() {
return _prefs;
}
/**
* Saves the preferences.
*/
public static void unload() {
savePrefs();
}
/**
* Save preferences to disk. Always write to the user settings folder, not
* the application settings folder.
*/
public static void savePrefs() {
try {
XMLBeanWriter wtr = new XMLBeanWriter(_prefs);
wtr.save(new File(_userSettingsFolder, USER_PREFS_FILE_NAME));
}
catch (Exception
ex) {
s_log.error("Error occured writing to preferences file: " + USER_PREFS_FILE_NAME, ex);
}
}
|