From: Artur Signell Date: Mon, 11 Nov 2013 14:26:41 +0000 (+0200) Subject: Merge commit 'fefedeab68461ebc04fd45f91a35835fc9026a56' X-Git-Tag: 7.2.0.beta1~235 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2f9bcc0c210dafecfdc2943b8603fa4f41a9f16f;p=vaadin-framework.git Merge commit 'fefedeab68461ebc04fd45f91a35835fc9026a56' Conflicts: client/src/com/vaadin/client/ui/VWindow.java Change-Id: I03768d21133066aed5ff70b8c6df9e2761eb4e4e --- 2f9bcc0c210dafecfdc2943b8603fa4f41a9f16f diff --cc client/src/com/vaadin/client/ui/VWindow.java index f5417e3642,62937b6a67..19e217129a --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@@ -60,11 -48,10 +60,13 @@@ import com.vaadin.client.LayoutManager import com.vaadin.client.Util; import com.vaadin.client.debug.internal.VDebugWindow; import com.vaadin.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; +import com.vaadin.client.ui.aria.AriaHelper; + import com.vaadin.client.ui.window.WindowMoveEvent; + import com.vaadin.client.ui.window.WindowMoveHandler; +import com.vaadin.shared.Connector; import com.vaadin.shared.EventId; import com.vaadin.shared.ui.window.WindowMode; +import com.vaadin.shared.ui.window.WindowState.WindowRole; /** * "Sub window" component. @@@ -1294,97 -1042,14 +1299,109 @@@ public class VWindow extends VWindowOve - contentPanel.getElement().getOffsetWidth(); } + /** + * Allows to specify which connectors contain the description for the + * window. Text contained in the widgets of the connectors will be read by + * assistive devices when it is opened. + *

+ * When the provided array is empty, an existing description is removed. + * + * @param connectors + * with the connectors of the widgets to use as description + */ + public void setAssistiveDescription(Connector[] connectors) { + if (connectors != null) { + assistiveConnectors = connectors; + + if (connectors.length == 0) { + Roles.getDialogRole().removeAriaDescribedbyProperty( + getElement()); + } else { + Id[] ids = new Id[connectors.length]; + for (int index = 0; index < connectors.length; index++) { + if (connectors[index] == null) { + throw new IllegalArgumentException( + "All values in parameter description need to be non-null"); + } + + Element element = ((ComponentConnector) connectors[index]) + .getWidget().getElement(); + AriaHelper.ensureHasId(element); + ids[index] = Id.of(element); + } + + Roles.getDialogRole().setAriaDescribedbyProperty(getElement(), + ids); + } + } else { + throw new IllegalArgumentException( + "Parameter description must be non-null"); + } + } + + /** + * 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 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 + * roles are alertdialog and dialog (@see Roles + * Model). + * + * The default role is dialog. + * + * @param role + * WAI-ARIA role to set for the window + */ + public void setWaiAriaRole(WindowRole role) { + if ("alertdialog".equals(role)) { + Roles.getAlertdialogRole().set(getElement()); + } else { + Roles.getDialogRole().set(getElement()); + } + } + + /** + * Registers the handlers that prevent to leave the window using the + * Tab-key. + *

+ * The value of the parameter doTabStop is stored and used for non-modal + * windows. For modal windows, the handlers are always registered, while + * preserving the stored value. + * + * @param doTabStop + * true to prevent leaving the window, false to allow leaving the + * window for non modal windows + */ + public void setTabStopEnabled(boolean doTabStop) { + this.doTabStop = doTabStop; + + if (doTabStop || vaadinModality) { + addTabBlockHandlers(); + } else { + removeTabBlockHandlers(); + } + } ++ + /** + * Adds a Handler for when user moves the window. + * + * @since 7.1.9 ++ * + * @return {@link HandlerRegistration} used to remove the handler + */ + public HandlerRegistration addMoveHandler(WindowMoveHandler handler) { + return addHandler(handler, WindowMoveEvent.getType()); + } + }