]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merge commit 'fefedeab68461ebc04fd45f91a35835fc9026a56'
authorArtur Signell <artur@vaadin.com>
Mon, 11 Nov 2013 14:26:41 +0000 (16:26 +0200)
committerArtur Signell <artur@vaadin.com>
Mon, 11 Nov 2013 14:26:41 +0000 (16:26 +0200)
Conflicts:
client/src/com/vaadin/client/ui/VWindow.java

Change-Id: I03768d21133066aed5ff70b8c6df9e2761eb4e4e

1  2 
client/src/com/vaadin/client/ui/VWindow.java
client/src/com/vaadin/client/ui/window/WindowConnector.java
server/src/com/vaadin/ui/Window.java

index f5417e3642472f44866227e42b8212e690cdd156,62937b6a6767c43172d16896e4f7e8f2160d0336..19e217129acc684de54dd85b111b4ae09958d0b1
@@@ -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.
 +     * <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());
+     }
  }
Simple merge