use of com.google.gerrit.client.changes.CommentInfo in project gerrit by GerritCodeReview.
the class ChangeScreen method filterForRevision.
private static NativeMap<JsArray<CommentInfo>> filterForRevision(NativeMap<JsArray<CommentInfo>> comments, int id) {
NativeMap<JsArray<CommentInfo>> filtered = NativeMap.create();
for (String k : comments.keySet()) {
JsArray<CommentInfo> allRevisions = comments.get(k);
JsArray<CommentInfo> thisRevision = JsArray.createArray().cast();
for (int i = 0; i < allRevisions.length(); i++) {
CommentInfo c = allRevisions.get(i);
if (c.patchSet() == id) {
thisRevision.push(c);
}
}
filtered.put(k, thisRevision);
}
return filtered;
}
use of com.google.gerrit.client.changes.CommentInfo in project gerrit by GerritCodeReview.
the class DraftBox method save.
void save(CallbackGroup group) {
if (pendingGroup != null) {
pendingGroup.addListener(group);
return;
}
String message = editArea.getValue().trim();
if (message.length() == 0) {
return;
}
CommentInfo input = CommentInfo.copy(comment);
input.message(message);
enableEdit(false);
pendingGroup = group;
final LocalComments lc = new LocalComments(psId);
GerritCallback<CommentInfo> cb = new GerritCallback<CommentInfo>() {
@Override
public void onSuccess(CommentInfo result) {
enableEdit(true);
pendingGroup = null;
set(result);
setEdit(false);
if (autoClosed) {
setOpen(false);
}
getCommentManager().setUnsaved(DraftBox.this, false);
}
@Override
public void onFailure(Throwable e) {
enableEdit(true);
pendingGroup = null;
if (RestApi.isNotSignedIn(e)) {
CommentInfo saved = CommentInfo.copy(comment);
saved.message(editArea.getValue().trim());
lc.setInlineComment(saved);
}
super.onFailure(e);
}
};
if (input.id() == null) {
CommentApi.createDraft(psId, input, group.add(cb));
} else {
CommentApi.updateDraft(psId, input.id(), input, group.add(cb));
}
CodeMirror cm = getCm();
cm.vim().handleKey("<Esc>");
cm.focus();
}
Aggregations