diff options
author | Sauli Tähkäpää <sauli@vaadin.com> | 2015-08-28 13:36:01 +0300 |
---|---|---|
committer | Johannes Dahlström <johannesd@vaadin.com> | 2015-11-04 13:56:10 +0200 |
commit | aaa5d35b7bbb800be31fdcb30218cf67880de85e (patch) | |
tree | a5f4c3a0284f2670e3fd050842882bcbf50a6769 | |
parent | 16f280649544ae02ff0a8282bc6966ea8021cfda (diff) | |
download | vaadin-framework-aaa5d35b7bbb800be31fdcb30218cf67880de85e.tar.gz vaadin-framework-aaa5d35b7bbb800be31fdcb30218cf67880de85e.zip |
Support caption fetching for HTML and Widget headers. (#18528)
Change-Id: Idad2cbbb6b138258ff6428e7ecc3d922ef99c675
-rw-r--r-- | server/src/com/vaadin/ui/Grid.java | 10 | ||||
-rw-r--r-- | server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java | 20 |
2 files changed, 23 insertions, 7 deletions
diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java index a4a6a83843..d9ac9a4019 100644 --- a/server/src/com/vaadin/ui/Grid.java +++ b/server/src/com/vaadin/ui/Grid.java @@ -2508,19 +2508,15 @@ public class Grid extends AbstractComponent implements SelectionNotifier, * Returns the caption of the header. By default the header caption is * the property id of the column. * - * @return the text in the default row of header, null if no default row + * @return the text in the default row of header. * * @throws IllegalStateException * if the column no longer is attached to the grid */ public String getHeaderCaption() throws IllegalStateException { checkColumnIsAttached(); - HeaderRow row = grid.getHeader().getDefaultRow(); - if (row != null) { - return row.getCell(grid.getPropertyIdByColumnId(state.id)) - .getText(); - } - return null; + + return state.headerCaption; } /** diff --git a/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java b/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java index 2b960d26a0..58ec5030be 100644 --- a/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java +++ b/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java @@ -15,6 +15,8 @@ */ package com.vaadin.tests.server.component.grid; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -354,4 +356,22 @@ public class GridColumns { assertEquals("hidingToggleCaption", firstColumn.getHidingToggleCaption()); } + + @Test + public void textHeaderCaptionIsReturned() { + Column firstColumn = grid.getColumns().get(0); + + firstColumn.setHeaderCaption("text"); + + assertThat(firstColumn.getHeaderCaption(), is("text")); + } + + @Test + public void defaultCaptionIsReturnedForHtml() { + Column firstColumn = grid.getColumns().get(0); + + grid.getDefaultHeaderRow().getCell("column0").setHtml("<b>html</b>"); + + assertThat(firstColumn.getHeaderCaption(), is("Column0")); + } } |