]> source.dussan.org Git - vaadin-framework.git/commitdiff
Refactored client Renderers once again #13334
authorJohn Ahlroos <john@vaadin.com>
Fri, 23 May 2014 11:24:47 +0000 (14:24 +0300)
committerVaadin Code Review <review@vaadin.com>
Mon, 26 May 2014 12:36:39 +0000 (12:36 +0000)
The following things are refactored in this changeset:
 * Cell interface removed
 * CellInfo -> Cell
 * Renderer interface becomes a single method interface
 * All other methods moved from Renderer to new ComplexRenderer interface

Change-Id: I567868b8dc73783988bce6c11bc23e12d5479172

14 files changed:
client/src/com/vaadin/client/ui/grid/Cell.java
client/src/com/vaadin/client/ui/grid/CellInfo.java [deleted file]
client/src/com/vaadin/client/ui/grid/EscalatorUpdater.java
client/src/com/vaadin/client/ui/grid/FlyweightCell.java
client/src/com/vaadin/client/ui/grid/FlyweightRow.java
client/src/com/vaadin/client/ui/grid/Grid.java
client/src/com/vaadin/client/ui/grid/Renderer.java
client/src/com/vaadin/client/ui/grid/renderers/AbstractRenderer.java [deleted file]
client/src/com/vaadin/client/ui/grid/renderers/ComplexRenderer.java [new file with mode: 0644]
client/src/com/vaadin/client/ui/grid/renderers/DateRenderer.java
client/src/com/vaadin/client/ui/grid/renderers/HtmlRenderer.java
client/src/com/vaadin/client/ui/grid/renderers/NumberRenderer.java
client/src/com/vaadin/client/ui/grid/renderers/TextRenderer.java
uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java

index c4e1471da4630380896f6d99812d64930966b371..33495ebf875f0971c5df7de2832ef89001f3b337 100644 (file)
  * License for the specific language governing permissions and limitations under
  * the License.
  */
-
 package com.vaadin.client.ui.grid;
 
 import com.google.gwt.dom.client.Element;
-import com.google.gwt.user.client.ui.HasOneWidget;
 
 /**
- * A representation of a single cell.
- * <p>
- * A Cell instance will be provided to the {@link EscalatorUpdater} responsible
- * for rendering the cells in a certain {@link RowContainer}.
+ * Describes a cell
+ * 
+ * TODO The description is still very vague since the content and naming of this
+ * class is still under debate and the API is not final. Improve the description
+ * when API has been finalized.
  * 
- * @since 7.4
  * @author Vaadin Ltd
  */
