From 0eb12c4c82ceca35f7e73ca285f49bb72251de88 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Fri, 23 May 2014 14:24:47 +0300 Subject: [PATCH] Refactored client Renderers once again #13334 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 --- .../src/com/vaadin/client/ui/grid/Cell.java | 79 ++++++----- .../com/vaadin/client/ui/grid/CellInfo.java | 82 ------------ .../client/ui/grid/EscalatorUpdater.java | 4 +- .../vaadin/client/ui/grid/FlyweightCell.java | 44 +++++-- .../vaadin/client/ui/grid/FlyweightRow.java | 8 +- .../src/com/vaadin/client/ui/grid/Grid.java | 15 ++- .../com/vaadin/client/ui/grid/Renderer.java | 52 +------- .../ui/grid/renderers/AbstractRenderer.java | 51 -------- .../ui/grid/renderers/ComplexRenderer.java | 123 ++++++++++++++++++ .../ui/grid/renderers/DateRenderer.java | 7 +- .../ui/grid/renderers/HtmlRenderer.java | 7 +- .../ui/grid/renderers/NumberRenderer.java | 7 +- .../ui/grid/renderers/TextRenderer.java | 7 +- .../widgetset/client/grid/VTestGrid.java | 16 +-- 14 files changed, 235 insertions(+), 267 deletions(-) delete mode 100644 client/src/com/vaadin/client/ui/grid/CellInfo.java delete mode 100644 client/src/com/vaadin/client/ui/grid/renderers/AbstractRenderer.java create mode 100644 client/src/com/vaadin/client/ui/grid/renderers/ComplexRenderer.java diff --git a/client/src/com/vaadin/client/ui/grid/Cell.java b/client/src/com/vaadin/client/ui/grid/Cell.java index c4e1471da4..33495ebf87 100644 --- a/client/src/com/vaadin/client/ui/grid/Cell.java +++ b/client/src/com/vaadin/client/ui/grid/Cell.java @@ -13,63 +13,70 @@ * 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. - *

- * 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. - *

