diff options
author | Teppo Kurki <teppo.kurki@vaadin.com> | 2015-06-03 14:26:35 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-06-05 09:58:51 +0000 |
commit | d5860be5b6043c9b6f9a1b5b1550b1666af2d6ef (patch) | |
tree | a3ece1ef0687829b8b81632cb5a87db6df1d2383 /server | |
parent | 3ecc805eff05fd8ba905890d0c90c07421d2172b (diff) | |
download | vaadin-framework-d5860be5b6043c9b6f9a1b5b1550b1666af2d6ef.tar.gz vaadin-framework-d5860be5b6043c9b6f9a1b5b1550b1666af2d6ef.zip |
Use headerCaption as default hidingToggleCaption (#18028)
Change-Id: Ifaf288da98d6d1d1c02760784b832cb5b5d93c07
Diffstat (limited to 'server')
-rw-r--r-- | server/src/com/vaadin/ui/Grid.java | 34 | ||||
-rw-r--r-- | server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java | 16 |
2 files changed, 35 insertions, 15 deletions
diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java index c061a81b73..96884d7fd5 100644 --- a/server/src/com/vaadin/ui/Grid.java +++ b/server/src/com/vaadin/ui/Grid.java @@ -2441,9 +2441,10 @@ public class Grid extends AbstractComponent implements SelectionNotifier, private Converter<?, Object> converter; /** - * A check for allowing the {@link #Column(Grid, GridColumnState, Object) - * constructor} to call {@link #setConverter(Converter)} with a - * <code>null</code>, even if model and renderer aren't compatible. + * A check for allowing the + * {@link #Column(Grid, GridColumnState, Object) constructor} to call + * {@link #setConverter(Converter)} with a <code>null</code>, even if + * model and renderer aren't compatible. */ private boolean isFirstConverterAssignment = true; @@ -2503,7 +2504,9 @@ public class Grid extends AbstractComponent implements SelectionNotifier, } /** - * Sets the caption of the header. + * Sets the caption of the header. This caption is also used as the + * hiding toggle caption, unless it is explicitly set via + * {@link #setHidingToggleCaption(String)}. * * @param caption * the text to show in the caption @@ -2515,6 +2518,9 @@ public class Grid extends AbstractComponent implements SelectionNotifier, public Column setHeaderCaption(String caption) throws IllegalStateException { checkColumnIsAttached(); + + state.headerCaption = caption; + HeaderRow row = grid.getHeader().getDefaultRow(); if (row != null) { row.getCell(grid.getPropertyIdByColumnId(state.id)).setText( @@ -2542,11 +2548,11 @@ public class Grid extends AbstractComponent implements SelectionNotifier, * toggle for this column in the grid's sidebar when the column is * {@link #isHidable() hidable}. * <p> - * By default, before triggering this setter, a user friendly version of - * the column's {@link #getPropertyId() property id} is used. + * The default value is <code>null</code>, and in that case the column's + * {@link #getHeaderCaption() header caption} is used. * <p> - * <em>NOTE:</em> setting this to <code>null</code> or empty string - * might cause the hiding toggle to not render correctly. + * <em>NOTE:</em> setting this to empty string might cause the hiding + * toggle to not render correctly. * * @since 7.5.0 * @param hidingToggleCaption @@ -3207,9 +3213,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier, DesignAttributeHandler.writeAttribute("hidden", attributes, isHidden(), def.hidden, boolean.class); DesignAttributeHandler.writeAttribute("hiding-toggle-caption", - attributes, getHidingToggleCaption(), - SharedUtil.propertyIdToHumanFriendly(getPropertyId()), - String.class); + attributes, getHidingToggleCaption(), null, String.class); DesignAttributeHandler.writeAttribute("property-id", attributes, getPropertyId(), null, Object.class); } @@ -3288,7 +3292,8 @@ public class Grid extends AbstractComponent implements SelectionNotifier, private final String nullRepresentation; - protected AbstractRenderer(Class<T> presentationType, String nullRepresentation) { + protected AbstractRenderer(Class<T> presentationType, + String nullRepresentation) { this.presentationType = presentationType; this.nullRepresentation = nullRepresentation; } @@ -3333,6 +3338,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier, /** * Null representation for the renderer + * * @return a textual representation of {@code null} */ protected String getNullRepresentation() { @@ -4303,7 +4309,6 @@ public class Grid extends AbstractComponent implements SelectionNotifier, String humanFriendlyPropertyId = SharedUtil .propertyIdToHumanFriendly(String.valueOf(datasourcePropertyId)); column.setHeaderCaption(humanFriendlyPropertyId); - column.setHidingToggleCaption(humanFriendlyPropertyId); if (datasource instanceof Sortable && ((Sortable) datasource).getSortableContainerPropertyIds() @@ -4513,8 +4518,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier, * @throws IllegalArgumentException * if {@code rows} is zero or less * @throws IllegalArgumentException - * if {@code rows} is {@link Double#isInfinite(double) - * infinite} + * if {@code rows} is {@link Double#isInfinite(double) infinite} * @throws IllegalArgumentException * if {@code rows} is {@link Double#isNaN(double) NaN} */ 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 35553bb406..2b960d26a0 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 @@ -338,4 +338,20 @@ public class GridColumns { public void testAddingColumnsWithSetColumnsNonDefaultContainer() { grid.setColumns("column1", "column2", "column50"); } + + @Test + public void testDefaultColumnHidingToggleCaption() { + Column firstColumn = grid.getColumns().get(0); + firstColumn.setHeaderCaption("headerCaption"); + assertEquals(null, firstColumn.getHidingToggleCaption()); + } + + @Test + public void testOverriddenColumnHidingToggleCaption() { + Column firstColumn = grid.getColumns().get(0); + firstColumn.setHidingToggleCaption("hidingToggleCaption"); + firstColumn.setHeaderCaption("headerCaption"); + assertEquals("hidingToggleCaption", + firstColumn.getHidingToggleCaption()); + } } |