我是Eclipse PreferencePages
的新手,目前正在为我的项目创建一个新的FieldEditorPreferencePage
。但是,在我的自定义首选项页面中,使用FileFieldEditors()
或DirectoryFieldEditors()
灰色的“应用”和“确定”按钮。另一方面,另一个FieldEditors
(布尔型和组合型)不禁用“应用”和“确定”按钮。Eclipse PreferencePage“Apply”和“OK”灰显
此外,将所有内容更改为Xtext的LanguageRootPreferencePage似乎也可以工作(尽管我不想使用它,因为我希望自定义首选项页面显示在它自己的选项卡中)。
例如:
//Simplified example of code
public class XPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage, IWorkbenchPropertyPage {
public XPreferencePage() {
super(FieldEditorPreferencePage.GRID);
setDescription("something");
}
protected void initialize() {
super.initalize();
//IPropertyChangeListeners go here
}
protected void createFieldEditors() {
//"Apply" and "OK" works here
g = new BooleanFieldEditor(SConstants.GENERATOR, "Generate Bindings", getFieldEditorParent());
addField(g);
//"Apply" and "OK" is greyed-out starting here
gp = new FileFieldEditor(SConstants.GENERATOR_PATH, "Generator Path:", false, 0, getFieldEditorParent());
gp.setEmptyStringAllowed(true);
addField(gp);
...
}
...
}
反正是有解决这一问题?我遵循Eclipse Article-Field-Editors的教程,但它似乎不适用于我。在线阅读说,它可能是由于否定IntegerField
(我没有),或者我试图改变默认设置(我也没有)。
我正在使用Eclipse Mars 4.5.0。
更新:上面的代码(部分)适用于FileFieldEditors
。但是,由于某种原因,我需要点击FileFieldEditor
字段,然后在“应用”和“确定”按钮再次可用之前,在首选项页面中选中并取消选中FileFieldEditor
上方每个FileFieldEditor
正上方的复选框。
此外,我还实施了一个IPropertyChangeListener
,当某些复选框未选中时,它将停用某些字段,这意味着此“检查并取消选中”替代方法对我无效。我也尝试将默认焦点设置为我的其中一个复选框,但这不起作用
页面顶部是否显示一条消息? –
不是没有消息,虽然我在我的运行配置的控制台收到警告说“警告:没有设置环境变量HOME”。但我猜这不会影响“应用”和“确定”按钮。然而,我发现当我进入我的PreferencePage并尝试去另外一个时,它会显示“无法接受更改 - 当前显示的页面包含无效值”,这很奇怪,因为它不包含任何值。当我向filefieldeditor输入内容时,我也会得到同样的错误。 – Schlez
我的意思是当按钮变灰时,首选项页面顶部的消息。 FileFieldEditor似乎总是显示一条消息。 –