Esempio n. 1
0
  private void revalidate() {

    if (currentRepoSelection != null && currentRepoSelection.equals(validatedRepoSelection)) {
      // nothing changed on previous page
      checkPage();
      return;
    }

    if (currentRepoSelection == null) return;

    specsPanel.clearRefSpecs();
    specsPanel.setEnable(false);
    saveButton.setVisible(false);
    saveButton.setSelection(false);
    validatedRepoSelection = null;
    transportError = null;
    getControl()
        .getDisplay()
        .asyncExec(
            new Runnable() {
              public void run() {
                revalidateImpl(currentRepoSelection);
              }
            });
  }
Esempio n. 2
0
  public void createControl(Composite parent) {
    final Composite panel = new Composite(parent, SWT.NULL);
    panel.setLayout(new GridLayout());

    specsPanel = new RefSpecPanel(panel, pushPage);
    specsPanel.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    specsPanel.addRefSpecTableListener(
        new SelectionChangeListener() {
          public void selectionChanged() {
            checkPage();
          }
        });

    if (!pushPage) {
      final Group tagsGroup = new Group(panel, SWT.NULL);
      tagsGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
      tagsGroup.setText(UIText.RefSpecPage_annotatedTagsGroup);
      tagsGroup.setLayout(new GridLayout());
      tagsAutoFollowButton = new Button(tagsGroup, SWT.RADIO);
      tagsAutoFollowButton.setText(UIText.RefSpecPage_annotatedTagsAutoFollow);
      tagsFetchTagsButton = new Button(tagsGroup, SWT.RADIO);
      tagsFetchTagsButton.setText(UIText.RefSpecPage_annotatedTagsFetchTags);
      tagsNoTagsButton = new Button(tagsGroup, SWT.RADIO);
      tagsNoTagsButton.setText(UIText.RefSpecPage_annotatedTagsNoTags);
    }

    saveButton = new Button(panel, SWT.CHECK);
    saveButton.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, false));

    Dialog.applyDialogFont(panel);
    setControl(panel);
    checkPage();
  }
Esempio n. 3
0
 private void checkPage() {
   if (transportError != null) {
     setErrorMessage(transportError);
     setPageComplete(false);
     return;
   }
   if (!specsPanel.isEmpty() && specsPanel.isValid() && !specsPanel.isMatchingAnyRefs()) {
     setErrorMessage(UIText.RefSpecPage_errorDontMatchSrc);
     setPageComplete(false);
     return;
   }
   setErrorMessage(specsPanel.getErrorMessage());
   setPageComplete(!specsPanel.isEmpty() && specsPanel.isValid());
 }
Esempio n. 4
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();
  }
Esempio n. 5
0
 /**
  * @return ref specifications as selected by user. Returned collection is a copy, so it may be
  *     modified by caller.
  */
 public List<RefSpec> getRefSpecs() {
   if (specsPanel == null) return Collections.emptyList();
   else return new ArrayList<RefSpec>(specsPanel.getRefSpecs());
 }