コード例 #1
0
  @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;
  }
  /** {@inheritDoc} */
  @Override
  public void propertyChange(PropertyChangeEvent event) {
    super.propertyChange(event);
    isDirty = true;
    setAutoDownloadEnabled(fieldEnableAutoDownload.getBooleanValue());

    // We need to do this check, when some property change, to refresh the valid state
    fieldDownloadPath.isValid();
  }
コード例 #5
0
  @Override
  protected void createFieldEditors() {

    versionsEditor =
        new ComboFieldEditor(
            GRADLE_VERSION_ID, "Gradle Version", AVAILABLE_VERSIONS, getFieldEditorParent());
    gradleHomeField = new DirectoryFieldEditor(GRADLE_HOME_ID, "Home", getFieldEditorParent());
    gradleHomeField.setErrorMessage("Yoy must specify a valid gradle installation");
    gradleHomeField.setEmptyStringAllowed(!shouldUseGradleHome);

    addField(versionsEditor);
    addField(gradleHomeField);
    addField(
        new StringFieldEditor(GRADLE_PLUGIN_VERSION_ID, "Plugin Version", getFieldEditorParent()));
    addField(
        new ComboFieldEditor(GRADLE_LOG_LEVEL_ID, "Log level", LOG_LEVELS, getFieldEditorParent()));
    addField(
        new BooleanFieldEditor(
            GRADLE_PRINT_STACKTRACES_ID, "Print stacktraces", getFieldEditorParent()));
  }
コード例 #6
0
  @Override
  public void propertyChange(PropertyChangeEvent event) {
    super.propertyChange(event);

    if (event.getSource() != versionsEditor) {
      checkState();
      return;
    }

    shouldUseGradleHome =
        event.getNewValue().equals(GradlePluginConstants.USE_GRADLE_HOME_VERSION_VALUE);
    gradleHomeField.setEmptyStringAllowed(!shouldUseGradleHome);
    checkState();
  }
コード例 #7
0
 @Override
 public void setValidateStrategy(int value) {
   super.setValidateStrategy(VALIDATE_ON_KEY_STROKE);
 }
