aboutsummaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
authorPekka Hyvönen <pekka@vaadin.com>2017-05-18 15:48:02 +0300
committerPekka Hyvönen <pekka@vaadin.com>2017-05-19 11:21:33 +0300
commitded683a75f5923274952a0a173ca09b61c834c82 (patch)
tree9f146d2ee294b04c1accee53a4764a5bb3c4ef37 /server/src
parent84c0bee7e90091b2b86c6c452d1bd87a27d98c7d (diff)
downloadvaadin-framework-ded683a75f5923274952a0a173ca09b61c834c82.tar.gz
vaadin-framework-ded683a75f5923274952a0a173ca09b61c834c82.zip
Add shorthand for adding a column with ComponentRenderer
Diffstat (limited to 'server/src')
-rw-r--r--server/src/main/java/com/vaadin/ui/Grid.java21
-rw-r--r--server/src/test/java/com/vaadin/tests/components/grid/GridComponentRendererTest.java5
2 files changed, 23 insertions, 3 deletions
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java
index 463e475a44..845a61a42a 100644
--- a/server/src/main/java/com/vaadin/ui/Grid.java
+++ b/server/src/main/java/com/vaadin/ui/Grid.java
@@ -2421,6 +2421,25 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
}
/**
+ * Adds a column that shows components.
+ * <p>
+ * This is a shorthand for {@link #addColum()} with a
+ * {@link ComponentRenderer}.
+ *
+ * @param componentProvider
+ * a value provider that will return a component for the given
+ * item
+ * @return the new column
+ * @param <V>
+ * the column value type, extends component
+ * @since 8.1
+ */
+ public <V extends Component> Column<T, V> addComponentColumn(
+ ValueProvider<T, V> componentProvider) {
+ return addColumn(componentProvider, new ComponentRenderer());
+ }
+
+ /**
* Creates a column instance from a value provider and a renderer.
*
* @param valueProvider
@@ -2428,6 +2447,8 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
* @param renderer
* the renderer
* @return a new column instance
+ * @param <V>
+ * the column value type
*
* @since 8.0.3
*/
diff --git a/server/src/test/java/com/vaadin/tests/components/grid/GridComponentRendererTest.java b/server/src/test/java/com/vaadin/tests/components/grid/GridComponentRendererTest.java
index 9e6eb33704..d0b2b11dca 100644
--- a/server/src/test/java/com/vaadin/tests/components/grid/GridComponentRendererTest.java
+++ b/server/src/test/java/com/vaadin/tests/components/grid/GridComponentRendererTest.java
@@ -15,7 +15,6 @@ import com.vaadin.tests.util.AlwaysLockedVaadinSession;
import com.vaadin.tests.util.MockUI;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Label;
-import com.vaadin.ui.renderers.ComponentRenderer;
/**
* Test to validate clean detaching in Grid with ComponentRenderer.
@@ -37,11 +36,11 @@ public class GridComponentRendererTest {
dataProvider = DataProvider.ofCollection(backend);
grid = new Grid<>();
grid.setDataProvider(dataProvider);
- grid.addColumn(p -> {
+ grid.addComponentColumn(p -> {
oldComponent = testComponent;
testComponent = new Label();
return testComponent;
- }, new ComponentRenderer());
+ });
new MockUI() {
@Override
public Future<Void> access(Runnable runnable) {