ApplyPreferences causes Default Preferences to disappear [message #912934] |
Fri, 14 September 2012 12:34 |
|
Hi,
I implemented a feature for multiple user preferences. The export of the UserPreferences is working ok. with
IPreferencesService service = Platform.getPreferencesService();
File exportFile = File.createTempFile(USER_PREFERENCE_FILE_PREFIX,
USER_PREFERENCE_FILE_SUFFIX, toFolder);
os = new FileOutputStream(exportFile);
service.exportPreferences(service.getRootNode(), os, null);
I also initialize my DefaultValues with the PreferenceInitializer framework.
But when I try to load the stored Preferences, all my default values are gone.
I load them with following code:
IPreferencesService service = Platform.getPreferencesService();
IExportedPreferences prefs;
try {
prefs = service.readPreferences(new FileInputStream(new File(
selectedFile)));
service.applyPreferences(prefs, getTransfers());
} catch (FileNotFoundException e) {
ExceptionDialog.show(e, shell);
} catch (CoreException e) {
ExceptionDialog.show(e, shell);
}
return null;
}
private static IPreferenceFilter[] getTransfers() {
IPreferenceFilter[] transfers = new IPreferenceFilter[1];
// For export all create a preference filter that can export
// all nodes of the Instance and Configuration scopes
transfers[0] = new IPreferenceFilter() {
@Override
public String[] getScopes() {
return new String[] { InstanceScope.SCOPE,
ConfigurationScope.SCOPE };
}
@Override
@SuppressWarnings("rawtypes")
public Map getMapping(String scope) {
return null;
}
};
return transfers;
}
I`m using Eclipse 3.6 as RCP
Is there a bug or am I doing something wrong here?
|
|
|
Re: ApplyPreferences causes Default Preferences to disappear [message #912975 is a reply to message #912934] |
Fri, 14 September 2012 14:11 |
|
Hi ... I`m sorry .. I have no Idea what I have done wrong but the problem I described above does not appear anymore.
But I run into another one.
The Problem is that the Preference Export only exports Preferences that differ from the default value.
So it is not possible to reset changed Preferences to the default by loading a stored PreferenceFile.
Does anyone know a way to solve this.
e.g.
- export every single preference
- reset the entire workbench to the default values
- ...
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03375 seconds