Add Cancel button to Register New Email dialog

Bug: issue 574
Change-Id: Ib9fbdee5d6de0da7905d5d132644e1ad97817652
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.java
index 1abfbc8..24439c7 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.java
@@ -90,6 +90,7 @@
   String contactFieldFax();
   String buttonOpenRegisterNewEmail();
   String buttonSendRegisterNewEmail();
+  String buttonCancel();
   String titleRegisterNewEmail();
   String descRegisterNewEmail();
 
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.properties b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.properties
index a22abe9..09ae95a 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.properties
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.properties
@@ -77,6 +77,7 @@
 contactFieldFax = Fax Number
 buttonOpenRegisterNewEmail = Register New Email ...
 buttonSendRegisterNewEmail = Register
+buttonCancel = Cancel
 titleRegisterNewEmail = Register Email Address
 descRegisterNewEmail = \
   <p>A confirmation link will be sent by email to this address.</p>\
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/ContactPanelShort.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/ContactPanelShort.java
index aa7e3d1..923a86a 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/ContactPanelShort.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/ContactPanelShort.java
@@ -254,6 +254,7 @@
     inEmail.setVisibleLength(60);
 
     final Button register = new Button(Util.C.buttonSendRegisterNewEmail());
+    final Button cancel = new Button(Util.C.buttonCancel());
     final FormPanel form = new FormPanel();
     form.addSubmitHandler(new FormPanel.SubmitHandler() {
       @Override
@@ -288,9 +289,21 @@
         form.submit();
       }
     });
+    cancel.addClickHandler(new ClickHandler() {
+      @Override
+      public void onClick(ClickEvent event) {
+        box.hide();
+      }
+    });
+
+    final FlowPanel buttons = new FlowPanel();
+    buttons.setStyleName(Gerrit.RESOURCES.css().patchSetActions());
+    buttons.add(register);
+    buttons.add(cancel);
+
     body.add(new HTML(Util.C.descRegisterNewEmail()));
     body.add(inEmail);
-    body.add(register);
+    body.add(buttons);
 
     box.setText(Util.C.titleRegisterNewEmail());
     box.setWidget(form);