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


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@9961 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/cellview/CellView.gwt.xml b/user/src/com/google/gwt/user/cellview/CellView.gwt.xml
index 4cb8426..5108725 100644
--- a/user/src/com/google/gwt/user/cellview/CellView.gwt.xml
+++ b/user/src/com/google/gwt/user/cellview/CellView.gwt.xml
@@ -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"/>
diff --git a/user/src/com/google/gwt/user/cellview/client/CellWidget.java b/user/src/com/google/gwt/user/cellview/client/CellWidget.java
index 2a1ab4d..00996df 100644
--- a/user/src/com/google/gwt/user/cellview/client/CellWidget.java
+++ b/user/src/com/google/gwt/user/cellview/client/CellWidget.java
@@ -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
@@ -57,6 +61,11 @@
   private final Cell<C> cell;
 
   /**
+   * For use with the editor framework.
+   */
+  private LeafValueEditor<C> editor;
+
+  /**
    * The key provider for the value.
    */
   private final ProvidesKey<C> keyProvider;
@@ -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 @@
     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.
    * 
diff --git a/user/test/com/google/gwt/user/cellview/client/CellWidgetTest.java b/user/test/com/google/gwt/user/cellview/client/CellWidgetTest.java
index 8a848e6..5b400f8 100644
--- a/user/test/com/google/gwt/user/cellview/client/CellWidgetTest.java
+++ b/user/test/com/google/gwt/user/cellview/client/CellWidgetTest.java
@@ -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());
   }
 
   /**