ComponentGrid extends Grid { public ComponentGrid<T> generateHeaders(ComponentHeaderGenerator generator) { componentGridDecorator.generateHeaders(generator); return this; } ComponentGrid(Class<T> typeOfRows); ComponentGridDecorator<T> getComponentGridDecorator(); FocusPreserveExtension getFocusPreserveExtension(); ComponentGrid<T> remove(T bean); ComponentGrid<T> add(T bean); ComponentGrid<T> addAll(Collection<T> beans); Grid.Column addComponentColumn(Object propertyId, ComponentGenerator<T> generator); ComponentGrid<T> refresh(); ComponentGrid<T> setRows(Collection<T> beans); ComponentGrid<T> generateHeaders(ComponentHeaderGenerator generator); ComponentGrid<T> generateHeaders(TextHeaderGenerator generator); ComponentGrid<T> generateHeaders(HtmlHeaderGenerator generator);  }
@Test public void testGenerateHtmlHeaders() { ComponentGrid grid = createTestGrid(); String headerText = grid.getDefaultHeaderRow().getCell(COLUMN_CAPTION).getText(); assertThat(headerText, is("Caption")); grid.generateHeaders(new HtmlHeaderGenerator() { @Override public String getHeader(Object propertyId) { return "HTML:<b>"+ propertyId + "</b>"; } }); headerText = grid.getDefaultHeaderRow().getCell(COLUMN_CAPTION).getHtml(); assertThat(headerText, is("HTML:<b>caption</b>")); }
@Test public void testGenerateComponentHeaders() { ComponentGrid grid = createTestGrid(); String headerText = grid.getDefaultHeaderRow().getCell(COLUMN_CAPTION).getText(); assertThat(headerText, is("Caption")); grid.generateHeaders(new ComponentHeaderGenerator() { @Override public Label getHeader(Object propertyId) { return new Label("" + propertyId); } }); Component headerComponent = grid.getDefaultHeaderRow().getCell(COLUMN_CAPTION).getComponent(); assertThat(headerComponent, instanceOf(Label.class)); }
@Test public void testGenerateTextHeaders() { ComponentGrid grid = createTestGrid(); String headerText = grid.getDefaultHeaderRow().getCell(COLUMN_CAPTION).getText(); assertThat(headerText, is("Caption")); grid.generateHeaders(new TextHeaderGenerator() { @Override public String getHeader(Object propertyId) { return "TEXT:"+ propertyId; } }); headerText = grid.getDefaultHeaderRow().getCell(COLUMN_CAPTION).getText(); assertThat(headerText, is("TEXT:caption")); }