编写Eclipse插件以修改“编辑器首选项”

|| 我想为Eclipse CDT开发一个插件(工具栏按钮),用户可以在其中轻松地在8和4个空格标签之间切换并打开/关闭软标签。 (为什么要打扰您?多亏我组织中的编码指南来区分C / C ++旧代码和新代码之间的区别) 我设法创建了工具栏按钮,但找不到修改“编辑器首选项”(通常在“工作区”首选项“常规”->“编辑器”->“文本编辑器”中找到的信息)的信息。 问题4587572似乎涵盖了一部分,但我对Plug-in开发人员还很陌生,所以我不太了解。 我想我想修改的EDITOR_TAB_WIDTH和EDITOR_SPACES_FOR_TABS属性 org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants 用于运行的文本编辑器。 不仅进行了修改,而且甚至无法使用以下代码读取属性。只需返回我提供的默认值:30。
int width = Platform.getPreferencesService().getInt(
    \"org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants\",
    \"EDITOR_TAB_WIDTH\", 30, null);
我的问题摘要是:如何从插件修改正在运行的编辑器的选项卡设置? 非常感谢您的帮助。     
已邀请:
        您可以使用类似于以下代码的代码在任何插件中获取和设置首选项。
IPreferenceStore s = new ScopedPreferenceStore(new InstanceScope(), \"org.eclipse.ui\");
ss.setValue(\"SHOW_MEMORY_MONITOR\", true);
    
        您应该尝试安装和使用可完成这项工作的AnyEdit工具-最受欢迎的eclipse插件之一。     
        感谢@nonty的建议。它运作良好。为了他人的利益,这是我的完整代码,用于更改CDT编辑器中的标签设置。
    public void run(IAction action) {
    if(action.isChecked())
    {
        IPreferenceStore ps = new ScopedPreferenceStore(new InstanceScope(), \"org.eclipse.cdt.core\");
        ps.setValue(\"org.eclipse.cdt.core.formatter.tabulation.size\",  8);
        ps.setValue(\"org.eclipse.cdt.core.formatter.indentation.size\", 8);
        ps.setValue(\"org.eclipse.cdt.core.formatter.use_tabs_only_for_leading_indentations\", true);
        ps.setValue(\"org.eclipse.cdt.core.formatter.tabulation.char\", \"tab\"); //=mixed/space/tab

        // To check if the value
        // int tabWidth = ps.getInt(\"org.eclipse.cdt.core.formatter.tabulation.size\");
        // String tabFormat = ps.getString(\"org.eclipse.cdt.core.formatter.tabulation.char\");
        // MessageDialog.openInformation(null, \"CDT Tab Width\", \"CDT tab width: \" + tabWidth + \" format: \" + tabFormat);
    }
}
现在,我要做的就是确保每个“编辑器”选项卡都记住它的“选项卡”设置,并在更改选项卡时自动切换回去。我从哪里开始... do!     

要回复问题请先登录注册