diff options
Diffstat (limited to 'src/com/vaadin/ui/Window.java')
-rw-r--r-- | src/com/vaadin/ui/Window.java | 2251 |
1 files changed, 1141 insertions, 1110 deletions
diff --git a/src/com/vaadin/ui/Window.java b/src/com/vaadin/ui/Window.java index ddd1f6fc3b..649bbe145e 100644 --- a/src/com/vaadin/ui/Window.java +++ b/src/com/vaadin/ui/Window.java @@ -6,15 +6,6 @@ package com.vaadin.ui; import java.io.Serializable; import java.lang.reflect.Method; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.Map; -import java.util.Set; import com.vaadin.Application; import com.vaadin.event.FieldEvents.BlurEvent; @@ -27,14 +18,10 @@ import com.vaadin.event.ShortcutAction; import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.event.ShortcutAction.ModifierKey; import com.vaadin.event.ShortcutListener; -import com.vaadin.terminal.DownloadStream; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.ParameterHandler; import com.vaadin.terminal.Resource; import com.vaadin.terminal.Sizeable; -import com.vaadin.terminal.Terminal; -import com.vaadin.terminal.URIHandler; import com.vaadin.terminal.gwt.client.ui.VView; import com.vaadin.terminal.gwt.client.ui.VWindow; @@ -85,8 +72,7 @@ import com.vaadin.terminal.gwt.client.ui.VWindow; */ @SuppressWarnings("serial") @ClientWidget(VWindow.class) -public class Window extends Panel implements URIHandler, ParameterHandler, - FocusNotifier, BlurNotifier { +public class Window extends Panel implements FocusNotifier, BlurNotifier { /** * <b>Application window only</b>. A border style used for opening resources @@ -106,57 +92,62 @@ public class Window extends Panel implements URIHandler, ParameterHandler, */ public static final int BORDER_DEFAULT = 2; - /** - * <b>Application window only</b>. The user terminal for this window. - */ - private Terminal terminal = null; - - /** - * <b>Application window only</b>. The application this window is attached - * to or null. - */ - private Application application = null; - - /** - * <b>Application window only</b>. List of URI handlers for this window. - */ - private LinkedList<URIHandler> uriHandlerList = null; - - /** - * <b>Application window only</b>. List of parameter handlers for this - * window. - */ - private LinkedList<ParameterHandler> parameterHandlerList = null; - - /** - * <b>Application window only</b>. List of sub windows in this window. A sub - * window cannot have other sub windows. - */ - private final LinkedHashSet<Window> subwindows = new LinkedHashSet<Window>(); - - /** - * <b>Application window only</b>. Explicitly specified theme of this window - * or null if the application theme should be used. - */ - private String theme = null; - - /** - * <b>Application window only</b>. Resources to be opened automatically on - * next repaint. The list is automatically cleared when it has been sent to - * the client. - */ - private final LinkedList<OpenResource> openList = new LinkedList<OpenResource>(); - - /** - * <b>Application window only</b>. Unique name of the window used to - * identify it. - */ - private String name = null; - - /** - * <b>Application window only.</b> Border mode of the Window. - */ - private int border = BORDER_DEFAULT; + // /** + // * <b>Application window only</b>. The user terminal for this window. + // */ + // private Terminal terminal = null; + // + // /** + // * <b>Application window only</b>. The application this window is attached + // * to or null. + // */ + // private Application application = null; + // + // /** + // * <b>Application window only</b>. List of URI handlers for this window. + // */ + // private LinkedList<URIHandler> uriHandlerList = null; + // + // /** + // * <b>Application window only</b>. List of parameter handlers for this + // * window. + // */ + // private LinkedList<ParameterHandler> parameterHandlerList = null; + // + // /** + // * <b>Application window only</b>. List of sub windows in this window. A + // sub + // * window cannot have other sub windows. + // */ + // private final LinkedHashSet<Window> subwindows = new + // LinkedHashSet<Window>(); + // + // /** + // * <b>Application window only</b>. Explicitly specified theme of this + // window + // * or null if the application theme should be used. + // */ + // private String theme = null; + // + // /** + // * <b>Application window only</b>. Resources to be opened automatically on + // * next repaint. The list is automatically cleared when it has been sent + // to + // * the client. + // */ + // private final LinkedList<OpenResource> openList = new + // LinkedList<OpenResource>(); + // + // /** + // * <b>Application window only</b>. Unique name of the window used to + // * identify it. + // */ + // private String name = null; + // + // /** + // * <b>Application window only.</b> Border mode of the Window. + // */ + // private int border = BORDER_DEFAULT; /** * <b>Sub window only</b>. Top offset in pixels for the sub window (relative @@ -170,12 +161,13 @@ public class Window extends Panel implements URIHandler, ParameterHandler, */ private int positionX = -1; - /** - * <b>Application window only</b>. A list of notifications that are waiting - * to be sent to the client. Cleared (set to null) when the notifications - * have been sent. - */ - private LinkedList<Notification> notifications; + // /** + // * <b>Application window only</b>. A list of notifications that are + // waiting + // * to be sent to the client. Cleared (set to null) when the notifications + // * have been sent. + // */ + // private LinkedList<Notification> notifications; /** * <b>Sub window only</b>. Modality flag for sub window. @@ -210,12 +202,13 @@ public class Window extends Panel implements URIHandler, ParameterHandler, */ private Focusable pendingFocus; - /** - * <b>Application window only</b>. A list of javascript commands that are - * waiting to be sent to the client. Cleared (set to null) when the commands - * have been sent. - */ - private ArrayList<String> jsExecQueue = null; + // /** + // * <b>Application window only</b>. A list of javascript commands that are + // * waiting to be sent to the client. Cleared (set to null) when the + // commands + // * have been sent. + // */ + // private ArrayList<String> jsExecQueue = null; /** * The component that should be scrolled into view after the next repaint. @@ -269,287 +262,297 @@ public class Window extends Panel implements URIHandler, ParameterHandler, super.addComponent(c); } - /** - * <b>Application window only</b>. Gets the user terminal. - * - * @return the user terminal - */ - public Terminal getTerminal() { - return terminal; - } + // /** + // * <b>Application window only</b>. Gets the user terminal. + // * + // * @return the user terminal + // */ + // public Terminal getTerminal() { + // return terminal; + // } /* ********************************************************************* */ - /** - * Gets the parent window of the component. - * <p> - * This is always the window itself. - * </p> - * <p> - * <b>This method is not meant to be overridden. Due to CDI requirements we - * cannot declare it as final even though it should be final.</b> - * </p> - * - * @see Component#getWindow() - * @return the window itself - */ - @Override - public Window getWindow() { - return this; - } - - /* - * (non-Javadoc) - * - * @see com.vaadin.ui.AbstractComponent#getApplication() - */ - @Override - public Application getApplication() { - if (getParent() == null) { - return application; - } - return getParent().getApplication(); - } - - /** - * Gets the parent component of the window. - * - * <p> - * The parent of an application window is always null. The parent of a sub - * window is the application window the sub window is attached to. - * </p> - * <p> - * <b>This method is not meant to be overridden. Due to CDI requirements we - * cannot declare it as final even though it should be final.</b> - * </p> - * - * - * @return the parent window - * @see Component#getParent() - */ - @Override - public Window getParent() { - return (Window) super.getParent(); - } + // /** + // * Gets the parent window of the component. + // * <p> + // * This is always the window itself. + // * </p> + // * <p> + // * <b>This method is not meant to be overridden. Due to CDI requirements + // we + // * cannot declare it as final even though it should be final.</b> + // * </p> + // * + // * @see Component#getRoot() + // * @return the window itself + // */ + // @Override + // public Root getRoot() { + // return this; + // } + + // /* + // * (non-Javadoc) + // * + // * @see com.vaadin.ui.AbstractComponent#getApplication() + // */ + // @Override + // public Application getApplication() { + // if (getParent() == null) { + // return application; + // } + // return getParent().getApplication(); + // } + + // /** + // * Gets the parent component of the window. + // * + // * <p> + // * The parent of an application window is always null. The parent of a sub + // * window is the application window the sub window is attached to. + // * </p> + // * <p> + // * <b>This method is not meant to be overridden. Due to CDI requirements + // we + // * cannot declare it as final even though it should be final.</b> + // * </p> + // * + // * + // * @return the parent window + // * @see Component#getParent() + // */ + // @Override + // public Window getParent() { + // return (Window) super.getParent(); + // } /* ********************************************************************* */ - /** - * <b>Application window only</b>. Adds a new URI handler to this window. If - * this is a sub window the URI handler is attached to the parent - * application window. - * - * @param handler - * the URI handler to add. - */ - public void addURIHandler(URIHandler handler) { - if (getParent() != null) { - // this is subwindow, attach to main level instead - // TODO hold internal list also and remove on detach - Window mainWindow = getParent(); - mainWindow.addURIHandler(handler); - } else { - if (uriHandlerList == null) { - uriHandlerList = new LinkedList<URIHandler>(); - } - synchronized (uriHandlerList) { - if (!uriHandlerList.contains(handler)) { - uriHandlerList.addLast(handler); - } - } - } - } - - /** - * <b>Application window only</b>. Removes the URI handler from this window. - * If this is a sub window the URI handler is removed from the parent - * application window. - * - * @param handler - * the URI handler to remove. - */ - public void removeURIHandler(URIHandler handler) { - if (getParent() != null) { - // this is subwindow - Window mainWindow = getParent(); - mainWindow.removeURIHandler(handler); - } else { - if (handler == null || uriHandlerList == null) { - return; - } - synchronized (uriHandlerList) { - uriHandlerList.remove(handler); - if (uriHandlerList.isEmpty()) { - uriHandlerList = null; - } - } - } - } - - /** - * <b>Application window only</b>. Handles an URI by passing the URI to all - * URI handlers defined using {@link #addURIHandler(URIHandler)}. All URI - * handlers are called for each URI but no more than one handler may return - * a {@link DownloadStream}. If more than one stream is returned a - * {@code RuntimeException} is thrown. - * - * @param context - * The URL of the application - * @param relativeUri - * The URI relative to {@code context} - * @return A {@code DownloadStream} that one of the URI handlers returned, - * null if no {@code DownloadStream} was returned. - */ - public DownloadStream handleURI(URL context, String relativeUri) { - - DownloadStream result = null; - if (uriHandlerList != null) { - Object[] handlers; - synchronized (uriHandlerList) { - handlers = uriHandlerList.toArray(); - } - for (int i = 0; i < handlers.length; i++) { - final DownloadStream ds = ((URIHandler) handlers[i]).handleURI( - context, relativeUri); - if (ds != null) { - if (result != null) { - throw new RuntimeException("handleURI for " + context - + " uri: '" + relativeUri - + "' returns ambigious result."); - } - result = ds; - } - } - } - return result; - } + // /** + // * <b>Application window only</b>. Adds a new URI handler to this window. + // If + // * this is a sub window the URI handler is attached to the parent + // * application window. + // * + // * @param handler + // * the URI handler to add. + // */ + // public void addURIHandler(URIHandler handler) { + // if (getParent() != null) { + // // this is subwindow, attach to main level instead + // // TODO hold internal list also and remove on detach + // Window mainWindow = getParent(); + // mainWindow.addURIHandler(handler); + // } else { + // if (uriHandlerList == null) { + // uriHandlerList = new LinkedList<URIHandler>(); + // } + // synchronized (uriHandlerList) { + // if (!uriHandlerList.contains(handler)) { + // uriHandlerList.addLast(handler); + // } + // } + // } + // } + + // /** + // * <b>Application window only</b>. Removes the URI handler from this + // window. + // * If this is a sub window the URI handler is removed from the parent + // * application window. + // * + // * @param handler + // * the URI handler to remove. + // */ + // public void removeURIHandler(URIHandler handler) { + // if (getParent() != null) { + // // this is subwindow + // Window mainWindow = getParent(); + // mainWindow.removeURIHandler(handler); + // } else { + // if (handler == null || uriHandlerList == null) { + // return; + // } + // synchronized (uriHandlerList) { + // uriHandlerList.remove(handler); + // if (uriHandlerList.isEmpty()) { + // uriHandlerList = null; + // } + // } + // } + // } + + // /** + // * <b>Application window only</b>. Handles an URI by passing the URI to + // all + // * URI handlers defined using {@link #addURIHandler(URIHandler)}. All URI + // * handlers are called for each URI but no more than one handler may + // return + // * a {@link DownloadStream}. If more than one stream is returned a + // * {@code RuntimeException} is thrown. + // * + // * @param context + // * The URL of the application + // * @param relativeUri + // * The URI relative to {@code context} + // * @return A {@code DownloadStream} that one of the URI handlers returned, + // * null if no {@code DownloadStream} was returned. + // */ + // public DownloadStream handleURI(URL context, String relativeUri) { + // + // DownloadStream result = null; + // if (uriHandlerList != null) { + // Object[] handlers; + // synchronized (uriHandlerList) { + // handlers = uriHandlerList.toArray(); + // } + // for (int i = 0; i < handlers.length; i++) { + // final DownloadStream ds = ((URIHandler) handlers[i]).handleURI( + // context, relativeUri); + // if (ds != null) { + // if (result != null) { + // throw new RuntimeException("handleURI for " + context + // + " uri: '" + relativeUri + // + "' returns ambigious result."); + // } + // result = ds; + // } + // } + // } + // return result; + // } /* ********************************************************************* */ - /** - * <b>Application window only</b>. Adds a new parameter handler to this - * window. If this is a sub window the parameter handler is attached to the - * parent application window. - * - * @param handler - * the parameter handler to add. - */ - public void addParameterHandler(ParameterHandler handler) { - if (getParent() != null) { - // this is subwindow - // TODO hold internal list also and remove on detach - Window mainWindow = getParent(); - mainWindow.addParameterHandler(handler); - } else { - if (parameterHandlerList == null) { - parameterHandlerList = new LinkedList<ParameterHandler>(); - } - synchronized (parameterHandlerList) { - if (!parameterHandlerList.contains(handler)) { - parameterHandlerList.addLast(handler); - } - } - } - - } - - /** - * <b>Application window only</b>. Removes the parameter handler from this - * window. If this is a sub window the parameter handler is removed from the - * parent application window. - * - * @param handler - * the parameter handler to remove. - */ - public void removeParameterHandler(ParameterHandler handler) { - if (getParent() != null) { - // this is subwindow - Window mainWindow = getParent(); - mainWindow.removeParameterHandler(handler); - } else { - if (handler == null || parameterHandlerList == null) { - return; - } - synchronized (parameterHandlerList) { - parameterHandlerList.remove(handler); - if (parameterHandlerList.isEmpty()) { - parameterHandlerList = null; - } - } - } - } - - /** - * <b>Application window only</b>. Handles parameters by passing the - * parameters to all {@code ParameterHandler}s defined using - * {@link #addParameterHandler(ParameterHandler)}. All - * {@code ParameterHandler}s are called for each set of parameters. - * - * @param parameters - * a map containing the parameter names and values - * @see ParameterHandler#handleParameters(Map) - */ - public void handleParameters(Map<String, String[]> parameters) { - if (parameterHandlerList != null) { - Object[] handlers; - synchronized (parameterHandlerList) { - handlers = parameterHandlerList.toArray(); - } - for (int i = 0; i < handlers.length; i++) { - ((ParameterHandler) handlers[i]).handleParameters(parameters); - } - } - } + // /** + // * <b>Application window only</b>. Adds a new parameter handler to this + // * window. If this is a sub window the parameter handler is attached to + // the + // * parent application window. + // * + // * @param handler + // * the parameter handler to add. + // */ + // public void addParameterHandler(ParameterHandler handler) { + // if (getParent() != null) { + // // this is subwindow + // // TODO hold internal list also and remove on detach + // Window mainWindow = getParent(); + // mainWindow.addParameterHandler(handler); + // } else { + // if (parameterHandlerList == null) { + // parameterHandlerList = new LinkedList<ParameterHandler>(); + // } + // synchronized (parameterHandlerList) { + // if (!parameterHandlerList.contains(handler)) { + // parameterHandlerList.addLast(handler); + // } + // } + // } + // + // } + + // /** + // * <b>Application window only</b>. Removes the parameter handler from this + // * window. If this is a sub window the parameter handler is removed from + // the + // * parent application window. + // * + // * @param handler + // * the parameter handler to remove. + // */ + // public void removeParameterHandler(ParameterHandler handler) { + // if (getParent() != null) { + // // this is subwindow + // Window mainWindow = getParent(); + // mainWindow.removeParameterHandler(handler); + // } else { + // if (handler == null || parameterHandlerList == null) { + // return; + // } + // synchronized (parameterHandlerList) { + // parameterHandlerList.remove(handler); + // if (parameterHandlerList.isEmpty()) { + // parameterHandlerList = null; + // } + // } + // } + // } + + // /** + // * <b>Application window only</b>. Handles parameters by passing the + // * parameters to all {@code ParameterHandler}s defined using + // * {@link #addParameterHandler(ParameterHandler)}. All + // * {@code ParameterHandler}s are called for each set of parameters. + // * + // * @param parameters + // * a map containing the parameter names and values + // * @see ParameterHandler#handleParameters(Map) + // */ + // public void handleParameters(Map<String, String[]> parameters) { + // if (parameterHandlerList != null) { + // Object[] handlers; + // synchronized (parameterHandlerList) { + // handlers = parameterHandlerList.toArray(); + // } + // for (int i = 0; i < handlers.length; i++) { + // ((ParameterHandler) handlers[i]).handleParameters(parameters); + // } + // } + // } /* ********************************************************************* */ - /** - * <b>Application window only</b>. Gets the theme for this window. - * <p> - * If the theme for this window is not explicitly set, the application theme - * name is returned. If the window is not attached to an application, the - * terminal default theme name is returned. If the theme name cannot be - * determined, null is returned - * </p> - * <p> - * Subwindows do not support themes and return the theme used by the parent - * window - * </p> - * - * @return the name of the theme used for the window - */ - public String getTheme() { - if (getParent() != null) { - return (getParent()).getTheme(); - } - if (theme != null) { - return theme; - } - if ((application != null) && (application.getTheme() != null)) { - return application.getTheme(); - } - if (terminal != null) { - return terminal.getDefaultTheme(); - } - return null; - } - - /** - * <b>Application window only</b>. Sets the name of the theme to use for - * this window. Changing the theme will cause the page to be reloaded. - * - * @param theme - * the name of the new theme for this window or null to use the - * application theme. - */ - public void setTheme(String theme) { - if (getParent() != null) { - throw new UnsupportedOperationException( - "Setting theme for sub-windows is not supported."); - } - this.theme = theme; - requestRepaint(); - } + // /** + // * <b>Application window only</b>. Gets the theme for this window. + // * <p> + // * If the theme for this window is not explicitly set, the application + // theme + // * name is returned. If the window is not attached to an application, the + // * terminal default theme name is returned. If the theme name cannot be + // * determined, null is returned + // * </p> + // * <p> + // * Subwindows do not support themes and return the theme used by the + // parent + // * window + // * </p> + // * + // * @return the name of the theme used for the window + // */ + // public String getTheme() { + // if (getParent() != null) { + // return (getParent()).getTheme(); + // } + // if (theme != null) { + // return theme; + // } + // if ((application != null) && (application.getTheme() != null)) { + // return application.getTheme(); + // } + // if (terminal != null) { + // return terminal.getDefaultTheme(); + // } + // return null; + // } + + // /** + // * <b>Application window only</b>. Sets the name of the theme to use for + // * this window. Changing the theme will cause the page to be reloaded. + // * + // * @param theme + // * the name of the new theme for this window or null to use the + // * application theme. + // */ + // public void setTheme(String theme) { + // if (getParent() != null) { + // throw new UnsupportedOperationException( + // "Setting theme for sub-windows is not supported."); + // } + // this.theme = theme; + // requestRepaint(); + // } /* * (non-Javadoc) @@ -561,12 +564,12 @@ public class Window extends Panel implements URIHandler, ParameterHandler, throws PaintException { // Sets the window name - final String name = getName(); - target.addAttribute("name", name == null ? "" : name); + // final String name = getName(); + // target.addAttribute("name", name == null ? "" : name); // Sets the window theme - final String theme = getTheme(); - target.addAttribute("theme", theme == null ? "" : theme); + // final String theme = getTheme(); + // target.addAttribute("theme", theme == null ? "" : theme); if (modal) { target.addAttribute("modal", true); @@ -600,10 +603,10 @@ public class Window extends Panel implements URIHandler, ParameterHandler, } // Marks the main window - if (getApplication() != null - && this == getApplication().getMainWindow()) { - target.addAttribute("main", true); - } + // if (getApplication() != null + // && this == getApplication().getMainWindow()) { + // target.addAttribute("main", true); + // } if (getContent() != null) { if (getContent().getHeightUnits() == Sizeable.UNITS_PERCENTAGE) { @@ -615,28 +618,28 @@ public class Window extends Panel implements URIHandler, ParameterHandler, } // Open requested resource - synchronized (openList) { - if (!openList.isEmpty()) { - for (final Iterator<OpenResource> i = openList.iterator(); i - .hasNext();) { - (i.next()).paintContent(target); - } - openList.clear(); - } - } + // synchronized (openList) { + // if (!openList.isEmpty()) { + // for (final Iterator<OpenResource> i = openList.iterator(); i + // .hasNext();) { + // (i.next()).paintContent(target); + // } + // openList.clear(); + // } + // } // Contents of the window panel is painted super.paintContent(target); - // Add executable javascripts if needed - if (jsExecQueue != null) { - for (String script : jsExecQueue) { - target.startTag("execJS"); - target.addAttribute("script", script); - target.endTag("execJS"); - } - jsExecQueue = null; - } + // // Add executable javascripts if needed + // if (jsExecQueue != null) { + // for (String script : jsExecQueue) { + // target.startTag("execJS"); + // target.addAttribute("script", script); + // target.endTag("execJS"); + // } + // jsExecQueue = null; + // } // Window position target.addVariable(this, "positionx", getPositionX()); @@ -645,53 +648,54 @@ public class Window extends Panel implements URIHandler, ParameterHandler, // Window closing target.addVariable(this, "close", false); - if (getParent() == null) { - // Paint subwindows - for (final Iterator<Window> i = subwindows.iterator(); i.hasNext();) { - final Window w = i.next(); - w.paint(target); - } - } else { - // mark subwindows - target.addAttribute("sub", true); - } - - // Paint notifications - if (notifications != null) { - target.startTag("notifications"); - for (final Iterator<Notification> it = notifications.iterator(); it - .hasNext();) { - final Notification n = it.next(); - target.startTag("notification"); - if (n.getCaption() != null) { - target.addAttribute("caption", n.getCaption()); - } - if (n.getMessage() != null) { - target.addAttribute("message", n.getMessage()); - } - if (n.getIcon() != null) { - target.addAttribute("icon", n.getIcon()); - } - if (!n.isHtmlContentAllowed()) { - target.addAttribute( - VView.NOTIFICATION_HTML_CONTENT_NOT_ALLOWED, true); - } - target.addAttribute("position", n.getPosition()); - target.addAttribute("delay", n.getDelayMsec()); - if (n.getStyleName() != null) { - target.addAttribute("style", n.getStyleName()); - } - target.endTag("notification"); - } - target.endTag("notifications"); - notifications = null; - } + // if (getParent() == null) { + // // Paint subwindows + // for (final Iterator<Window> i = subwindows.iterator(); i.hasNext();) + // { + // final Window w = i.next(); + // w.paint(target); + // } + // } else { + // // mark subwindows + // target.addAttribute("sub", true); + // } + + // // Paint notifications + // if (notifications != null) { + // target.startTag("notifications"); + // for (final Iterator<Notification> it = notifications.iterator(); it + // .hasNext();) { + // final Notification n = it.next(); + // target.startTag("notification"); + // if (n.getCaption() != null) { + // target.addAttribute("caption", n.getCaption()); + // } + // if (n.getMessage() != null) { + // target.addAttribute("message", n.getMessage()); + // } + // if (n.getIcon() != null) { + // target.addAttribute("icon", n.getIcon()); + // } + // if (!n.isHtmlContentAllowed()) { + // target.addAttribute( + // VView.NOTIFICATION_HTML_CONTENT_NOT_ALLOWED, true); + // } + // target.addAttribute("position", n.getPosition()); + // target.addAttribute("delay", n.getDelayMsec()); + // if (n.getStyleName() != null) { + // target.addAttribute("style", n.getStyleName()); + // } + // target.endTag("notification"); + // } + // target.endTag("notifications"); + // notifications = null; + // } if (pendingFocus != null) { // ensure focused component is still attached to this main window - if (pendingFocus.getWindow() == this - || (pendingFocus.getWindow() != null && pendingFocus - .getWindow().getParent() == this)) { + if (pendingFocus.getRoot() == this + || (pendingFocus.getRoot() != null && pendingFocus + .getRoot().getParent() == this)) { target.addAttribute("focused", pendingFocus); } pendingFocus = null; @@ -713,7 +717,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler, */ public void scrollIntoView(Component component) throws IllegalArgumentException { - if (component.getWindow() != this) { + if (component.getRoot() != this) { throw new IllegalArgumentException( "The component where to scroll must be inside this window."); } @@ -721,405 +725,421 @@ public class Window extends Panel implements URIHandler, ParameterHandler, requestRepaint(); } - /** - * Opens the given resource in this window. The contents of this Window is - * replaced by the {@code Resource}. - * - * @param resource - * the resource to show in this window - */ - public void open(Resource resource) { - synchronized (openList) { - if (!openList.contains(resource)) { - openList.add(new OpenResource(resource, null, -1, -1, - BORDER_DEFAULT)); - } - } - requestRepaint(); - } + // /** + // * Opens the given resource in this window. The contents of this Window is + // * replaced by the {@code Resource}. + // * + // * @param resource + // * the resource to show in this window + // */ + // public void open(Resource resource) { + // synchronized (openList) { + // if (!openList.contains(resource)) { + // openList.add(new OpenResource(resource, null, -1, -1, + // BORDER_DEFAULT)); + // } + // } + // requestRepaint(); + // } /* ********************************************************************* */ - /** - * Opens the given resource in a window with the given name. - * <p> - * The supplied {@code windowName} is used as the target name in a - * window.open call in the client. This means that special values such as - * "_blank", "_self", "_top", "_parent" have special meaning. An empty or - * <code>null</code> window name is also a special case. - * </p> - * <p> - * "", null and "_self" as {@code windowName} all causes the resource to be - * opened in the current window, replacing any old contents. For - * downloadable content you should avoid "_self" as "_self" causes the - * client to skip rendering of any other changes as it considers them - * irrelevant (the page will be replaced by the resource). This can speed up - * the opening of a resource, but it might also put the client side into an - * inconsistent state if the window content is not completely replaced e.g., - * if the resource is downloaded instead of displayed in the browser. - * </p> - * <p> - * "_blank" as {@code windowName} causes the resource to always be opened in - * a new window or tab (depends on the browser and browser settings). - * </p> - * <p> - * "_top" and "_parent" as {@code windowName} works as specified by the HTML - * standard. - * </p> - * <p> - * Any other {@code windowName} will open the resource in a window with that - * name, either by opening a new window/tab in the browser or by replacing - * the contents of an existing window with that name. - * </p> - * - * @param resource - * the resource. - * @param windowName - * the name of the window. - */ - public void open(Resource resource, String windowName) { - synchronized (openList) { - if (!openList.contains(resource)) { - openList.add(new OpenResource(resource, windowName, -1, -1, - BORDER_DEFAULT)); - } - } - requestRepaint(); - } - - /** - * Opens the given resource in a window with the given size, border and - * name. For more information on the meaning of {@code windowName}, see - * {@link #open(Resource, String)}. - * - * @param resource - * the resource. - * @param windowName - * the name of the window. - * @param width - * the width of the window in pixels - * @param height - * the height of the window in pixels - * @param border - * the border style of the window. See {@link #BORDER_NONE - * Window.BORDER_* constants} - */ - public void open(Resource resource, String windowName, int width, - int height, int border) { - synchronized (openList) { - if (!openList.contains(resource)) { - openList.add(new OpenResource(resource, windowName, width, - height, border)); - } - } - requestRepaint(); - } + // /** + // * Opens the given resource in a window with the given name. + // * <p> + // * The supplied {@code windowName} is used as the target name in a + // * window.open call in the client. This means that special values such as + // * "_blank", "_self", "_top", "_parent" have special meaning. An empty or + // * <code>null</code> window name is also a special case. + // * </p> + // * <p> + // * "", null and "_self" as {@code windowName} all causes the resource to + // be + // * opened in the current window, replacing any old contents. For + // * downloadable content you should avoid "_self" as "_self" causes the + // * client to skip rendering of any other changes as it considers them + // * irrelevant (the page will be replaced by the resource). This can speed + // up + // * the opening of a resource, but it might also put the client side into + // an + // * inconsistent state if the window content is not completely replaced + // e.g., + // * if the resource is downloaded instead of displayed in the browser. + // * </p> + // * <p> + // * "_blank" as {@code windowName} causes the resource to always be opened + // in + // * a new window or tab (depends on the browser and browser settings). + // * </p> + // * <p> + // * "_top" and "_parent" as {@code windowName} works as specified by the + // HTML + // * standard. + // * </p> + // * <p> + // * Any other {@code windowName} will open the resource in a window with + // that + // * name, either by opening a new window/tab in the browser or by replacing + // * the contents of an existing window with that name. + // * </p> + // * + // * @param resource + // * the resource. + // * @param windowName + // * the name of the window. + // */ + // public void open(Resource resource, String windowName) { + // synchronized (openList) { + // if (!openList.contains(resource)) { + // openList.add(new OpenResource(resource, windowName, -1, -1, + // BORDER_DEFAULT)); + // } + // } + // requestRepaint(); + // } + + // /** + // * Opens the given resource in a window with the given size, border and + // * name. For more information on the meaning of {@code windowName}, see + // * {@link #open(Resource, String)}. + // * + // * @param resource + // * the resource. + // * @param windowName + // * the name of the window. + // * @param width + // * the width of the window in pixels + // * @param height + // * the height of the window in pixels + // * @param border + // * the border style of the window. See {@link #BORDER_NONE + // * Window.BORDER_* constants} + // */ + // public void open(Resource resource, String windowName, int width, + // int height, int border) { + // synchronized (openList) { + // if (!openList.contains(resource)) { + // openList.add(new OpenResource(resource, windowName, width, + // height, border)); + // } + // } + // requestRepaint(); + // } /* ********************************************************************* */ - /** - * Gets the full URL of the window. The returned URL is window specific and - * can be used to directly refer to the window. - * <p> - * Note! This method can not be used for portlets. - * </p> - * - * @return the URL of the window or null if the window is not attached to an - * application - */ - public URL getURL() { - - if (application == null) { - return null; - } - - try { - return new URL(application.getURL(), getName() + "/"); - } catch (final MalformedURLException e) { - throw new RuntimeException( - "Internal problem getting window URL, please report"); - } - } - - /** - * <b>Application window only</b>. Gets the unique name of the window. The - * name of the window is used to uniquely identify it. - * <p> - * The name also determines the URL that can be used for direct access to a - * window. All windows can be accessed through - * {@code http://host:port/app/win} where {@code http://host:port/app} is - * the application URL (as returned by {@link Application#getURL()} and - * {@code win} is the window name. - * </p> - * <p> - * Note! Portlets do not support direct window access through URLs. - * </p> - * - * @return the Name of the Window. - */ - public String getName() { - return name; - } - - /** - * Returns the border style of the window. - * - * @see #setBorder(int) - * @return the border style for the window - */ - public int getBorder() { - return border; - } - - /** - * Sets the border style for this window. Valid values are - * {@link Window#BORDER_NONE}, {@link Window#BORDER_MINIMAL}, - * {@link Window#BORDER_DEFAULT}. - * <p> - * <b>Note!</b> Setting this seems to currently have no effect whatsoever on - * the window. - * </p> - * - * @param border - * the border style to set - */ - public void setBorder(int border) { - this.border = border; - } - - /** - * Sets the application this window is attached to. - * - * <p> - * This method is called by the framework and should not be called directly - * from application code. {@link com.vaadin.Application#addWindow(Window)} - * should be used to add the window to an application and - * {@link com.vaadin.Application#removeWindow(Window)} to remove the window - * from the application. - * </p> - * <p> - * This method invokes {@link Component#attach()} and - * {@link Component#detach()} methods when necessary. - * <p> - * - * @param application - * the application the window is attached to - */ - public void setApplication(Application application) { - - // If the application is not changed, dont do nothing - if (application == this.application) { - return; - } - - // Sends detach event if the window is connected to application - if (this.application != null) { - detach(); - } - - // Connects to new parent - this.application = application; - - // Sends the attach event if connected to a window - if (application != null) { - attach(); - } - } - - /** - * <b>Application window only</b>. Sets the unique name of the window. The - * name of the window is used to uniquely identify it inside the - * application. - * <p> - * The name also determines the URL that can be used for direct access to a - * window. All windows can be accessed through - * {@code http://host:port/app/win} where {@code http://host:port/app} is - * the application URL (as returned by {@link Application#getURL()} and - * {@code win} is the window name. - * </p> - * <p> - * This method can only be called before the window is added to an - * application. - * </p> - * <p> - * Note! Portlets do not support direct window access through URLs. - * </p> - * - * @param name - * the new name for the window or null if the application should - * automatically assign a name to it - * @throws IllegalStateException - * if the window is attached to an application - */ - public void setName(String name) throws IllegalStateException { - - // The name can not be changed in application - if (getApplication() != null) { - throw new IllegalStateException( - "Window name can not be changed while " - + "the window is in application"); - } - - this.name = name; - } - - /** - * Sets the user terminal. Used by the terminal adapter, should never be - * called from application code. - * - * @param type - * the terminal to set. - */ - public void setTerminal(Terminal type) { - terminal = type; - } - - /** - * Private class for storing properties related to opening resources. - */ - private class OpenResource implements Serializable { - - /** - * The resource to open - */ - private final Resource resource; - - /** - * The name of the target window - */ - private final String name; - - /** - * The width of the target window - */ - private final int width; - - /** - * The height of the target window - */ - private final int height; - - /** - * The border style of the target window - */ - private final int border; - - /** - * Creates a new open resource. - * - * @param resource - * The resource to open - * @param name - * The name of the target window - * @param width - * The width of the target window - * @param height - * The height of the target window - * @param border - * The border style of the target window - */ - private OpenResource(Resource resource, String name, int width, - int height, int border) { - this.resource = resource; - this.name = name; - this.width = width; - this.height = height; - this.border = border; - } - - /** - * Paints the open request. Should be painted inside the window. - * - * @param target - * the paint target - * @throws PaintException - * if the paint operation fails - */ - private void paintContent(PaintTarget target) throws PaintException { - target.startTag("open"); - target.addAttribute("src", resource); - if (name != null && name.length() > 0) { - target.addAttribute("name", name); - } - if (width >= 0) { - target.addAttribute("width", width); - } - if (height >= 0) { - target.addAttribute("height", height); - } - switch (border) { - case Window.BORDER_MINIMAL: - target.addAttribute("border", "minimal"); - break; - case Window.BORDER_NONE: - target.addAttribute("border", "none"); - break; - } - - target.endTag("open"); - } - } - - /* - * (non-Javadoc) - * - * @see com.vaadin.ui.Panel#changeVariables(java.lang.Object, java.util.Map) - */ - @Override - public void changeVariables(Object source, Map<String, Object> variables) { - - boolean sizeHasChanged = false; - // size is handled in super class, but resize events only in windows -> - // so detect if size change occurs before super.changeVariables() - if (variables.containsKey("height") - && (getHeightUnits() != UNITS_PIXELS || (Integer) variables - .get("height") != getHeight())) { - sizeHasChanged = true; - } - if (variables.containsKey("width") - && (getWidthUnits() != UNITS_PIXELS || (Integer) variables - .get("width") != getWidth())) { - sizeHasChanged = true; - } - - super.changeVariables(source, variables); - - // Positioning - final Integer positionx = (Integer) variables.get("positionx"); - if (positionx != null) { - final int x = positionx.intValue(); - // This is information from the client so it is already using the - // position. No need to repaint. - setPositionX(x < 0 ? -1 : x, false); - } - final Integer positiony = (Integer) variables.get("positiony"); - if (positiony != null) { - final int y = positiony.intValue(); - // This is information from the client so it is already using the - // position. No need to repaint. - setPositionY(y < 0 ? -1 : y, false); - } - - if (isClosable()) { - // Closing - final Boolean close = (Boolean) variables.get("close"); - if (close != null && close.booleanValue()) { - close(); - } - } - - // fire event if size has really changed - if (sizeHasChanged) { - fireResize(); - } - - if (variables.containsKey(FocusEvent.EVENT_ID)) { - fireEvent(new FocusEvent(this)); - } else if (variables.containsKey(BlurEvent.EVENT_ID)) { - fireEvent(new BlurEvent(this)); - } - - } + // /** + // * Gets the full URL of the window. The returned URL is window specific + // and + // * can be used to directly refer to the window. + // * <p> + // * Note! This method can not be used for portlets. + // * </p> + // * + // * @return the URL of the window or null if the window is not attached to + // an + // * application + // */ + // public URL getURL() { + // + // if (application == null) { + // return null; + // } + // + // try { + // return new URL(application.getURL(), getName() + "/"); + // } catch (final MalformedURLException e) { + // throw new RuntimeException( + // "Internal problem getting window URL, please report"); + // } + // } + + // /** + // * <b>Application window only</b>. Gets the unique name of the window. The + // * name of the window is used to uniquely identify it. + // * <p> + // * The name also determines the URL that can be used for direct access to + // a + // * window. All windows can be accessed through + // * {@code http://host:port/app/win} where {@code http://host:port/app} is + // * the application URL (as returned by {@link Application#getURL()} and + // * {@code win} is the window name. + // * </p> + // * <p> + // * Note! Portlets do not support direct window access through URLs. + // * </p> + // * + // * @return the Name of the Window. + // */ + // public String getName() { + // return name; + // } + + // /** + // * Returns the border style of the window. + // * + // * @see #setBorder(int) + // * @return the border style for the window + // */ + // public int getBorder() { + // return border; + // } + + // /** + // * Sets the border style for this window. Valid values are + // * {@link Window#BORDER_NONE}, {@link Window#BORDER_MINIMAL}, + // * {@link Window#BORDER_DEFAULT}. + // * <p> + // * <b>Note!</b> Setting this seems to currently have no effect whatsoever + // on + // * the window. + // * </p> + // * + // * @param border + // * the border style to set + // */ + // public void setBorder(int border) { + // this.border = border; + // } + + // /** + // * Sets the application this window is attached to. + // * + // * <p> + // * This method is called by the framework and should not be called + // directly + // * from application code. {@link com.vaadin.Application#addWindow(Window)} + // * should be used to add the window to an application and + // * {@link com.vaadin.Application#removeWindow(Window)} to remove the + // window + // * from the application. + // * </p> + // * <p> + // * This method invokes {@link Component#attach()} and + // * {@link Component#detach()} methods when necessary. + // * <p> + // * + // * @param application + // * the application the window is attached to + // */ + // public void setApplication(Application application) { + // + // // If the application is not changed, dont do nothing + // if (application == this.application) { + // return; + // } + // + // // Sends detach event if the window is connected to application + // if (this.application != null) { + // detach(); + // } + // + // // Connects to new parent + // this.application = application; + // + // // Sends the attach event if connected to a window + // if (application != null) { + // attach(); + // } + // } + + // /** + // * <b>Application window only</b>. Sets the unique name of the window. The + // * name of the window is used to uniquely identify it inside the + // * application. + // * <p> + // * The name also determines the URL that can be used for direct access to + // a + // * window. All windows can be accessed through + // * {@code http://host:port/app/win} where {@code http://host:port/app} is + // * the application URL (as returned by {@link Application#getURL()} and + // * {@code win} is the window name. + // * </p> + // * <p> + // * This method can only be called before the window is added to an + // * application. + // * </p> + // * <p> + // * Note! Portlets do not support direct window access through URLs. + // * </p> + // * + // * @param name + // * the new name for the window or null if the application should + // * automatically assign a name to it + // * @throws IllegalStateException + // * if the window is attached to an application + // */ + // public void setName(String name) throws IllegalStateException { + // + // // The name can not be changed in application + // if (getApplication() != null) { + // throw new IllegalStateException( + // "Window name can not be changed while " + // + "the window is in application"); + // } + // + // this.name = name; + // } + + // /** + // * Sets the user terminal. Used by the terminal adapter, should never be + // * called from application code. + // * + // * @param type + // * the terminal to set. + // */ + // public void setTerminal(Terminal type) { + // terminal = type; + // } + + // /** + // * Private class for storing properties related to opening resources. + // */ + // private class OpenResource implements Serializable { + // + // /** + // * The resource to open + // */ + // private final Resource resource; + // + // /** + // * The name of the target window + // */ + // private final String name; + // + // /** + // * The width of the target window + // */ + // private final int width; + // + // /** + // * The height of the target window + // */ + // private final int height; + // + // /** + // * The border style of the target window + // */ + // private final int border; + // + // /** + // * Creates a new open resource. + // * + // * @param resource + // * The resource to open + // * @param name + // * The name of the target window + // * @param width + // * The width of the target window + // * @param height + // * The height of the target window + // * @param border + // * The border style of the target window + // */ + // private OpenResource(Resource resource, String name, int width, + // int height, int border) { + // this.resource = resource; + // this.name = name; + // this.width = width; + // this.height = height; + // this.border = border; + // } + // + // /** + // * Paints the open request. Should be painted inside the window. + // * + // * @param target + // * the paint target + // * @throws PaintException + // * if the paint operation fails + // */ + // private void paintContent(PaintTarget target) throws PaintException { + // target.startTag("open"); + // target.addAttribute("src", resource); + // if (name != null && name.length() > 0) { + // target.addAttribute("name", name); + // } + // if (width >= 0) { + // target.addAttribute("width", width); + // } + // if (height >= 0) { + // target.addAttribute("height", height); + // } + // switch (border) { + // case Window.BORDER_MINIMAL: + // target.addAttribute("border", "minimal"); + // break; + // case Window.BORDER_NONE: + // target.addAttribute("border", "none"); + // break; + // } + // + // target.endTag("open"); + // } + // } + // + // /* + // * (non-Javadoc) + // * + // * @see com.vaadin.ui.Panel#changeVariables(java.lang.Object, + // java.util.Map) + // */ + // @Override + // public void changeVariables(Object source, Map<String, Object> variables) + // { + // + // boolean sizeHasChanged = false; + // // size is handled in super class, but resize events only in windows -> + // // so detect if size change occurs before super.changeVariables() + // if (variables.containsKey("height") + // && (getHeightUnits() != UNITS_PIXELS || (Integer) variables + // .get("height") != getHeight())) { + // sizeHasChanged = true; + // } + // if (variables.containsKey("width") + // && (getWidthUnits() != UNITS_PIXELS || (Integer) variables + // .get("width") != getWidth())) { + // sizeHasChanged = true; + // } + // + // super.changeVariables(source, variables); + // + // // Positioning + // final Integer positionx = (Integer) variables.get("positionx"); + // if (positionx != null) { + // final int x = positionx.intValue(); + // // This is information from the client so it is already using the + // // position. No need to repaint. + // setPositionX(x < 0 ? -1 : x, false); + // } + // final Integer positiony = (Integer) variables.get("positiony"); + // if (positiony != null) { + // final int y = positiony.intValue(); + // // This is information from the client so it is already using the + // // position. No need to repaint. + // setPositionY(y < 0 ? -1 : y, false); + // } + // + // if (isClosable()) { + // // Closing + // final Boolean close = (Boolean) variables.get("close"); + // if (close != null && close.booleanValue()) { + // close(); + // } + // } + // + // // fire event if size has really changed + // if (sizeHasChanged) { + // fireResize(); + // } + // + // if (variables.containsKey(FocusEvent.EVENT_ID)) { + // fireEvent(new FocusEvent(this)); + // } else if (variables.containsKey(BlurEvent.EVENT_ID)) { + // fireEvent(new BlurEvent(this)); + // } + // + // } /** * Method that handles window closing (from UI). @@ -1138,7 +1158,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler, * </p> */ protected void close() { - Window parent = getParent(); + Window parent = (Window) getParent(); if (parent == null) { fireClose(); } else { @@ -1411,53 +1431,54 @@ public class Window extends Panel implements URIHandler, ParameterHandler, fireEvent(new ResizeEvent(this)); } - private void attachWindow(Window w) { - subwindows.add(w); - w.setParent(this); - requestRepaint(); - } - - /** - * Adds a window inside another window. - * - * <p> - * Adding windows inside another window creates "subwindows". These windows - * should not be added to application directly and are not accessible - * directly with any url. Addding windows implicitly sets their parents. - * </p> - * - * <p> - * Only one level of subwindows are supported. Thus you can add windows - * inside such windows whose parent is <code>null</code>. - * </p> - * - * @param window - * @throws IllegalArgumentException - * if a window is added inside non-application level window. - * @throws NullPointerException - * if the given <code>Window</code> is <code>null</code>. - */ - public void addWindow(Window window) throws IllegalArgumentException, - NullPointerException { - - if (window == null) { - throw new NullPointerException("Argument must not be null"); - } - - if (window.getApplication() != null) { - throw new IllegalArgumentException( - "Window was already added to application" - + " - it can not be added to another window also."); - } else if (getParent() != null) { - throw new IllegalArgumentException( - "You can only add windows inside application-level windows."); - } else if (window.subwindows.size() > 0) { - throw new IllegalArgumentException( - "Only one level of subwindows are supported."); - } - - attachWindow(window); - } + // private void attachWindow(Window w) { + // // subwindows.add(w); + // w.setParent(this); + // requestRepaint(); + // } + + // /** + // * Adds a window inside another window. + // * + // * <p> + // * Adding windows inside another window creates "subwindows". These + // windows + // * should not be added to application directly and are not accessible + // * directly with any url. Addding windows implicitly sets their parents. + // * </p> + // * + // * <p> + // * Only one level of subwindows are supported. Thus you can add windows + // * inside such windows whose parent is <code>null</code>. + // * </p> + // * + // * @param window + // * @throws IllegalArgumentException + // * if a window is added inside non-application level window. + // * @throws NullPointerException + // * if the given <code>Window</code> is <code>null</code>. + // */ + // public void addWindow(Window window) throws IllegalArgumentException, + // NullPointerException { + // + // if (window == null) { + // throw new NullPointerException("Argument must not be null"); + // } + // + // if (window.getApplication() != null) { + // throw new IllegalArgumentException( + // "Window was already added to application" + // + " - it can not be added to another window also."); + // } else if (getParent() != null) { + // throw new IllegalArgumentException( + // "You can only add windows inside application-level windows."); + // } else if (window.subwindows.size() > 0) { + // throw new IllegalArgumentException( + // "Only one level of subwindows are supported."); + // } + // + // attachWindow(window); + // } /** * Remove the given subwindow from this window. @@ -1473,10 +1494,10 @@ public class Window extends Panel implements URIHandler, ParameterHandler, * @return true if the subwindow was removed, false otherwise */ public boolean removeWindow(Window window) { - if (!subwindows.remove(window)) { - // Window window is not a subwindow of this window. - return false; - } + // if (!subwindows.remove(window)) { + // // Window window is not a subwindow of this window. + // return false; + // } window.setParent(null); window.fireClose(); requestRepaint(); @@ -1493,44 +1514,47 @@ public class Window extends Panel implements URIHandler, ParameterHandler, * (depends on the order getting to dirty list. e.g. which window got * variable changes). */ - private int bringToFrontSequence = 0; - - /** - * If there are currently several sub windows visible, calling this method - * makes this window topmost. - * <p> - * This method can only be called if this window is a sub window and - * connected a top level window. Else an illegal state exception is thrown. - * Also if there are modal windows and this window is not modal, and illegal - * state exception is thrown. - * <p> - * <strong> Note, this API works on sub windows only. Browsers can't reorder - * OS windows.</strong> - */ - public void bringToFront() { - Window parent = getParent(); - if (parent == null) { - throw new IllegalStateException( - "Window must be attached to parent before calling bringToFront method."); - } - for (Window w : parent.getChildWindows()) { - if (w.isModal() && !isModal()) { - throw new IllegalStateException( - "There are modal windows currently visible, non-modal window cannot be brought to front."); - } - } - bringToFront = getParent().bringToFrontSequence++; - requestRepaint(); - } - - /** - * Get the set of all child windows. - * - * @return Set of child windows. - */ - public Set<Window> getChildWindows() { - return Collections.unmodifiableSet(subwindows); - } + // private int bringToFrontSequence = 0; + + // /** + // * If there are currently several sub windows visible, calling this method + // * makes this window topmost. + // * <p> + // * This method can only be called if this window is a sub window and + // * connected a top level window. Else an illegal state exception is + // thrown. + // * Also if there are modal windows and this window is not modal, and + // illegal + // * state exception is thrown. + // * <p> + // * <strong> Note, this API works on sub windows only. Browsers can't + // reorder + // * OS windows.</strong> + // */ + // public void bringToFront() { + // Window parent = getParent(); + // if (parent == null) { + // throw new IllegalStateException( + // "Window must be attached to parent before calling bringToFront method."); + // } + // for (Window w : parent.getChildWindows()) { + // if (w.isModal() && !isModal()) { + // throw new IllegalStateException( + // "There are modal windows currently visible, non-modal window cannot be brought to front."); + // } + // } + // bringToFront = getParent().bringToFrontSequence++; + // requestRepaint(); + // } + + // /** + // * Get the set of all child windows. + // * + // * @return Set of child windows. + // */ + // public Set<Window> getChildWindows() { + // return Collections.unmodifiableSet(subwindows); + // } /** * Sets sub-window modal, so that widgets behind it cannot be accessed. @@ -1606,161 +1630,165 @@ public class Window extends Panel implements URIHandler, ParameterHandler, requestRepaint(); } - /** - * Shows a notification message on the middle of the window. The message - * automatically disappears ("humanized message"). - * - * Care should be taken to to avoid XSS vulnerabilities as the caption is - * rendered as html. - * - * @see #showNotification(com.vaadin.ui.Window.Notification) - * @see Notification - * - * @param caption - * The message - */ - public void showNotification(String caption) { - addNotification(new Notification(caption)); - } - - /** - * Shows a notification message the window. The position and behavior of the - * message depends on the type, which is one of the basic types defined in - * {@link Notification}, for instance Notification.TYPE_WARNING_MESSAGE. - * - * Care should be taken to to avoid XSS vulnerabilities as the caption is - * rendered as html. - * - * @see #showNotification(com.vaadin.ui.Window.Notification) - * @see Notification - * - * @param caption - * The message - * @param type - * The message type - */ - public void showNotification(String caption, int type) { - addNotification(new Notification(caption, type)); - } - - /** - * Shows a notification consisting of a bigger caption and a smaller - * description on the middle of the window. The message automatically - * disappears ("humanized message"). - * - * Care should be taken to to avoid XSS vulnerabilities as the caption and - * description are rendered as html. - * - * @see #showNotification(com.vaadin.ui.Window.Notification) - * @see Notification - * - * @param caption - * The caption of the message - * @param description - * The message description - * - */ - public void showNotification(String caption, String description) { - addNotification(new Notification(caption, description)); - } - - /** - * Shows a notification consisting of a bigger caption and a smaller - * description. The position and behavior of the message depends on the - * type, which is one of the basic types defined in {@link Notification}, - * for instance Notification.TYPE_WARNING_MESSAGE. - * - * Care should be taken to to avoid XSS vulnerabilities as the caption and - * description are rendered as html. - * - * @see #showNotification(com.vaadin.ui.Window.Notification) - * @see Notification - * - * @param caption - * The caption of the message - * @param description - * The message description - * @param type - * The message type - */ - public void showNotification(String caption, String description, int type) { - addNotification(new Notification(caption, description, type)); - } - - /** - * Shows a notification consisting of a bigger caption and a smaller - * description. The position and behavior of the message depends on the - * type, which is one of the basic types defined in {@link Notification}, - * for instance Notification.TYPE_WARNING_MESSAGE. - * - * Care should be taken to avoid XSS vulnerabilities if html content is - * allowed. - * - * @see #showNotification(com.vaadin.ui.Window.Notification) - * @see Notification - * - * @param caption - * The message caption - * @param description - * The message description - * @param type - * The type of message - * @param htmlContentAllowed - * Whether html in the caption and description should be - * displayed as html or as plain text - */ - public void showNotification(String caption, String description, int type, - boolean htmlContentAllowed) { - addNotification(new Notification(caption, description, type, - htmlContentAllowed)); - } - - /** - * Shows a notification message. - * - * @see Notification - * @see #showNotification(String) - * @see #showNotification(String, int) - * @see #showNotification(String, String) - * @see #showNotification(String, String, int) - * - * @param notification - * The notification message to show - */ - public void showNotification(Notification notification) { - addNotification(notification); - } - - private void addNotification(Notification notification) { - if (notifications == null) { - notifications = new LinkedList<Notification>(); - } - notifications.add(notification); - requestRepaint(); - } - - /** - * This method is used by Component.Focusable objects to request focus to - * themselves. Focus renders must be handled at window level (instead of - * Component.Focusable) due we want the last focused component to be focused - * in client too. Not the one that is rendered last (the case we'd get if - * implemented in Focusable only). - * - * To focus component from Vaadin application, use Focusable.focus(). See - * {@link Focusable}. - * - * @param focusable - * to be focused on next paint - */ - void setFocusedComponent(Focusable focusable) { - if (getParent() != null) { - // focus is handled by main windows - (getParent()).setFocusedComponent(focusable); - } else { - pendingFocus = focusable; - requestRepaint(); - } - } + // /** + // * Shows a notification message on the middle of the window. The message + // * automatically disappears ("humanized message"). + // * + // * Care should be taken to to avoid XSS vulnerabilities as the caption is + // * rendered as html. + // * + // * @see #showNotification(com.vaadin.ui.Window.Notification) + // * @see Notification + // * + // * @param caption + // * The message + // */ + // public void showNotification(String caption) { + // addNotification(new Notification(caption)); + // } + + // /** + // * Shows a notification message the window. The position and behavior of + // the + // * message depends on the type, which is one of the basic types defined in + // * {@link Notification}, for instance Notification.TYPE_WARNING_MESSAGE. + // * + // * Care should be taken to to avoid XSS vulnerabilities as the caption is + // * rendered as html. + // * + // * @see #showNotification(com.vaadin.ui.Window.Notification) + // * @see Notification + // * + // * @param caption + // * The message + // * @param type + // * The message type + // */ + // public void showNotification(String caption, int type) { + // addNotification(new Notification(caption, type)); + // } + + // /** + // * Shows a notification consisting of a bigger caption and a smaller + // * description on the middle of the window. The message automatically + // * disappears ("humanized message"). + // * + // * Care should be taken to to avoid XSS vulnerabilities as the caption and + // * description are rendered as html. + // * + // * @see #showNotification(com.vaadin.ui.Window.Notification) + // * @see Notification + // * + // * @param caption + // * The caption of the message + // * @param description + // * The message description + // * + // */ + // public void showNotification(String caption, String description) { + // addNotification(new Notification(caption, description)); + // } + + // /** + // * Shows a notification consisting of a bigger caption and a smaller + // * description. The position and behavior of the message depends on the + // * type, which is one of the basic types defined in {@link Notification}, + // * for instance Notification.TYPE_WARNING_MESSAGE. + // * + // * Care should be taken to to avoid XSS vulnerabilities as the caption and + // * description are rendered as html. + // * + // * @see #showNotification(com.vaadin.ui.Window.Notification) + // * @see Notification + // * + // * @param caption + // * The caption of the message + // * @param description + // * The message description + // * @param type + // * The message type + // */ + // public void showNotification(String caption, String description, int + // type) { + // addNotification(new Notification(caption, description, type)); + // } + + // /** + // * Shows a notification consisting of a bigger caption and a smaller + // * description. The position and behavior of the message depends on the + // * type, which is one of the basic types defined in {@link Notification}, + // * for instance Notification.TYPE_WARNING_MESSAGE. + // * + // * Care should be taken to avoid XSS vulnerabilities if html content is + // * allowed. + // * + // * @see #showNotification(com.vaadin.ui.Window.Notification) + // * @see Notification + // * + // * @param caption + // * The message caption + // * @param description + // * The message description + // * @param type + // * The type of message + // * @param htmlContentAllowed + // * Whether html in the caption and description should be + // * displayed as html or as plain text + // */ + // public void showNotification(String caption, String description, int + // type, + // boolean htmlContentAllowed) { + // addNotification(new Notification(caption, description, type, + // htmlContentAllowed)); + // } + + // /** + // * Shows a notification message. + // * + // * @see Notification + // * @see #showNotification(String) + // * @see #showNotification(String, int) + // * @see #showNotification(String, String) + // * @see #showNotification(String, String, int) + // * + // * @param notification + // * The notification message to show + // */ + // public void showNotification(Notification notification) { + // addNotification(notification); + // } + // + // private void addNotification(Notification notification) { + // if (notifications == null) { + // notifications = new LinkedList<Notification>(); + // } + // notifications.add(notification); + // requestRepaint(); + // } + + // /** + // * This method is used by Component.Focusable objects to request focus to + // * themselves. Focus renders must be handled at window level (instead of + // * Component.Focusable) due we want the last focused component to be + // focused + // * in client too. Not the one that is rendered last (the case we'd get if + // * implemented in Focusable only). + // * + // * To focus component from Vaadin application, use Focusable.focus(). See + // * {@link Focusable}. + // * + // * @param focusable + // * to be focused on next paint + // */ + // void setFocusedComponent(Focusable focusable) { + // if (getParent() != null) { + // // focus is handled by main windows + // (getParent()).setFocusedComponent(focusable); + // } else { + // pendingFocus = focusable; + // requestRepaint(); + // } + // } /** * A notification message, used to display temporary messages to the user - @@ -2097,41 +2125,44 @@ public class Window extends Panel implements URIHandler, ParameterHandler, } } - /** - * Executes JavaScript in this window. - * - * <p> - * This method allows one to inject javascript from the server to client. A - * client implementation is not required to implement this functionality, - * but currently all web-based clients do implement this. - * </p> - * - * <p> - * Executing javascript this way often leads to cross-browser compatibility - * issues and regressions that are hard to resolve. Use of this method - * should be avoided and instead it is recommended to create new widgets - * with GWT. For more info on creating own, reusable client-side widgets in - * Java, read the corresponding chapter in Book of Vaadin. - * </p> - * - * @param script - * JavaScript snippet that will be executed. - */ - public void executeJavaScript(String script) { - - if (getParent() != null) { - throw new UnsupportedOperationException( - "Only application level windows can execute javascript."); - } - - if (jsExecQueue == null) { - jsExecQueue = new ArrayList<String>(); - } - - jsExecQueue.add(script); - - requestRepaint(); - } + // /** + // * Executes JavaScript in this window. + // * + // * <p> + // * This method allows one to inject javascript from the server to client. + // A + // * client implementation is not required to implement this functionality, + // * but currently all web-based clients do implement this. + // * </p> + // * + // * <p> + // * Executing javascript this way often leads to cross-browser + // compatibility + // * issues and regressions that are hard to resolve. Use of this method + // * should be avoided and instead it is recommended to create new widgets + // * with GWT. For more info on creating own, reusable client-side widgets + // in + // * Java, read the corresponding chapter in Book of Vaadin. + // * </p> + // * + // * @param script + // * JavaScript snippet that will be executed. + // */ + // public void executeJavaScript(String script) { + // + // if (getParent() != null) { + // throw new UnsupportedOperationException( + // "Only application level windows can execute javascript."); + // } + // + // if (jsExecQueue == null) { + // jsExecQueue = new ArrayList<String>(); + // } + // + // jsExecQueue.add(script); + // + // requestRepaint(); + // } /** * Returns the closable status of the sub window. If a sub window is @@ -2334,24 +2365,24 @@ public class Window extends Panel implements URIHandler, ParameterHandler, removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); } - /** - * {@inheritDoc} - * - * If the window is a sub-window focusing will cause the sub-window to be - * brought on top of other sub-windows on gain keyboard focus. - */ - @Override - public void focus() { - if (getParent() != null) { - /* - * When focusing a sub-window it basically means it should be - * brought to the front. Instead of just moving the keyboard focus - * we focus the window and bring it top-most. - */ - bringToFront(); - } else { - super.focus(); - } - } + // /** + // * {@inheritDoc} + // * + // * If the window is a sub-window focusing will cause the sub-window to be + // * brought on top of other sub-windows on gain keyboard focus. + // */ + // @Override + // public void focus() { + // if (getParent() != null) { + // /* + // * When focusing a sub-window it basically means it should be + // * brought to the front. Instead of just moving the keyboard focus + // * we focus the window and bring it top-most. + // */ + // bringToFront(); + // } else { + // super.focus(); + // } + // } } |