use of com.google.gerrit.client.change.LocalComments 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