【问题标题】:how to get the PreferenceStore in XText generated plugin如何在 XText 生成的插件中获取 PreferenceStore
【发布时间】:2020-07-13 17:41:09
【问题描述】:

我正在尝试扩展 XText 为 DSL 生成的首选项页面。我设法添加了一个利用字段编辑器的新首选项页面,但我看不到如何获取IPreferenceStore 实例以跟踪http://www.vogella.com/articles/EclipsePreferences/article.html 中所述的修改配置

【问题讨论】:

    标签: eclipse xtext emf


    【解决方案1】:

    IPreferenceStore可以注入(见documentation):

            <page
                category="org.xtext.example.mydsl.MyDsl"
                class="org.xtext.example.mydsl.ui.MyDslExecutableExtensionFactory:org.xtext.example.mydsl.ui.MyPage"
                id="org.xtext.example.mydsl.MyDsl.coloring"
                name="MyPage">
                <keywordReference id="org.xtext.example.mydsl.ui.keyword_MyDsl"/>
            </page>
    

    例如

    public class MyPage extends FieldEditorPreferencePage {
        @Inject
        public MyPage (IPreferenceStore preferenceStore) {
            setPreferenceStore(preferenceStore);
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-15
      相关资源
      最近更新 更多