Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Preferences in ConfigurationScope are not written
Preferences in ConfigurationScope are not written [message #1781812] Tue, 13 February 2018 13:14 Go to next message
Felix Funke is currently offline Felix FunkeFriend
Messages: 6
Registered: October 2013
Junior Member
Hello,

I have a problem in my application with the preferences of ConfigurationScope.

I have written two simple command handlers. One writes a few preferences into the ConfigurationScope, the other one reads and prints them to System.out (taken from the Vogella tutorial):

public class TestHandler {
    @Execute
    public void execute() {
        IEclipsePreferences preferences = ConfigurationScope.INSTANCE.getNode("myapp");
        Preferences node1 = preferences.node("node1");
        Preferences node2 = preferences.node("node2");
        node1.put("h1", "Hello");
        node1.put("h2", "Hello again");
        node2.put("h1", "Moin");

        try {
            // forces the application to save the preferences
            preferences.flush();
        } catch (BackingStoreException e2) {
            e2.printStackTrace();
        }
    }
}


public class Test2Handler {
    @Execute
    public void execute() {
        IEclipsePreferences preferences = ConfigurationScope.INSTANCE.getNode("myapp");
        Preferences sub1 = preferences.node("node1");
        Preferences sub2 = preferences.node("node2");
        System.out.println(sub1.get("h1", "default"));
        System.out.println(sub1.get("h2", "default"));
        System.out.println(sub2.get("h1", "default"));
    }

}


When I execute both commands from within the IDE, the preferences get written to <IDE-Workspace-Directory>/.metadata/.plugins/org.eclipse.pde.core/myapp.product/.settings. I can restart the application and just execute the Test2Handler and it will print the preferences as expected.

But when I use my Tycho-build to generate an executable application, the behavior changes. I can execute TestHandler and Test2Handler2 and see that the values have changed from "default" to "Hello" and "Moin". But when I restart the application everything is back to "default". In addition nothing in stored in the directory or any subdirectories from where I started my exported application.

Am I missing something here?`

Thanks
Felix
Re: Preferences in ConfigurationScope are not written [message #1781893 is a reply to message #1781812] Wed, 14 February 2018 11:09 Go to previous message
Felix Funke is currently offline Felix FunkeFriend
Messages: 6
Registered: October 2013
Junior Member
Problem has been solved. In addition to my application bundle I had another plugin with just an activator. This bundle was set to StartLevel 3 and used the preferences to try to store something in the ConfigurationScope. When I deactivated the plugin, my application bundle could use the ConfigurationScope as expected.

Thanks
Felix
Previous Topic:How to contribute to main toolbar using Eclipse 4?
Next Topic:E4 Product Mulitple Platform Issue
Goto Forum:
  


Current Time: Wed Sep 19 17:25:01 GMT 2018

Powered by FUDForum. Page generated in 0.01725 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top