From bda7e54cb6eadddf07fb19d88479c642c4831a66 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Fri, 11 Aug 2017 15:27:27 +0300 Subject: Provide API for setting row heights in Grid for different sections (#9810) Fixes #9425 --- server/src/main/java/com/vaadin/ui/Grid.java | 98 ++++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 6 deletions(-) (limited to 'server') diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java index 70e947ccd8..1aca35d3ec 100644 --- a/server/src/main/java/com/vaadin/ui/Grid.java +++ b/server/src/main/java/com/vaadin/ui/Grid.java @@ -3012,27 +3012,113 @@ public class Grid extends AbstractListing implements HasComponents, } /** - * Sets the height of a row. If -1 (default), the row height is calculated - * based on the theme for an empty row before the Grid is displayed. + * Sets the height of body, header and footer rows. If -1 (default), the row + * height is calculated based on the theme for an empty row before the Grid + * is displayed. *

* Note that all header, body and footer rows get the same height if * explicitly set. In automatic mode, each section is calculated separately * based on an empty row of that type. + * + * @see #setBodyRowHeight(double) + * @see #setHeaderRowHeight(double) + * @see #setFooterRowHeight(double) * * @param rowHeight * The height of a row in pixels or -1 for automatic calculation */ public void setRowHeight(double rowHeight) { - getState().rowHeight = rowHeight; + setBodyRowHeight(rowHeight); + setHeaderRowHeight(rowHeight); + setFooterRowHeight(rowHeight); + } + + /** + * Sets the height of a body row. If -1 (default), the row height is + * calculated based on the theme for an empty row before the Grid is + * displayed. + * + * @param rowHeight + * The height of a row in pixels or -1 for automatic calculation + * @since 8.1.2 + */ + public void setBodyRowHeight(double rowHeight) { + getState().bodyRowHeight = rowHeight; + } + + /** + * Sets the height of a header row. If -1 (default), the row height is + * calculated based on the theme for an empty row before the Grid is + * displayed. + * + * @param rowHeight + * The height of a row in pixels or -1 for automatic calculation + * @since 8.1.2 + */ + public void setHeaderRowHeight(double rowHeight) { + getState().headerRowHeight = rowHeight; } /** - * Returns the currently explicitly set row height or -1 if automatic. + * Sets the height of a footer row. If -1 (default), the row height is + * calculated based on the theme for an empty row before the Grid is + * displayed. * - * @return explicitly set row height in pixels or -1 if in automatic mode + * @param rowHeight + * The height of a row in pixels or -1 for automatic calculation + * @since 8.1.2 */ + public void setFooterRowHeight(double rowHeight) { + getState().footerRowHeight = rowHeight; + } + + /** + * Returns the current body row height.-1 if row height is in automatic + * calculation mode. + * + * @see #getBodyRowHeight() + * @see #getHeaderRowHeight() + * @see #getFooterRowHeight() + * + * @return body row height + * @deprecated replaced by three separate row height controls + */ + @Deprecated public double getRowHeight() { - return getState(false).rowHeight; + return getBodyRowHeight(); + } + + /** + * Returns the current body row height. -1 if row height is in automatic + * calculation mode. + * + * @return body row height + * @since 8.1.2 + */ + public double getBodyRowHeight() { + return getState(false).bodyRowHeight; + } + + /** + * Returns the current header row height. -1 if row height is in automatic + * calculation mode. + * + * @return header row height + * @since 8.1.2 + */ + public double getHeaderRowHeight() { + return getState(false).headerRowHeight; + } + + /** + * Returns the current footer row height. -1 if row height is in automatic + * calculation mode. + * + * @return footer row height + * @since 8.1.2 + */ + public double getFooterRowHeight() { + return getState(false).footerRowHeight; } /** -- cgit v1.2.3