Ejemplo n.º 1
0
  private void revalidateImpl(final RepositorySelection newRepoSelection) {
    final ListRemoteOperation listRemotesOp;
    try {
      final URIish uri;
      uri = newRepoSelection.getURI(pushPage);
      int timeout =
          Activator.getDefault()
              .getPreferenceStore()
              .getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);
      listRemotesOp = new ListRemoteOperation(local, uri, timeout);
      if (credentials != null)
        listRemotesOp.setCredentialsProvider(
            new UsernamePasswordCredentialsProvider(
                credentials.getUser(), credentials.getPassword()));
      getContainer()
          .run(
              true,
              true,
              new IRunnableWithProgress() {
                public void run(IProgressMonitor monitor)
                    throws InvocationTargetException, InterruptedException {
                  listRemotesOp.run(monitor);
                }
              });
    } catch (InvocationTargetException e) {
      final Throwable cause = e.getCause();
      transportError(cause.getMessage());
      ErrorDialog.openError(
          getShell(),
          UIText.RefSpecPage_errorTransportDialogTitle,
          UIText.RefSpecPage_errorTransportDialogMessage,
          new Status(IStatus.ERROR, Activator.getPluginId(), 0, cause.getMessage(), cause));
      return;
    } catch (InterruptedException e) {
      transportError(UIText.RefSpecPage_operationCancelled);
      return;
    }

    this.validatedRepoSelection = newRepoSelection;

    specsPanel.setAssistanceData(
        local, listRemotesOp.getRemoteRefs(), currentRepoSelection.getConfig());

    if (newRepoSelection.isConfigSelected()) {
      saveButton.setVisible(true);
      saveButton.setText(
          NLS.bind(UIText.RefSpecPage_saveSpecifications, currentRepoSelection.getConfigName()));
      saveButton.getParent().layout();

      if (!pushPage) {
        tagsAutoFollowButton.setSelection(false);
        tagsFetchTagsButton.setSelection(false);
        tagsNoTagsButton.setSelection(false);

        final TagOpt tagOpt = newRepoSelection.getConfig().getTagOpt();
        switch (tagOpt) {
          case AUTO_FOLLOW:
            tagsAutoFollowButton.setSelection(true);
            break;
          case FETCH_TAGS:
            tagsFetchTagsButton.setSelection(true);
            break;
          case NO_TAGS:
            tagsNoTagsButton.setSelection(true);
            break;
        }
      }
    } else if (!pushPage) tagsAutoFollowButton.setSelection(true);

    checkPage();
  }