use of org.eclipse.jgit.lib.PersonIdent in project egit by eclipse.
the class CommitEditorPage method createUserArea.
private Composite createUserArea(Composite parent, FormToolkit toolkit, PersonIdent person, boolean author) {
Composite userArea = toolkit.createComposite(parent);
GridLayoutFactory.fillDefaults().spacing(2, 2).numColumns(3).applyTo(userArea);
Label userLabel = toolkit.createLabel(userArea, null);
userLabel.setImage(getImage(author ? UIIcons.ELCL16_AUTHOR : UIIcons.ELCL16_COMMITTER));
if (author)
userLabel.setToolTipText(UIText.CommitEditorPage_TooltipAuthor);
else
userLabel.setToolTipText(UIText.CommitEditorPage_TooltipCommitter);
boolean signedOff = isSignedOffBy(person);
final Text userText = new Text(userArea, SWT.FLAT | SWT.READ_ONLY);
addToFocusTracking(userText);
setPerson(userText, person, author);
toolkit.adapt(userText, false, false);
userText.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);
IPropertyChangeListener uiPrefsListener = (event) -> {
String property = event.getProperty();
if (UIPreferences.DATE_FORMAT.equals(property) || UIPreferences.DATE_FORMAT_CHOICE.equals(property)) {
setPerson(userText, person, author);
userArea.layout();
}
};
Activator.getDefault().getPreferenceStore().addPropertyChangeListener(uiPrefsListener);
userText.addDisposeListener((e) -> {
Activator.getDefault().getPreferenceStore().removePropertyChangeListener(uiPrefsListener);
});
GridDataFactory.fillDefaults().span(signedOff ? 1 : 2, 1).applyTo(userText);
if (signedOff) {
Label signedOffLabel = toolkit.createLabel(userArea, null);
signedOffLabel.setImage(getImage(UIIcons.SIGNED_OFF));
if (author)
signedOffLabel.setToolTipText(UIText.CommitEditorPage_TooltipSignedOffByAuthor);
else
signedOffLabel.setToolTipText(UIText.CommitEditorPage_TooltipSignedOffByCommitter);
}
return userArea;
}
use of org.eclipse.jgit.lib.PersonIdent in project egit by eclipse.
the class CommitHelper method getHeadCommitInfo.
/**
* @param repository
* @return info related to the HEAD commit
*/
public static CommitInfo getHeadCommitInfo(Repository repository) {
RevCommit headCommit = getHeadCommit(repository);
if (headCommit == null)
return null;
String commitMessage = headCommit.getFullMessage().replaceAll("\n", // $NON-NLS-1$
Text.DELIMITER);
PersonIdent authorIdent = headCommit.getAuthorIdent();
String author = authorIdent.getName() + " <" + authorIdent.getEmailAddress() + // $NON-NLS-1$ //$NON-NLS-2$
">";
PersonIdent committerIdent = headCommit.getCommitterIdent();
String committer = committerIdent.getName() + " <" + committerIdent.getEmailAddress() + // $NON-NLS-1$ //$NON-NLS-2$
">";
return new CommitInfo(headCommit, author, committer, commitMessage);
}
use of org.eclipse.jgit.lib.PersonIdent 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));
}
use of org.eclipse.jgit.lib.PersonIdent 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;
}
use of org.eclipse.jgit.lib.PersonIdent in project egit by eclipse.
the class CreateTagHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
List<RepositoryCommit> commits = getCommits(event);
if (commits.size() == 1) {
RepositoryCommit commit = commits.get(0);
Repository repository = commit.getRepository();
CreateTagDialog dialog = new CreateTagDialog(HandlerUtil.getActiveShellChecked(event), commit.getRevCommit().getId(), repository);
if (dialog.open() != Window.OK)
return null;
final TagBuilder tag = new TagBuilder();
PersonIdent personIdent = new PersonIdent(repository);
String tagName = dialog.getTagName();
tag.setTag(tagName);
tag.setTagger(personIdent);
tag.setMessage(dialog.getTagMessage());
tag.setObjectId(commit.getRevCommit());
try {
new TagOperation(repository, tag, dialog.shouldOverWriteTag()).execute(new NullProgressMonitor());
} catch (CoreException e) {
throw new ExecutionException(e.getMessage(), e);
}
if (dialog.shouldStartPushWizard())
PushTagsWizard.openWizardDialog(repository, tagName);
}
return null;
}
Aggregations