Reviewers: ,
Description:
ValueListBox should implement HasEnabled, functionality can easily be
delegated to the internal ListBox.
http://code.google.com/p/google-web-toolkit/issues/detail?id=6112
Please review this at http://gwt-code-reviews.appspot.com/1832803/
Affected files:
user/src/com/google/gwt/user/client/ui/ValueListBox.java
user/test/com/google/gwt/user/client/ui/ValueListBoxTest.java
Index: user/src/com/google/gwt/user/client/ui/ValueListBox.java
===================================================================
--- user/src/com/google/gwt/user/client/ui/ValueListBox.java (revision
11270)
+++ user/src/com/google/gwt/user/client/ui/ValueListBox.java (working copy)
@@ -42,7 +42,7 @@
* @param <T> the value type
*/
public class ValueListBox<T> extends Composite implements
- HasConstrainedValue<T>, IsEditor<TakesValueEditor<T>> {
+ HasConstrainedValue<T>, HasEnabled, IsEditor<TakesValueEditor<T>> {
private final List<T> values = new ArrayList<T>();
private final Map<Object, Integer> valueKeyToIndex = new HashMap<Object,
Integer>();
@@ -92,6 +92,11 @@
return value;
}
+ @Override
+ public boolean isEnabled() {
+ return getListBox().isEnabled();
+ }
+
public void setAcceptableValues(Collection<T> newValues) {
values.clear();
valueKeyToIndex.clear();
@@ -105,6 +110,11 @@
updateListBox();
}
+ @Override
+ public void setEnabled(boolean enabled) {
+ getListBox().setEnabled(enabled);
+ }
+
/**
* Set the value and display it in the select element. Add the value to
the
* acceptable set if it is not already there.
Index: user/test/com/google/gwt/user/client/ui/ValueListBoxTest.java
===================================================================
--- user/test/com/google/gwt/user/client/ui/ValueListBoxTest.java (revision
11270)
+++ user/test/com/google/gwt/user/client/ui/ValueListBoxTest.java (working
copy)
@@ -77,6 +77,18 @@
assertEquals(3, getSelect().getLength());
}
+ public void testEnabled() {
+ subject.setEnabled(true);
+
+ // Make sure it worked
+ assertEquals(true, subject.isEnabled());
+
+ subject.setEnabled(false);
+
+ // Make sure it worked
+ assertEquals(false, subject.isEnabled());
+ }
+
public void testNakedSet() {
assertNull(subject.getValue());
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors