You should be using the activator for your plugin not the preference plugin. If your activator extends AbstractUIPlugin
it will have a getPreferenceStore()
method.
Your preference page needs to call
setPreferenceStore(Activator.getDefault().getPreferenceStore());
during initialization (normally in the constructor).
You probably also want to use the org.eclipse.core.runtime.preferences
extension point to define a preferences initializer to ensure the preferences always have a value.
Update: Example activator
public class Activator extends AbstractUIPlugin {
private static Activator plugin;
public Activator() {
}
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
public static Activator getDefault() {
return plugin;
}
}