Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Create a User Scope
Create a User Scope [message #541541] Mon, 21 June 2010 13:52 Go to next message
lukas is currently offline lukasFriend
Messages: 4
Registered: June 2010
Junior Member
Hello all,

Im looking for a example of a user made scope for the eclipse preferences. I found this one (at the end of the document):

http://www.eclipse.org/eclipse/platform-core/documents/user_ settings/faq.html

My Problem is, that it doesnt work. Im getting a NullPointerException when ServerScope.Node(String) is called
.
The only thing they do in the example is to create a Scope and a Node for it. Can someone post an example of a working scope?

Thank you for your help.
Re: Create a User Scope [message #541700 is a reply to message #541541] Tue, 22 June 2010 08:46 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 418
Registered: July 2009
Senior Member
Hi Lukas,

Did you try the example project on the same page?

--

Best Regards,
Wim Jongman
-- "640K ought to be enough for anybody." - Bill Gates, 1981
(Eclipse Old
Skool Quote Service)

> Hello all,
>
> Im looking for a example of a user made scope for the eclipse preferences.
I found this one (at the end of the document):
>
>
http://www.eclipse.org/eclipse/platform-core/documents/user_ settings/faq.html
>
> My Problem is, that it doesnt work. Im getting a NullPointerException when
ServerScope.Node(String) is called
Re: Create a User Scope [message #541904 is a reply to message #541541] Wed, 23 June 2010 06:25 Go to previous message
lukas is currently offline lukasFriend
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

Previous Topic:Problem with RCP perspective layout
Next Topic:How to remove "Installation Details" button and "Key Scrolling" feature?
Goto Forum:
  


Current Time: Mon Dec 22 19:37:59 GMT 2014

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

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