Preferences in ConfigurationScope are not written [message #1781812] |
Tue, 13 February 2018 13:14 |
Felix Funke 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.02816 seconds