// Path: componentrenderer/src/main/java/de/datenhahn/vaadin/componentrenderer/grid/ComponentGenerator.java
// public interface ComponentGenerator<T> extends Serializable {
// 
//     /**
//      * Called to generate the component for a component cell based
//      * on the passed typed bean.
//      *
//      * @param bean the bean being the source for the current row's data
//      * @return a <b>new</b> instance of the component used to display the data
//      */
//     Component getComponent(T bean);
// }
// 
// Path: componentrenderer/src/main/java/de/datenhahn/vaadin/componentrenderer/grid/ComponentGrid.java
// public class ComponentGrid<T> extends Grid {
// 
//     private final ComponentGridDecorator<T> componentGridDecorator;
// 
//     public ComponentGrid(Class<T> typeOfRows) {
//         super();
//         setContainerDataSource(new BeanItemContainer<T>(typeOfRows));
//         componentGridDecorator = new ComponentGridDecorator<T>(this, typeOfRows);
//     }
// 
//     public ComponentGridDecorator<T> getComponentGridDecorator() {
//         return componentGridDecorator;
//     }
// 
//     public FocusPreserveExtension getFocusPreserveExtension() {
//         return componentGridDecorator.getFocusPreserveExtension();
//     }
// 
//     /**
//      * Remove a bean from the grid.
//      *
//      * @return the decorator for method chaining
//      */
//     public ComponentGrid<T> remove(T bean) {
//         componentGridDecorator.remove(bean);
//         return this;
//     }
// 
//     /**
//      * Add a bean to the grid.
//      *
//      * @return the decorator for method chaining
//      */
//     public ComponentGrid<T>  add(T bean) {
//         componentGridDecorator.add(bean);
//         return this;
//     }
// 
//     /**
//      * Add all beans to the decorated grid's container.
//      *
//      * @param beans a collection of beans
//      * @return the grid for method chaining
//      */
//     public ComponentGrid<T> addAll(Collection<T> beans) {
//         componentGridDecorator.addAll(beans);
//         return this;
//     }
// 
//     /**
//      * Add a generated component column to the ComponentGrid.
//      *
//      * @param propertyId the generated column's property-id
//      * @param generator  the component-generator
//      * @return the grid for method chaining
//      */
//     public Grid.Column  addComponentColumn(Object propertyId, ComponentGenerator<T> generator) {
//         return componentGridDecorator.addComponentColumn(propertyId, generator);
//     }
// 
//     /**
//      * Refreshes the grid preserving its current cell focus.
//      */
//     public ComponentGrid<T>  refresh() {
//         componentGridDecorator.refresh();
//         return this;
//     }
// 
//     /**
//      * Remove all items from the underlying {@link BeanItemContainer} and add
//      * the new beans.
//      *
//      * @param beans a collection of beans
//      * @return the grid for method chaining
//      */
//     public ComponentGrid<T>  setRows(Collection<T> beans) {
//         componentGridDecorator.setRows(beans);
//         return this;
//     }
//     /**
//      * Generates component header fields using the passed {@link ComponentHeaderGenerator} and
//      * sets them to the columns.
//      *
//      * @param generator the header generator
//      * @return the grid for method chaining
//      */
//     public ComponentGrid<T> generateHeaders(ComponentHeaderGenerator generator) {
//         componentGridDecorator.generateHeaders(generator);
//         return this;
//     }
// 
//     /**
//      * Generates text header fields using the passed {@link TextHeaderGenerator} and
//      * sets them to the columns.
//      *
//      * @param generator the header generator
//      * @return the grid for method chaining
//      */
//     public ComponentGrid<T> generateHeaders(TextHeaderGenerator generator) {
//         componentGridDecorator.generateHeaders(generator);
//         return this;
//     }
// 
//     /**
//      * Generates html header fields using the passed {@link HtmlHeaderGenerator} and
//      * sets them to the columns.
//      *
//      * @param generator the header generator
//      * @return the grid for method chaining
//      */
//     public ComponentGrid<T> generateHeaders(HtmlHeaderGenerator generator) {
//         componentGridDecorator.generateHeaders(generator);
//         return this;
//     }
// }


