diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java index c7a9014191..7eb7822e8f 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java @@ -105,6 +105,7 @@ public abstract class AbstractPatchContentTable extends NavigationTable table.setStyleName(Gerrit.RESOURCES.css().patchContentTable()); } + @Override public void notifyDraftDelta(final int delta) { if (fileList != null) { fileList.notifyDraftDelta(patchKey, delta); @@ -406,15 +407,17 @@ public abstract class AbstractPatchContentTable extends NavigationTable newComment.setSide(side); newComment.setMessage(""); - createCommentEditor(suggestRow, column, newComment).setFocus(true); + findOrCreateCommentEditor(suggestRow, column, newComment, true) + .setFocus(true); } } else { Gerrit.doSignIn(History.getToken()); } } - private CommentEditorPanel createCommentEditor(final int suggestRow, - final int column, final PatchLineComment newComment) { + private CommentEditorPanel findOrCreateCommentEditor(final int suggestRow, + final int column, final PatchLineComment newComment, + final boolean create) { int row = suggestRow; int spans[] = new int[column + 1]; FIND_ROW: while (row < table.getRowCount()) { @@ -451,7 +454,7 @@ public abstract class AbstractPatchContentTable extends NavigationTable } } - if (newComment == null) { + if (newComment == null || !create) { return null; } @@ -819,22 +822,22 @@ public abstract class AbstractPatchContentTable extends NavigationTable private void createReplyEditor() { final PatchLineComment newComment = newComment(); newComment.setMessage(""); - createEditor(newComment).setFocus(true); + findOrCreateEditor(newComment, true).setFocus(true); } private void cannedReply(String message) { final PatchLineComment newComment = newComment(); newComment.setMessage(message); - CommentEditorPanel p = createEditor(newComment); + CommentEditorPanel p = findOrCreateEditor(newComment, false); if (p == null) { - enableButtons(false); PatchUtil.DETAIL_SVC.saveDraft(newComment, new GerritCallback() { + @Override public void onSuccess(final PatchLineComment result) { enableButtons(true); notifyDraftDelta(1); - createEditor(result).setOpen(false); + findOrCreateEditor(result, true).setOpen(false); } @Override @@ -851,10 +854,11 @@ public abstract class AbstractPatchContentTable extends NavigationTable } } - private CommentEditorPanel createEditor(final PatchLineComment newComment) { + private CommentEditorPanel findOrCreateEditor( + PatchLineComment newComment, boolean create) { int row = rowOf(getElement()); int column = columnOf(getElement()); - return createCommentEditor(row + 1, column, newComment); + return findOrCreateCommentEditor(row + 1, column, newComment, create); } private PatchLineComment newComment() {