Search in sources :

Example 1 with PreferenceBasedDateFormatter

use of org.eclipse.egit.ui.internal.PreferenceBasedDateFormatter in project egit by eclipse.

the class BlameInformationControl method setInput.

@Override
public void setInput(Object input) {
    if (input == null) {
        // Make sure we don't hold a reference to this when nothing is
        // shown, it can be big
        this.revision = null;
        if (showAnnotationsLink != null) {
            // parent...)
            if (!showAnnotationsLink.isDisposed())
                showAnnotationsLink.removeSelectionListener(showAnnotationsLinkSelectionAdapter);
            showAnnotationsLink = null;
            showAnnotationsLinkSelectionAdapter = null;
        }
        return;
    }
    this.revision = (BlameRevision) input;
    // Used for showing the diff hunk of this line instead of the full diff.
    if (rulerInfo != null)
        revisionRulerLineNumber = rulerInfo.getLineOfLastMouseButtonActivity();
    RevCommit commit = this.revision.getCommit();
    String linkText = MessageFormat.format(UIText.BlameInformationControl_Commit, commit.abbreviate(7).name());
    commitLabel.setText(linkText);
    PreferenceBasedDateFormatter dateFormatter = PreferenceBasedDateFormatter.create();
    PersonIdent author = commit.getAuthorIdent();
    if (author != null) {
        setControlVisible(authorLabel, true);
        authorLabel.setText(MessageFormat.format(UIText.BlameInformationControl_Author, author.getName(), author.getEmailAddress(), dateFormatter.formatDate(author)));
    } else
        setControlVisible(authorLabel, false);
    PersonIdent committer = commit.getCommitterIdent();
    setControlVisible(authorLabel, author != null);
    if (committer != null && !committer.equals(author)) {
        setControlVisible(committerLabel, true);
        committerLabel.setText(MessageFormat.format(UIText.BlameInformationControl_Committer, committer.getName(), committer.getEmailAddress(), dateFormatter.formatDate(committer)));
    } else
        setControlVisible(committerLabel, false);
    messageText.setText(commit.getFullMessage());
    createDiffs();
    displayArea.layout();
    scrolls.setMinSize(displayArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
Also used : PersonIdent(org.eclipse.jgit.lib.PersonIdent) PreferenceBasedDateFormatter(org.eclipse.egit.ui.internal.PreferenceBasedDateFormatter) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Example 2 with PreferenceBasedDateFormatter

use of org.eclipse.egit.ui.internal.PreferenceBasedDateFormatter in project egit by eclipse.

the class RepositoryCommit method getStyledText.

/**
 * @param object
 * @return styled text
 */
@Override
public StyledString getStyledText(Object object) {
    StyledString styled = new StyledString();
    styled.append(abbreviate());
    // $NON-NLS-1$
    styled.append(": ");
    styled.append(commit.getShortMessage());
    PersonIdent author = commit.getAuthorIdent();
    PersonIdent committer = commit.getCommitterIdent();
    if (author != null && committer != null) {
        PreferenceBasedDateFormatter formatter = PreferenceBasedDateFormatter.create();
        if (author.getName().equals(committer.getName())) {
            styled.append(MessageFormat.format(UIText.RepositoryCommit_AuthorDate, author.getName(), formatter.formatDate(author)), StyledString.QUALIFIER_STYLER);
        } else {
            styled.append(MessageFormat.format(UIText.RepositoryCommit_AuthorDateCommitter, author.getName(), formatter.formatDate(author), committer.getName()), StyledString.QUALIFIER_STYLER);
        }
    }
    return styled;
}
Also used : PersonIdent(org.eclipse.jgit.lib.PersonIdent) StyledString(org.eclipse.jface.viewers.StyledString) PreferenceBasedDateFormatter(org.eclipse.egit.ui.internal.PreferenceBasedDateFormatter)

Example 3 with PreferenceBasedDateFormatter

use of org.eclipse.egit.ui.internal.PreferenceBasedDateFormatter in project egit by eclipse.

the class CommitEditorPage method setPerson.

private void setPerson(Text text, PersonIdent person, boolean isAuthor) {
    PreferenceBasedDateFormatter formatter = PreferenceBasedDateFormatter.create();
    boolean isRelative = formatter.getFormat() == GitDateFormatter.Format.RELATIVE;
    String textTemplate = null;
    if (isAuthor) {
        textTemplate = isRelative ? UIText.CommitEditorPage_LabelAuthorRelative : UIText.CommitEditorPage_LabelAuthor;
    } else {
        textTemplate = isRelative ? UIText.CommitEditorPage_LabelCommitterRelative : UIText.CommitEditorPage_LabelCommitter;
    }
    text.setText(MessageFormat.format(textTemplate, person.getName(), person.getEmailAddress(), formatter.formatDate(person)));
}
Also used : PreferenceBasedDateFormatter(org.eclipse.egit.ui.internal.PreferenceBasedDateFormatter)

Aggregations

PreferenceBasedDateFormatter (org.eclipse.egit.ui.internal.PreferenceBasedDateFormatter)3 PersonIdent (org.eclipse.jgit.lib.PersonIdent)2 StyledString (org.eclipse.jface.viewers.StyledString)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1