Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » ApplyPreferences causes Default Preferences to disappear
ApplyPreferences causes Default Preferences to disappear [message #912934] Fri, 14 September 2012 08:34 Go to previous message
Stefan Nöbauer is currently offline Stefan Nöbauer
Messages: 20
Registered: January 2012
Junior Member
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?


 
Read Message
Read Message
Read Message
Read Message
Previous Topic:disposing the Perspective
Next Topic:InjectionException: java.lang.NoClassDefFoundError: XmlSchemaCollection
Goto Forum:
  


Current Time: Thu May 23 18:42:46 EDT 2013

Powered by FUDForum. Page generated in 0.01702 seconds