コード例 #8
0
  @Override
  protected void createFieldEditors() {
    Composite main = getFieldEditorParent();
    GridLayoutFactory.swtDefaults().margins(0, 0).applyTo(main);

    Group cloningGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
    cloningGroup.setText(UIText.GitPreferenceRoot_CloningRepoGroupHeader);
    GridDataFactory.fillDefaults().grab(true, false).span(GROUP_SPAN, 1).applyTo(cloningGroup);
    DirectoryFieldEditor editor =
        new DirectoryFieldEditor(
            UIPreferences.DEFAULT_REPO_DIR,
            UIText.GitPreferenceRoot_DefaultRepoFolderLabel,
            cloningGroup) {

          /** The own control is the variableButton */
          private static final int NUMBER_OF_OWN_CONTROLS = 1;

          @Override
          protected boolean doCheckState() {
            String fileName = getTextControl().getText();
            fileName = fileName.trim();
            if (fileName.length() == 0 && isEmptyStringAllowed()) return true;

            IStringVariableManager manager =
                VariablesPlugin.getDefault().getStringVariableManager();
            String substitutedFileName;
            try {
              substitutedFileName = manager.performStringSubstitution(fileName);
            } catch (CoreException e) {
              // It's apparently invalid
              return false;
            }

            File file = new File(substitutedFileName);
            // other than the super implementation, we don't
            // require the file to exist
            return !file.exists() || file.isDirectory();
          }

          @Override
          public int getNumberOfControls() {
            return super.getNumberOfControls() + NUMBER_OF_OWN_CONTROLS;
          }

          @Override
          protected void doFillIntoGrid(Composite parent, int numColumns) {
            super.doFillIntoGrid(parent, numColumns - NUMBER_OF_OWN_CONTROLS);
          }

          @Override
          protected void adjustForNumColumns(int numColumns) {
            super.adjustForNumColumns(numColumns - NUMBER_OF_OWN_CONTROLS);
          }

          @Override
          protected void createControl(Composite parent) {
            // setting validate strategy using the setter method is too late
            super.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);

            super.createControl(parent);

            if (HAS_DEBUG_UI) addVariablesButton(parent);
          }

          private void addVariablesButton(Composite parent) {
            Button variableButton = new Button(parent, SWT.PUSH);
            variableButton.setText(UIText.GitPreferenceRoot_DefaultRepoFolderVariableButton);

            variableButton.addSelectionListener(
                new SelectionAdapter() {
                  public void widgetSelected(SelectionEvent e) {
                    org.eclipse.debug.ui.StringVariableSelectionDialog dialog =
                        new org.eclipse.debug.ui.StringVariableSelectionDialog(getShell());
                    int returnCode = dialog.open();
                    if (returnCode == Window.OK) setStringValue(dialog.getVariableExpression());
                  }
                });
          }
        };
    updateMargins(cloningGroup);
    editor.setEmptyStringAllowed(false);
    editor
        .getLabelControl(cloningGroup)
        .setToolTipText(UIText.GitPreferenceRoot_DefaultRepoFolderTooltip);
    addField(editor);

    Group remoteConnectionsGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
    GridDataFactory.fillDefaults()
        .grab(true, false)
        .span(GROUP_SPAN, 1)
        .applyTo(remoteConnectionsGroup);
    remoteConnectionsGroup.setText(UIText.GitPreferenceRoot_RemoteConnectionsGroupHeader);

    IntegerFieldEditor timeoutEditor =
        new IntegerFieldEditor(
            UIPreferences.REMOTE_CONNECTION_TIMEOUT,
            UIText.RemoteConnectionPreferencePage_TimeoutLabel,
            remoteConnectionsGroup);
    timeoutEditor
        .getLabelControl(remoteConnectionsGroup)
        .setToolTipText(UIText.RemoteConnectionPreferencePage_ZeroValueTooltip);
    addField(timeoutEditor);
    updateMargins(remoteConnectionsGroup);

    Group repoChangeScannerGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
    GridDataFactory.fillDefaults()
        .grab(true, false)
        .span(GROUP_SPAN, 1)
        .applyTo(repoChangeScannerGroup);
    repoChangeScannerGroup.setText(UIText.GitPreferenceRoot_RepoChangeScannerGroupHeader);
    addField(
        new BooleanFieldEditor(
            UIPreferences.REFESH_ON_INDEX_CHANGE,
            UIText.RefreshPreferencesPage_RefreshWhenIndexChange,
            repoChangeScannerGroup));
    addField(
        new BooleanFieldEditor(
            UIPreferences.REFESH_ONLY_WHEN_ACTIVE,
            UIText.RefreshPreferencesPage_RefreshOnlyWhenActive,
            repoChangeScannerGroup));
    updateMargins(repoChangeScannerGroup);

    Group mergeGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
    GridDataFactory.fillDefaults().grab(true, false).span(GROUP_SPAN, 1).applyTo(mergeGroup);
    mergeGroup.setText(UIText.GitPreferenceRoot_MergeGroupHeader);
    ComboFieldEditor mergeMode =
        new ComboFieldEditor(
            UIPreferences.MERGE_MODE,
            UIText.GitPreferenceRoot_MergeModeLabel,
            MERGE_MODE_NAMES_AND_VALUES,
            mergeGroup);
    mergeMode.getLabelControl(mergeGroup).setToolTipText(UIText.GitPreferenceRoot_MergeModeTooltip);
    addField(mergeMode);
    updateMargins(mergeGroup);

    Group blameGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
    GridDataFactory.fillDefaults().grab(true, false).span(GROUP_SPAN, 1).applyTo(blameGroup);
    blameGroup.setText(UIText.GitPreferenceRoot_BlameGroupHeader);
    addField(
        new BooleanFieldEditor(
            UIPreferences.BLAME_IGNORE_WHITESPACE,
            UIText.GitPreferenceRoot_BlameIgnoreWhitespaceLabel,
            blameGroup));
    updateMargins(blameGroup);

    Group secureGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
    GridDataFactory.fillDefaults().grab(true, false).span(GROUP_SPAN, 1).applyTo(secureGroup);
    secureGroup.setText(UIText.GitPreferenceRoot_SecureStoreGroupLabel);
    addField(
        new BooleanFieldEditor(
            UIPreferences.CLONE_WIZARD_STORE_SECURESTORE,
            UIText.GitPreferenceRoot_SecureStoreUseByDefault,
            secureGroup));
    updateMargins(secureGroup);
  }
 private void setAutoDownloadEnabled(boolean enabled) {
   Composite parent = getFieldEditorParent();
   fieldEnableAutoDelete.setEnabled(enabled, parent);
   fieldDownloadPath.setEnabled(enabled, parent);
 }