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.
- 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.
+ * <p>
+ * 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<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
+ * roles are alertdialog and dialog (@see <a
+ * href="http://www.w3.org/TR/2011/CR-wai-aria-20110118/roles">Roles
+ * Model</a>).
+ *
+ * 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.
+ * <p>
+ * 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());
+ }
+
}