1

I have the following problem. I have a Preferences Page that stores preferences using the Store mechanism. Now, these preferences must be accessed from a plugin that does not include org.eclipse.ui, which means that the store mechanism is not available and I can only use the Runtime preference mechanism.

How can I use the Preference Page to create a runtime preference?

I have the following problem:

  • When using preference pages, the class used is Activator.getDefault().getPreferenceStore()
  • When using runtime plugins, the class is new InstanceScope().getNode("<plugin id>");

How do I synchronize both?

tcb
  • 2,745
  • 21
  • 20
Mario Ortegón
  • 18,670
  • 17
  • 71
  • 81

1 Answers1

3

See Eclipse: OSGI Preferences vs. PreferenceStore

Basically, InstanceScope.INSTANCE.getNode("bundle.id") gives you the org.eclipse.core.runtime.preferences.IEclipsePreferences that backs your bundle's org.eclipse.jface.preference.IPreferenceStore. You shouldn't have to sync them, as they're the same thing.

Have they been out of sync? You might have to do a IPersistentPreferenceStore#save() and/or a org.osgi.service.prefs.Preferences.flush() if they're not in sync by default (although I thought those methods were simply to write out to the disk cache).

Community
  • 1
  • 1
Paul Webster
  • 10,614
  • 1
  • 25
  • 32
  • However, that doesn't solve my scenario completely, does it? Because the IPreferenceStore is used in a ui plugin, but I need to read the preference in a core plugin – Mario Ortegón Jun 17 '11 at 14:18
  • yes, the point is you can use `InstanceScope.INSTANCE.getNode("bundle.id")` in your core plugin – Paul Webster Jun 17 '11 at 17:01
  • Get it, the id I use should be unique for both plugins and that does the trick. I assume that it should be the id of the core plugin also. thanks! Accepted – Mario Ortegón Jun 21 '11 at 15:04