Preferences in ConfigurationScope are not written [message #1781812] |
Tue, 13 February 2018 08:14  |
Eclipse User |
|
|
|
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 06:09  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03026 seconds