开发者

Preference Page and runtime plugins

开发者 https://www.devze.com 2023-03-12 14:40 出处:网络
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, whi

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 I开发者_开发问答nstanceScope().getNode("<plugin id>");

How do I synchronize both?


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号