- * 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 null. + * @return the column index */ - public Element getElement(); + public int getColumn() { + return column; + } /** - * Sets the column span of the cell. - *

- * 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 1 to - * unset any column spans - * @throws IllegalArgumentException - * if numberOfCells < 1 + * @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 index 2f3dae8c4d..0000000000 --- a/client/src/com/vaadin/client/ui/grid/CellInfo.java +++ /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; - } - -} diff --git a/client/src/com/vaadin/client/ui/grid/EscalatorUpdater.java b/client/src/com/vaadin/client/ui/grid/EscalatorUpdater.java index c856d5f027..c6fe90850a 100644 --- a/client/src/com/vaadin/client/ui/grid/EscalatorUpdater.java +++ b/client/src/com/vaadin/client/ui/grid/EscalatorUpdater.java @@ -36,7 +36,7 @@ public interface EscalatorUpdater { public static final EscalatorUpdater NULL = new EscalatorUpdater() { @Override public void updateCells(final Row row, - final Iterable cellsToUpdate) { + final Iterable 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 cellsToUpdate); + public void updateCells(Row row, Iterable cellsToUpdate); } diff --git a/client/src/com/vaadin/client/ui/grid/FlyweightCell.java b/client/src/com/vaadin/client/ui/grid/FlyweightCell.java index 16ee265611..950b3e167a 100644 --- a/client/src/com/vaadin/client/ui/grid/FlyweightCell.java +++ b/client/src/com/vaadin/client/ui/grid/FlyweightCell.java @@ -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. + * *

- * 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 Flyweight-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 TD element + * or a TH 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)); } diff --git a/client/src/com/vaadin/client/ui/grid/FlyweightRow.java b/client/src/com/vaadin/client/ui/grid/FlyweightRow.java index 8bb9a54321..3505b317d1 100644 --- a/client/src/com/vaadin/client/ui/grid/FlyweightRow.java +++ b/client/src/com/vaadin/client/ui/grid/FlyweightRow.java @@ -35,7 +35,7 @@ import com.google.gwt.dom.client.Node; */ class FlyweightRow implements Row { - static class CellIterator implements Iterator { + static class CellIterator implements Iterator { /** A defensive copy of the cells in the current row. */ private final ArrayList cells; private int cursor = 0; @@ -188,11 +188,11 @@ class FlyweightRow implements Row { * @see #setup(Element, int, int[]) * @see #teardown() */ - Iterable getCells() { + Iterable getCells() { assertSetup(); - return new Iterable() { + return new Iterable() { @Override - public Iterator iterator() { + public Iterator iterator() { return new CellIterator(cells); } }; diff --git a/client/src/com/vaadin/client/ui/grid/Grid.java b/client/src/com/vaadin/client/ui/grid/Grid.java index b81fc3c673..d1e299ba5a 100644 --- a/client/src/com/vaadin/client/ui/grid/Grid.java +++ b/client/src/com/vaadin/client/ui/grid/Grid.java @@ -510,7 +510,7 @@ public class Grid extends Composite { public abstract Renderer getGroupRenderer(ColumnGroup group); @Override - public void updateCells(Row row, Iterable cellsToUpdate) { + public void updateCells(Row row, Iterable cellsToUpdate) { int rowIndex; if (inverted) { @@ -521,7 +521,7 @@ public class Grid extends Composite { if (firstRowIsVisible() && rowIndex == 0) { // column headers - for (Cell cell : cellsToUpdate) { + for (FlyweightCell cell : cellsToUpdate) { GridColumn column = getColumnFromVisibleIndex(cell .getColumn()); if (column != null) { @@ -551,7 +551,7 @@ public class Grid extends Composite { assert groupRow != null; - for (Cell cell : cellsToUpdate) { + for (FlyweightCell cell : cellsToUpdate) { GridColumn column = getColumnFromVisibleIndex(cell .getColumn()); ColumnGroup group = getGroupForColumn(groupRow, column); @@ -653,7 +653,8 @@ public class Grid extends Composite { return new EscalatorUpdater() { @Override - public void updateCells(Row row, Iterable cellsToUpdate) { + public void updateCells(Row row, + Iterable cellsToUpdate) { int rowIndex = row.getRow(); if (dataSource == null) { setCellsLoading(cellsToUpdate); @@ -666,7 +667,7 @@ public class Grid 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 extends Composite { } } - private void setCellsLoading(Iterable cellsToUpdate) { - for (Cell cell : cellsToUpdate) { + private void setCellsLoading(Iterable cellsToUpdate) { + for (FlyweightCell cell : cellsToUpdate) { cell.getElement().setInnerText("..."); } } diff --git a/client/src/com/vaadin/client/ui/grid/Renderer.java b/client/src/com/vaadin/client/ui/grid/Renderer.java index b96b89b730..e312a9da20 100644 --- a/client/src/com/vaadin/client/ui/grid/Renderer.java +++ b/client/src/com/vaadin/client/ui/grid/Renderer.java @@ -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 <T> into cell. @@ -34,44 +31,6 @@ import com.google.gwt.dom.client.NativeEvent; */ public interface Renderer { - /** - * 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. - * null if no events are consumed - * - * @return the consumed events, or null if no events are consumed - * - * @see com.google.gwt.dom.client.BrowserEvents - */ - Collection getConsumedEvents(); - - /** - * Called whenever a registered event is triggered in the column the - * renderer renders. - *

- * 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 { * @param data * The column data object */ - void render(Cell cell, T data); - - /** - * Called when the cell is "activated" by pressing enter or - * double clicking - * - * @return true 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 index 91f3b27eef..0000000000 --- a/client/src/com/vaadin/client/ui/grid/renderers/AbstractRenderer.java +++ /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 implements Renderer { - - @Override - public void init(Cell cell) { - // Implement if needed - } - - @Override - public Collection 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 index 0000000000..cf3e43c88a --- /dev/null +++ b/client/src/com/vaadin/client/ui/grid/renderers/ComplexRenderer.java @@ -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()}. + * + *

+ * 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 implements Renderer { + + /** + * 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. + * null 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 getConsumedEvents() { + return null; + } + + /** + * Called whenever a registered event is triggered in the column the + * renderer renders. + *

+ * 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 true if the content should be set visible + */ + public boolean setContentVisible(FlyweightCell cell, boolean visible) { + return false; + } + + /** + * Called when the cell is "activated" by pressing enter, + * double clicking or performing a double tap on the cell. + * + * @return true if event was handled and should not be + * interpreted as a generic gesture by Grid. + */ + public boolean onActivate() { + return false; + } +} diff --git a/client/src/com/vaadin/client/ui/grid/renderers/DateRenderer.java b/client/src/com/vaadin/client/ui/grid/renderers/DateRenderer.java index 59f56eafc4..d52e97c62c 100644 --- a/client/src/com/vaadin/client/ui/grid/renderers/DateRenderer.java +++ b/client/src/com/vaadin/client/ui/grid/renderers/DateRenderer.java @@ -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 { +public class DateRenderer implements Renderer { private DateTimeFormat format = DateTimeFormat.getShortDateTimeFormat(); @@ -35,7 +36,7 @@ public class DateRenderer extends AbstractRenderer { .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); } diff --git a/client/src/com/vaadin/client/ui/grid/renderers/HtmlRenderer.java b/client/src/com/vaadin/client/ui/grid/renderers/HtmlRenderer.java index 0c33f46cd8..6cb9603d3c 100644 --- a/client/src/com/vaadin/client/ui/grid/renderers/HtmlRenderer.java +++ b/client/src/com/vaadin/client/ui/grid/renderers/HtmlRenderer.java @@ -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 { +public class HtmlRenderer implements Renderer { @Override - public void render(Cell cell, String htmlString) { + public void render(FlyweightCell cell, String htmlString) { cell.getElement().setInnerSafeHtml( SafeHtmlUtils.fromSafeConstant(htmlString)); } diff --git a/client/src/com/vaadin/client/ui/grid/renderers/NumberRenderer.java b/client/src/com/vaadin/client/ui/grid/renderers/NumberRenderer.java index a21f0d776a..b1bf7083a5 100644 --- a/client/src/com/vaadin/client/ui/grid/renderers/NumberRenderer.java +++ b/client/src/com/vaadin/client/ui/grid/renderers/NumberRenderer.java @@ -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 * The number type to render. */ -public class NumberRenderer extends AbstractRenderer { +public class NumberRenderer implements Renderer { private NumberFormat format = NumberFormat.getDecimalFormat(); @@ -57,7 +58,7 @@ public class NumberRenderer extends AbstractRenderer { } @Override - public void render(Cell cell, Number number) { + public void render(FlyweightCell cell, Number number) { cell.getElement().setInnerText(format.format(number)); } } diff --git a/client/src/com/vaadin/client/ui/grid/renderers/TextRenderer.java b/client/src/com/vaadin/client/ui/grid/renderers/TextRenderer.java index a60ad705d6..36ffbae22d 100644 --- a/client/src/com/vaadin/client/ui/grid/renderers/TextRenderer.java +++ b/client/src/com/vaadin/client/ui/grid/renderers/TextRenderer.java @@ -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 { +public class TextRenderer implements Renderer { @Override - public void render(Cell cell, String text) { + public void render(FlyweightCell cell, String text) { cell.getElement().setInnerText(text); } } diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java index bdbff4a6f0..dcbe367bb2 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java @@ -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 cellsToUpdate) { - for (final Cell cell : cellsToUpdate) { + final Iterable 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 cellsToUpdate) { - for (final Cell cell : cellsToUpdate) { + final Iterable 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 cellsToUpdate) { - for (final Cell cell : cellsToUpdate) { + final Iterable cellsToUpdate) { + for (final FlyweightCell cell : cellsToUpdate) { renderCell(cell); } } -- 2.39.5