ApplyPreferences causes Default Preferences to disappear [message #912934] |
Fri, 14 September 2012 08:34  |
Eclipse User |
|
|
|
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?
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03667 seconds