Merge "Disable form while publishing comments"

This commit is contained in:
Shawn Pearce
2011-04-07 19:00:45 -07:00
committed by Android Code Review
2 changed files with 21 additions and 1 deletions

View File

@@ -120,6 +120,19 @@ public class PublishCommentScreen extends AccountScreen implements
buttonRow.add(cancel);
}
private void enableForm(final boolean enabled) {
for (final ValueRadioButton approvalButton : approvalButtons) {
approvalButton.setEnabled(enabled);
}
message.setEnabled(enabled);
for (final CommentEditorPanel commentEditor : commentEditors) {
commentEditor.enableButtons(enabled);
}
send.setEnabled(enabled);
submit.setEnabled(enabled);
cancel.setEnabled(enabled);
}
@Override
protected void onLoad() {
super.onLoad();
@@ -326,6 +339,7 @@ public class PublishCommentScreen extends AccountScreen implements
}
}
enableForm(false);
PatchUtil.DETAIL_SVC.publishComments(patchSetId, message.getText().trim(),
new HashSet<ApprovalCategoryValue.Id>(values.values()),
new GerritCallback<VoidResult>() {
@@ -337,6 +351,12 @@ public class PublishCommentScreen extends AccountScreen implements
goChange();
}
}
@Override
public void onFailure(Throwable caught) {
super.onFailure(caught);
enableForm(true);
}
});
}

View File

@@ -195,7 +195,7 @@ public class CommentPanel extends Composite implements HasDoubleClickHandlers,
handlerManager.fireEvent(event);
}
protected void enableButtons(final boolean on) {
public void enableButtons(final boolean on) {
for (Widget w : getButtonPanel()) {
if (w instanceof Button) {
((Button) w).setEnabled(on);