@Override
 protected void checkState() {
   super.checkState();
   if (!isValid()) {
     return;
   }
 }
 /**
  * The field editor preference page implementation of a <code>PreferencePage</code> method loads
  * all the field editors with their default values.
  */
 @Override
 protected void performDefaults() {
   if (fields != null) {
     Iterator<FieldEditor> e = fields.iterator();
     while (e.hasNext()) {
       FieldEditor pe = e.next();
       pe.loadDefault();
     }
   }
   // Force a recalculation of my error state.
   checkState();
   super.performDefaults();
 }
  @Override
  protected void checkState() {
    super.checkState();
    File gradleHome = new File(gradleHomeField.getStringValue());
    // should I perform validations here?
    if (!GradlePluginUtils.isFileValidGradleInstallation(gradleHome) && shouldUseGradleHome) {
      setValid(false);
      setErrorMessage(gradleHomeField.getErrorMessage());
      return;
    }

    setErrorMessage(null);
    setValid(true);
  }
  /**
   * The field editor preference page implementation of this <code>IPreferencePage</code> (and
   * <code>IPropertyChangeListener</code>) method intercepts <code>IS_VALID</code> events but passes
   * other events on to its superclass.
   */
  public void propertyChange(PropertyChangeEvent event) {

    if (event.getProperty().equals(FieldEditor.IS_VALID)) {
      boolean newValue = ((Boolean) event.getNewValue()).booleanValue();
      // If the new value is true then we must check all field editors.
      // If it is false, then the page is invalid in any case.
      if (newValue) {
        checkState();
      } else {
        invalidFieldEditor = (FieldEditor) event.getSource();
        setValid(newValue);
      }
    }
  }
  /* (non-Javadoc)
   * Method declared on PreferencePage.
   */
  @Override
  protected Control createContents(Composite parent) {
    fieldEditorParent = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    fieldEditorParent.setLayout(layout);
    fieldEditorParent.setFont(parent.getFont());

    createFieldEditors();

    if (style == GRID) {
      adjustGridLayout();
    }

    initialize();
    checkState();
    return fieldEditorParent;
  }