|
|
Re: Create a User Scope [message #541904 is a reply to message #541541] |
Wed, 23 June 2010 06:25 |
lukas Messages: 4 Registered: June 2010 |
Junior Member |
|
|
Hello Wim,
Yes i Tried the example project from this page. My Problem is the following i try to add a node to my Scope node and after that i get the NullPointerExample.
I Wrote a little example so its more clear what i mean:
IPreferencesService service = Platform.getPreferencesService();
service.setDefaultLookupOrder(Activator.PLUGIN_ID,
"myDefaultLookUpOrder", new String[] {
MyScope.SCOPE, ConfigurationScope.SCOPE, InstanceScope.SCOPE,
DefaultScope.SCOPE });
String key = "name";
String defaultValue = "Error while loading Property";
IEclipsePreferences root = service.getRootNode();
Preferences myScopeNode = root.node(myScopeNode.SCOPE)
.node(Activator.PLUGIN_ID);
myScopeNode.put("name","Eddy");
Preferences instanceNode = root.node(InstanceScope.SCOPE)
.node(Activator.PLUGIN_ID);
instanceNode.put("name", "Test");
Preferences configurationNode = root.node(ConfigurationScope.SCOPE)
.node(Activator.PLUGIN_ID);
configurationNode.put("name", "Wim");
Preferences defaultNode = root.node(DefaultScope.SCOPE).node(
Activator.PLUGIN_ID);
defaultNode.put("name", "Lukas");
Preferences[] nodes = new Preferences[] { myScopeNode, configurationNode,
instanceNode, defaultNode };
System.out.println("Name: " + service.get(key, defaultValue, nodes));
The Code is in a View and called after "cratePartcontrol" Method.
The Line "Preferences myScopeNode = root.node(myScopeNode.SCOPE).node(Activator.PLUGIN_ID);" cause the NullPointerException because in the Scope (same implementation like in the example) the method "public Preferences node(String path)" returns null. And thats wrong as far is i know.
Without my own Scope it works.
[Updated on: Wed, 23 June 2010 06:26] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03110 seconds