-public interface Cell extends HasOneWidget {
+public class Cell {
+
+    private final int row;
+
+    private final int column;
+
+    private final Element element;
 
     /**
-     * Gets the index of the row this cell is in.
+     * Constructs a new {@link Cell}
      * 
-     * @return the index of the row this cell is in
+     * @param row
+     *            The index of the row
+     * @param column
+     *            The index of the column
+     * @param element
+     *            The cell element
      */
-    public int getRow();
+    public Cell(int row, int column, Element element) {
+        super();
+        this.row = row;
+        this.column = column;
+        this.element = element;
+    }
 
     /**
-     * Gets the index of the column this cell is in.
+     * Returns the index of the row the cell resides on
+     * 
+     * @return the row index
      * 
-     * @return the index of the column this cell is in
      */
-    public int getColumn();
+    public int getRow() {
+        return row;
+    }
 
     /**
-     * Gets the root element for this cell. The {@link EscalatorUpdater} may
-     * update the class names of the element, add inline styles and freely
-     * modify the contents.
-     * <p>
-     * Avoid modifying the dimensions, positioning or colspan of the cell
-     * element.
+     * Returns the index of the column the cell resides on
      * 
-     * @return The root element for this cell. Never <code>null</code>.
+     * @return the column index
      */
-    public Element getElement();
+    public int getColumn() {
+        return column;
+    }
 
     /**
-     * Sets the column span of the cell.
-     * <p>
-     * This will overwrite any possible "colspan" attribute in the current
-     * element (i.e. the object returned by {@link #getElement()}). This will
-     * also handle internal bookkeeping, skip the rendering of any affected
-     * adjacent cells, and make sure that the current cell's dimensions are
-     * handled correctly.
+     * Returns the element of the cell
      * 
-     * @param numberOfCells
-     *            the number of cells to span to the right, or <code>1</code> to
-     *            unset any column spans
-     * @throws IllegalArgumentException
-     *             if <code>numberOfCells &lt; 1</code>
+     * @return the element
      */
-    public void setColSpan(int numberOfCells) throws IllegalArgumentException;
-}
\ No newline at end of file
+    public Element getElement() {
+        return element;
+    }
+
+}
diff --git a/client/src/com/vaadin/client/ui/grid/CellInfo.java b/client/src/com/vaadin/client/ui/grid/CellInfo.java
deleted file mode 100644 (file)
index 2f3dae8..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.client.ui.grid;
-
-import com.google.gwt.dom.client.Element;
-
-/**
- * Describes a cell
- * 
- * TODO The description is still very vague since the content and naming of this
- * class is still under debate and the API is not final. Improve the description
- * when API has been finalized.
- * 
- * @author Vaadin Ltd
- */
-public class CellInfo {
-
-    private final int row;
-
-    private final int column;
-
-    private final Element element;
-
-    /**
-     * Constructs a new {@link CellInfo}
-     * 
-     * @param row
-     *            The index of the row
-     * @param column
-     *            The index of the column
-     * @param element
-     *            The cell element
-     */
-    public CellInfo(int row, int column, Element element) {
-        super();
-        this.row = row;
-        this.column = column;
-        this.element = element;
-    }
-
-    /**
-     * Returns the index of the row the cell resides on
-     * 
-     * @return the row index
-     * 
-     */
-    public int getRow() {
-        return row;
-    }
-
-    /**
-     * Returns the index of the column the cell resides on
-     * 
-     * @return the column index
-     */
-    public int getColumn() {
-        return column;
-    }
-
-    /**
-     * Returns the element of the cell
-     * 
-     * @return the element
-     */
-    public Element getElement() {
-        return element;
-    }
-
-}
index c856d5f0270888d4bfa31aaa0cd182b7e9decba5..c6fe90850ac2a9e56112dc3f101f7608b2694103 100644 (file)
@@ -36,7 +36,7 @@ public interface EscalatorUpdater {
     public static final EscalatorUpdater NULL = new EscalatorUpdater() {
         @Override
         public void updateCells(final Row row,
-                final Iterable<Cell> cellsToUpdate) {
+                final Iterable<FlyweightCell> cellsToUpdate) {
             // NOOP
         }
     };
@@ -61,5 +61,5 @@ public interface EscalatorUpdater {
      *            You should neither store nor reuse the reference to the list,
      *            nor to the individual cells
      */
-    public void updateCells(Row row, Iterable<Cell> cellsToUpdate);
+    public void updateCells(Row row, Iterable<FlyweightCell> cellsToUpdate);
 }
index 16ee265611c503b6e52bc21426df483d296c8445..950b3e167aede1d7acb540173f3746e7e9128553 100644 (file)
@@ -25,18 +25,19 @@ import com.google.gwt.user.client.ui.Widget;
 import com.vaadin.client.ui.grid.FlyweightRow.CellIterator;
 
 /**
- * An internal implementation of the {@link Cell} interface.
+ * A {@link FlyweightCell} represents a cell in the {@link Grid} or
+ * {@link Escalator} at a certain point in time.
+ * 
  * <p>
- * These instances are populated into a {@link FlyweightRow} instance, and
- * intended to be reused when rendering cells in an escalator.
+ * Since the {@link FlyweightCell} follows the <code>Flyweight</code>-pattern
+ * any instance of this object is subject to change without the user knowing it
+ * and so should not be stored anywhere outside of the method providing these
+ * instances.
  * 
  * @since 7.4
  * @author Vaadin Ltd
- * @see FlyweightRow#getCells()
- * @see FlyweightRow#addCells(int, int)
- * @see FlyweightRow#removeCells(int, int)
  */
-class FlyweightCell implements Cell {
+public class FlyweightCell {
     static final String COLSPAN_ATTR = "colSpan";
 
     private final int column;
@@ -53,19 +54,26 @@ class FlyweightCell implements Cell {
         this.escalator = escalator;
     }
 
-    @Override
+    /**
+     * Returns the row index of the cell
+     */
     public int getRow() {
         assertSetup();
         return row.getRow();
     }
 
-    @Override
+    /**
+     * Returns the column index of the cell
+     */
     public int getColumn() {
         assertSetup();
         return column;
     }
 
-    @Override
+    /**
+     * Returns the element of the cell. Can be either a <code>TD</code> element
+     * or a <code>TH</code> element.
+     */
     public Element getElement() {
         return (Element) row.getElement().getChild(column);
     }
@@ -109,7 +117,6 @@ class FlyweightCell implements Cell {
                 + "inappropriately.";
     }
 
-    @Override
     public void setColSpan(final int numberOfCells) {
         /*-
          * This will default to 1 if unset, as per DOM specifications:
@@ -157,12 +164,18 @@ class FlyweightCell implements Cell {
         }
     }
 
-    @Override
+    /**
+     * @deprecated Will be removed in further refactorings
+     */
+    @Deprecated
     public Widget getWidget() {
         return Escalator.getWidgetFromCell(getElement());
     }
 
-    @Override
+    /**
+     * @deprecated Will be removed in further refactorings
+     */
+    @Deprecated
     public void setWidget(Widget widget) {
 
         Widget oldWidget = getWidget();
@@ -197,7 +210,10 @@ class FlyweightCell implements Cell {
         }
     }
 
-    @Override
+    /**
+     * @deprecated Will be removed in further refactorings
+     */
+    @Deprecated
     public void setWidget(IsWidget w) {
         setWidget(Widget.asWidgetOrNull(w));
     }
index 8bb9a543215a8eaf24e129736301da9ec955d97e..3505b317d1230dc9c60a0e265ca6e680c7b7e654 100644 (file)
@@ -35,7 +35,7 @@ import com.google.gwt.dom.client.Node;
  */
 class FlyweightRow implements Row {
 
-    static class CellIterator implements Iterator<Cell> {
+    static class CellIterator implements Iterator<FlyweightCell> {
         /** A defensive copy of the cells in the current row. */
         private final ArrayList<FlyweightCell> cells;
         private int cursor = 0;
@@ -188,11 +188,11 @@ class FlyweightRow implements Row {
      * @see #setup(Element, int, int[])
      * @see #teardown()
      */
-    Iterable<Cell> getCells() {
+    Iterable<FlyweightCell> getCells() {
         assertSetup();
-        return new Iterable<Cell>() {
+        return new Iterable<FlyweightCell>() {
             @Override
-            public Iterator<Cell> iterator() {
+            public Iterator<FlyweightCell> iterator() {
                 return new CellIterator(cells);
             }
         };
index b81fc3c67315890670f4d0abc06fcc0b1a2c9506..d1e299ba5ac29ee5dcfc1b44cac3c83bc6005cd5 100644 (file)
@@ -510,7 +510,7 @@ public class Grid<T> extends Composite {
         public abstract Renderer<String> getGroupRenderer(ColumnGroup<T> group);
 
         @Override
-        public void updateCells(Row row, Iterable<Cell> cellsToUpdate) {
+        public void updateCells(Row row, Iterable<FlyweightCell> cellsToUpdate) {
 
             int rowIndex;
             if (inverted) {
@@ -521,7 +521,7 @@ public class Grid<T> extends Composite {
 
             if (firstRowIsVisible() && rowIndex == 0) {
                 // column headers
-                for (Cell cell : cellsToUpdate) {
+                for (FlyweightCell cell : cellsToUpdate) {
                     GridColumn<?, T> column = getColumnFromVisibleIndex(cell
                             .getColumn());
                     if (column != null) {
@@ -551,7 +551,7 @@ public class Grid<T> extends Composite {
 
                 assert groupRow != null;
 
-                for (Cell cell : cellsToUpdate) {
+                for (FlyweightCell cell : cellsToUpdate) {
                     GridColumn<?, T> column = getColumnFromVisibleIndex(cell
                             .getColumn());
                     ColumnGroup<T> group = getGroupForColumn(groupRow, column);
@@ -653,7 +653,8 @@ public class Grid<T> extends Composite {
         return new EscalatorUpdater() {
 
             @Override
-            public void updateCells(Row row, Iterable<Cell> cellsToUpdate) {
+            public void updateCells(Row row,
+                    Iterable<FlyweightCell> cellsToUpdate) {
                 int rowIndex = row.getRow();
                 if (dataSource == null) {
                     setCellsLoading(cellsToUpdate);
@@ -666,7 +667,7 @@ public class Grid<T> extends Composite {
                     return;
                 }
 
-                for (Cell cell : cellsToUpdate) {
+                for (FlyweightCell cell : cellsToUpdate) {
                     GridColumn column = getColumnFromVisibleIndex(cell
                             .getColumn());
                     if (column != null) {
@@ -676,8 +677,8 @@ public class Grid<T> extends Composite {
                 }
             }
 
-            private void setCellsLoading(Iterable<Cell> cellsToUpdate) {
-                for (Cell cell : cellsToUpdate) {
+            private void setCellsLoading(Iterable<FlyweightCell> cellsToUpdate) {
+                for (FlyweightCell cell : cellsToUpdate) {
                     cell.getElement().setInnerText("...");
                 }
             }
index b96b89b7309fc0e31892e532e5940401ef04f28b..e312a9da20f8c6aa52eebc7a8a93ec3b225bab41 100644 (file)
@@ -15,9 +15,6 @@
  */
 package com.vaadin.client.ui.grid;
 
-import java.util.Collection;
-
-import com.google.gwt.dom.client.NativeEvent;
 
 /**
  * Renderer for rending a value &lt;T&gt; into cell.
@@ -34,44 +31,6 @@ import com.google.gwt.dom.client.NativeEvent;
  */
 public interface Renderer<T> {
 
-    /**
-     * Called at initialization stage. Perform any initialization here e.g.
-     * attach handlers, attach widgets etc.
-     * 
-     * @param cell
-     *            The cell. Note that the cell is a flyweight and should not be
-     *            stored outside of the method as it will change.
-     */
-    void init(Cell cell);
-
-    /**
-     * Returns the events that the renderer should consume. These are also the
-     * events that the Grid will pass to
-     * {@link #onBrowserEvent(CellInfo, NativeEvent)} when they occur.
-     * <code>null</code> if no events are consumed
-     * 
-     * @return the consumed events, or null if no events are consumed
-     * 
-     * @see com.google.gwt.dom.client.BrowserEvents
-     */
-    Collection<String> getConsumedEvents();
-
-    /**
-     * Called whenever a registered event is triggered in the column the
-     * renderer renders.
-     * <p>
-     * The events that triggers this needs to be returned by the
-     * {@link #getConsumedEvents()} method.
-     * 
-     * @param cellInfo
-     *            Object containing information about the cell the event was
-     *            triggered on.
-     * 
-     * @param event
-     *            The original DOM event
-     */
-    void onBrowserEvent(CellInfo cell, NativeEvent event);
-
     /**
      * Called whenever the {@link Grid} updates a cell
      * 
@@ -82,14 +41,5 @@ public interface Renderer<T> {
      * @param data
      *            The column data object
      */
-    void render(Cell cell, T data);
-
-    /**
-     * Called when the cell is "activated" by pressing <code>enter</code> or
-     * double clicking
-     * 
-     * @return <code>true</code> if event was handled and should not be
-     *         interpreted as a generic gesture by Grid.
-     */
-    boolean onActivate();
+    void render(FlyweightCell cell, T data);
 }
diff --git a/client/src/com/vaadin/client/ui/grid/renderers/AbstractRenderer.java b/client/src/com/vaadin/client/ui/grid/renderers/AbstractRenderer.java
deleted file mode 100644 (file)
index 91f3b27..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.client.ui.grid.renderers;
-
-import java.util.Collection;
-
-import com.google.gwt.dom.client.NativeEvent;
-import com.vaadin.client.ui.grid.Cell;
-import com.vaadin.client.ui.grid.CellInfo;
-import com.vaadin.client.ui.grid.Renderer;
-
-/**
- * Abstract base class for renderers.
- * 
- * @author Vaadin Ltd
- */
-public abstract class AbstractRenderer<T> implements Renderer<T> {
-
-    @Override
-    public void init(Cell cell) {
-        // Implement if needed
-    }
-
-    @Override
-    public Collection<String> getConsumedEvents() {
-        return null;
-    }
-
-    @Override
-    public void onBrowserEvent(CellInfo cell, NativeEvent event) {
-        // Implement if needed
-    }
-
-    @Override
-    public boolean onActivate() {
-        return false;
-    }
-}
diff --git a/client/src/com/vaadin/client/ui/grid/renderers/ComplexRenderer.java b/client/src/com/vaadin/client/ui/grid/renderers/ComplexRenderer.java
new file mode 100644 (file)
index 0000000..cf3e43c
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.client.ui.grid.renderers;
+
+import java.util.Collection;
+
+import com.google.gwt.dom.client.NativeEvent;
+import com.vaadin.client.ui.grid.Cell;
+import com.vaadin.client.ui.grid.FlyweightCell;
+import com.vaadin.client.ui.grid.Renderer;
+
+/**
+ * Base class for renderers that needs initialization and destruction logic
+ * (override {@link #init(FlyweightCell) and #destroy(FlyweightCell) } and event
+ * handling (see {@link #onBrowserEvent(Cell, NativeEvent)},
+ * {@link #getConsumedEvents()} and {@link #onActivate()}.
+ * 
+ * <p>
+ * Also provides a helper method for hiding the cell contents by overriding
+ * {@link #setContentVisible(FlyweightCell, boolean)}
+ * 
+ * @since 7.4
+ * @author Vaadin Ltd
+ */
+public abstract class ComplexRenderer<T> implements Renderer<T> {
+
+    /**
+     * Called at initialization stage. Perform any initialization here e.g.
+     * attach handlers, attach widgets etc.
+     * 
+     * @param cell
+     *            The cell. Note that the cell is not to be stored outside of
+     *            the method as the cell install will change. See
+     *            {@link FlyweightCell}
+     */
+    public void init(FlyweightCell cell) {
+        // Implement if needed
+    }
+
+    /**
+     * Called after the cell is deemed to be destroyed and no longer used by the
+     * Grid. Called after the cell element is detached from the DOM.
+     * 
+     * @param cell
+     *            The cell. Note that the cell is not to be stored outside of
+     *            the method as the cell install will change. See
+     *            {@link FlyweightCell}
+     */
+    public void destroy(FlyweightCell cell) {
+        // Implement if needed
+    }
+
+    /**
+     * Returns the events that the renderer should consume. These are also the
+     * events that the Grid will pass to
+     * {@link #onBrowserEvent(Cell, NativeEvent)} when they occur.
+     * <code>null</code> if no events are consumed
+     * 
+     * @return the consumed events, or null if no events are consumed
+     * 
+     * @see com.google.gwt.dom.client.BrowserEvents
+     */
+    public Collection<String> getConsumedEvents() {
+        return null;
+    }
+
+    /**
+     * Called whenever a registered event is triggered in the column the
+     * renderer renders.
+     * <p>
+     * The events that triggers this needs to be returned by the
+     * {@link #getConsumedEvents()} method.
+     * 
+     * @param cell
+     *            Object containing information about the cell the event was
+     *            triggered on.
+     * 
+     * @param event
+     *            The original DOM event
+     */
+    public void onBrowserEvent(Cell cell, NativeEvent event) {
+        // Implement if needed
+    }
+
+    /**
+     * Hides content by setting visibility: hidden to all elements inside the
+     * cell. Text nodes are left as is for now - renderers that add such to the
+     * root element need to implement explicit support hiding them
+     * 
+     * @param cell
+     *            The cell
+     * @param visible
+     *            Is the cell content be visible
+     * @return <code>true</code> if the content should be set visible
+     */
+    public boolean setContentVisible(FlyweightCell cell, boolean visible) {
+        return false;
+    }
+
+    /**
+     * Called when the cell is "activated" by pressing <code>enter</code>,
+     * double clicking or performing a double tap on the cell.
+     * 
+     * @return <code>true</code> if event was handled and should not be
+     *         interpreted as a generic gesture by Grid.
+     */
+    public boolean onActivate() {
+        return false;
+    }
+}
index 59f56eafc44def28d2273e004880b89b0ebe6951..d52e97c62c5f37cfcb03fb97d946180f657132c7 100644 (file)
@@ -19,7 +19,8 @@ import java.util.Date;
 
 import com.google.gwt.i18n.client.DateTimeFormat;
 import com.google.gwt.i18n.client.TimeZone;
-import com.vaadin.client.ui.grid.Cell;
+import com.vaadin.client.ui.grid.FlyweightCell;
+import com.vaadin.client.ui.grid.Renderer;
 
 /**
  * A renderer for rendering dates into cells
@@ -27,7 +28,7 @@ import com.vaadin.client.ui.grid.Cell;
  * @since 7.4
  * @author Vaadin Ltd
  */
-public class DateRenderer extends AbstractRenderer<Date> {
+public class DateRenderer implements Renderer<Date> {
 
     private DateTimeFormat format = DateTimeFormat.getShortDateTimeFormat();
 
@@ -35,7 +36,7 @@ public class DateRenderer extends AbstractRenderer<Date> {
             .getTimezoneOffset());
 
     @Override
-    public void render(Cell cell, Date date) {
+    public void render(FlyweightCell cell, Date date) {
         String dateStr = format.format(date, timeZone);
         cell.getElement().setInnerText(dateStr);
     }
index 0c33f46cd88b64aed6645bcda1c85bf6d0ca8d8b..6cb9603d3cf3c4f0315cecf46c63e5f40c8a5d6b 100644 (file)
@@ -17,7 +17,8 @@ package com.vaadin.client.ui.grid.renderers;
 
 import com.google.gwt.safehtml.shared.SafeHtml;
 import com.google.gwt.safehtml.shared.SafeHtmlUtils;
-import com.vaadin.client.ui.grid.Cell;
+import com.vaadin.client.ui.grid.FlyweightCell;
+import com.vaadin.client.ui.grid.Renderer;
 
 /**
  * Renders a string as HTML into a cell.
@@ -31,10 +32,10 @@ import com.vaadin.client.ui.grid.Cell;
  * @author Vaadin Ltd
  * @see SafeHtmlUtils#fromSafeConstant(String)
  */
-public class HtmlRenderer extends AbstractRenderer<String> {
+public class HtmlRenderer implements Renderer<String> {
 
     @Override
-    public void render(Cell cell, String htmlString) {
+    public void render(FlyweightCell cell, String htmlString) {
         cell.getElement().setInnerSafeHtml(
                 SafeHtmlUtils.fromSafeConstant(htmlString));
     }
index a21f0d776af146a05d8152aae7997df024084342..b1bf7083a5625da52cd08a69142e0e69223648c5 100644 (file)
@@ -16,7 +16,8 @@
 package com.vaadin.client.ui.grid.renderers;
 
 import com.google.gwt.i18n.client.NumberFormat;
-import com.vaadin.client.ui.grid.Cell;
+import com.vaadin.client.ui.grid.FlyweightCell;
+import com.vaadin.client.ui.grid.Renderer;
 
 /**
  * Renders a number into a cell using a specific {@link NumberFormat}. By
@@ -28,7 +29,7 @@ import com.vaadin.client.ui.grid.Cell;
  * @param <T>
  *            The number type to render.
  */
-public class NumberRenderer<T extends Number> extends AbstractRenderer<T> {
+public class NumberRenderer<T extends Number> implements Renderer<T> {
 
     private NumberFormat format = NumberFormat.getDecimalFormat();
 
@@ -57,7 +58,7 @@ public class NumberRenderer<T extends Number> extends AbstractRenderer<T> {
     }
 
     @Override
-    public void render(Cell cell, Number number) {
+    public void render(FlyweightCell cell, Number number) {
         cell.getElement().setInnerText(format.format(number));
     }
 }
index a60ad705d6ab0387343a4c7e1fde36dcd7a424bd..36ffbae22df3b5c202114cce23a5f7d31581cf2e 100644 (file)
@@ -15,7 +15,8 @@
  */
 package com.vaadin.client.ui.grid.renderers;
 
-import com.vaadin.client.ui.grid.Cell;
+import com.vaadin.client.ui.grid.FlyweightCell;
+import com.vaadin.client.ui.grid.Renderer;
 
 /**
  * Renderer that renders text into a cell.
@@ -23,10 +24,10 @@ import com.vaadin.client.ui.grid.Cell;
  * @since 7.4
  * @author Vaadin Ltd
  */
-public class TextRenderer extends AbstractRenderer<String> {
+public class TextRenderer implements Renderer<String> {
 
     @Override
-    public void render(Cell cell, String text) {
+    public void render(FlyweightCell cell, String text) {
         cell.getElement().setInnerText(text);
     }
 }
index bdbff4a6f0cfb0149de888da92011da47cb2474f..dcbe367bb2c9b0fd3e226089677c83ad6f9ff5d4 100644 (file)
@@ -5,10 +5,10 @@ import java.util.List;
 
 import com.google.gwt.user.client.Window.Location;
 import com.google.gwt.user.client.ui.Composite;
-import com.vaadin.client.ui.grid.Cell;
 import com.vaadin.client.ui.grid.ColumnConfiguration;
 import com.vaadin.client.ui.grid.Escalator;
 import com.vaadin.client.ui.grid.EscalatorUpdater;
+import com.vaadin.client.ui.grid.FlyweightCell;
 import com.vaadin.client.ui.grid.Row;
 import com.vaadin.client.ui.grid.RowContainer;
 import com.vaadin.shared.ui.grid.ScrollDestination;
@@ -43,8 +43,8 @@ public class VTestGrid extends Composite {
             return new EscalatorUpdater() {
                 @Override
                 public void updateCells(final Row row,
-                        final Iterable<Cell> cellsToUpdate) {
-                    for (final Cell cell : cellsToUpdate) {
+                        final Iterable<FlyweightCell> cellsToUpdate) {
+                    for (final FlyweightCell cell : cellsToUpdate) {
                         if (cell.getColumn() % 3 == 0) {
                             cell.setColSpan(2);
                         }
@@ -61,8 +61,8 @@ public class VTestGrid extends Composite {
             return new EscalatorUpdater() {
                 @Override
                 public void updateCells(final Row row,
-                        final Iterable<Cell> cellsToUpdate) {
-                    for (final Cell cell : cellsToUpdate) {
+                        final Iterable<FlyweightCell> cellsToUpdate) {
+                    for (final FlyweightCell cell : cellsToUpdate) {
                         if (cell.getColumn() % 3 == 1) {
                             cell.setColSpan(2);
                         }
@@ -79,7 +79,7 @@ public class VTestGrid extends Composite {
             return new EscalatorUpdater() {
                 private int i = 0;
 
-                public void renderCell(final Cell cell) {
+                public void renderCell(final FlyweightCell cell) {
                     final Integer columnName = columns.get(cell.getColumn());
                     final Integer rowName = rows.get(cell.getRow());
                     String cellInfo = columnName + "," + rowName;
@@ -123,8 +123,8 @@ public class VTestGrid extends Composite {
 
                 @Override
                 public void updateCells(final Row row,
-                        final Iterable<Cell> cellsToUpdate) {
-                    for (final Cell cell : cellsToUpdate) {
+                        final Iterable<FlyweightCell> cellsToUpdate) {
+                    for (final FlyweightCell cell : cellsToUpdate) {
                         renderCell(cell);
                     }
                 }