Search code examples
eclipseeclipse-pluginpreferenceseclipse-pde

How can two eclipse plugin use the same preferences store?


I have two plugins, say com.site.plugin.core and com.site.plugin.ui.
I'd like to separate core part from UI part, so at plugin com.site.plugin.ui I created Preferences page where I defined some preferences, which should be used by com.site.plugin.core. I check article at Eclipse site, but it is quite outdated, and linked bug also do not provide much info.
So is it possible to do this using standard Eclipse mechanism, or I need use direct low-level API via package org.eclipse.core.runtime.preferences?


Solution

  • I believe that the UI depends on Core and not otherwise. In this case, you could use the Core's preference store in the UI plugin's preference page, like this:

    IPreferenceStore store = CorePluginActivator.getDefault().getPreferenceStore();
    setPreferenceStore(store);
    

    In this way the preference page will store the values in the Core plugin. The Core plugin can use the values without depending on the UI plugin.