use of com.google.gerrit.client.blame.BlameInfo in project gerrit by GerritCodeReview.
the class PatchSetSelectBox method setUpBlame.
void setUpBlame(final CodeMirror cm, final boolean isBase, final PatchSet.Id rev, final String path) {
if (!Patch.isMagic(path) && Gerrit.isSignedIn() && Gerrit.info().change().allowBlame()) {
Anchor blameIcon = createBlameIcon();
blameIcon.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
if (cm.extras().getBlameInfo() != null) {
cm.extras().toggleAnnotation();
} else {
ChangeApi.blame(rev, path, isBase).get(new GerritCallback<JsArray<BlameInfo>>() {
@Override
public void onSuccess(JsArray<BlameInfo> lines) {
cm.extras().toggleAnnotation(lines);
}
});
}
}
});
linkPanel.add(blameIcon);
}
}
use of com.google.gerrit.client.blame.BlameInfo in project gerrit by GerritCodeReview.
the class Extras method setAnnotations.
public final void setAnnotations(JsArray<BlameInfo> blameInfos) {
if (blameInfos.length() > 0) {
setBlameInfo(blameInfos);
JsArrayString gutters = ((JsArrayString) JsArrayString.createArray());
gutters.push(ANNOTATION_GUTTER_ID);
cm.setOption("gutters", gutters);
annotated = true;
DateTimeFormat format = DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_SHORT);
JsArray<LintLine> annotations = JsArray.createArray().cast();
for (BlameInfo blameInfo : Natives.asList(blameInfos)) {
for (RangeInfo range : Natives.asList(blameInfo.ranges())) {
Date commitTime = new Date(blameInfo.time() * 1000L);
String shortId = blameInfo.id().substring(0, 8);
String shortBlame = C.shortBlameMsg(shortId, format.format(commitTime), blameInfo.author());
String detailedBlame = C.detailedBlameMsg(blameInfo.id(), blameInfo.author(), FormatUtil.mediumFormat(commitTime), blameInfo.commitMsg());
annotations.push(LintLine.create(shortBlame, detailedBlame, shortId, Pos.create(range.start() - 1)));
}
}
cm.setOption("lint", getAnnotation(annotations));
}
}
Aggregations