/** * Adds a new browser level window to this application. * * @param uI * the UI window to add to the application */ public void addWindow(LegacyWindow uI) { if (uI.getName() == null) { String name = Integer.toString(namelessUIIndex++); uI.setName(name); } uI.setApplication(this); legacyUINames.put(uI.getName(), uI); uI.setSession(VaadinSession.getCurrent()); }
/** * Opens the given resource in this UI. The contents of this UI is replaced * by the {@code Resource}. * * @param resource * the resource to show in this UI * * @deprecated As of 7.0, use getPage().setLocation instead */ @Deprecated public void open(Resource resource) { open(resource, null, false); }
/** * Gets the last known height of the browser window in which this UI * resides. * * @return the browser window height in pixels * @deprecated As of 7.0, use the similarly named api in Page instead */ @Deprecated public int getBrowserWindowHeight() { return getPage().getBrowserWindowHeight(); }
/** * 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() { LegacyApplication application = getApplication(); if (application == null) { return null; } try { return new URL(application.getURL(), getName() + "/"); } catch (MalformedURLException e) { throw new RuntimeException( "Internal problem getting window URL, please report"); } }
public void close() { isRunning = false; Collection<LegacyWindow> windows = getWindows(); for (LegacyWindow legacyWindow : windows) { String logoutUrl = getLogoutURL(); if (logoutUrl == null) { URL url = getURL(); if (url != null) { logoutUrl = url.toString(); } } if (logoutUrl != null) { legacyWindow.getPage().setLocation(logoutUrl); } legacyWindow.close(); } }
/** * This implementation replaces a component in the content container ( * {@link #getContent()}) instead of in the actual UI. * * This method should only be called when the content is a * {@link ComponentContainer} (default {@link VerticalLayout} or explicitly * set). */ public void replaceComponent(Component oldComponent, Component newComponent) { getContent().replaceComponent(oldComponent, newComponent); }
/** * Creates a new legacy window with the given caption. * * @param caption * the caption of the window */ public LegacyWindow(String caption) { this(); setCaption(caption); }
this.name = name; if (isAttached()) { throw new IllegalStateException( "Window name can not be changed while "
protected Class<?> getAssociatedClass() { if (associatedClass == null) { UI current = UI.getCurrent(); if (current instanceof LegacyWindow) { LegacyWindow legacyWindow = (LegacyWindow) current; return legacyWindow.getApplication().getClass(); } else { return current.getClass(); } } return associatedClass; }
/** * Removes a {@link BrowserWindowResizeListener} from this UI. The listener * will no longer be notified when the browser window is resized. * * @param resizeListener * the listener to remove * @deprecated As of 7.0, use the similarly named api in Page instead */ @Deprecated public void removeListener(BrowserWindowResizeListener resizeListener) { getPage().removeBrowserWindowResizeListener(resizeListener); }
/** * This implementation removes the component from the content container ( * {@link #getContent()}) instead of from the actual UI. * * This method should only be called when the content is a * {@link ComponentContainer} (default {@link VerticalLayout} or explicitly * set). */ public void removeComponent(Component component) { getContent().removeComponent(component); }
/** * Creates a legacy window with the given caption and content layout. * * @param caption * @param content */ public LegacyWindow(String caption, ComponentContainer content) { super(content); setCaption(caption); }
/** * Sets the main window of this application. Setting window as a main window * of this application also adds the window to this application. * * @param mainWindow * the UI to set as the default window */ public void setMainWindow(LegacyWindow mainWindow) { if (this.mainWindow != null) { throw new IllegalStateException("mainWindow has already been set"); } if (mainWindow.isAttached()) { throw new IllegalStateException( "mainWindow is attached to another application"); } if (UI.getCurrent() == null) { // Assume setting a main window from Application.init if there's // no current UI -> set the main window as the current UI UI.setCurrent(mainWindow); } addWindow(mainWindow); this.mainWindow = mainWindow; }
/** * Gets the last known width of the browser window in which this UI resides. * * @return the browser window width in pixels * * @deprecated As of 7.0, use the similarly named api in Page instead */ @Deprecated public int getBrowserWindowWidth() { return getPage().getBrowserWindowWidth(); }
/** * This implementation removes the components from the content container ( * {@link #getContent()}) instead of from the actual UI. * * This method should only be called when the content is a * {@link ComponentContainer} (default {@link VerticalLayout} or explicitly * set). */ public void removeAllComponents() { getContent().removeAllComponents(); }
open(resource, windowName, true);
/** * Adds a new {@link BrowserWindowResizeListener} to this UI. The listener * will be notified whenever the browser window within which this UI resides * is resized. * * @param resizeListener * the listener to add * * @see BrowserWindowResizeListener#browserWindowResized(com.vaadin.server.Page.BrowserWindowResizeEvent) * BrowserWindowResizeListener#browserWindowResized(BrowserWindowResizeEvent) * @see #setResizeLazy(boolean) * * @deprecated As of 7.0, use the similarly named api in Page instead */ @Deprecated public void addListener(BrowserWindowResizeListener resizeListener) { getPage().addBrowserWindowResizeListener(resizeListener); }
/** * Adds a component to this UI. The component is not added directly to the * UI, but instead to the content container ({@link #getContent()}). * * This method should only be called when the content is a * {@link ComponentContainer} (default {@link VerticalLayout} or explicitly * set). * * @param component * the component to add to this UI * * @see #getContent() */ public void addComponent(Component component) { getContent().addComponent(component); }
/** * 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)}. * <p> * As of Vaadin 7.0.0, the functionality for opening a Resource in a Page * has been replaced with similar methods based on a String URL. This is * because the usage of Resource is problematic with memory management and * with security features in some browsers. Is is recommended to instead use * {@link Link} for starting downloads. * </p> * * @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. * @deprecated As of 7.0, use getPage().open instead */ @Deprecated public void open(Resource resource, String windowName, int width, int height, BorderStyle border) { getPage().open(resource, windowName, width, height, border); }