Fixed checkstyle errors.
Patch by: jlabanca
Review by: rjrjr
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@5351 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/ui/CheckBox.java b/user/src/com/google/gwt/user/client/ui/CheckBox.java
index d29f8c6..92419cd 100644
--- a/user/src/com/google/gwt/user/client/ui/CheckBox.java
+++ b/user/src/com/google/gwt/user/client/ui/CheckBox.java
@@ -119,17 +119,6 @@
return addHandler(handler, ValueChangeEvent.getType());
}
- protected void ensureDomEventHandlers() {
- addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent event) {
- // Checkboxes always toggle their value, no need to compare
- // with old value. Radio buttons are not so lucky, see
- // overrides in RadioButton
- ValueChangeEvent.fire(CheckBox.this, getValue());
- }
- });
- }
-
/**
* Returns the value property of the input element that backs this widget.
* This is the value that will be associated with the CheckBox name and
@@ -328,6 +317,17 @@
}
}
+ protected void ensureDomEventHandlers() {
+ addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ // Checkboxes always toggle their value, no need to compare
+ // with old value. Radio buttons are not so lucky, see
+ // overrides in RadioButton
+ ValueChangeEvent.fire(CheckBox.this, getValue());
+ }
+ });
+ }
+
/**
* <b>Affected Elements:</b>
* <ul>
diff --git a/user/src/com/google/gwt/user/client/ui/RadioButton.java b/user/src/com/google/gwt/user/client/ui/RadioButton.java
index a0dedc1..a298bd6 100644
--- a/user/src/com/google/gwt/user/client/ui/RadioButton.java
+++ b/user/src/com/google/gwt/user/client/ui/RadioButton.java
@@ -18,7 +18,6 @@
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.EventTarget;
import com.google.gwt.event.dom.client.BlurEvent;
-import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.dom.client.MouseUpEvent;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
@@ -70,65 +69,6 @@
}
/**
- * Overridden to send ValueChangeEvents only when appropriate.
- */
- @Override
- public void onBrowserEvent(Event event) {
- switch (DOM.eventGetType(event)) {
- case Event.ONMOUSEUP:
- case Event.ONBLUR:
- case Event.ONKEYDOWN:
- // Note the old value for onValueChange purposes (in ONCLICK case)
- oldValue = getValue();
- break;
-
- case Event.ONCLICK:
- EventTarget target = event.getEventTarget();
- if (Element.is(target) && labelElem.isOrHasChild(Element.as(target))) {
-
- // They clicked the label. Note our pre-click value, and
- // short circuit event routing so that other click handlers
- // don't hear about it
- oldValue = getValue();
- return;
- }
-
- // It's not the label. Let our handlers hear about the
- // click...
- super.onBrowserEvent(event);
- // ...and now maybe tell them about the change
- ValueChangeEvent.fireIfNotEqual(RadioButton.this, oldValue, getValue());
- return;
- }
-
- super.onBrowserEvent(event);
- }
-
- @Override
- public void sinkEvents(int eventBitsToAdd) {
- // Like CheckBox, we want to hear about inputElem. We
- // also want to know what's going on with the label, to
- // make sure onBrowserEvent is able to record value changes
- // initiated by label events
- if (isOrWasAttached()) {
- Event.sinkEvents(inputElem, eventBitsToAdd
- | Event.getEventsSunk(inputElem));
- Event.sinkEvents(labelElem, eventBitsToAdd
- | Event.getEventsSunk(labelElem));
- } else {
- super.sinkEvents(eventBitsToAdd);
- }
- }
-
- /**
- * No-op. CheckBox's click handler is no good for radio button, so don't use
- * it. Our event handling is all done in {@link #onBrowserEvent}
- */
- @Override
- protected void ensureDomEventHandlers() {
- }
-
- /**
* Creates a new radio associated with a particular group, and initialized
* with the given HTML label. All radio buttons associated with the same group
* name belong to a mutually-exclusive set.
@@ -167,6 +107,41 @@
}
/**
+ * Overridden to send ValueChangeEvents only when appropriate.
+ */
+ @Override
+ public void onBrowserEvent(Event event) {
+ switch (DOM.eventGetType(event)) {
+ case Event.ONMOUSEUP:
+ case Event.ONBLUR:
+ case Event.ONKEYDOWN:
+ // Note the old value for onValueChange purposes (in ONCLICK case)
+ oldValue = getValue();
+ break;
+
+ case Event.ONCLICK:
+ EventTarget target = event.getEventTarget();
+ if (Element.is(target) && labelElem.isOrHasChild(Element.as(target))) {
+
+ // They clicked the label. Note our pre-click value, and
+ // short circuit event routing so that other click handlers
+ // don't hear about it
+ oldValue = getValue();
+ return;
+ }
+
+ // It's not the label. Let our handlers hear about the
+ // click...
+ super.onBrowserEvent(event);
+ // ...and now maybe tell them about the change
+ ValueChangeEvent.fireIfNotEqual(RadioButton.this, oldValue, getValue());
+ return;
+ }
+
+ super.onBrowserEvent(event);
+ }
+
+ /**
* Change the group name of this radio button.
*
* Radio buttons are grouped by their name attribute, so changing their name
@@ -185,4 +160,28 @@
// not to propagate name when it propagates everything else
super.replaceInputElement(DOM.createInputRadio(name));
}
+
+ @Override
+ public void sinkEvents(int eventBitsToAdd) {
+ // Like CheckBox, we want to hear about inputElem. We
+ // also want to know what's going on with the label, to
+ // make sure onBrowserEvent is able to record value changes
+ // initiated by label events
+ if (isOrWasAttached()) {
+ Event.sinkEvents(inputElem, eventBitsToAdd
+ | Event.getEventsSunk(inputElem));
+ Event.sinkEvents(labelElem, eventBitsToAdd
+ | Event.getEventsSunk(labelElem));
+ } else {
+ super.sinkEvents(eventBitsToAdd);
+ }
+ }
+
+ /**
+ * No-op. CheckBox's click handler is no good for radio button, so don't use
+ * it. Our event handling is all done in {@link #onBrowserEvent}
+ */
+ @Override
+ protected void ensureDomEventHandlers() {
+ }
}
diff --git a/user/test/com/google/gwt/user/client/ui/CheckBoxTest.java b/user/test/com/google/gwt/user/client/ui/CheckBoxTest.java
index 94cceec..6f4e8e5 100644
--- a/user/test/com/google/gwt/user/client/ui/CheckBoxTest.java
+++ b/user/test/com/google/gwt/user/client/ui/CheckBoxTest.java
@@ -45,7 +45,6 @@
public void onClick(Widget sender) {
++fired;
}
-
}
private static class Handler implements ValueChangeHandler<Boolean> {