Esempio n. 1
0
  private void setSourceCommit(RevCommit commit) {
    sourceNameLabel.setText(commit.abbreviate(7).name());
    sourceIcon.setImage(UIIcons.getImage(resourceManager, UIIcons.CHANGESET));

    sourceRefName = commit.name();

    upstreamConfig = UpstreamConfig.NONE;
    checkPage();
  }
Esempio n. 2
0
  private void createHeaderArea(Composite parent, FormToolkit toolkit, int span) {
    RevCommit commit = getCommit().getRevCommit();
    Composite top = toolkit.createComposite(parent);
    GridDataFactory.fillDefaults().grab(true, false).span(span, 1).applyTo(top);
    GridLayoutFactory.fillDefaults().numColumns(2).applyTo(top);

    Composite userArea = toolkit.createComposite(top);
    GridLayoutFactory.fillDefaults().spacing(2, 2).numColumns(1).applyTo(userArea);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(userArea);

    PersonIdent author = commit.getAuthorIdent();
    if (author != null) createUserArea(userArea, toolkit, author, true);

    PersonIdent committer = commit.getCommitterIdent();
    if (committer != null && !committer.equals(author))
      createUserArea(userArea, toolkit, committer, false);

    int count = commit.getParentCount();
    if (count > 0) {
      Composite parents = toolkit.createComposite(top);
      GridLayoutFactory.fillDefaults().spacing(2, 2).numColumns(2).applyTo(parents);
      GridDataFactory.fillDefaults().grab(false, false).applyTo(parents);

      for (int i = 0; i < count; i++) {
        final RevCommit parentCommit = commit.getParent(i);
        toolkit
            .createLabel(parents, UIText.CommitEditorPage_LabelParent)
            .setForeground(toolkit.getColors().getColor(IFormColors.TB_TOGGLE));
        final Hyperlink link =
            toolkit.createHyperlink(
                parents, parentCommit.abbreviate(PARENT_LENGTH).name(), SWT.NONE);
        link.addHyperlinkListener(
            new HyperlinkAdapter() {

              public void linkActivated(HyperlinkEvent e) {
                try {
                  CommitEditor.open(
                      new RepositoryCommit(getCommit().getRepository(), parentCommit));
                  if ((e.getStateMask() & SWT.MOD1) != 0) getEditor().close(false);
                } catch (PartInitException e1) {
                  Activator.logError("Error opening commit editor", e1); // $NON-NLS-1$
                }
              }
            });
      }
    }

    createTagsArea(userArea, toolkit, 2);
  }