From 40ab6dc0397f697001c3e05820863680fcac2e73 Mon Sep 17 00:00:00 2001 From: Denis Date: Wed, 8 Feb 2017 14:55:11 +0200 Subject: Provide a way to set styles for Header/Footer Cells and Rows in a Grid (#8499) Fixes #8422 --- .../com/vaadin/ui/components/grid/FooterCell.java | 15 ++++++++ .../com/vaadin/ui/components/grid/FooterRow.java | 15 ++++++++ .../com/vaadin/ui/components/grid/HeaderCell.java | 15 ++++++++ .../com/vaadin/ui/components/grid/HeaderRow.java | 15 ++++++++ .../vaadin/ui/components/grid/StaticSection.java | 40 ++++++++++++++++++++++ 5 files changed, 100 insertions(+) (limited to 'server') diff --git a/server/src/main/java/com/vaadin/ui/components/grid/FooterCell.java b/server/src/main/java/com/vaadin/ui/components/grid/FooterCell.java index 092637c891..d9777cbb77 100644 --- a/server/src/main/java/com/vaadin/ui/components/grid/FooterCell.java +++ b/server/src/main/java/com/vaadin/ui/components/grid/FooterCell.java @@ -87,4 +87,19 @@ public interface FooterCell extends Serializable { * @return column id for this cell */ public String getColumnId(); + + /** + * Returns the custom style name for this cell. + * + * @return the style name or null if no style name has been set + */ + public String getStyleName(); + + /** + * Sets a custom style name for this cell. + * + * @param styleName + * the style name to set or null to not use any style name + */ + public void setStyleName(String styleName); } diff --git a/server/src/main/java/com/vaadin/ui/components/grid/FooterRow.java b/server/src/main/java/com/vaadin/ui/components/grid/FooterRow.java index 1234c270e3..42e4650471 100644 --- a/server/src/main/java/com/vaadin/ui/components/grid/FooterRow.java +++ b/server/src/main/java/com/vaadin/ui/components/grid/FooterRow.java @@ -115,4 +115,19 @@ public interface FooterRow extends Serializable { * @see Column#setId(String) */ FooterCell join(String... columnIdsToMerge); + + /** + * Returns the custom style name for this row. + * + * @return the style name or null if no style name has been set + */ + public String getStyleName(); + + /** + * Sets a custom style name for this row. + * + * @param styleName + * the style name to set or null to not use any style name + */ + public void setStyleName(String styleName); } diff --git a/server/src/main/java/com/vaadin/ui/components/grid/HeaderCell.java b/server/src/main/java/com/vaadin/ui/components/grid/HeaderCell.java index 741ea96617..6801622740 100644 --- a/server/src/main/java/com/vaadin/ui/components/grid/HeaderCell.java +++ b/server/src/main/java/com/vaadin/ui/components/grid/HeaderCell.java @@ -87,4 +87,19 @@ public interface HeaderCell extends Serializable { * @return column id for this cell */ public String getColumnId(); + + /** + * Returns the custom style name for this cell. + * + * @return the style name or null if no style name has been set + */ + public String getStyleName(); + + /** + * Sets a custom style name for this cell. + * + * @param styleName + * the style name to set or null to not use any style name + */ + public void setStyleName(String styleName); } diff --git a/server/src/main/java/com/vaadin/ui/components/grid/HeaderRow.java b/server/src/main/java/com/vaadin/ui/components/grid/HeaderRow.java index a25d6f2595..f11843e147 100644 --- a/server/src/main/java/com/vaadin/ui/components/grid/HeaderRow.java +++ b/server/src/main/java/com/vaadin/ui/components/grid/HeaderRow.java @@ -115,4 +115,19 @@ public interface HeaderRow extends Serializable { * @see Column#setId(String) */ HeaderCell join(String... columnIdsToMerge); + + /** + * Returns the custom style name for this row. + * + * @return the style name or null if no style name has been set + */ + public String getStyleName(); + + /** + * Sets a custom style name for this row. + * + * @param styleName + * the style name to set or null to not use any style name + */ + public void setStyleName(String styleName); } diff --git a/server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java b/server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java index b621f09ad0..c53cc9c976 100644 --- a/server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java +++ b/server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java @@ -204,6 +204,25 @@ public abstract class StaticSection> return internalGetCell(section.getInternalIdForColumn(column)); } + /** + * Returns the custom style name for this row. + * + * @return the style name or null if no style name has been set + */ + public String getStyleName() { + return getRowState().styleName; + } + + /** + * Sets a custom style name for this row. + * + * @param styleName + * the style name to set or null to not use any style name + */ + public void setStyleName(String styleName) { + getRowState().styleName = styleName; + } + /** * Returns the cell in this section that corresponds to the given * internal column id. @@ -515,6 +534,27 @@ public abstract class StaticSection> public GridStaticCellType getCellType() { return cellState.type; } + + /** + * Returns the custom style name for this cell. + * + * @return the style name or null if no style name has been set + */ + public String getStyleName() { + return cellState.styleName; + } + + /** + * Sets a custom style name for this cell. + * + * @param styleName + * the style name to set or null to not use any style + * name + */ + public void setStyleName(String styleName) { + cellState.styleName = styleName; + row.section.markAsDirty(); + } /** * Reads the declarative design from the given table cell element. -- cgit v1.2.3