Revision: 9962
Author: [email protected]
Date: Thu Apr 7 16:16:56 2011
Log: Cherry picking r9961 into releases/2.3 for issues 6206 and 6216.
http://code.google.com/p/google-web-toolkit/source/detail?r=9962
Modified:
/releases/2.3/user/src/com/google/gwt/user/cellview/CellView.gwt.xml
/releases/2.3/user/src/com/google/gwt/user/cellview/client/CellWidget.java
/releases/2.3/user/test/com/google/gwt/user/cellview/client/CellWidgetTest.java
=======================================
--- /releases/2.3/user/src/com/google/gwt/user/cellview/CellView.gwt.xml
Thu Apr 7 07:38:23 2011
+++ /releases/2.3/user/src/com/google/gwt/user/cellview/CellView.gwt.xml
Thu Apr 7 16:16:56 2011
@@ -16,6 +16,7 @@
<module>
<inherits name="com.google.gwt.user.User"/>
<inherits name="com.google.gwt.cell.Cell"/>
+ <inherits name="com.google.gwt.editor.Editor"/>
<inherits name="com.google.gwt.view.View"/>
<inherits name="com.google.gwt.user.UserAgent"/>
<source path="client"/>
=======================================
---
/releases/2.3/user/src/com/google/gwt/user/cellview/client/CellWidget.java
Mon Dec 13 11:55:24 2010
+++
/releases/2.3/user/src/com/google/gwt/user/cellview/client/CellWidget.java
Thu Apr 7 16:16:56 2011
@@ -20,6 +20,10 @@
import com.google.gwt.cell.client.ValueUpdater;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
+
+import com.google.gwt.editor.client.IsEditor;
+import com.google.gwt.editor.client.LeafValueEditor;
+import com.google.gwt.editor.client.adapters.TakesValueEditor;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.HandlerRegistration;
@@ -36,8 +40,8 @@
*
* @param <C> the type that the Cell represents
*/
-public class CellWidget<C> extends Widget implements HasKeyProvider<C>,
- HasValue<C> {
+public class CellWidget<C> extends Widget implements HasKeyProvider<C>,
HasValue<C>,
+ IsEditor<LeafValueEditor<C>> {
/**
* Create the default element used to wrap the Cell. The default element
is a
@@ -56,6 +60,11 @@
*/
private final Cell<C> cell;
+ /**
+ * For use with the editor framework.
+ */
+ private LeafValueEditor<C> editor;
+
/**
* The key provider for the value.
*/
@@ -71,7 +80,8 @@
*/
private final ValueUpdater<C> valueUpdater = new ValueUpdater<C>() {
public void update(C value) {
- ValueChangeEvent.fire(CellWidget.this, value);
+ // no need to redraw, the Cell took care of it
+ setValue(value, true, false);
}
};
@@ -140,6 +150,13 @@
public HandlerRegistration addValueChangeHandler(ValueChangeHandler<C>
handler) {
return addHandler(handler, ValueChangeEvent.getType());
}
+
+ public LeafValueEditor<C> asEditor() {
+ if (editor == null) {
+ editor = TakesValueEditor.of(this);
+ }
+ return editor;
+ }
/**
* Get the {@link Cell} wrapped by this widget.
=======================================
---
/releases/2.3/user/test/com/google/gwt/user/cellview/client/CellWidgetTest.java
Mon Dec 13 11:55:24 2010
+++
/releases/2.3/user/test/com/google/gwt/user/cellview/client/CellWidgetTest.java
Thu Apr 7 16:16:56 2011
@@ -115,6 +115,7 @@
cw.onBrowserEvent(event);
cell.assertLastEventKey("test");
cell.assertLastEventValue("test");
+ assertEquals("newValue", cw.getValue());
}
public void testOnBrowserEventWithKeyProvider() {
@@ -134,6 +135,7 @@
cw.onBrowserEvent(event);
cell.assertLastEventKey("t");
cell.assertLastEventValue("test");
+ assertEquals("newValue", cw.getValue());
}
public void testOnBrowserEventWithValueChangeHandler() {
@@ -151,6 +153,7 @@
cell.assertLastEventKey("test");
cell.assertLastEventValue("test");
handler.assertLastValue("newValue");
+ assertEquals("newValue", cw.getValue());
}
public void testRedraw() {
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors