I'm creating my own PreferencePage for Eclipse for a RCP application. There is a FileFieldEditor which I want to be enabled and disabled by an BooleanFieldEditor.
Now I can't figure out how to implement this.
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);
Any ideas where to place the code to enable and disable the FileFieldEditor? I know how to enable/disable but in which method has the code to be placed?
Already tried in createFieldEditors(), checkState(), updateFieldEditors() and createControl().
You can override the
@Override
public void propertyChange(PropertyChangeEvent event)
{
... extra here
super.propertyChange(event);
}
method of FieldEditorPreferencePage
to get the property change events (for all the fields).