How to change Eclipse Preferences programmatically

孤街醉人 提交于 2019-12-30 07:44:06

问题


What approach should be to change Eclipse Preferences?

They are stored in <workspace>/.metadata/.plugin/org.eclipse.core.runtime/.settings

But I hope to find Java API and a way to discover any preference ID.


回答1:


Somewhat confusingly there are several APIs a plugin can use for preferences.

If your plugin activator extends AbstractUIPlugin then you can call

IPreferenceStore prefStore = getPreferenceStore();

in the activator to get the preference store for your plugin.

You can also use

IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode("node id");

to get a slightly different interface to the preferences.

There is also the org.eclipse.equinox.preferences.preferences extension point which lets you define an 'initializer' to set the default values for preferences.



来源:https://stackoverflow.com/questions/26113234/how-to-change-eclipse-preferences-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!