diff options
author | michaelvogt <michael@vaadin.com> | 2013-07-24 11:17:23 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-07-24 10:15:42 +0000 |
commit | 985d661e00dabaf5aa78bf67c3d2220e05cacb1e (patch) | |
tree | 115406954846196965ec3acbc85a0d1a8fba6d17 | |
parent | 3bbb824c7f1dd9ed23fd65283332db31a24a1935 (diff) | |
download | vaadin-framework-985d661e00dabaf5aa78bf67c3d2220e05cacb1e.tar.gz vaadin-framework-985d661e00dabaf5aa78bf67c3d2220e05cacb1e.zip |
Make settting of assistive description of Window optional (#12276)
Throws exception on server side for null parameter
Adds client side getter for descriptions
Change-Id: I7d6231eec52b584f674b97b9d0c8ee0b78b19297
-rw-r--r-- | client/src/com/vaadin/client/ui/VWindow.java | 16 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/Window.java | 34 | ||||
-rw-r--r-- | shared/src/com/vaadin/shared/ui/window/WindowState.java | 2 |
3 files changed, 38 insertions, 14 deletions
diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java index 2c85497707..7c0c875072 100644 --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@ -18,7 +18,9 @@ package com.vaadin.client.ui; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Comparator; +import java.util.List; import com.google.gwt.aria.client.Id; import com.google.gwt.aria.client.RelevantValue; @@ -153,6 +155,7 @@ public class VWindow extends VWindowOverlay implements private boolean closable = true; + private Connector[] assistiveConnectors = new Connector[0]; private String assistivePrefix; private String assistivePostfix; @@ -1282,6 +1285,8 @@ public class VWindow extends VWindowOverlay implements */ public void setAssistiveDescription(Connector[] connectors) { if (connectors != null) { + assistiveConnectors = connectors; + Id[] ids = new Id[connectors.length]; for (int index = 0; index < connectors.length; index++) { if (connectors[index] == null) { @@ -1303,6 +1308,17 @@ public class VWindow extends VWindowOverlay implements } /** + * Gets the connectors that are used as assistive description. Text + * contained in these connectors will be read by assistive devices when the + * window is opened. + * + * @return list of previously set connectors + */ + public List<Connector> getAssistiveDescription() { + return Collections.unmodifiableList(Arrays.asList(assistiveConnectors)); + } + + /** * Sets the WAI-ARIA role the window. * * This role defines how an assistive device handles a window. Available diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java index 658c821f88..dfe83d48a1 100644 --- a/server/src/com/vaadin/ui/Window.java +++ b/server/src/com/vaadin/ui/Window.java @@ -18,6 +18,9 @@ package com.vaadin.ui; import java.io.Serializable; import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import java.util.Map; import com.vaadin.event.FieldEvents.BlurEvent; @@ -997,27 +1000,32 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, } /** - * Allows to specify which component contains the description for the - * window. Text contained in this component will be read by assistive + * Allows to specify which components contain the description for the + * window. Text contained in these components will be read by assistive * devices when it is opened. * - * @param connector - * with the component to use as description + * @param connectors + * with the components to use as description */ - public void setAssistiveDescription(Connector connector) { - setAssistiveDescription(new Connector[] { connector }); + public void setAssistiveDescription(Connector... connectors) { + if (connectors == null) { + throw new IllegalArgumentException( + "Parameter connectors must be non-null"); + } else { + getState().contentDescription = connectors; + } } /** - * Allows to specify which components contain the description for the - * window. Text contained in this component will be read by assistive - * devices when it is opened. + * Gets the components that are used as assistive description. Text + * contained in these components will be read by assistive devices when the + * window is opened. * - * @param connectors - * with the components to use as description + * @return list of previously set components */ - public void setAssistiveDescription(Connector... connectors) { - getState().contentDescription = connectors; + public List<Connector> getAssistiveDescription() { + return Collections.unmodifiableList(Arrays + .asList(getState().contentDescription)); } /** diff --git a/shared/src/com/vaadin/shared/ui/window/WindowState.java b/shared/src/com/vaadin/shared/ui/window/WindowState.java index 55a9b3ec55..3cb6bbe61e 100644 --- a/shared/src/com/vaadin/shared/ui/window/WindowState.java +++ b/shared/src/com/vaadin/shared/ui/window/WindowState.java @@ -41,7 +41,7 @@ public class WindowState extends PanelState { public String assistivePrefix = ""; public String assistivePostfix = ""; - public Connector[] contentDescription; + public Connector[] contentDescription = new Connector[0]; public WindowRole role = WindowRole.DIALOG; public boolean assistiveTabStop = false; public String assistiveTabStopTopText = "Top of dialog"; |