Merge "Fix Reply 'Done' button"

This commit is contained in:
Shawn O. Pearce
2012-10-25 13:00:43 -07:00
committed by Gerrit Code Review

View File

@@ -105,6 +105,7 @@ public abstract class AbstractPatchContentTable extends NavigationTable<Object>
table.setStyleName(Gerrit.RESOURCES.css().patchContentTable()); table.setStyleName(Gerrit.RESOURCES.css().patchContentTable());
} }
@Override
public void notifyDraftDelta(final int delta) { public void notifyDraftDelta(final int delta) {
if (fileList != null) { if (fileList != null) {
fileList.notifyDraftDelta(patchKey, delta); fileList.notifyDraftDelta(patchKey, delta);
@@ -406,15 +407,17 @@ public abstract class AbstractPatchContentTable extends NavigationTable<Object>
newComment.setSide(side); newComment.setSide(side);
newComment.setMessage(""); newComment.setMessage("");
createCommentEditor(suggestRow, column, newComment).setFocus(true); findOrCreateCommentEditor(suggestRow, column, newComment, true)
.setFocus(true);
} }
} else { } else {
Gerrit.doSignIn(History.getToken()); Gerrit.doSignIn(History.getToken());
} }
} }
private CommentEditorPanel createCommentEditor(final int suggestRow, private CommentEditorPanel findOrCreateCommentEditor(final int suggestRow,
final int column, final PatchLineComment newComment) { final int column, final PatchLineComment newComment,
final boolean create) {
int row = suggestRow; int row = suggestRow;
int spans[] = new int[column + 1]; int spans[] = new int[column + 1];
FIND_ROW: while (row < table.getRowCount()) { 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; return null;
} }
@@ -819,22 +822,22 @@ public abstract class AbstractPatchContentTable extends NavigationTable<Object>
private void createReplyEditor() { private void createReplyEditor() {
final PatchLineComment newComment = newComment(); final PatchLineComment newComment = newComment();
newComment.setMessage(""); newComment.setMessage("");
createEditor(newComment).setFocus(true); findOrCreateEditor(newComment, true).setFocus(true);
} }
private void cannedReply(String message) { private void cannedReply(String message) {
final PatchLineComment newComment = newComment(); final PatchLineComment newComment = newComment();
newComment.setMessage(message); newComment.setMessage(message);
CommentEditorPanel p = createEditor(newComment); CommentEditorPanel p = findOrCreateEditor(newComment, false);
if (p == null) { if (p == null) {
enableButtons(false); enableButtons(false);
PatchUtil.DETAIL_SVC.saveDraft(newComment, PatchUtil.DETAIL_SVC.saveDraft(newComment,
new GerritCallback<PatchLineComment>() { new GerritCallback<PatchLineComment>() {
@Override
public void onSuccess(final PatchLineComment result) { public void onSuccess(final PatchLineComment result) {
enableButtons(true); enableButtons(true);
notifyDraftDelta(1); notifyDraftDelta(1);
createEditor(result).setOpen(false); findOrCreateEditor(result, true).setOpen(false);
} }
@Override @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 row = rowOf(getElement());
int column = columnOf(getElement()); int column = columnOf(getElement());
return createCommentEditor(row + 1, column, newComment); return findOrCreateCommentEditor(row + 1, column, newComment, create);
} }
private PatchLineComment newComment() { private PatchLineComment newComment() {