Writing Eclipse plugin to modify Editor Preferences(编写 Eclipse 插件来修改编辑器首选项)
问题描述
我想为 Eclipse CDT 开发一个插件(工具栏按钮),用户可以在其中轻松地在 8 和 4 个空格选项卡之间切换并打开/关闭软选项卡.(为什么要问这个问题?感谢我的组织中的编码指南,用于区分 C/C++ 旧代码和新代码)
I'd like to develop a plugin (tool bar buttons) for Eclipse CDT where users can easily switch between 8 and 4 spaces tabs and turn on/off soft tabs. (Why bother you asked? Thanks to the coding guideline in my org for tabbing difference between C/C++ legacy and new codes)
我设法创建了工具栏按钮,但找不到修改编辑器首选项的信息(通常在工作区首选项 General->Editors->Text Editors 中找到的那些).
I managed to create toolbar buttons but I couldn't find information to modify Editor Preferences (The ones you normally find in Workspace preferences General->Editors->Text Editors).
问题 4587572 似乎涵盖了一点,但我对插件开发还是很陌生,所以我不真懂.
The question 4587572 seems to cover a bit but I'm still very new to Plug-in dev so I don't really understand.
我想我想修改 EDITOR_TAB_WIDTH 和 EDITOR_SPACES_FOR_TABS 的属性org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants用于正在运行的文本编辑器.
I guess I want to modify EDITOR_TAB_WIDTH and EDITOR_SPACES_FOR_TABS properties of org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants for the running text Editor.
不仅修改,我什至无法使用以下代码读取属性.只返回我提供的默认值:30.
Not only modifying, I couldn't even read the properties with following code. Just returns me default value:30 I provided.
int width = Platform.getPreferencesService().getInt(
"org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants",
"EDITOR_TAB_WIDTH", 30, null);
我的问题总结是:如何从我的插件修改正在运行的编辑器的选项卡设置?
My question in summary is: How do I modify tab settings of a running Editor from my plugin?
非常感谢您的帮助.
推荐答案
您可以使用类似于以下的代码来获取和设置任何插件中的首选项.
You can use code similar to the following to get and set preferences in any plugin.
IPreferenceStore s = new ScopedPreferenceStore(new InstanceScope(), "org.eclipse.ui");
ss.setValue("SHOW_MEMORY_MONITOR", true);
这篇关于编写 Eclipse 插件来修改编辑器首选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:编写 Eclipse 插件来修改编辑器首选项
基础教程推荐
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 降序排序:Java Map 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01