import com.vaadin.server.Sizeable;
import com.vaadin.ui.Component;
import com.vaadin.ui.TabSheet;
import com.vaadin.v7.ui.ComboBox;
import com.vaadin.v7.ui.Grid;
import com.vaadin.v7.ui.VerticalLayout;
import de.datenhahn.vaadin.componentrenderer.grid.ComponentGenerator;
import de.datenhahn.vaadin.componentrenderer.grid.ComponentGrid;
import java.util.HashMap;
import java.util.Map;
            return comboBox;
        }

        private ComboBox create(final Customer data) {
            final ComboBox comboBox = new ComboBox();
            comboBox.setWidth(150, Sizeable.Unit.PIXELS);
            comboBox.setHeight(50, Sizeable.Unit.PIXELS);
            comboBox.addItems(Customer.Food.FISH, Customer.Food.HAMBURGER, Customer.Food.VEGETABLES);
            comboBox.setValue(data.getFood());
            return comboBox;
        }
    }

    private void init() {

        setSizeFull();
        setMargin(true);
        setSpacing(true);

        TabSheet sheet = new TabSheet();
        sheet.setSizeFull();
        sheet.addTab(createGrid(), "Tab 1");
        sheet.addTab(createGrid(), "Tab 2");

        addComponent(sheet);
        setExpandRatio(sheet, 1.0f);

    }

    private Grid createGrid() {
// Path: componentrenderer/src/main/java/de/datenhahn/vaadin/componentrenderer/grid/ComponentGenerator.java
// public interface ComponentGenerator<T> extends Serializable {
// 
//     /**
//      * Called to generate the component for a component cell based
//      * on the passed typed bean.
//      *
//      * @param bean the bean being the source for the current row's data
//      * @return a <b>new</b> instance of the component used to display the data
//      */
//     Component getComponent(T bean);
// }
// 
// Path: componentrenderer/src/main/java/de/datenhahn/vaadin/componentrenderer/grid/ComponentGrid.java
// public class ComponentGrid<T> extends Grid {
// 
//     private final ComponentGridDecorator<T> componentGridDecorator;
// 
//     public ComponentGrid(Class<T> typeOfRows) {
//         super();
//         setContainerDataSource(new BeanItemContainer<T>(typeOfRows));
//         componentGridDecorator = new ComponentGridDecorator<T>(this, typeOfRows);
//     }
// 
//     public ComponentGridDecorator<T> getComponentGridDecorator() {
//         return componentGridDecorator;
//     }
// 
//     public FocusPreserveExtension getFocusPreserveExtension() {
//         return componentGridDecorator.getFocusPreserveExtension();
//     }
// 
//     /**
//      * Remove a bean from the grid.
//      *
//      * @return the decorator for method chaining
//      */
//     public ComponentGrid<T> remove(T bean) {
//         componentGridDecorator.remove(bean);
//         return this;
//     }
// 
//     /**
//      * Add a bean to the grid.
//      *
//      * @return the decorator for method chaining
//      */
//     public ComponentGrid<T>  add(T bean) {
//         componentGridDecorator.add(bean);
//         return this;
//     }
// 
//     /**
//      * Add all beans to the decorated grid's container.
//      *
//      * @param beans a collection of beans
//      * @return the grid for method chaining
//      */
//     public ComponentGrid<T> addAll(Collection<T> beans) {
//         componentGridDecorator.addAll(beans);
//         return this;
//     }
// 
//     /**
//      * Add a generated component column to the ComponentGrid.
//      *
//      * @param propertyId the generated column's property-id
//      * @param generator  the component-generator
//      * @return the grid for method chaining
//      */
//     public Grid.Column  addComponentColumn(Object propertyId, ComponentGenerator<T> generator) {
//         return componentGridDecorator.addComponentColumn(propertyId, generator);
//     }
// 
//     /**
//      * Refreshes the grid preserving its current cell focus.
//      */
//     public ComponentGrid<T>  refresh() {
//         componentGridDecorator.refresh();
//         return this;
//     }
// 
//     /**
//      * Remove all items from the underlying {@link BeanItemContainer} and add
//      * the new beans.
//      *
//      * @param beans a collection of beans
//      * @return the grid for method chaining
//      */
//     public ComponentGrid<T>  setRows(Collection<T> beans) {
//         componentGridDecorator.setRows(beans);
//         return this;
//     }
//     /**
//      * Generates component header fields using the passed {@link ComponentHeaderGenerator} and
//      * sets them to the columns.
//      *
//      * @param generator the header generator
//      * @return the grid for method chaining
//      */
//     public ComponentGrid<T> generateHeaders(ComponentHeaderGenerator generator) {
//         componentGridDecorator.generateHeaders(generator);
//         return this;
//     }
// 
//     /**
//      * Generates text header fields using the passed {@link TextHeaderGenerator} and
//      * sets them to the columns.
//      *
//      * @param generator the header generator
//      * @return the grid for method chaining
//      */
//     public ComponentGrid<T> generateHeaders(TextHeaderGenerator generator) {
//         componentGridDecorator.generateHeaders(generator);
//         return this;
//     }
// 
//     /**
//      * Generates html header fields using the passed {@link HtmlHeaderGenerator} and
//      * sets them to the columns.
//      *
//      * @param generator the header generator
//      * @return the grid for method chaining
//      */
//     public ComponentGrid<T> generateHeaders(HtmlHeaderGenerator generator) {
//         componentGridDecorator.generateHeaders(generator);
//         return this;
//     }
// }


// Path: componentrenderer-demo/src/main/java/de/datenhahn/vaadin/componentrenderer/demo/TestbenchCachingGridTab.java
import com.vaadin.server.Sizeable;
import com.vaadin.ui.Component;
import com.vaadin.ui.TabSheet;
import com.vaadin.v7.ui.ComboBox;
import com.vaadin.v7.ui.Grid;
import com.vaadin.v7.ui.VerticalLayout;
import de.datenhahn.vaadin.componentrenderer.grid.ComponentGenerator;
import de.datenhahn.vaadin.componentrenderer.grid.ComponentGrid;
import java.util.HashMap;
import java.util.Map;

            return comboBox;
        }

        private ComboBox create(final Customer data) {
            final ComboBox comboBox = new ComboBox();
            comboBox.setWidth(150, Sizeable.Unit.PIXELS);
            comboBox.setHeight(50, Sizeable.Unit.PIXELS);
            comboBox.addItems(Customer.Food.FISH, Customer.Food.HAMBURGER, Customer.Food.VEGETABLES);
            comboBox.setValue(data.getFood());
            return comboBox;
        }
    }

    private void init() {

        setSizeFull();
        setMargin(true);
        setSpacing(true);

        TabSheet sheet = new TabSheet();
        sheet.setSizeFull();
        sheet.addTab(createGrid(), "Tab 1");
        sheet.addTab(createGrid(), "Tab 2");

        addComponent(sheet);
        setExpandRatio(sheet, 1.0f);

    }

    private Grid createGrid() {
        ComponentGrid<Customer> grid = new ComponentGrid<>(Customer.class);