ComponentGridDecorator implements Serializable { public Grid.Column addComponentColumn(Object propertyId, ComponentGenerator<T> generator) { gpc.addGeneratedProperty(propertyId, new ComponentPropertyGenerator<>(typeOfRows, generator)); return grid.getColumn(propertyId) .setRenderer(new ComponentRenderer()) .setEditorField(new ComponentCustomField()); } ComponentGridDecorator(Grid grid, Class<T> typeOfRows); FocusPreserveExtension getFocusPreserveExtension(); Grid getGrid(); Grid.Column addComponentColumn(Object propertyId, ComponentGenerator<T> generator); ComponentGridDecorator<T> setRows(Collection<T> beans); ComponentGridDecorator<T> addAll(Collection<T> beans); ComponentGridDecorator<T> remove(T bean); ComponentGridDecorator<T> add(T bean); ComponentGridDecorator<T> refresh(); ComponentGridDecorator<T> generateHeaders(ComponentHeaderGenerator generator); ComponentGridDecorator<T> generateHeaders(TextHeaderGenerator generator); ComponentGridDecorator<T> generateHeaders(HtmlHeaderGenerator generator);  }
@Test public void testAddComponentColumn() { Grid grid = createTestGrid(); ComponentGridDecorator<ExampleBean> decorator = new ComponentGridDecorator<>(grid, ExampleBean.class); Item firstItem = grid.getContainerDataSource().getItem(grid.getContainerDataSource().getIdByIndex(0)); assertThat((String) firstItem.getItemProperty(COLUMN_CAPTION).getValue(), is(FOO_0)); decorator.addComponentColumn(COLUMN_CAPTION, new ComponentGenerator<ExampleBean>() { @Override public Component getComponent(ExampleBean bean) { return new Label(bean.getCaption()); } }); firstItem = grid.getContainerDataSource().getItem(grid.getContainerDataSource().getIdByIndex(0)); assertThat(firstItem.getItemProperty(COLUMN_CAPTION).getValue(), is(instanceOf(Label.class))); Label firstLabel = (Label) firstItem.getItemProperty(COLUMN_CAPTION).getValue(); assertThat(firstLabel.getValue(), is(FOO_0)); }