views:

190

answers:

2

I have an Eclipse plug-in with a checkbox in the plug-in's preference page. This checkbox is used for enabling and disabling an editor, which is being launched from this plug-in.

However, the problem is, I would also like to be able to enable and disable this 'editor-launch' from another plug-in, by having actions which change the value of the checkbox in the above mentioned preference page.

Here's the problem, how do I access that local preference store from another plug-in?

I've tried things like..

View myView = (View) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("ViewID");

But this 'myView' always seems to be null.. And also, what would I do with the view since it's the Plug-in I want.

Platform.getBundle('bundleName')...

Same here, want the Plugin, not the bundle corresponding to is.

No matter what I try nothing seems to work.
Does anyone have any ideas?

A: 

This thread recommend the use of a Service tracker:

ServiceTracker tracker = new ServiceTracker(ToolkitPlugin.getDefault().getBundle().getBundleContext(),
                                            IProxyService.class.getName(), null);
tracker.open();
proxyService = (IProxyService) tracker.getService();
proxyService.addProxyChangeListener(this);
VonC
A: 

This may work.

Prefs stores are found per plugin. This is one way to get a prefs store for the plugin whose activator class is ActivatorA.

IPreferenceStore store = ActivatorA.getDefault().getPreferenceStore();

If you want another plugin to refer to the same store, perhaps you could expose some api on ActivatorA for it to get there, e.g.

public IPreferenceStore getSharedPrefs() { return ActivatorA.getDefault().getPreferenceStore(); }

The second plugin would find the shared store by doing this

IPreferenceStore sharedPrefs = ActivatorA.getSharedPrefs();

Good luck.

bwinspur