【发布时间】:2020-07-13 17:41:09
【问题描述】:
我正在尝试扩展 XText 为 DSL 生成的首选项页面。我设法添加了一个利用字段编辑器的新首选项页面,但我看不到如何获取IPreferenceStore 实例以跟踪http://www.vogella.com/articles/EclipsePreferences/article.html 中所述的修改配置
【问题讨论】:
我正在尝试扩展 XText 为 DSL 生成的首选项页面。我设法添加了一个利用字段编辑器的新首选项页面,但我看不到如何获取IPreferenceStore 实例以跟踪http://www.vogella.com/articles/EclipsePreferences/article.html 中所述的修改配置
【问题讨论】:
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);
}
}
【讨论】: