Fix Reply 'Done' button

This was recently broken by the improvements to avoid creating
unnecessary editor boxes on a line of code. When the user clicks
Reply 'Done' they want the draft comment recorded immediately,
without needing to click Save.

Change-Id: I47b59f323bfae7504385ac079a0641057e5378c1
This commit is contained in:
Shawn O. Pearce
2012-10-25 12:50:24 -07:00
parent 7f9a985500
commit dd0b17dcbb

View File

@@ -105,6 +105,7 @@ public abstract class AbstractPatchContentTable extends NavigationTable<Object>
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<Object>
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<Object>
}
}
if (newComment == null) {
if (newComment == null || !create) {
return null;
}
@@ -819,22 +822,22 @@ public abstract class AbstractPatchContentTable extends NavigationTable<Object>
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<PatchLineComment>() {
@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<Object>
}
}
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() {