How to change Eclipse Preferences programmatically(如何以编程方式更改 Eclipse 首选项)
问题描述
应该采用什么方法来更改 Eclipse 首选项?
What approach should be to change Eclipse Preferences?
它们存储在 <workspace>/.metadata/.plugin/org.eclipse.core.runtime/.settings
但我希望找到 Java API 和发现任何偏好 ID 的方法.
But I hope to find Java API and a way to discover any preference ID.
推荐答案
有点令人困惑的是,插件可以使用几个 API 来进行偏好设置.
Somewhat confusingly there are several APIs a plugin can use for preferences.
如果你的插件激活器扩展了 AbstractUIPlugin 那么你可以调用
If your plugin activator extends AbstractUIPlugin then you can call
IPreferenceStore prefStore = getPreferenceStore();
在激活器中获取插件的偏好存储.
in the activator to get the preference store for your plugin.
你也可以使用
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode("node id");
获得与首选项略有不同的界面.
to get a slightly different interface to the preferences.
还有 org.eclipse.equinox.preferences.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.
这篇关于如何以编程方式更改 Eclipse 首选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何以编程方式更改 Eclipse 首选项
基础教程推荐
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 存储 20 位数字的数据类型 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
