gpt4 book ai didi

java - 自己的偏好页面 : Enable and disable FieldEditor by BooleanFieldEditor

转载 作者:行者123 更新时间:2023-12-01 22:35:38 26 4
gpt4 key购买 nike

我正在为 RCP 应用程序创建我自己的 Eclipse PreferencePage。有一个 FileFieldEditor,我想通过 BooleanFieldEditor 启用和禁用它。

现在我不知道如何实现这个。

public class PreferencePage extends FieldEditorPreferencePage implements
IWorkbenchPreferencePage {

FileFieldEditor subversionPathEditor;
BooleanFieldEditor subversionSupportBooleanFieldEditor;

public PreferencePage() {
super(GRID);
setPreferenceStore(Activator.getDefault().getPreferenceStore());
setDescription(""); //$NON-NLS-1$
}


protected void createFieldEditors() {
subversionSupportBooleanFieldEditor = new BooleanFieldEditor
("subversionSupport", "Enable Subversion support", BooleanFieldEditor.DEFAULT, getFieldEditorParent());
System.out.println(subversionSupportBooleanFieldEditor.getPreferenceName());

subversionSupportBooleanFieldEditor.setPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if ("field_editor_value".equalsIgnoreCase(event.getProperty())) {
Boolean enabled = (Boolean)event.getNewValue();
subversionPathEditor.setEnabled(enabled, getFieldEditorParent());
}

}
});
addField(subversionSupportBooleanFieldEditor);
subversionPathEditor = new FileFieldEditor("SubversionPathEditor", "Subversion client executable: ", true,
FileFieldEditor.VALIDATE_ON_KEY_STROKE, getFieldEditorParent());
subversionPathEditor.setStringValue(VCSSettings.getSubversionPath());
addField(subversionPathEditor);

有什么想法可以在哪里放置代码来启用和禁用 FileFieldEditor?我知道如何启用/禁用,但是在哪个方法中放置代码?

已经在 createFieldEditors()、checkState()、updateFieldEditors() 和 createControl() 中尝试过。

最佳答案

您可以覆盖

@Override
public void propertyChange(PropertyChangeEvent event)
{
... extra here

super.propertyChange(event);
}

FieldEditorPreferencePage 的方法来获取属性更改事件(对于所有字段)。

关于java - 自己的偏好页面 : Enable and disable FieldEditor by BooleanFieldEditor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26909856/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com