Revision: 9961
Author:   jlaba...@google.com
Date:     Thu Apr  7 10:52:25 2011
Log: Fixing issue 6206 (CellWidget#getValue() is never updated) and 6216 (CellWidget should implement IsEditor<C>).

Review at http://gwt-code-reviews.appspot.com/1400802/.

Issue: 6206, 6216
Patch by: tbroyer
Review by: jlabanca

http://code.google.com/p/google-web-toolkit/source/detail?r=9961

Modified:
 /trunk/user/src/com/google/gwt/user/cellview/CellView.gwt.xml
 /trunk/user/src/com/google/gwt/user/cellview/client/CellWidget.java
 /trunk/user/test/com/google/gwt/user/cellview/client/CellWidgetTest.java

=======================================
--- /trunk/user/src/com/google/gwt/user/cellview/CellView.gwt.xml Thu Apr 7 05:39:53 2011 +++ /trunk/user/src/com/google/gwt/user/cellview/CellView.gwt.xml Thu Apr 7 10:52:25 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"/>
=======================================
--- /trunk/user/src/com/google/gwt/user/cellview/client/CellWidget.java Thu Mar 24 07:36:36 2011 +++ /trunk/user/src/com/google/gwt/user/cellview/client/CellWidget.java Thu Apr 7 10:52:25 2011
@@ -21,6 +21,9 @@
 import com.google.gwt.dom.client.Document;
 import com.google.gwt.dom.client.Element;
 import com.google.gwt.dom.client.Style.Unit;
+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;
@@ -37,7 +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);
     }
   };

@@ -139,6 +149,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.
=======================================
--- /trunk/user/test/com/google/gwt/user/cellview/client/CellWidgetTest.java Thu Mar 24 07:36:36 2011 +++ /trunk/user/test/com/google/gwt/user/cellview/client/CellWidgetTest.java Thu Apr 7 10:52:25 2011
@@ -117,6 +117,7 @@
     cw.onBrowserEvent(event);
     cell.assertLastEventKey("test");
     cell.assertLastEventValue("test");
+    assertEquals("newValue", cw.getValue());
   }

   public void testOnBrowserEventWithKeyProvider() {
@@ -135,6 +136,7 @@
     cw.onBrowserEvent(event);
     cell.assertLastEventKey("t");
     cell.assertLastEventValue("test");
+    assertEquals("newValue", cw.getValue());
   }

   public void testOnBrowserEventWithValueChangeHandler() {
@@ -152,6 +154,7 @@
     cell.assertLastEventKey("test");
     cell.assertLastEventValue("test");
     handler.assertLastValue("newValue");
+    assertEquals("newValue", cw.getValue());
   }

   /**

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to