diff options
author | Knoobie <Knoobie@gmx.de> | 2017-10-30 09:00:21 +0100 |
---|---|---|
committer | Péter Török <31210544+torok-peter@users.noreply.github.com> | 2017-10-30 10:00:21 +0200 |
commit | e65efdfb50bc10bedf506d475f582276f6be0e2f (patch) | |
tree | 73c6ef9f6ad9658ea2ff564024f8426433c69b06 /server | |
parent | fb6e81221bd1b5ab0b81a3ee6c82e4286df57264 (diff) | |
download | vaadin-framework-e65efdfb50bc10bedf506d475f582276f6be0e2f.tar.gz vaadin-framework-e65efdfb50bc10bedf506d475f582276f6be0e2f.zip |
add Grid.Column#get/setAssistiveCaption (#10219)
* add Grid#Column#get/setAssistiveCaption
* fix test and update doc
* move testGridAssistiveCaption to GridTest
* delete test file
* delete test file
* Delete GridAssistiveCaptionTest.java
* Create GridAssistiveCaptionTest
* Create GridAssistiveCaption
* Rename GridAssistiveCaption to GridAssistiveCaption.java
* Rename GridAssistiveCaptionTest to GridAssistiveCaptionTest.java
* Reformat using eclipse
Diffstat (limited to 'server')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/Grid.java | 34 | ||||
-rw-r--r-- | server/src/test/java/com/vaadin/tests/server/component/grid/GridTest.java | 7 |
2 files changed, 41 insertions, 0 deletions
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java index 7282afb44c..1e35578b19 100644 --- a/server/src/main/java/com/vaadin/ui/Grid.java +++ b/server/src/main/java/com/vaadin/ui/Grid.java @@ -1203,6 +1203,36 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents, } /** + * Sets the header aria-label for this column. + * + * @param caption + * the header aria-label, null removes + * the aria-label from this column + * + * @return this column + * + * @since + */ + public Column<T, V> setAssistiveCaption(String caption) { + if (Objects.equals(caption, getAssistiveCaption())) { + return this; + } + getState().assistiveCaption = caption; + return this; + } + + /** + * Gets the header caption for this column. + * + * @return header caption + * + * @since + */ + public String getAssistiveCaption() { + return getState(false).assistiveCaption; + } + + /** * Sets the header caption for this column. * * @param caption @@ -2131,6 +2161,10 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents, setHidingToggleCaption(DesignAttributeHandler.readAttribute( "hiding-toggle-caption", attributes, String.class)); } + if (design.hasAttr("assistive-caption")) { + setAssistiveCaption(DesignAttributeHandler.readAttribute( + "assistive-caption", attributes, String.class)); + } // Read size info where necessary. if (design.hasAttr("width")) { diff --git a/server/src/test/java/com/vaadin/tests/server/component/grid/GridTest.java b/server/src/test/java/com/vaadin/tests/server/component/grid/GridTest.java index d27c7c5260..8e31e9acc6 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/grid/GridTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/grid/GridTest.java @@ -80,6 +80,13 @@ public class GridTest { } @Test + public void testGridAssistiveCaption() { + assertEquals(null, fooColumn.getAssistiveCaption()); + fooColumn.setAssistiveCaption("Press Enter to sort."); + assertEquals("Press Enter to sort.", fooColumn.getAssistiveCaption()); + } + + @Test public void testCreateGridWithDataCommunicator() { DataCommunicator<String> specificDataCommunicator = new DataCommunicator<>(); |