Today I got the question how to avoid the usage of Plugin.getDefault().getPreferenceStore() to access preferences as for example in:
Plugin.getDefault().getPreferenceStore()
.getBoolean(IPreferenceConstants.TEST);
The solution is easy you can directly use InstanceScope.Instance, the underlying storage is the same.
InstanceScope.INSTANCE.getNode("com.vogella.eclipse.test").
getBoolean(IPreferenceConstants.TEST, true);
I hope this helps.
[Reminder for myself, we should probably start using that also in platform…]
Why is InstanceScope perferable to Plugin.getDefault()?
Dorian, because it avoids a dependency to Eclipse 3.x API.
But it is not equivalent. It doesn’t check the other scopes (like the default scope), if no value is set in the instance scope. If you want to avoid the preference store of JFace, you can use e.g. the IPreferencesService.