@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);
  }
 @Override
 public void performApply() {
   try {
     fMDInstallRootDirEditor.store();
     IPath mdInstallRoot = new Path(fMDInstallRootDirEditor.getStringValue());
     JavaCore.setClasspathVariable(
         MDVariableInitializer.MD_CLASSPATH_VARIABLE, mdInstallRoot, new NullProgressMonitor());
     IPreferenceStore store = this.getPreferenceStore();
     ((IPersistentPreferenceStore) store).save();
     hasApplied = true;
   } catch (IOException e) {
     Activator.log(IStatus.ERROR, "MDPreferencePage (save)", e);
   } catch (JavaModelException e) {
     Activator.log(IStatus.ERROR, "MDPreferencePage (save)", e);
   }
 }
  /** {@inheritDoc} */
  @Override
  public boolean performOk() {

    if (isDirty) {
      // Activator.setSystemVariables();
      boolean isAutoDelete = false;
      String downloadPath = null;
      boolean isAutoDownload = fieldEnableAutoDownload.getBooleanValue();

      if (isAutoDownload) {
        isAutoDelete = fieldEnableAutoDelete.getBooleanValue();
        downloadPath = fieldDownloadPath.getStringValue();
      }

      if (isAutoDownload && ((downloadPath == null) || (downloadPath.length() == 0))) {
        String message =
            "'Download Path' is empty. This will set the download path to default path "
                + new Path(System.getProperty("user.home") + "/" + DEFAULT_DOWNLOAD_DIRECTORY)
                    .toOSString();
        boolean response =
            MessageDialog.openConfirm(
                getFieldEditorParent().getShell(), "Confirm default path", message);

        // Return
        if (!response) {
          return false;
        }
        downloadPath =
            new Path(System.getProperty("user.home") + "/" + DEFAULT_DOWNLOAD_DIRECTORY)
                .toOSString();
        fieldDownloadPath.setStringValue(downloadPath);

        // Check if download directory exists. If not, create it.
        File directory = new File(downloadPath);
        if (!directory.exists()) {
          directory.mkdirs();
        }
      }
      updateBackendService(fieldEnableAutoDownload.getBooleanValue(), isAutoDelete, downloadPath);
    }

    // We need to do this check, when some property change, to refresh the valid state
    fieldDownloadPath.isValid();

    boolean perform = super.performOk();
    return perform;
  }