diff options
author | Johannes Dahlström <johannesd@vaadin.com> | 2012-08-27 12:40:41 +0300 |
---|---|---|
committer | Johannes Dahlström <johannesd@vaadin.com> | 2012-08-27 12:40:41 +0300 |
commit | a67ca492c18451c0f286e90b3a5fb34bde2d3c47 (patch) | |
tree | 77f8879242385bfa6f970bfb129531dd32ce242a /server | |
parent | c8cee295021dcd33982217e3ad1c374bfca63a29 (diff) | |
parent | fc3f7f62b05ae69b242d64084f676d7733962c60 (diff) | |
download | vaadin-framework-a67ca492c18451c0f286e90b3a5fb34bde2d3c47.tar.gz vaadin-framework-a67ca492c18451c0f286e90b3a5fb34bde2d3c47.zip |
Merge branch 'master' into root-cleanup
Rename Root -> UI in root cleanup code
Conflicts:
client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java
server/src/com/vaadin/ui/UI.java
Diffstat (limited to 'server')
96 files changed, 1906 insertions, 2908 deletions
diff --git a/server/src/com/vaadin/Application.java b/server/src/com/vaadin/Application.java index 8efcadb667..bdad94355d 100644 --- a/server/src/com/vaadin/Application.java +++ b/server/src/com/vaadin/Application.java @@ -52,14 +52,14 @@ import com.vaadin.data.util.converter.ConverterFactory; import com.vaadin.data.util.converter.DefaultConverterFactory; import com.vaadin.event.EventRouter; import com.vaadin.service.ApplicationContext; -import com.vaadin.shared.ApplicationConstants; +import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.terminal.AbstractErrorMessage; import com.vaadin.terminal.ApplicationResource; import com.vaadin.terminal.CombinedRequest; import com.vaadin.terminal.DeploymentConfiguration; import com.vaadin.terminal.RequestHandler; -import com.vaadin.terminal.RootProvider; import com.vaadin.terminal.Terminal; +import com.vaadin.terminal.UIProvider; import com.vaadin.terminal.VariableOwner; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.WrappedRequest.BrowserDetails; @@ -75,8 +75,8 @@ import com.vaadin.terminal.gwt.server.WebApplicationContext; import com.vaadin.tools.ReflectTools; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.AbstractField; -import com.vaadin.ui.Root; import com.vaadin.ui.Table; +import com.vaadin.ui.UI; import com.vaadin.ui.Window; /** @@ -135,9 +135,9 @@ public class Application implements Terminal.ErrorListener, Serializable { /** * The name of the parameter that is by default used in e.g. web.xml to - * define the name of the default {@link Root} class. + * define the name of the default {@link UI} class. */ - public static final String ROOT_PARAMETER = "root"; + public static final String UI_PARAMETER = "UI"; private static final Method BOOTSTRAP_FRAGMENT_METHOD = ReflectTools .findMethod(BootstrapListener.class, "modifyBootstrapFragment", @@ -165,19 +165,19 @@ public class Application implements Terminal.ErrorListener, Serializable { private static final Pattern WINDOW_NAME_PATTERN = Pattern .compile("^/?([^/]+).*"); - private Root.LegacyWindow mainWindow; + private UI.LegacyWindow mainWindow; private String theme; - private Map<String, Root.LegacyWindow> legacyRootNames = new HashMap<String, Root.LegacyWindow>(); + private Map<String, UI.LegacyWindow> legacyUINames = new HashMap<String, UI.LegacyWindow>(); /** * 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 root to set as the default window + * the UI to set as the default window */ - public void setMainWindow(Root.LegacyWindow mainWindow) { + public void setMainWindow(UI.LegacyWindow mainWindow) { if (this.mainWindow != null) { throw new IllegalStateException( "mainWindow has already been set"); @@ -202,9 +202,9 @@ public class Application implements Terminal.ErrorListener, Serializable { * Note that each application must have at least one main window. * </p> * - * @return the root used as the default window + * @return the UI used as the default window */ - public Root.LegacyWindow getMainWindow() { + public UI.LegacyWindow getMainWindow() { return mainWindow; } @@ -216,11 +216,11 @@ public class Application implements Terminal.ErrorListener, Serializable { * {@inheritDoc} * * @see #getWindow(String) - * @see Application#getRoot(WrappedRequest) + * @see Application#getUI(WrappedRequest) */ @Override - public Root.LegacyWindow getRoot(WrappedRequest request) { + public UI.LegacyWindow getUI(WrappedRequest request) { String pathInfo = request.getRequestPathInfo(); String name = null; if (pathInfo != null && pathInfo.length() > 0) { @@ -230,7 +230,7 @@ public class Application implements Terminal.ErrorListener, Serializable { name = matcher.group(1); } } - Root.LegacyWindow window = getWindow(name); + UI.LegacyWindow window = getWindow(name); if (window != null) { return window; } @@ -240,8 +240,8 @@ public class Application implements Terminal.ErrorListener, Serializable { /** * Sets the application's theme. * <p> - * Note that this theme can be overridden for a specific root with - * {@link Application#getThemeForRoot(Root)}. Setting theme to be + * Note that this theme can be overridden for a specific UI with + * {@link Application#getThemeForUI(UI)}. Setting theme to be * <code>null</code> selects the default theme. For the available theme * names, see the contents of the VAADIN/themes directory. * </p> @@ -255,7 +255,7 @@ public class Application implements Terminal.ErrorListener, Serializable { /** * Gets the application's theme. The application's theme is the default - * theme used by all the roots for which a theme is not explicitly + * theme used by all the uIs for which a theme is not explicitly * defined. If the application theme is not explicitly set, * <code>null</code> is returned. * @@ -273,70 +273,70 @@ public class Application implements Terminal.ErrorListener, Serializable { */ @Override - public String getThemeForRoot(Root root) { + public String getThemeForUI(UI uI) { return theme; } /** * <p> - * Gets a root by name. Returns <code>null</code> if the application is + * Gets a UI by name. Returns <code>null</code> if the application is * not running or it does not contain a window corresponding to the * name. * </p> * * @param name * the name of the requested window - * @return a root corresponding to the name, or <code>null</code> to use + * @return a UI corresponding to the name, or <code>null</code> to use * the default window */ - public Root.LegacyWindow getWindow(String name) { - return legacyRootNames.get(name); + public UI.LegacyWindow getWindow(String name) { + return legacyUINames.get(name); } /** * Counter to get unique names for windows with no explicit name */ - private int namelessRootIndex = 0; + private int namelessUIIndex = 0; /** * Adds a new browser level window to this application. Please note that - * Root doesn't have a name that is used in the URL - to add a named - * window you should instead use {@link #addWindow(Root, String)} + * UI doesn't have a name that is used in the URL - to add a named + * window you should instead use {@link #addWindow(UI, String)} * - * @param root - * the root window to add to the application + * @param uI + * the UI window to add to the application * @return returns the name that has been assigned to the window * - * @see #addWindow(Root, String) + * @see #addWindow(UI, String) */ - public void addWindow(Root.LegacyWindow root) { - if (root.getName() == null) { - String name = Integer.toString(namelessRootIndex++); - root.setName(name); + public void addWindow(UI.LegacyWindow uI) { + if (uI.getName() == null) { + String name = Integer.toString(namelessUIIndex++); + uI.setName(name); } - legacyRootNames.put(root.getName(), root); - root.setApplication(this); + legacyUINames.put(uI.getName(), uI); + uI.setApplication(this); } /** * Removes the specified window from the application. This also removes - * all name mappings for the window (see - * {@link #addWindow(Root, String) and #getWindowName(Root)}. + * all name mappings for the window (see {@link #addWindow(UI, String) + * and #getWindowName(UI)}. * * <p> * Note that removing window from the application does not close the * browser window - the window is only removed from the server-side. * </p> * - * @param root - * the root to remove + * @param uI + * the UI to remove */ - public void removeWindow(Root.LegacyWindow root) { - for (Entry<String, Root.LegacyWindow> entry : legacyRootNames + public void removeWindow(UI.LegacyWindow uI) { + for (Entry<String, UI.LegacyWindow> entry : legacyUINames .entrySet()) { - if (entry.getValue() == root) { - legacyRootNames.remove(entry.getKey()); + if (entry.getValue() == uI) { + legacyUINames.remove(entry.getKey()); } } } @@ -350,8 +350,8 @@ public class Application implements Terminal.ErrorListener, Serializable { * * @return the unmodifiable collection of windows. */ - public Collection<Root.LegacyWindow> getWindows() { - return Collections.unmodifiableCollection(legacyRootNames.values()); + public Collection<UI.LegacyWindow> getWindows() { + return Collections.unmodifiableCollection(legacyUINames.values()); } } @@ -490,23 +490,23 @@ public class Application implements Terminal.ErrorListener, Serializable { private LinkedList<RequestHandler> requestHandlers = new LinkedList<RequestHandler>(); - private int nextRootId = 0; - private Map<Integer, Root> roots = new HashMap<Integer, Root>(); + private int nextUIId = 0; + private Map<Integer, UI> uIs = new HashMap<Integer, UI>(); - private final Map<String, Integer> retainOnRefreshRoots = new HashMap<String, Integer>(); + private final Map<String, Integer> retainOnRefreshUIs = new HashMap<String, Integer>(); private final EventRouter eventRouter = new EventRouter(); /** - * Keeps track of which roots have been inited. + * Keeps track of which uIs have been inited. * <p> * TODO Investigate whether this might be derived from the different states - * in getRootForRrequest. + * in getUIForRrequest. * </p> */ - private Set<Integer> initedRoots = new HashSet<Integer>(); + private Set<Integer> initedUIs = new HashSet<Integer>(); - private List<RootProvider> rootProviders = new LinkedList<RootProvider>(); + private List<UIProvider> uiProviders = new LinkedList<UIProvider>(); /** * Gets the user of the application. @@ -583,15 +583,15 @@ public class Application implements Terminal.ErrorListener, Serializable { * <p> * In effect this will cause the application stop returning any windows when * asked. When the application is closed, close events are fired for its - * roots, its state is removed from the session, and the browser window is + * UIs, its state is removed from the session, and the browser window is * redirected to the application logout url set with * {@link #setLogoutURL(String)}. If the logout url has not been set, the * browser window is reloaded and the application is restarted. */ public void close() { applicationIsRunning = false; - for (Root root : getRoots()) { - root.fireCloseEvent(); + for (UI ui : getUIs()) { + ui.fireCloseEvent(); } } @@ -1831,110 +1831,108 @@ public class Application implements Terminal.ErrorListener, Serializable { } /** - * Gets a root for a request for which no root is already known. This method - * is called when the framework processes a request that does not originate - * from an existing root instance. This typically happens when a host page - * is requested. + * Gets a UI for a request for which no UI is already known. This method is + * called when the framework processes a request that does not originate + * from an existing UI instance. This typically happens when a host page is + * requested. * * <p> * Subclasses of Application may override this method to provide custom - * logic for choosing how to create a suitable root or for picking an - * already created root. If an existing root is picked, care should be taken - * to avoid keeping the same root open in multiple browser windows, as that - * will cause the states to go out of sync. + * logic for choosing how to create a suitable UI or for picking an already + * created UI. If an existing UI is picked, care should be taken to avoid + * keeping the same UI open in multiple browser windows, as that will cause + * the states to go out of sync. * </p> * * <p> - * If {@link BrowserDetails} are required to create a Root, the - * implementation can throw a {@link RootRequiresMoreInformationException} - * exception. In this case, the framework will instruct the browser to send - * the additional details, whereupon this method is invoked again with the - * browser details present in the wrapped request. Throwing the exception if - * the browser details are already available is not supported. + * If {@link BrowserDetails} are required to create a UI, the implementation + * can throw a {@link UIRequiresMoreInformationException} exception. In this + * case, the framework will instruct the browser to send the additional + * details, whereupon this method is invoked again with the browser details + * present in the wrapped request. Throwing the exception if the browser + * details are already available is not supported. * </p> * * <p> * The default implementation in {@link Application} creates a new instance - * of the Root class returned by {@link #getRootClassName(WrappedRequest)}, - * which in turn uses the {@value #ROOT_PARAMETER} parameter from web.xml. - * If {@link DeploymentConfiguration#getClassLoader()} for the request - * returns a {@link ClassLoader}, it is used for loading the Root class. - * Otherwise the {@link ClassLoader} used to load this class is used. + * of the UI class returned by {@link #getUIClassName(WrappedRequest)}, + * which in turn uses the {@value #UI_PARAMETER} parameter from web.xml. If + * {@link DeploymentConfiguration#getClassLoader()} for the request returns + * a {@link ClassLoader}, it is used for loading the UI class. Otherwise the + * {@link ClassLoader} used to load this class is used. * </p> * * @param request - * the wrapped request for which a root is needed - * @return a root instance to use for the request - * @throws RootRequiresMoreInformationException + * the wrapped request for which a UI is needed + * @return a UI instance to use for the request + * @throws UIRequiresMoreInformationException * may be thrown by an implementation to indicate that - * {@link BrowserDetails} are required to create a root + * {@link BrowserDetails} are required to create a UI * - * @see #getRootClassName(WrappedRequest) - * @see Root - * @see RootRequiresMoreInformationException + * @see #getUIClassName(WrappedRequest) + * @see UI + * @see UIRequiresMoreInformationException * @see WrappedRequest#getBrowserDetails() * * @since 7.0 */ - protected Root getRoot(WrappedRequest request) - throws RootRequiresMoreInformationException { + protected UI getUI(WrappedRequest request) + throws UIRequiresMoreInformationException { // Iterate in reverse order - test check newest provider first - for (int i = rootProviders.size() - 1; i >= 0; i--) { - RootProvider provider = rootProviders.get(i); + for (int i = uiProviders.size() - 1; i >= 0; i--) { + UIProvider provider = uiProviders.get(i); - Class<? extends Root> rootClass = provider.getRootClass(this, - request); + Class<? extends UI> uiClass = provider.getUIClass(this, request); - if (rootClass != null) { - return provider.instantiateRoot(this, rootClass, request); + if (uiClass != null) { + return provider.instantiateUI(this, uiClass, request); } } throw new RuntimeException( - "No root providers available or providers are not able to find root instance"); + "No UI providers available or providers are not able to find UI instance"); } /** - * Finds the theme to use for a specific root. If no specific theme is + * Finds the theme to use for a specific UI. If no specific theme is * required, <code>null</code> is returned. * * TODO Tell what the default implementation does once it does something. * - * @param root - * the root to get a theme for + * @param uI + * the UI to get a theme for * @return the name of the theme, or <code>null</code> if the default theme * should be used * * @since 7.0 */ - public String getThemeForRoot(Root root) { - Theme rootTheme = getAnnotationFor(root.getClass(), Theme.class); - if (rootTheme != null) { - return rootTheme.value(); + public String getThemeForUI(UI uI) { + Theme uiTheme = getAnnotationFor(uI.getClass(), Theme.class); + if (uiTheme != null) { + return uiTheme.value(); } else { return null; } } /** - * Finds the widgetset to use for a specific root. If no specific widgetset - * is required, <code>null</code> is returned. + * Finds the widgetset to use for a specific UI. If no specific widgetset is + * required, <code>null</code> is returned. * * TODO Tell what the default implementation does once it does something. * - * @param root - * the root to get a widgetset for + * @param uI + * the UI to get a widgetset for * @return the name of the widgetset, or <code>null</code> if the default * widgetset should be used * * @since 7.0 */ - public String getWidgetsetForRoot(Root root) { - Widgetset rootWidgetset = getAnnotationFor(root.getClass(), - Widgetset.class); - if (rootWidgetset != null) { - return rootWidgetset.value(); + public String getWidgetsetForUI(UI uI) { + Widgetset uiWidgetset = getAnnotationFor(uI.getClass(), Widgetset.class); + if (uiWidgetset != null) { + return uiWidgetset.value(); } else { return null; } @@ -2088,7 +2086,7 @@ public class Application implements Terminal.ErrorListener, Serializable { */ private static final ThreadLocal<Application> currentApplication = new ThreadLocal<Application>(); - private boolean rootPreserved = false; + private boolean uiPreserved = false; /** * Gets the currently used application. The current application is @@ -2140,144 +2138,140 @@ public class Application implements Terminal.ErrorListener, Serializable { return configuration.isProductionMode(); } - public void addRootProvider(RootProvider rootProvider) { - rootProviders.add(rootProvider); + public void addUIProvider(UIProvider uIProvider) { + uiProviders.add(uIProvider); } - public void removeRootProvider(RootProvider rootProvider) { - rootProviders.remove(rootProvider); + public void removeUIProvider(UIProvider uIProvider) { + uiProviders.remove(uIProvider); } /** - * Finds the {@link Root} to which a particular request belongs. If the - * request originates from an existing Root, that root is returned. In other - * cases, the method attempts to create and initialize a new root and might - * throw a {@link RootRequiresMoreInformationException} if all required + * Finds the {@link UI} to which a particular request belongs. If the + * request originates from an existing UI, that UI is returned. In other + * cases, the method attempts to create and initialize a new UI and might + * throw a {@link UIRequiresMoreInformationException} if all required * information is not available. * <p> * Please note that this method can also return a newly created - * <code>Root</code> which has not yet been initialized. You can use - * {@link #isRootInitPending(int)} with the root's id ( - * {@link Root#getRootId()} to check whether the initialization is still - * pending. + * <code>UI</code> which has not yet been initialized. You can use + * {@link #isUIInitPending(int)} with the UI's id ( {@link UI#getUIId()} to + * check whether the initialization is still pending. * </p> * * @param request - * the request for which a root is desired - * @return a root belonging to the request - * @throws RootRequiresMoreInformationException - * if no existing root could be found and creating a new root + * the request for which a UI is desired + * @return a UI belonging to the request + * @throws UIRequiresMoreInformationException + * if no existing UI could be found and creating a new UI * requires additional information from the browser * - * @see #getRoot(WrappedRequest) - * @see RootRequiresMoreInformationException + * @see #getUI(WrappedRequest) + * @see UIRequiresMoreInformationException * * @since 7.0 */ - public Root getRootForRequest(WrappedRequest request) - throws RootRequiresMoreInformationException { - Root root = Root.getCurrent(); - if (root != null) { - return root; + public UI getUIForRequest(WrappedRequest request) + throws UIRequiresMoreInformationException { + UI uI = UI.getCurrent(); + if (uI != null) { + return uI; } - Integer rootId = getRootId(request); + Integer uiId = getUIId(request); synchronized (this) { BrowserDetails browserDetails = request.getBrowserDetails(); boolean hasBrowserDetails = browserDetails != null && browserDetails.getUriFragment() != null; - root = roots.get(rootId); + uI = uIs.get(uiId); - if (root == null && isRootPreserved()) { - // Check for a known root - if (!retainOnRefreshRoots.isEmpty()) { + if (uI == null && isUiPreserved()) { + // Check for a known UI + if (!retainOnRefreshUIs.isEmpty()) { - Integer retainedRootId; + Integer retainedUIId; if (!hasBrowserDetails) { - throw new RootRequiresMoreInformationException(); + throw new UIRequiresMoreInformationException(); } else { String windowName = browserDetails.getWindowName(); - retainedRootId = retainOnRefreshRoots.get(windowName); + retainedUIId = retainOnRefreshUIs.get(windowName); } - if (retainedRootId != null) { - rootId = retainedRootId; - root = roots.get(rootId); + if (retainedUIId != null) { + uiId = retainedUIId; + uI = uIs.get(uiId); } } } - if (root == null) { - // Throws exception if root can not yet be created - root = getRoot(request); + if (uI == null) { + // Throws exception if UI can not yet be created + uI = getUI(request); - // Initialize some fields for a newly created root - if (root.getApplication() == null) { - root.setApplication(this); + // Initialize some fields for a newly created UI + if (uI.getApplication() == null) { + uI.setApplication(this); } - if (root.getRootId() < 0) { + if (uI.getUIId() < 0) { - if (rootId == null) { + if (uiId == null) { // Get the next id if none defined - rootId = Integer.valueOf(nextRootId++); + uiId = Integer.valueOf(nextUIId++); } - root.setRootId(rootId.intValue()); - roots.put(rootId, root); + uI.setUIId(uiId.intValue()); + uIs.put(uiId, uI); } } // Set thread local here so it is available in init - Root.setCurrent(root); + UI.setCurrent(uI); - if (!initedRoots.contains(rootId)) { - boolean initRequiresBrowserDetails = isRootPreserved() - || !root.getClass() - .isAnnotationPresent(EagerInit.class); + if (!initedUIs.contains(uiId)) { + boolean initRequiresBrowserDetails = isUiPreserved() + || !uI.getClass().isAnnotationPresent(EagerInit.class); if (!initRequiresBrowserDetails || hasBrowserDetails) { - root.doInit(request); + uI.doInit(request); - // Remember that this root has been initialized - initedRoots.add(rootId); + // Remember that this UI has been initialized + initedUIs.add(uiId); // init() might turn on preserve so do this afterwards - if (isRootPreserved()) { - // Remember this root + if (isUiPreserved()) { + // Remember this UI String windowName = request.getBrowserDetails() .getWindowName(); - retainOnRefreshRoots.put(windowName, rootId); + retainOnRefreshUIs.put(windowName, uiId); } } } } // end synchronized block - return root; + return uI; } /** - * Internal helper to finds the root id for a request. + * Internal helper to finds the UI id for a request. * * @param request - * the request to get the root id for - * @return a root id, or <code>null</code> if no root id is defined + * the request to get the UI id for + * @return a UI id, or <code>null</code> if no UI id is defined * * @since 7.0 */ - private static Integer getRootId(WrappedRequest request) { + private static Integer getUIId(WrappedRequest request) { if (request instanceof CombinedRequest) { - // Combined requests has the rootid parameter in the second request + // Combined requests has the uiId parameter in the second request CombinedRequest combinedRequest = (CombinedRequest) request; request = combinedRequest.getSecondRequest(); } - String rootIdString = request - .getParameter(ApplicationConstants.ROOT_ID_PARAMETER); - Integer rootId = rootIdString == null ? null - : new Integer(rootIdString); - return rootId; + String uiIdString = request.getParameter(UIConstants.UI_ID_PARAMETER); + Integer uiId = uiIdString == null ? null : new Integer(uiIdString); + return uiId; } /** - * Sets whether the same Root state should be reused if the framework can + * Sets whether the same UI state should be reused if the framework can * detect that the application is opened in a browser window where it has * previously been open. The framework attempts to discover this by checking * the value of window.name in the browser. @@ -2286,62 +2280,62 @@ public class Application implements Terminal.ErrorListener, Serializable { * the UI is already shown, as it might not be retained as intended. * </p> * - * @param rootPreserved - * <code>true</code>if the same Root instance should be reused - * e.g. when the browser window is refreshed. + * @param uiPreserved + * <code>true</code>if the same UI instance should be reused e.g. + * when the browser window is refreshed. */ - public void setRootPreserved(boolean rootPreserved) { - this.rootPreserved = rootPreserved; - if (!rootPreserved) { - retainOnRefreshRoots.clear(); + public void setUiPreserved(boolean uiPreserved) { + this.uiPreserved = uiPreserved; + if (!uiPreserved) { + retainOnRefreshUIs.clear(); } } /** - * Checks whether the same Root state should be reused if the framework can + * Checks whether the same UI state should be reused if the framework can * detect that the application is opened in a browser window where it has * previously been open. The framework attempts to discover this by checking * the value of window.name in the browser. * - * @return <code>true</code>if the same Root instance should be reused e.g. + * @return <code>true</code>if the same UI instance should be reused e.g. * when the browser window is refreshed. */ - public boolean isRootPreserved() { - return rootPreserved; + public boolean isUiPreserved() { + return uiPreserved; } /** - * Checks whether there's a pending initialization for the root with the - * given id. + * Checks whether there's a pending initialization for the UI with the given + * id. * - * @param rootId - * root id to check for + * @param uiId + * UI id to check for * @return <code>true</code> of the initialization is pending, - * <code>false</code> if the root id is not registered or if the - * root has already been initialized + * <code>false</code> if the UI id is not registered or if the UI + * has already been initialized * - * @see #getRootForRequest(WrappedRequest) + * @see #getUIForRequest(WrappedRequest) */ - public boolean isRootInitPending(int rootId) { - return !initedRoots.contains(Integer.valueOf(rootId)); + public boolean isUIInitPending(int uiId) { + return !initedUIs.contains(Integer.valueOf(uiId)); } /** - * Gets all the roots of this application. This includes roots that have - * been requested but not yet initialized. Please note, that roots are not + * Gets all the uIs of this application. This includes uIs that have been + * requested but not yet initialized. Please note, that uIs are not * automatically removed e.g. if the browser window is closed and that there - * is no way to manually remove a root. Inactive roots will thus not be - * released for GC until the entire application is released when the session - * has timed out (unless there are dangling references). Improved support - * for releasing unused roots is planned for an upcoming alpha release of - * Vaadin 7. + * is no way to manually remove a UI. Inactive uIs will thus not be released + * for GC until the entire application is released when the session has + * timed out (unless there are dangling references). Improved support for + * releasing unused uIs is planned for an upcoming alpha release of Vaadin + * 7. * - * @return a collection of roots belonging to this application + * @return a collection of uIs belonging to this application * * @since 7.0 */ - public Collection<Root> getRoots() { - return Collections.unmodifiableCollection(roots.values()); + public Collection<UI> getUIs() { + return Collections.unmodifiableCollection(uIs.values()); } private int connectorIdSequence = 0; @@ -2363,17 +2357,17 @@ public class Application implements Terminal.ErrorListener, Serializable { } /** - * Returns a Root with the given id. + * Returns a UI with the given id. * <p> * This is meant for framework internal use. * </p> * - * @param rootId - * The root id - * @return The root with the given id or null if not found + * @param uiId + * The UI id + * @return The UI with the given id or null if not found */ - public Root getRootById(int rootId) { - return roots.get(rootId); + public UI getUIById(int uiId) { + return uIs.get(uiId); } /** @@ -2424,41 +2418,39 @@ public class Application implements Terminal.ErrorListener, Serializable { } /** - * Removes all those roots from the application for whom - * {@link #isRootAlive} returns false. Close events are fired for the - * removed roots. + * Removes all those UIs from the application for which {@link #isUIAlive} + * returns false. Close events are fired for the removed UIs. * <p> * Called by the framework at the end of every request. * - * @see Root.CloseEvent - * @see Root.CloseListener - * @see #isRootAlive(Root) + * @see UI.CloseEvent + * @see UI.CloseListener + * @see #isUIAlive(UI) * * @since 7.0.0 */ - public void closeInactiveRoots() { - for (Iterator<Root> i = roots.values().iterator(); i.hasNext();) { - Root root = i.next(); - if (!isRootAlive(root)) { + public void closeInactiveUIs() { + for (Iterator<UI> i = uIs.values().iterator(); i.hasNext();) { + UI ui = i.next(); + if (!isUIAlive(ui)) { i.remove(); - retainOnRefreshRoots.values().remove(root.getRootId()); - root.fireCloseEvent(); + retainOnRefreshUIs.values().remove(ui.getUIId()); + ui.fireCloseEvent(); getLogger().info( - "Closed root #" + root.getRootId() - + " due to inactivity"); + "Closed UI #" + ui.getUIId() + " due to inactivity"); } } } /** * Returns the number of seconds that must pass without a valid heartbeat or - * UIDL request being received from a root before that root is removed from - * the application. This is a lower bound; it might take longer to close an - * inactive root. Returns a negative number if heartbeat is disabled and + * UIDL request being received from a UI before that UI is removed from the + * application. This is a lower bound; it might take longer to close an + * inactive UI. Returns a negative number if heartbeat is disabled and * timeout never occurs. * * @see #getUidlRequestTimeout() - * @see #closeInactiveRoots() + * @see #closeInactiveUIs() * @see DeploymentConfiguration#getHeartbeatInterval() * * @since 7.0.0 @@ -2467,24 +2459,23 @@ public class Application implements Terminal.ErrorListener, Serializable { * never occurs. */ protected int getHeartbeatTimeout() { - // Permit three missed heartbeats before closing the root + // Permit three missed heartbeats before closing the UI return (int) (configuration.getHeartbeatInterval() * (3.1)); } /** * Returns the number of seconds that must pass without a valid UIDL request - * being received from a root before the root is removed from the - * application, even though heartbeat requests are received. This is a lower - * bound; it might take longer to close an inactive root. Returns a negative - * number if + * being received from a UI before the UI is removed from the application, + * even though heartbeat requests are received. This is a lower bound; it + * might take longer to close an inactive UI. Returns a negative number if * <p> - * This timeout only has effect if cleanup of inactive roots is enabled; - * otherwise heartbeat requests are enough to extend root lifetime + * This timeout only has effect if cleanup of inactive UIs is enabled; + * otherwise heartbeat requests are enough to extend UI lifetime * indefinitely. * - * @see DeploymentConfiguration#isIdleRootCleanupEnabled() + * @see DeploymentConfiguration#isIdleUICleanupEnabled() * @see #getHeartbeatTimeout() - * @see #closeInactiveRoots() + * @see #closeInactiveUIs() * * @since 7.0.0 * @@ -2492,29 +2483,29 @@ public class Application implements Terminal.ErrorListener, Serializable { * timeout never occurs. */ protected int getUidlRequestTimeout() { - return configuration.isIdleRootCleanupEnabled() ? getContext() + return configuration.isIdleUICleanupEnabled() ? getContext() .getMaxInactiveInterval() : -1; } /** - * Returns whether the given root is alive (the client-side actively + * Returns whether the given UI is alive (the client-side actively * communicates with the server) or whether it can be removed from the * application and eventually collected. * * @since 7.0.0 * - * @param root - * The Root whose status to check - * @return true if the root is alive, false if it could be removed. + * @param ui + * The UI whose status to check + * @return true if the UI is alive, false if it could be removed. */ - protected boolean isRootAlive(Root root) { + protected boolean isUIAlive(UI ui) { long now = System.currentTimeMillis(); if (getHeartbeatTimeout() >= 0 - && now - root.getLastHeartbeatTime() > 1000 * getHeartbeatTimeout()) { + && now - ui.getLastHeartbeatTime() > 1000 * getHeartbeatTimeout()) { return false; } if (getUidlRequestTimeout() >= 0 - && now - root.getLastUidlRequestTime() > 1000 * getUidlRequestTimeout()) { + && now - ui.getLastUidlRequestTime() > 1000 * getUidlRequestTimeout()) { return false; } return true; diff --git a/server/src/com/vaadin/RootRequiresMoreInformationException.java b/server/src/com/vaadin/UIRequiresMoreInformationException.java index 74026dd161..493c31acb6 100644 --- a/server/src/com/vaadin/RootRequiresMoreInformationException.java +++ b/server/src/com/vaadin/UIRequiresMoreInformationException.java @@ -20,18 +20,18 @@ import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.WrappedRequest.BrowserDetails; /** - * Exception that is thrown to indicate that creating or initializing the root + * Exception that is thrown to indicate that creating or initializing the UI * requires information detailed from the web browser ({@link BrowserDetails}) * to be present. * * This exception may not be thrown if that information is already present in * the current WrappedRequest. * - * @see Application#getRoot(WrappedRequest) + * @see Application#getUI(WrappedRequest) * @see WrappedRequest#getBrowserDetails() * * @since 7.0 */ -public class RootRequiresMoreInformationException extends Exception { +public class UIRequiresMoreInformationException extends Exception { // Nothing of interest here } diff --git a/server/src/com/vaadin/annotations/EagerInit.java b/server/src/com/vaadin/annotations/EagerInit.java index 5131a79576..462c6bb5ac 100644 --- a/server/src/com/vaadin/annotations/EagerInit.java +++ b/server/src/com/vaadin/annotations/EagerInit.java @@ -21,15 +21,15 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** - * Indicates that the init method in a Root class can be called before full + * Indicates that the init method in a UI class can be called before full * browser details ({@link WrappedRequest#getBrowserDetails()}) are available. * This will make the UI appear more quickly, as ensuring the availability of * this information typically requires an additional round trip to the client. * - * @see Root#init(com.vaadin.terminal.WrappedRequest) + * @see UI#init(com.vaadin.terminal.WrappedRequest) * @see WrappedRequest#getBrowserDetails() * * @since 7.0 diff --git a/server/src/com/vaadin/annotations/Theme.java b/server/src/com/vaadin/annotations/Theme.java index e2610d2b3f..052bc245fd 100644 --- a/server/src/com/vaadin/annotations/Theme.java +++ b/server/src/com/vaadin/annotations/Theme.java @@ -21,10 +21,10 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** - * Defines a specific theme for a {@link Root}. + * Defines a specific theme for a {@link UI}. */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) diff --git a/server/src/com/vaadin/annotations/Widgetset.java b/server/src/com/vaadin/annotations/Widgetset.java index e80f887691..69e3e19319 100644 --- a/server/src/com/vaadin/annotations/Widgetset.java +++ b/server/src/com/vaadin/annotations/Widgetset.java @@ -21,10 +21,10 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** - * Defines a specific theme for a {@link Root}. + * Defines a specific theme for a {@link UI}. */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) diff --git a/server/src/com/vaadin/data/Buffered.java b/server/src/com/vaadin/data/Buffered.java index 2472524bbc..0b59c9ff97 100644 --- a/server/src/com/vaadin/data/Buffered.java +++ b/server/src/com/vaadin/data/Buffered.java @@ -77,82 +77,6 @@ public interface Buffered extends Serializable { public void discard() throws SourceException; /** - * Tests if the object is in write-through mode. If the object is in - * write-through mode, all modifications to it will result in - * <code>commit</code> being called after the modification. - * - * @return <code>true</code> if the object is in write-through mode, - * <code>false</code> if it's not. - * @deprecated As of 7.0, use {@link #setBuffered(boolean)} instead. Note - * that setReadThrough(true), setWriteThrough(true) equals - * setBuffered(false) - */ - @Deprecated - public boolean isWriteThrough(); - - /** - * Sets the object's write-through mode to the specified status. When - * switching the write-through mode on, the <code>commit</code> operation - * will be performed. - * - * @param writeThrough - * Boolean value to indicate if the object should be in - * write-through mode after the call. - * @throws SourceException - * If the operation fails because of an exception is thrown by - * the data source. - * @throws InvalidValueException - * If the implicit commit operation fails because of a - * validation error. - * - * @deprecated As of 7.0, use {@link #setBuffered(boolean)} instead. Note - * that setReadThrough(true), setWriteThrough(true) equals - * setBuffered(false) - */ - @Deprecated - public void setWriteThrough(boolean writeThrough) throws SourceException, - InvalidValueException; - - /** - * Tests if the object is in read-through mode. If the object is in - * read-through mode, retrieving its value will result in the value being - * first updated from the data source to the object. - * <p> - * The only exception to this rule is that when the object is not in - * write-through mode and it's buffer contains a modified value, the value - * retrieved from the object will be the locally modified value in the - * buffer which may differ from the value in the data source. - * </p> - * - * @return <code>true</code> if the object is in read-through mode, - * <code>false</code> if it's not. - * @deprecated As of 7.0, use {@link #isBuffered(boolean)} instead. Note - * that setReadThrough(true), setWriteThrough(true) equals - * setBuffered(false) - */ - @Deprecated - public boolean isReadThrough(); - - /** - * Sets the object's read-through mode to the specified status. When - * switching read-through mode on, the object's value is updated from the - * data source. - * - * @param readThrough - * Boolean value to indicate if the object should be in - * read-through mode after the call. - * - * @throws SourceException - * If the operation fails because of an exception is thrown by - * the data source. The cause is included in the exception. - * @deprecated As of 7.0, use {@link #setBuffered(boolean)} instead. Note - * that setReadThrough(true), setWriteThrough(true) equals - * setBuffered(false) - */ - @Deprecated - public void setReadThrough(boolean readThrough) throws SourceException; - - /** * Sets the object's buffered mode to the specified status. * <p> * When the object is in buffered mode, an internal buffer will be used to diff --git a/server/src/com/vaadin/data/util/QueryContainer.java b/server/src/com/vaadin/data/util/QueryContainer.java deleted file mode 100644 index add93c25ee..0000000000 --- a/server/src/com/vaadin/data/util/QueryContainer.java +++ /dev/null @@ -1,685 +0,0 @@ -/* - * Copyright 2011 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package com.vaadin.data.util; - -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; - -import com.vaadin.data.Container; -import com.vaadin.data.Item; -import com.vaadin.data.Property; - -/** - * <p> - * The <code>QueryContainer</code> is the specialized form of Container which is - * Ordered and Indexed. This is used to represent the contents of relational - * database tables accessed through the JDBC Connection in the Vaadin Table. - * This creates Items based on the queryStatement provided to the container. - * </p> - * - * <p> - * The <code>QueryContainer</code> can be visualized as a representation of a - * relational database table.Each Item in the container represents the row - * fetched by the query.All cells in a column have same data type and the data - * type information is retrieved from the metadata of the resultset. - * </p> - * - * <p> - * Note : If data in the tables gets modified, Container will not get reflected - * with the updates, we have to explicity invoke QueryContainer.refresh method. - * {@link com.vaadin.data.util.QueryContainer#refresh() refresh()} - * </p> - * - * @see com.vaadin.data.Container - * - * @author Vaadin Ltd. - * @since 4.0 - * - * @deprecated will be removed in the future, use the SQLContainer add-on - */ - -@Deprecated -@SuppressWarnings("serial") -public class QueryContainer implements Container, Container.Ordered, - Container.Indexed { - - // default ResultSet type - public static final int DEFAULT_RESULTSET_TYPE = ResultSet.TYPE_SCROLL_INSENSITIVE; - - // default ResultSet concurrency - public static final int DEFAULT_RESULTSET_CONCURRENCY = ResultSet.CONCUR_READ_ONLY; - - private int resultSetType = DEFAULT_RESULTSET_TYPE; - - private int resultSetConcurrency = DEFAULT_RESULTSET_CONCURRENCY; - - private final String queryStatement; - - private final Connection connection; - - private ResultSet result; - - private Collection<String> propertyIds; - - private final HashMap<String, Class<?>> propertyTypes = new HashMap<String, Class<?>>(); - - private int size = -1; - - private Statement statement; - - /** - * Constructs new <code>QueryContainer</code> with the specified - * <code>queryStatement</code>. - * - * @param queryStatement - * Database query - * @param connection - * Connection object - * @param resultSetType - * @param resultSetConcurrency - * @throws SQLException - * when database operation fails - */ - public QueryContainer(String queryStatement, Connection connection, - int resultSetType, int resultSetConcurrency) throws SQLException { - this.queryStatement = queryStatement; - this.connection = connection; - this.resultSetType = resultSetType; - this.resultSetConcurrency = resultSetConcurrency; - init(); - } - - /** - * Constructs new <code>QueryContainer</code> with the specified - * queryStatement using the default resultset type and default resultset - * concurrency. - * - * @param queryStatement - * Database query - * @param connection - * Connection object - * @see QueryContainer#DEFAULT_RESULTSET_TYPE - * @see QueryContainer#DEFAULT_RESULTSET_CONCURRENCY - * @throws SQLException - * when database operation fails - */ - public QueryContainer(String queryStatement, Connection connection) - throws SQLException { - this(queryStatement, connection, DEFAULT_RESULTSET_TYPE, - DEFAULT_RESULTSET_CONCURRENCY); - } - - /** - * Fills the Container with the items and properties. Invoked by the - * constructor. - * - * @throws SQLException - * when parameter initialization fails. - * @see QueryContainer#QueryContainer(String, Connection, int, int). - */ - private void init() throws SQLException { - refresh(); - ResultSetMetaData metadata; - metadata = result.getMetaData(); - final int count = metadata.getColumnCount(); - final ArrayList<String> list = new ArrayList<String>(count); - for (int i = 1; i <= count; i++) { - final String columnName = metadata.getColumnName(i); - list.add(columnName); - final Property<?> p = getContainerProperty(new Integer(1), - columnName); - propertyTypes.put(columnName, - p == null ? Object.class : p.getType()); - } - propertyIds = Collections.unmodifiableCollection(list); - } - - /** - * <p> - * Restores items in the container. This method will update the latest data - * to the container. - * </p> - * Note: This method should be used to update the container with the latest - * items. - * - * @throws SQLException - * when database operation fails - * - */ - - public void refresh() throws SQLException { - close(); - statement = connection.createStatement(resultSetType, - resultSetConcurrency); - result = statement.executeQuery(queryStatement); - result.last(); - size = result.getRow(); - } - - /** - * Releases and nullifies the <code>statement</code>. - * - * @throws SQLException - * when database operation fails - */ - - public void close() throws SQLException { - if (statement != null) { - statement.close(); - } - statement = null; - } - - /** - * Gets the Item with the given Item ID from the Container. - * - * @param id - * ID of the Item to retrieve - * @return Item Id. - */ - - @Override - public Item getItem(Object id) { - return new Row(id); - } - - /** - * Gets the collection of propertyId from the Container. - * - * @return Collection of Property ID. - */ - - @Override - public Collection<String> getContainerPropertyIds() { - return propertyIds; - } - - /** - * Gets an collection of all the item IDs in the container. - * - * @return collection of Item IDs - */ - @Override - public Collection<?> getItemIds() { - final Collection<Integer> c = new ArrayList<Integer>(size); - for (int i = 1; i <= size; i++) { - c.add(new Integer(i)); - } - return c; - } - - /** - * Gets the property identified by the given itemId and propertyId from the - * container. If the container does not contain the property - * <code>null</code> is returned. - * - * @param itemId - * ID of the Item which contains the Property - * @param propertyId - * ID of the Property to retrieve - * - * @return Property with the given ID if exists; <code>null</code> - * otherwise. - */ - - @Override - public synchronized Property<?> getContainerProperty(Object itemId, - Object propertyId) { - if (!(itemId instanceof Integer && propertyId instanceof String)) { - return null; - } - Object value; - try { - result.absolute(((Integer) itemId).intValue()); - value = result.getObject((String) propertyId); - } catch (final Exception e) { - return null; - } - - // Handle also null values from the database - return new ObjectProperty<Object>(value != null ? value - : new String("")); - } - - /** - * Gets the data type of all properties identified by the given type ID. - * - * @param id - * ID identifying the Properties - * - * @return data type of the Properties - */ - - @Override - public Class<?> getType(Object id) { - return propertyTypes.get(id); - } - - /** - * Gets the number of items in the container. - * - * @return the number of items in the container. - */ - @Override - public int size() { - return size; - } - - /** - * Tests if the list contains the specified Item. - * - * @param id - * ID the of Item to be tested. - * @return <code>true</code> if given id is in the container; - * <code>false</code> otherwise. - */ - @Override - public boolean containsId(Object id) { - if (!(id instanceof Integer)) { - return false; - } - final int i = ((Integer) id).intValue(); - if (i < 1) { - return false; - } - if (i > size) { - return false; - } - return true; - } - - /** - * Creates new Item with the given ID into the Container. - * - * @param itemId - * ID of the Item to be created. - * - * @return Created new Item, or <code>null</code> if it fails. - * - * @throws UnsupportedOperationException - * if the addItem method is not supported. - */ - @Override - public Item addItem(Object itemId) throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Creates a new Item into the Container, and assign it an ID. - * - * @return ID of the newly created Item, or <code>null</code> if it fails. - * @throws UnsupportedOperationException - * if the addItem method is not supported. - */ - @Override - public Object addItem() throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Removes the Item identified by ItemId from the Container. - * - * @param itemId - * ID of the Item to remove. - * @return <code>true</code> if the operation succeeded; <code>false</code> - * otherwise. - * @throws UnsupportedOperationException - * if the removeItem method is not supported. - */ - @Override - public boolean removeItem(Object itemId) - throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Adds new Property to all Items in the Container. - * - * @param propertyId - * ID of the Property - * @param type - * Data type of the new Property - * @param defaultValue - * The value all created Properties are initialized to. - * @return <code>true</code> if the operation succeeded; <code>false</code> - * otherwise. - * @throws UnsupportedOperationException - * if the addContainerProperty method is not supported. - */ - @Override - public boolean addContainerProperty(Object propertyId, Class<?> type, - Object defaultValue) throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Removes a Property specified by the given Property ID from the Container. - * - * @param propertyId - * ID of the Property to remove - * @return <code>true</code> if the operation succeeded; <code>false</code> - * otherwise. - * @throws UnsupportedOperationException - * if the removeContainerProperty method is not supported. - */ - @Override - public boolean removeContainerProperty(Object propertyId) - throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Removes all Items from the Container. - * - * @return <code>true</code> if the operation succeeded; <code>false</code> - * otherwise. - * @throws UnsupportedOperationException - * if the removeAllItems method is not supported. - */ - @Override - public boolean removeAllItems() throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Adds new item after the given item. - * - * @param previousItemId - * Id of the previous item in ordered container. - * @param newItemId - * Id of the new item to be added. - * @return Returns new item or <code>null</code> if the operation fails. - * @throws UnsupportedOperationException - * if the addItemAfter method is not supported. - */ - @Override - public Item addItemAfter(Object previousItemId, Object newItemId) - throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Adds new item after the given item. - * - * @param previousItemId - * Id of the previous item in ordered container. - * @return Returns item id created new item or <code>null</code> if the - * operation fails. - * @throws UnsupportedOperationException - * if the addItemAfter method is not supported. - */ - @Override - public Object addItemAfter(Object previousItemId) - throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Returns id of first item in the Container. - * - * @return ID of the first Item in the list. - */ - @Override - public Object firstItemId() { - if (size < 1) { - return null; - } - return new Integer(1); - } - - /** - * Returns <code>true</code> if given id is first id at first index. - * - * @param id - * ID of an Item in the Container. - */ - @Override - public boolean isFirstId(Object id) { - return size > 0 && (id instanceof Integer) - && ((Integer) id).intValue() == 1; - } - - /** - * Returns <code>true</code> if given id is last id at last index. - * - * @param id - * ID of an Item in the Container - * - */ - @Override - public boolean isLastId(Object id) { - return size > 0 && (id instanceof Integer) - && ((Integer) id).intValue() == size; - } - - /** - * Returns id of last item in the Container. - * - * @return ID of the last Item. - */ - @Override - public Object lastItemId() { - if (size < 1) { - return null; - } - return new Integer(size); - } - - /** - * Returns id of next item in container at next index. - * - * @param id - * ID of an Item in the Container. - * @return ID of the next Item or null. - */ - @Override - public Object nextItemId(Object id) { - if (size < 1 || !(id instanceof Integer)) { - return null; - } - final int i = ((Integer) id).intValue(); - if (i >= size) { - return null; - } - return new Integer(i + 1); - } - - /** - * Returns id of previous item in container at previous index. - * - * @param id - * ID of an Item in the Container. - * @return ID of the previous Item or null. - */ - @Override - public Object prevItemId(Object id) { - if (size < 1 || !(id instanceof Integer)) { - return null; - } - final int i = ((Integer) id).intValue(); - if (i <= 1) { - return null; - } - return new Integer(i - 1); - } - - /** - * The <code>Row</code> class implements methods of Item. - * - * @author Vaadin Ltd. - * @since 4.0 - */ - class Row implements Item { - - Object id; - - private Row(Object rowId) { - id = rowId; - } - - /** - * Adds the item property. - * - * @param id - * ID of the new Property. - * @param property - * Property to be added and associated with ID. - * @return <code>true</code> if the operation succeeded; - * <code>false</code> otherwise. - * @throws UnsupportedOperationException - * if the addItemProperty method is not supported. - */ - @Override - public boolean addItemProperty(Object id, Property property) - throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Gets the property corresponding to the given property ID stored in - * the Item. - * - * @param propertyId - * identifier of the Property to get - * @return the Property with the given ID or <code>null</code> - */ - @Override - public Property<?> getItemProperty(Object propertyId) { - return getContainerProperty(id, propertyId); - } - - /** - * Gets the collection of property IDs stored in the Item. - * - * @return unmodifiable collection containing IDs of the Properties - * stored the Item. - */ - @Override - public Collection<String> getItemPropertyIds() { - return propertyIds; - } - - /** - * Removes given item property. - * - * @param id - * ID of the Property to be removed. - * @return <code>true</code> if the item property is removed; - * <code>false</code> otherwise. - * @throws UnsupportedOperationException - * if the removeItemProperty is not supported. - */ - @Override - public boolean removeItemProperty(Object id) - throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - } - - /** - * Closes the statement. - * - * @see #close() - */ - @Override - public void finalize() { - try { - close(); - } catch (final SQLException ignored) { - - } - } - - /** - * Adds the given item at the position of given index. - * - * @param index - * Index to add the new item. - * @param newItemId - * Id of the new item to be added. - * @return new item or <code>null</code> if the operation fails. - * @throws UnsupportedOperationException - * if the addItemAt is not supported. - */ - @Override - public Item addItemAt(int index, Object newItemId) - throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Adds item at the position of provided index in the container. - * - * @param index - * Index to add the new item. - * @return item id created new item or <code>null</code> if the operation - * fails. - * - * @throws UnsupportedOperationException - * if the addItemAt is not supported. - */ - - @Override - public Object addItemAt(int index) throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Gets the Index id in the container. - * - * @param index - * Index Id. - * @return ID in the given index. - */ - @Override - public Object getIdByIndex(int index) { - if (size < 1 || index < 0 || index >= size) { - return null; - } - return new Integer(index + 1); - } - - /** - * Gets the index of the Item corresponding to id in the container. - * - * @param id - * ID of an Item in the Container - * @return index of the Item, or -1 if the Container does not include the - * Item - */ - - @Override - public int indexOfId(Object id) { - if (size < 1 || !(id instanceof Integer)) { - return -1; - } - final int i = ((Integer) id).intValue(); - if (i >= size || i < 1) { - return -1; - } - return i - 1; - } - -} diff --git a/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java b/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java index 0146c92b5c..6e5ba0dc57 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java @@ -69,7 +69,9 @@ final public class ColumnProperty implements Property { * @param value * @param type * - * @deprecated + * @deprecated as of 7.0. Use + * {@link #ColumnProperty(String, boolean, boolean, boolean, boolean, Object, Class) + * instead */ @Deprecated public ColumnProperty(String propertyId, boolean readOnly, @@ -144,7 +146,7 @@ final public class ColumnProperty implements Property { @Override public void setValue(Object newValue) throws ReadOnlyException, - ConversionException { + ConversionException { if (newValue == null && !nullable) { throw new NotNullableException( "Null values are not allowed for this property."); diff --git a/server/src/com/vaadin/event/ActionManager.java b/server/src/com/vaadin/event/ActionManager.java index 50ddef6265..296d12ba92 100644 --- a/server/src/com/vaadin/event/ActionManager.java +++ b/server/src/com/vaadin/event/ActionManager.java @@ -67,7 +67,7 @@ public class ActionManager implements Action.Container, Action.Handler, private void requestRepaint() { if (viewer != null) { - viewer.requestRepaint(); + viewer.markAsDirty(); } } diff --git a/server/src/com/vaadin/terminal/AbstractClientConnector.java b/server/src/com/vaadin/terminal/AbstractClientConnector.java index bc1cd2af1a..157bd17e41 100644 --- a/server/src/com/vaadin/terminal/AbstractClientConnector.java +++ b/server/src/com/vaadin/terminal/AbstractClientConnector.java @@ -31,16 +31,19 @@ import java.util.NoSuchElementException; import java.util.logging.Logger; import com.vaadin.Application; +import com.vaadin.external.json.JSONException; +import com.vaadin.external.json.JSONObject; import com.vaadin.shared.communication.ClientRpc; import com.vaadin.shared.communication.ServerRpc; import com.vaadin.shared.communication.SharedState; +import com.vaadin.terminal.gwt.server.AbstractCommunicationManager; import com.vaadin.terminal.gwt.server.ClientConnector; import com.vaadin.terminal.gwt.server.ClientMethodInvocation; import com.vaadin.terminal.gwt.server.RpcManager; import com.vaadin.terminal.gwt.server.RpcTarget; import com.vaadin.terminal.gwt.server.ServerRpcManager; import com.vaadin.ui.HasComponents; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * An abstract base class for ClientConnector implementations. This class @@ -68,6 +71,8 @@ public abstract class AbstractClientConnector implements ClientConnector { */ private SharedState sharedState; + private Class<? extends SharedState> stateType; + /** * Pending RPC method invocations to be sent. */ @@ -80,11 +85,18 @@ public abstract class AbstractClientConnector implements ClientConnector { private ClientConnector parent; /* Documentation copied from interface */ + @Deprecated @Override public void requestRepaint() { - Root root = getRoot(); - if (root != null) { - root.getConnectorTracker().markDirty(this); + markAsDirty(); + } + + /* Documentation copied from interface */ + @Override + public void markAsDirty() { + UI uI = getUI(); + if (uI != null) { + uI.getConnectorTracker().markDirty(this); } } @@ -137,14 +149,24 @@ public abstract class AbstractClientConnector implements ClientConnector { registerRpc(implementation, type); } - @Override - public SharedState getState() { + protected SharedState getState() { if (null == sharedState) { sharedState = createState(); } + + UI uI = getUI(); + if (uI != null && !uI.getConnectorTracker().isDirty(this)) { + requestRepaint(); + } + return sharedState; } + @Override + public JSONObject encodeState() throws JSONException { + return AbstractCommunicationManager.encodeState(this, getState()); + } + /** * Creates the shared state bean to be used in server to client * communication. @@ -172,17 +194,33 @@ public abstract class AbstractClientConnector implements ClientConnector { } } - /* - * (non-Javadoc) - * - * @see com.vaadin.terminal.gwt.server.ClientConnector#getStateType() - */ @Override public Class<? extends SharedState> getStateType() { + // Lazy load because finding type can be expensive because of the + // exceptions flying around + if (stateType == null) { + stateType = findStateType(); + } + + return stateType; + } + + private Class<? extends SharedState> findStateType() { try { - Method m = getClass().getMethod("getState", (Class[]) null); - Class<?> type = m.getReturnType(); - return type.asSubclass(SharedState.class); + Class<?> class1 = getClass(); + while (class1 != null) { + try { + Method m = class1.getDeclaredMethod("getState", + (Class[]) null); + Class<?> type = m.getReturnType(); + return type.asSubclass(SharedState.class); + } catch (NoSuchMethodException nsme) { + // Try in superclass instead + class1 = class1.getSuperclass(); + } + } + throw new NoSuchMethodException(getClass().getCanonicalName() + + ".getState()"); } catch (Exception e) { throw new RuntimeException("Error finding state type for " + getClass().getName(), e); @@ -255,8 +293,6 @@ public abstract class AbstractClientConnector implements ClientConnector { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { addMethodInvocationToQueue(rpcInterfaceName, method, args); - // TODO no need to do full repaint if only RPC calls - requestRepaint(); return null; } @@ -279,6 +315,8 @@ public abstract class AbstractClientConnector implements ClientConnector { // add to queue pendingInvocations.add(new ClientMethodInvocation(this, interfaceName, method, parameters)); + // TODO no need to do full repaint if only RPC calls + requestRepaint(); } /** @@ -325,28 +363,28 @@ public abstract class AbstractClientConnector implements ClientConnector { * @return The connector's application, or <code>null</code> if not attached */ protected Application getApplication() { - Root root = getRoot(); - if (root == null) { + UI uI = getUI(); + if (uI == null) { return null; } else { - return root.getApplication(); + return uI.getApplication(); } } /** - * Finds a Root ancestor of this connector. <code>null</code> is returned if - * no Root ancestor is found (typically because the connector is not + * Finds a UI ancestor of this connector. <code>null</code> is returned if + * no UI ancestor is found (typically because the connector is not * attached to a proper hierarchy). * - * @return the Root ancestor of this connector, or <code>null</code> if none + * @return the UI ancestor of this connector, or <code>null</code> if none * is found. */ @Override - public Root getRoot() { + public UI getUI() { ClientConnector connector = this; while (connector != null) { - if (connector instanceof Root) { - return (Root) connector; + if (connector instanceof UI) { + return (UI) connector; } connector = connector.getParent(); } @@ -358,11 +396,17 @@ public abstract class AbstractClientConnector implements ClientConnector { } @Override + @Deprecated public void requestRepaintAll() { - requestRepaint(); + markAsDirtyRecursive(); + } + + @Override + public void markAsDirtyRecursive() { + markAsDirty(); for (ClientConnector connector : getAllChildrenIterable(this)) { - connector.requestRepaintAll(); + connector.markAsDirtyRecursive(); } } @@ -438,14 +482,14 @@ public abstract class AbstractClientConnector implements ClientConnector { extensions.add(extension); extension.setParent(this); - requestRepaint(); + markAsDirty(); } @Override public void removeExtension(Extension extension) { extension.setParent(null); extensions.remove(extension); - requestRepaint(); + markAsDirty(); } @Override @@ -482,9 +526,9 @@ public abstract class AbstractClientConnector implements ClientConnector { @Override public void attach() { - requestRepaint(); + markAsDirty(); - getRoot().getConnectorTracker().registerConnector(this); + getUI().getConnectorTracker().registerConnector(this); for (ClientConnector connector : getAllChildrenIterable(this)) { connector.attach(); @@ -496,7 +540,7 @@ public abstract class AbstractClientConnector implements ClientConnector { * {@inheritDoc} * * <p> - * The {@link #getApplication()} and {@link #getRoot()} methods might return + * The {@link #getApplication()} and {@link #getUI()} methods might return * <code>null</code> after this method is called. * </p> */ @@ -506,7 +550,7 @@ public abstract class AbstractClientConnector implements ClientConnector { connector.detach(); } - getRoot().getConnectorTracker().unregisterConnector(this); + getUI().getConnectorTracker().unregisterConnector(this); } @Override diff --git a/server/src/com/vaadin/terminal/AbstractJavaScriptExtension.java b/server/src/com/vaadin/terminal/AbstractJavaScriptExtension.java index aae71640aa..1def6df697 100644 --- a/server/src/com/vaadin/terminal/AbstractJavaScriptExtension.java +++ b/server/src/com/vaadin/terminal/AbstractJavaScriptExtension.java @@ -166,7 +166,7 @@ public abstract class AbstractJavaScriptExtension extends AbstractExtension { } @Override - public JavaScriptExtensionState getState() { + protected JavaScriptExtensionState getState() { return (JavaScriptExtensionState) super.getState(); } } diff --git a/server/src/com/vaadin/terminal/AbstractRootProvider.java b/server/src/com/vaadin/terminal/AbstractUIProvider.java index 0b63003440..5bb4d35b30 100644 --- a/server/src/com/vaadin/terminal/AbstractRootProvider.java +++ b/server/src/com/vaadin/terminal/AbstractUIProvider.java @@ -17,13 +17,13 @@ package com.vaadin.terminal;
import com.vaadin.Application;
-import com.vaadin.ui.Root;
+import com.vaadin.ui.UI;
-public abstract class AbstractRootProvider implements RootProvider {
+public abstract class AbstractUIProvider implements UIProvider {
@Override
- public Root instantiateRoot(Application application,
- Class<? extends Root> type, WrappedRequest request) {
+ public UI instantiateUI(Application application,
+ Class<? extends UI> type, WrappedRequest request) {
try {
return type.newInstance();
} catch (InstantiationException e) {
diff --git a/server/src/com/vaadin/terminal/DefaultRootProvider.java b/server/src/com/vaadin/terminal/DefaultUIProvider.java index cbf8c98828..8713c45b31 100644 --- a/server/src/com/vaadin/terminal/DefaultRootProvider.java +++ b/server/src/com/vaadin/terminal/DefaultUIProvider.java @@ -17,19 +17,19 @@ package com.vaadin.terminal;
import com.vaadin.Application;
-import com.vaadin.RootRequiresMoreInformationException;
-import com.vaadin.ui.Root;
+import com.vaadin.UIRequiresMoreInformationException;
+import com.vaadin.ui.UI;
-public class DefaultRootProvider extends AbstractRootProvider {
+public class DefaultUIProvider extends AbstractUIProvider {
@Override
- public Class<? extends Root> getRootClass(Application application,
- WrappedRequest request) throws RootRequiresMoreInformationException {
- Object rootClassNameObj = application
- .getProperty(Application.ROOT_PARAMETER);
+ public Class<? extends UI> getUIClass(Application application,
+ WrappedRequest request) throws UIRequiresMoreInformationException {
+ Object uiClassNameObj = application
+ .getProperty(Application.UI_PARAMETER);
- if (rootClassNameObj instanceof String) {
- String rootClassName = rootClassNameObj.toString();
+ if (uiClassNameObj instanceof String) {
+ String uiClassName = uiClassNameObj.toString();
ClassLoader classLoader = request.getDeploymentConfiguration()
.getClassLoader();
@@ -37,12 +37,12 @@ public class DefaultRootProvider extends AbstractRootProvider { classLoader = getClass().getClassLoader();
}
try {
- Class<? extends Root> rootClass = Class.forName(rootClassName,
- true, classLoader).asSubclass(Root.class);
+ Class<? extends UI> uiClass = Class.forName(uiClassName, true,
+ classLoader).asSubclass(UI.class);
- return rootClass;
+ return uiClass;
} catch (ClassNotFoundException e) {
- throw new RuntimeException("Could not find root class", e);
+ throw new RuntimeException("Could not find UI class", e);
}
}
diff --git a/server/src/com/vaadin/terminal/DeploymentConfiguration.java b/server/src/com/vaadin/terminal/DeploymentConfiguration.java index d3fd4567f2..0cfbdb7544 100644 --- a/server/src/com/vaadin/terminal/DeploymentConfiguration.java +++ b/server/src/com/vaadin/terminal/DeploymentConfiguration.java @@ -98,7 +98,7 @@ public interface DeploymentConfiguration extends Serializable { /** * Get the class loader to use for loading classes loaded by name, e.g. - * custom Root classes. <code>null</code> indicates that the default class + * custom UI classes. <code>null</code> indicates that the default class * loader should be used. * * @return the class loader to use, or <code>null</code> @@ -162,7 +162,7 @@ public interface DeploymentConfiguration extends Serializable { public int getResourceCacheTime(); /** - * Returns the number of seconds between heartbeat requests of a root, or a + * Returns the number of seconds between heartbeat requests of a UI, or a * non-positive number if heartbeat is disabled. * * @since 7.0.0 @@ -172,7 +172,7 @@ public interface DeploymentConfiguration extends Serializable { public int getHeartbeatInterval(); /** - * Returns whether roots that have no other activity than heartbeat requests + * Returns whether UIs that have no other activity than heartbeat requests * should be closed after they have been idle the maximum inactivity time * enforced by the session. * @@ -180,9 +180,9 @@ public interface DeploymentConfiguration extends Serializable { * * @since 7.0.0 * - * @return True if roots receiving only heartbeat requests are eventually - * closed; false if heartbeat requests extend root lifetime + * @return True if UIs receiving only heartbeat requests are eventually + * closed; false if heartbeat requests extend UI lifetime * indefinitely. */ - public boolean isIdleRootCleanupEnabled(); + public boolean isIdleUICleanupEnabled(); } diff --git a/server/src/com/vaadin/terminal/JavaScriptCallbackHelper.java b/server/src/com/vaadin/terminal/JavaScriptCallbackHelper.java index 6153cf2619..f0063a8708 100644 --- a/server/src/com/vaadin/terminal/JavaScriptCallbackHelper.java +++ b/server/src/com/vaadin/terminal/JavaScriptCallbackHelper.java @@ -60,9 +60,7 @@ public class JavaScriptCallbackHelper implements Serializable { JavaScriptFunction javaScriptCallback) { callbacks.put(functionName, javaScriptCallback); JavaScriptConnectorState state = getConnectorState(); - if (state.getCallbackNames().add(functionName)) { - connector.requestRepaint(); - } + state.getCallbackNames().add(functionName); ensureRpc(); } @@ -100,7 +98,6 @@ public class JavaScriptCallbackHelper implements Serializable { connector.addMethodInvocationToQueue( JavaScriptCallbackRpc.class.getName(), CALL_METHOD, new Object[] { name, args }); - connector.requestRepaint(); } public void registerRpc(Class<?> rpcInterfaceType) { @@ -119,7 +116,6 @@ public class JavaScriptCallbackHelper implements Serializable { } rpcInterfaces.put(interfaceName, methodNames); - connector.requestRepaint(); } } diff --git a/server/src/com/vaadin/terminal/Page.java b/server/src/com/vaadin/terminal/Page.java index 8eb77b7d0d..66ef7da296 100644 --- a/server/src/com/vaadin/terminal/Page.java +++ b/server/src/com/vaadin/terminal/Page.java @@ -25,27 +25,27 @@ import java.util.List; import com.vaadin.event.EventRouter; import com.vaadin.shared.ui.BorderStyle; -import com.vaadin.shared.ui.root.PageClientRpc; -import com.vaadin.shared.ui.root.RootConstants; +import com.vaadin.shared.ui.ui.PageClientRpc; +import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.terminal.WrappedRequest.BrowserDetails; import com.vaadin.terminal.gwt.server.WebApplicationContext; import com.vaadin.terminal.gwt.server.WebBrowser; import com.vaadin.tools.ReflectTools; import com.vaadin.ui.JavaScript; import com.vaadin.ui.Notification; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; public class Page implements Serializable { /** * Listener that gets notified when the size of the browser window - * containing the root has changed. + * containing the uI has changed. * - * @see Root#addListener(BrowserWindowResizeListener) + * @see UI#addListener(BrowserWindowResizeListener) */ public interface BrowserWindowResizeListener extends Serializable { /** - * Invoked when the browser window containing a Root has been resized. + * Invoked when the browser window containing a UI has been resized. * * @param event * a browser window resize event @@ -54,7 +54,7 @@ public class Page implements Serializable { } /** - * Event that is fired when a browser window containing a root is resized. + * Event that is fired when a browser window containing a uI is resized. */ public class BrowserWindowResizeEvent extends EventObject { @@ -65,7 +65,7 @@ public class Page implements Serializable { * Creates a new event * * @param source - * the root for which the browser window has been resized + * the uI for which the browser window has been resized * @param width * the new width of the browser window * @param height @@ -254,9 +254,9 @@ public class Page implements Serializable { } /** - * Gets the root in which the fragment has changed. + * Gets the uI in which the fragment has changed. * - * @return the root in which the fragment has changed + * @return the uI in which the fragment has changed */ public Page getPage() { return (Page) getSource(); @@ -279,15 +279,15 @@ public class Page implements Serializable { */ private String fragment; - private final Root root; + private final UI uI; private int browserWindowWidth = -1; private int browserWindowHeight = -1; private JavaScript javaScript; - public Page(Root root) { - this.root = root; + public Page(UI uI) { + this.uI = uI; } private void addListener(Class<?> eventType, Object target, Method method) { @@ -332,7 +332,7 @@ public class Page implements Serializable { if (fireEvents) { fireEvent(new FragmentChangedEvent(this, newFragment)); } - root.requestRepaint(); + uI.markAsDirty(); } } @@ -374,7 +374,7 @@ public class Page implements Serializable { } public WebBrowser getWebBrowser() { - return ((WebApplicationContext) root.getApplication().getContext()) + return ((WebApplicationContext) uI.getApplication().getContext()) .getBrowser(); } @@ -399,8 +399,8 @@ public class Page implements Serializable { } /** - * Adds a new {@link BrowserWindowResizeListener} to this root. The listener - * will be notified whenever the browser window within which this root + * 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 @@ -415,7 +415,7 @@ public class Page implements Serializable { } /** - * Removes a {@link BrowserWindowResizeListener} from this root. The + * Removes a {@link BrowserWindowResizeListener} from this uI. The * listener will no longer be notified when the browser window is resized. * * @param resizeListener @@ -427,7 +427,7 @@ public class Page implements Serializable { } /** - * Gets the last known height of the browser window in which this root + * Gets the last known height of the browser window in which this uI * resides. * * @return the browser window height in pixels @@ -437,7 +437,7 @@ public class Page implements Serializable { } /** - * Gets the last known width of the browser window in which this root + * Gets the last known width of the browser window in which this uI * resides. * * @return the browser window width in pixels @@ -450,7 +450,7 @@ public class Page implements Serializable { if (javaScript == null) { // Create and attach on first use javaScript = new JavaScript(); - javaScript.extend(root); + javaScript.extend(uI); } return javaScript; @@ -474,32 +474,32 @@ public class Page implements Serializable { target.startTag("notification"); if (n.getCaption() != null) { target.addAttribute( - RootConstants.ATTRIBUTE_NOTIFICATION_CAPTION, + UIConstants.ATTRIBUTE_NOTIFICATION_CAPTION, n.getCaption()); } if (n.getDescription() != null) { target.addAttribute( - RootConstants.ATTRIBUTE_NOTIFICATION_MESSAGE, + UIConstants.ATTRIBUTE_NOTIFICATION_MESSAGE, n.getDescription()); } if (n.getIcon() != null) { target.addAttribute( - RootConstants.ATTRIBUTE_NOTIFICATION_ICON, + UIConstants.ATTRIBUTE_NOTIFICATION_ICON, n.getIcon()); } if (!n.isHtmlContentAllowed()) { target.addAttribute( - RootConstants.NOTIFICATION_HTML_CONTENT_NOT_ALLOWED, + UIConstants.NOTIFICATION_HTML_CONTENT_NOT_ALLOWED, true); } target.addAttribute( - RootConstants.ATTRIBUTE_NOTIFICATION_POSITION, - n.getPosition()); - target.addAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_DELAY, + UIConstants.ATTRIBUTE_NOTIFICATION_POSITION, n + .getPosition().ordinal()); + target.addAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_DELAY, n.getDelayMsec()); if (n.getStyleName() != null) { target.addAttribute( - RootConstants.ATTRIBUTE_NOTIFICATION_STYLE, + UIConstants.ATTRIBUTE_NOTIFICATION_STYLE, n.getStyleName()); } target.endTag("notification"); @@ -509,21 +509,21 @@ public class Page implements Serializable { } if (fragment != null) { - target.addAttribute(RootConstants.FRAGMENT_VARIABLE, fragment); + target.addAttribute(UIConstants.FRAGMENT_VARIABLE, fragment); } } /** - * Opens the given resource in this root. The contents of this Root is + * 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 root + * the resource to show in this uI */ public void open(Resource resource) { openList.add(new OpenResource(resource, null, -1, -1, BORDER_DEFAULT)); - root.requestRepaint(); + uI.markAsDirty(); } /** @@ -566,7 +566,7 @@ public class Page implements Serializable { public void open(Resource resource, String windowName) { openList.add(new OpenResource(resource, windowName, -1, -1, BORDER_DEFAULT)); - root.requestRepaint(); + uI.markAsDirty(); } /** @@ -589,7 +589,7 @@ public class Page implements Serializable { int height, BorderStyle border) { openList.add(new OpenResource(resource, windowName, width, height, border)); - root.requestRepaint(); + uI.markAsDirty(); } /** @@ -603,7 +603,7 @@ public class Page implements Serializable { notifications = new LinkedList<Notification>(); } notifications.add(notification); - root.requestRepaint(); + uI.markAsDirty(); } /** @@ -622,21 +622,21 @@ public class Page implements Serializable { } /** - * Gets the Page to which the current root belongs. This is automatically + * Gets the Page to which the current uI belongs. This is automatically * defined when processing requests to the server. In other cases, (e.g. - * from background threads), the current root is not automatically defined. + * from background threads), the current uI is not automatically defined. * - * @see Root#getCurrent() + * @see UI#getCurrent() * * @return the current page instance if available, otherwise * <code>null</code> */ public static Page getCurrent() { - Root currentRoot = Root.getCurrent(); - if (currentRoot == null) { + UI currentUI = UI.getCurrent(); + if (currentUI == null) { return null; } - return currentRoot.getPage(); + return currentUI.getPage(); } /** @@ -647,7 +647,7 @@ public class Page implements Serializable { * the new page title to set */ public void setTitle(String title) { - root.getRpcProxy(PageClientRpc.class).setTitle(title); + uI.getRpcProxy(PageClientRpc.class).setTitle(title); } } diff --git a/server/src/com/vaadin/terminal/RootProvider.java b/server/src/com/vaadin/terminal/UIProvider.java index 476cf1bd78..27b63fbcac 100644 --- a/server/src/com/vaadin/terminal/RootProvider.java +++ b/server/src/com/vaadin/terminal/UIProvider.java @@ -17,13 +17,13 @@ package com.vaadin.terminal;
import com.vaadin.Application;
-import com.vaadin.RootRequiresMoreInformationException;
-import com.vaadin.ui.Root;
+import com.vaadin.UIRequiresMoreInformationException;
+import com.vaadin.ui.UI;
-public interface RootProvider {
- public Class<? extends Root> getRootClass(Application application,
- WrappedRequest request) throws RootRequiresMoreInformationException;
+public interface UIProvider {
+ public Class<? extends UI> getUIClass(Application application,
+ WrappedRequest request) throws UIRequiresMoreInformationException;
- public Root instantiateRoot(Application application,
- Class<? extends Root> type, WrappedRequest request);
+ public UI instantiateUI(Application application,
+ Class<? extends UI> type, WrappedRequest request);
}
diff --git a/server/src/com/vaadin/terminal/Vaadin6Component.java b/server/src/com/vaadin/terminal/Vaadin6Component.java index 048000e31d..eb169c90f9 100644 --- a/server/src/com/vaadin/terminal/Vaadin6Component.java +++ b/server/src/com/vaadin/terminal/Vaadin6Component.java @@ -52,4 +52,15 @@ public interface Vaadin6Component extends VariableOwner, Component, */ public void paintContent(PaintTarget target) throws PaintException; + /** + * (non-Javadoc) {@inheritDoc} + * <p> + * For a Vaadin6Component, markAsDirty will also cause + * {@link #paintContent(PaintTarget)} to be called before sending changes to + * the client. + * + * @see com.vaadin.terminal.gwt.server.ClientConnector#markAsDirty() + */ + @Override + public void markAsDirty(); } diff --git a/server/src/com/vaadin/terminal/WrappedRequest.java b/server/src/com/vaadin/terminal/WrappedRequest.java index c317eae048..343a60848e 100644 --- a/server/src/com/vaadin/terminal/WrappedRequest.java +++ b/server/src/com/vaadin/terminal/WrappedRequest.java @@ -27,10 +27,10 @@ import javax.servlet.ServletRequest; import javax.servlet.http.HttpServletRequest; import com.vaadin.Application; -import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.UIRequiresMoreInformationException; import com.vaadin.annotations.EagerInit; import com.vaadin.terminal.gwt.server.WebBrowser; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * A generic request to the server, wrapping a more specific request type, e.g. @@ -219,9 +219,10 @@ public interface WrappedRequest extends Serializable { * for instance using javascript in the browser. * * This information is only guaranteed to be available in some special - * cases, for instance when {@link Application#getRoot} is called again - * after throwing {@link RootRequiresMoreInformationException} or in - * {@link Root#init(WrappedRequest)} for a Root class not annotated with + * cases, for instance when + * {@link Application#getUIForRequest(WrappedRequest)} is called again after + * throwing {@link UIRequiresMoreInformationException} or in + * {@link UI#init(WrappedRequest)} for a UI class not annotated with * {@link EagerInit} * * @return the browser details, or <code>null</code> if details are not diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java index dea42b6b69..345f462239 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java +++ b/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java @@ -56,13 +56,13 @@ import com.liferay.portal.kernel.util.PropsUtil; import com.vaadin.Application; import com.vaadin.Application.ApplicationStartEvent; import com.vaadin.Application.SystemMessages; -import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.UIRequiresMoreInformationException; import com.vaadin.terminal.DeploymentConfiguration; import com.vaadin.terminal.Terminal; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.WrappedResponse; import com.vaadin.terminal.gwt.server.AbstractCommunicationManager.Callback; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * Portlet 2.0 base class. This replaces the servlet in servlet/portlet 1.0 @@ -496,36 +496,35 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet /* Notify listeners */ // Finds the window within the application - Root root = null; + UI uI = null; synchronized (application) { if (application.isRunning()) { switch (requestType) { case RENDER: case ACTION: // Both action requests and render requests are ok - // without a Root as they render the initial HTML + // without a UI as they render the initial HTML // and then do a second request try { - root = application - .getRootForRequest(wrappedRequest); - } catch (RootRequiresMoreInformationException e) { - // Ignore problem and continue without root + uI = application + .getUIForRequest(wrappedRequest); + } catch (UIRequiresMoreInformationException e) { + // Ignore problem and continue without UI } break; case BROWSER_DETAILS: - // Should not try to find a root here as the - // combined request details might change the root + // Should not try to find a UI here as the + // combined request details might change the UI break; case FILE_UPLOAD: // no window break; case APPLICATION_RESOURCE: // use main window - should not need any window - // root = application.getRoot(); + // UI = application.getUI(); break; default: - root = application - .getRootForRequest(wrappedRequest); + uI = application.getUIForRequest(wrappedRequest); } // if window not found, not a problem - use null } @@ -535,25 +534,24 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet // starts? if (request instanceof RenderRequest) { applicationContext.firePortletRenderRequest(application, - root, (RenderRequest) request, + uI, (RenderRequest) request, (RenderResponse) response); } else if (request instanceof ActionRequest) { applicationContext.firePortletActionRequest(application, - root, (ActionRequest) request, + uI, (ActionRequest) request, (ActionResponse) response); } else if (request instanceof EventRequest) { - applicationContext.firePortletEventRequest(application, - root, (EventRequest) request, - (EventResponse) response); + applicationContext.firePortletEventRequest(application, uI, + (EventRequest) request, (EventResponse) response); } else if (request instanceof ResourceRequest) { applicationContext.firePortletResourceRequest(application, - root, (ResourceRequest) request, + uI, (ResourceRequest) request, (ResourceResponse) response); } /* Handle the request */ if (requestType == RequestType.FILE_UPLOAD) { - // Root is resolved in handleFileUpload by + // UI is resolved in handleFileUpload by // PortletCommunicationManager applicationManager.handleFileUpload(application, wrappedRequest, wrappedResponse); @@ -565,7 +563,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet } else if (requestType == RequestType.UIDL) { // Handles AJAX UIDL requests applicationManager.handleUidlRequest(wrappedRequest, - wrappedResponse, portletWrapper, root); + wrappedResponse, portletWrapper, uI); return; } else { /* @@ -595,7 +593,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet } finally { if (applicationRunning) { - application.closeInactiveRoots(); + application.closeInactiveUIs(); } // Notifies transaction end @@ -612,7 +610,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet } } finally { - Root.setCurrent(null); + UI.setCurrent(null); Application.setCurrent(null); PortletSession session = request @@ -908,7 +906,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet throws PortletException { try { final Application application = getApplicationClass().newInstance(); - application.setRootPreserved(true); + application.setUiPreserved(true); return application; } catch (final IllegalAccessException e) { throw new PortletException("getNewApplication failed", e); diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java index 0fc8bc09a0..13fd869166 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java +++ b/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java @@ -56,7 +56,7 @@ import com.vaadin.terminal.ThemeResource; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.WrappedResponse; import com.vaadin.terminal.gwt.server.AbstractCommunicationManager.Callback; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * Abstract implementation of the ApplicationServlet which handles all @@ -320,21 +320,21 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements /* Handle the request */ if (requestType == RequestType.FILE_UPLOAD) { - // Root is resolved in communication manager + // UI is resolved in communication manager applicationManager.handleFileUpload(application, request, response); return; } else if (requestType == RequestType.UIDL) { - Root root = application.getRootForRequest(request); - if (root == null) { - throw new ServletException(ERROR_NO_ROOT_FOUND); + UI uI = application.getUIForRequest(request); + if (uI == null) { + throw new ServletException(ERROR_NO_UI_FOUND); } // Handles AJAX UIDL requests applicationManager.handleUidlRequest(request, response, - servletWrapper, root); + servletWrapper, uI); return; } else if (requestType == RequestType.BROWSER_DETAILS) { - // Browser details - not related to a specific root + // Browser details - not related to a specific UI applicationManager.handleBrowserDetailsRequest(request, response, application); return; @@ -362,7 +362,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements } finally { if (applicationRunning) { - application.closeInactiveRoots(); + application.closeInactiveUIs(); } // Notifies transaction end @@ -380,7 +380,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements .onRequestEnd(request, response); } } finally { - Root.setCurrent(null); + UI.setCurrent(null); Application.setCurrent(null); HttpSession session = request.getSession(false); diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index b5ea6a8735..a0ecd01b89 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -60,7 +60,7 @@ import javax.servlet.http.HttpServletResponse; import com.vaadin.Application; import com.vaadin.Application.SystemMessages; -import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.UIRequiresMoreInformationException; import com.vaadin.annotations.JavaScript; import com.vaadin.annotations.StyleSheet; import com.vaadin.external.json.JSONArray; @@ -74,6 +74,7 @@ import com.vaadin.shared.communication.LegacyChangeVariablesInvocation; import com.vaadin.shared.communication.MethodInvocation; import com.vaadin.shared.communication.SharedState; import com.vaadin.shared.communication.UidlValue; +import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.terminal.AbstractClientConnector; import com.vaadin.terminal.CombinedRequest; import com.vaadin.terminal.LegacyPaint; @@ -98,7 +99,7 @@ import com.vaadin.ui.AbstractField; import com.vaadin.ui.Component; import com.vaadin.ui.ConnectorTracker; import com.vaadin.ui.HasComponents; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.Window; /** @@ -147,7 +148,7 @@ public abstract class AbstractCommunicationManager implements Serializable { public static final char VAR_ESCAPE_CHARACTER = '\u001b'; - private final HashMap<Integer, ClientCache> rootToClientCache = new HashMap<Integer, ClientCache>(); + private final HashMap<Integer, ClientCache> uiToClientCache = new HashMap<Integer, ClientCache>(); private static final int MAX_BUFFER_SIZE = 64 * 1024; @@ -507,7 +508,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * Internally process a UIDL request from the client. * * This method calls - * {@link #handleVariables(WrappedRequest, WrappedResponse, Callback, Application, Root)} + * {@link #handleVariables(WrappedRequest, WrappedResponse, Callback, Application, UI)} * to process any changes to variables by the client and then repaints * affected components using {@link #paintAfterVariableChanges()}. * @@ -521,7 +522,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * @param request * @param response * @param callback - * @param root + * @param uI * target window for the UIDL request, can be null if target not * found * @throws IOException @@ -529,7 +530,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * @throws JSONException */ public void handleUidlRequest(WrappedRequest request, - WrappedResponse response, Callback callback, Root root) + WrappedResponse response, Callback callback, UI uI) throws IOException, InvalidUIDLSecurityKeyException, JSONException { checkWidgetsetVersion(request); @@ -551,7 +552,7 @@ public abstract class AbstractCommunicationManager implements Serializable { if (request.getParameter(GET_PARAM_HIGHLIGHT_COMPONENT) != null) { String pid = request .getParameter(GET_PARAM_HIGHLIGHT_COMPONENT); - highlightedConnector = root.getConnectorTracker().getConnector( + highlightedConnector = uI.getConnectorTracker().getConnector( pid); highlightConnector(highlightedConnector); } @@ -568,10 +569,10 @@ public abstract class AbstractCommunicationManager implements Serializable { // Finds the window within the application if (application.isRunning()) { // Returns if no window found - if (root == null) { + if (uI == null) { // This should not happen, no windows exists but // application is still open. - getLogger().warning("Could not get root for application"); + getLogger().warning("Could not get UI for application"); return; } } else { @@ -580,11 +581,11 @@ public abstract class AbstractCommunicationManager implements Serializable { return; } - // Keep the root alive - root.setLastUidlRequestTime(System.currentTimeMillis()); + // Keep the UI alive + uI.setLastUidlRequestTime(System.currentTimeMillis()); // Change all variables based on request parameters - if (!handleVariables(request, response, callback, application, root)) { + if (!handleVariables(request, response, callback, application, uI)) { // var inconsistency; the client is probably out-of-sync SystemMessages ci = null; @@ -615,8 +616,8 @@ public abstract class AbstractCommunicationManager implements Serializable { } paintAfterVariableChanges(request, response, callback, repaintAll, - outWriter, root, analyzeLayouts); - postPaint(root); + outWriter, uI, analyzeLayouts); + postPaint(uI); } outWriter.close(); @@ -649,20 +650,20 @@ public abstract class AbstractCommunicationManager implements Serializable { * Method called after the paint phase while still being synchronized on the * application * - * @param root + * @param uI * */ - protected void postPaint(Root root) { + protected void postPaint(UI uI) { // Remove connectors that have been detached from the application during // handling of the request - root.getConnectorTracker().cleanConnectorMap(); + uI.getConnectorTracker().cleanConnectorMap(); if (pidToNameToStreamVariable != null) { Iterator<String> iterator = pidToNameToStreamVariable.keySet() .iterator(); while (iterator.hasNext()) { String connectorId = iterator.next(); - if (root.getConnectorTracker().getConnector(connectorId) == null) { + if (uI.getConnectorTracker().getConnector(connectorId) == null) { // Owner is no longer attached to the application Map<String, StreamVariable> removed = pidToNameToStreamVariable .get(connectorId); @@ -750,7 +751,7 @@ public abstract class AbstractCommunicationManager implements Serializable { */ private void paintAfterVariableChanges(WrappedRequest request, WrappedResponse response, Callback callback, boolean repaintAll, - final PrintWriter outWriter, Root root, boolean analyzeLayouts) + final PrintWriter outWriter, UI uI, boolean analyzeLayouts) throws PaintException, IOException, JSONException { // Removes application if it has stopped during variable changes @@ -769,7 +770,7 @@ public abstract class AbstractCommunicationManager implements Serializable { outWriter.print(getSecurityKeyUIDL(request)); } - writeUidlResponse(request, repaintAll, outWriter, root, analyzeLayouts); + writeUidlResponse(request, repaintAll, outWriter, uI, analyzeLayouts); closeJsonMessage(outWriter); @@ -814,17 +815,17 @@ public abstract class AbstractCommunicationManager implements Serializable { @SuppressWarnings("unchecked") public void writeUidlResponse(WrappedRequest request, boolean repaintAll, - final PrintWriter outWriter, Root root, boolean analyzeLayouts) + final PrintWriter outWriter, UI ui, boolean analyzeLayouts) throws PaintException, JSONException { ArrayList<ClientConnector> dirtyVisibleConnectors = new ArrayList<ClientConnector>(); - Application application = root.getApplication(); + Application application = ui.getApplication(); // Paints components - ConnectorTracker rootConnectorTracker = root.getConnectorTracker(); + ConnectorTracker uiConnectorTracker = ui.getConnectorTracker(); getLogger().log(Level.FINE, "* Creating response to client"); if (repaintAll) { - getClientCache(root).clear(); - rootConnectorTracker.markAllConnectorsDirty(); - rootConnectorTracker.markAllClientSidesUninitialized(); + getClientCache(ui).clear(); + uiConnectorTracker.markAllConnectorsDirty(); + uiConnectorTracker.markAllClientSidesUninitialized(); // Reset sent locales locales = null; @@ -832,18 +833,18 @@ public abstract class AbstractCommunicationManager implements Serializable { } dirtyVisibleConnectors - .addAll(getDirtyVisibleConnectors(rootConnectorTracker)); + .addAll(getDirtyVisibleConnectors(uiConnectorTracker)); getLogger().log( Level.FINE, "Found " + dirtyVisibleConnectors.size() + " dirty connectors to paint"); for (ClientConnector connector : dirtyVisibleConnectors) { - boolean initialized = rootConnectorTracker + boolean initialized = uiConnectorTracker .isClientSideInitialized(connector); connector.beforeClientResponse(!initialized); } - rootConnectorTracker.markAllConnectorsClean(); + uiConnectorTracker.markAllConnectorsClean(); outWriter.print("\"changes\":["); @@ -855,12 +856,11 @@ public abstract class AbstractCommunicationManager implements Serializable { if (analyzeLayouts) { invalidComponentRelativeSizes = ComponentSizeValidator - .validateComponentRelativeSizes(root.getContent(), null, - null); + .validateComponentRelativeSizes(ui.getContent(), null, null); // Also check any existing subwindows - if (root.getWindows() != null) { - for (Window subWindow : root.getWindows()) { + if (ui.getWindows() != null) { + for (Window subWindow : ui.getWindows()) { invalidComponentRelativeSizes = ComponentSizeValidator .validateComponentRelativeSizes( subWindow.getContent(), @@ -884,49 +884,19 @@ public abstract class AbstractCommunicationManager implements Serializable { // processing. JSONObject sharedStates = new JSONObject(); for (ClientConnector connector : dirtyVisibleConnectors) { - SharedState state = connector.getState(); - if (null != state) { - // encode and send shared state - try { - Class<? extends SharedState> stateType = connector - .getStateType(); - Object diffState = rootConnectorTracker - .getDiffState(connector); - if (diffState == null) { - diffState = new JSONObject(); - // Use an empty state object as reference for full - // repaints - boolean emptyInitialState = JavaScriptConnectorState.class - .isAssignableFrom(stateType); - if (!emptyInitialState) { - try { - SharedState referenceState = stateType - .newInstance(); - diffState = JsonCodec.encode(referenceState, - null, stateType, - root.getConnectorTracker()); - } catch (Exception e) { - getLogger().log( - Level.WARNING, - "Error creating reference object for state of type " - + stateType.getName()); - } - } - rootConnectorTracker.setDiffState(connector, diffState); - } - JSONObject stateJson = (JSONObject) JsonCodec.encode(state, - diffState, stateType, root.getConnectorTracker()); + // encode and send shared state + try { + JSONObject stateJson = connector.encodeState(); - if (stateJson.length() != 0) { - sharedStates.put(connector.getConnectorId(), stateJson); - } - } catch (JSONException e) { - throw new PaintException( - "Failed to serialize shared state for connector " - + connector.getClass().getName() + " (" - + connector.getConnectorId() + "): " - + e.getMessage(), e); + if (stateJson != null && stateJson.length() != 0) { + sharedStates.put(connector.getConnectorId(), stateJson); } + } catch (JSONException e) { + throw new PaintException( + "Failed to serialize shared state for connector " + + connector.getClass().getName() + " (" + + connector.getConnectorId() + "): " + + e.getMessage(), e); } } outWriter.print("\"state\":"); @@ -985,10 +955,10 @@ public abstract class AbstractCommunicationManager implements Serializable { outWriter.append(hierarchyInfo.toString()); outWriter.print(", "); // close hierarchy - // send server to client RPC calls for components in the root, in call + // send server to client RPC calls for components in the UI, in call // order - // collect RPC calls from components in the root in the order in + // collect RPC calls from components in the UI in the order in // which they were performed, remove the calls from components LinkedList<ClientConnector> rpcPendingQueue = new LinkedList<ClientConnector>( @@ -1019,7 +989,7 @@ public abstract class AbstractCommunicationManager implements Serializable { // } paramJson.put(JsonCodec.encode( invocation.getParameters()[i], referenceParameter, - parameterType, root.getConnectorTracker())); + parameterType, ui.getConnectorTracker())); } invocationJson.put(paramJson); rpcCalls.put(invocationJson); @@ -1121,7 +1091,7 @@ public abstract class AbstractCommunicationManager implements Serializable { final String resource = (String) i.next(); InputStream is = null; try { - is = getThemeResourceAsStream(root, getTheme(root), resource); + is = getThemeResourceAsStream(ui, getTheme(ui), resource); } catch (final Exception e) { // FIXME: Handle exception getLogger().log(Level.FINER, @@ -1158,7 +1128,7 @@ public abstract class AbstractCommunicationManager implements Serializable { Collection<Class<? extends ClientConnector>> usedClientConnectors = paintTarget .getUsedClientConnectors(); boolean typeMappingsOpen = false; - ClientCache clientCache = getClientCache(root); + ClientCache clientCache = getClientCache(ui); List<Class<? extends ClientConnector>> newConnectorTypes = new ArrayList<Class<? extends ClientConnector>>(); @@ -1271,12 +1241,44 @@ public abstract class AbstractCommunicationManager implements Serializable { } for (ClientConnector connector : dirtyVisibleConnectors) { - rootConnectorTracker.markClientSideInitialized(connector); + uiConnectorTracker.markClientSideInitialized(connector); } writePerformanceData(outWriter); } + public static JSONObject encodeState(ClientConnector connector, + SharedState state) throws JSONException { + UI uI = connector.getUI(); + ConnectorTracker connectorTracker = uI.getConnectorTracker(); + Class<? extends SharedState> stateType = connector.getStateType(); + Object diffState = connectorTracker.getDiffState(connector); + if (diffState == null) { + // Use an empty state object as reference for full + // repaints + + boolean supportsDiffState = !JavaScriptConnectorState.class + .isAssignableFrom(stateType); + if (supportsDiffState) { + diffState = new JSONObject(); + try { + SharedState referenceState = stateType.newInstance(); + diffState = JsonCodec.encode(referenceState, null, + stateType, uI.getConnectorTracker()); + } catch (Exception e) { + getLogger().log( + Level.WARNING, + "Error creating reference object for state of type " + + stateType.getName()); + } + connectorTracker.setDiffState(connector, diffState); + } + } + JSONObject stateJson = (JSONObject) JsonCodec.encode(state, diffState, + stateType, uI.getConnectorTracker()); + return stateJson; + } + /** * Resolves a resource URI, registering the URI with this * {@code AbstractCommunicationManager} if needed and returns a fully @@ -1391,12 +1393,12 @@ public abstract class AbstractCommunicationManager implements Serializable { } - private ClientCache getClientCache(Root root) { - Integer rootId = Integer.valueOf(root.getRootId()); - ClientCache cache = rootToClientCache.get(rootId); + private ClientCache getClientCache(UI uI) { + Integer uiId = Integer.valueOf(uI.getUIId()); + ClientCache cache = uiToClientCache.get(uiId); if (cache == null) { cache = new ClientCache(); - rootToClientCache.put(rootId, cache); + uiToClientCache.put(uiId, cache); } return cache; } @@ -1442,7 +1444,7 @@ public abstract class AbstractCommunicationManager implements Serializable { HasComponents parent = child.getParent(); if (parent == null) { - if (child instanceof Root) { + if (child instanceof UI) { return child.isVisible(); } else { return false; @@ -1509,15 +1511,15 @@ public abstract class AbstractCommunicationManager implements Serializable { return pendingInvocations; } - protected abstract InputStream getThemeResourceAsStream(Root root, + protected abstract InputStream getThemeResourceAsStream(UI uI, String themeName, String resource); private int getTimeoutInterval() { return maxInactiveInterval; } - private String getTheme(Root root) { - String themeName = root.getApplication().getThemeForRoot(root); + private String getTheme(UI uI) { + String themeName = uI.getApplication().getThemeForUI(uI); String requestThemeName = getRequestTheme(); if (requestThemeName != null) { @@ -1556,7 +1558,7 @@ public abstract class AbstractCommunicationManager implements Serializable { */ private boolean handleVariables(WrappedRequest request, WrappedResponse response, Callback callback, - Application application2, Root root) throws IOException, + Application application2, UI uI) throws IOException, InvalidUIDLSecurityKeyException, JSONException { boolean success = true; @@ -1592,7 +1594,7 @@ public abstract class AbstractCommunicationManager implements Serializable { for (int bi = 1; bi < bursts.length; bi++) { // unescape any encoded separator characters in the burst final String burst = unescapeBurst(bursts[bi]); - success &= handleBurst(request, root, burst); + success &= handleBurst(request, uI, burst); // In case that there were multiple bursts, we know that this is // a special synchronous case for closing window. Thus we are @@ -1607,7 +1609,7 @@ public abstract class AbstractCommunicationManager implements Serializable { new CharArrayWriter()); paintAfterVariableChanges(request, response, callback, - true, outWriter, root, false); + true, outWriter, uI, false); } @@ -1634,23 +1636,22 @@ public abstract class AbstractCommunicationManager implements Serializable { * directly. * * @param source - * @param root - * the root receiving the burst + * @param uI + * the UI receiving the burst * @param burst * the content of the burst as a String to be parsed * @return true if the processing of the burst was successful and there were * no messages to non-existent components */ - public boolean handleBurst(WrappedRequest source, Root root, - final String burst) { + public boolean handleBurst(WrappedRequest source, UI uI, final String burst) { boolean success = true; try { Set<Connector> enabledConnectors = new HashSet<Connector>(); List<MethodInvocation> invocations = parseInvocations( - root.getConnectorTracker(), burst); + uI.getConnectorTracker(), burst); for (MethodInvocation invocation : invocations) { - final ClientConnector connector = getConnector(root, + final ClientConnector connector = getConnector(uI, invocation.getConnectorId()); if (connector != null && connector.isConnectorEnabled()) { @@ -1661,7 +1662,7 @@ public abstract class AbstractCommunicationManager implements Serializable { for (int i = 0; i < invocations.size(); i++) { MethodInvocation invocation = invocations.get(i); - final ClientConnector connector = getConnector(root, + final ClientConnector connector = getConnector(uI, invocation.getConnectorId()); if (connector == null) { @@ -1717,7 +1718,7 @@ public abstract class AbstractCommunicationManager implements Serializable { if (connector instanceof Component) { errorComponent = (Component) connector; } - handleChangeVariablesError(root.getApplication(), + handleChangeVariablesError(uI.getApplication(), errorComponent, realException, null); } } else { @@ -1749,7 +1750,7 @@ public abstract class AbstractCommunicationManager implements Serializable { errorComponent = (Component) dropHandlerOwner; } } - handleChangeVariablesError(root.getApplication(), + handleChangeVariablesError(uI.getApplication(), errorComponent, e, changes); } } @@ -1879,9 +1880,8 @@ public abstract class AbstractCommunicationManager implements Serializable { owner.changeVariables(source, m); } - protected ClientConnector getConnector(Root root, String connectorId) { - ClientConnector c = root.getConnectorTracker() - .getConnector(connectorId); + protected ClientConnector getConnector(UI uI, String connectorId) { + ClientConnector c = uI.getConnectorTracker().getConnector(connectorId); if (c == null && connectorId.equals(getDragAndDropService().getConnectorId())) { return getDragAndDropService(); @@ -2233,7 +2233,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * invisible subtrees are omitted. * * @param w - * root window for which dirty components is to be fetched + * UI window for which dirty components is to be fetched * @return */ private ArrayList<ClientConnector> getDirtyVisibleConnectors( @@ -2346,7 +2346,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * We will use the same APP/* URI space as ApplicationResources but * prefix url with UPLOAD * - * eg. APP/UPLOAD/[ROOTID]/[PID]/[NAME]/[SECKEY] + * eg. APP/UPLOAD/[UIID]/[PID]/[NAME]/[SECKEY] * * SECKEY is created on each paint to make URL's unpredictable (to * prevent CSRF attacks). @@ -2355,8 +2355,8 @@ public abstract class AbstractCommunicationManager implements Serializable { * handling post */ String paintableId = owner.getConnectorId(); - int rootId = owner.getRoot().getRootId(); - String key = rootId + "/" + paintableId + "/" + name; + int uiId = owner.getUI().getUIId(); + String key = uiId + "/" + paintableId + "/" + name; if (pidToNameToStreamVariable == null) { pidToNameToStreamVariable = new HashMap<String, Map<String, StreamVariable>>(); @@ -2417,34 +2417,34 @@ public abstract class AbstractCommunicationManager implements Serializable { WrappedResponse response, Application application) throws IOException { - // if we do not yet have a currentRoot, it should be initialized + // if we do not yet have a currentUI, it should be initialized // shortly, and we should send the initial UIDL - boolean sendUIDL = Root.getCurrent() == null; + boolean sendUIDL = UI.getCurrent() == null; try { CombinedRequest combinedRequest = new CombinedRequest(request); - Root root = application.getRootForRequest(combinedRequest); + UI uI = application.getUIForRequest(combinedRequest); response.setContentType("application/json; charset=UTF-8"); - // Use the same logic as for determined roots + // Use the same logic as for determined UIs BootstrapHandler bootstrapHandler = getBootstrapHandler(); BootstrapContext context = bootstrapHandler.createContext( - combinedRequest, response, application, root.getRootId()); + combinedRequest, response, application, uI.getUIId()); String widgetset = context.getWidgetsetName(); String theme = context.getThemeName(); String themeUri = bootstrapHandler.getThemeUri(context, theme); - // TODO These are not required if it was only the init of the root + // TODO These are not required if it was only the init of the UI // that was delayed JSONObject params = new JSONObject(); params.put("widgetset", widgetset); params.put("themeUri", themeUri); - // Root id might have changed based on e.g. window.name - params.put(ApplicationConstants.ROOT_ID_PARAMETER, root.getRootId()); + // UI id might have changed based on e.g. window.name + params.put(UIConstants.UI_ID_PARAMETER, uI.getUIId()); if (sendUIDL) { - String initialUIDL = getInitialUIDL(combinedRequest, root); + String initialUIDL = getInitialUIDL(combinedRequest, uI); params.put("uidl", initialUIDL); } @@ -2459,7 +2459,7 @@ public abstract class AbstractCommunicationManager implements Serializable { // NOTE GateIn requires the buffers to be flushed to work outWriter.flush(); out.flush(); - } catch (RootRequiresMoreInformationException e) { + } catch (UIRequiresMoreInformationException e) { // Requiring more information at this point is not allowed // TODO handle in a better way throw new RuntimeException(e); @@ -2475,24 +2475,24 @@ public abstract class AbstractCommunicationManager implements Serializable { * * @param request * the request that caused the initialization - * @param root - * the root for which the UIDL should be generated + * @param uI + * the UI for which the UIDL should be generated * @return a string with the initial UIDL message * @throws PaintException * if an exception occurs while painting * @throws JSONException * if an exception occurs while encoding output */ - protected String getInitialUIDL(WrappedRequest request, Root root) + protected String getInitialUIDL(WrappedRequest request, UI uI) throws PaintException, JSONException { // TODO maybe unify writeUidlResponse()? StringWriter sWriter = new StringWriter(); PrintWriter pWriter = new PrintWriter(sWriter); pWriter.print("{"); - if (isXSRFEnabled(root.getApplication())) { + if (isXSRFEnabled(uI.getApplication())) { pWriter.print(getSecurityKeyUIDL(request)); } - writeUidlResponse(request, true, pWriter, root, false); + writeUidlResponse(request, true, pWriter, uI, false); pWriter.print("}"); String initialUIDL = sWriter.toString(); getLogger().log(Level.FINE, "Initial UIDL:" + initialUIDL); @@ -2525,7 +2525,7 @@ public abstract class AbstractCommunicationManager implements Serializable { final String mimetype = response.getDeploymentConfiguration() .getMimeType(resourceName); - // Security check: avoid accidentally serving from the root of the + // Security check: avoid accidentally serving from the UI of the // classpath instead of relative to the context class if (resourceName.startsWith("/")) { getLogger().warning( @@ -2600,8 +2600,8 @@ public abstract class AbstractCommunicationManager implements Serializable { /** * Handles file upload request submitted via Upload component. * - * @param root - * The root for this request + * @param UI + * The UI for this request * * @see #getStreamVariableTargetUrl(ReceiverOwner, String, StreamVariable) * @@ -2615,7 +2615,7 @@ public abstract class AbstractCommunicationManager implements Serializable { throws IOException, InvalidUIDLSecurityKeyException { /* - * URI pattern: APP/UPLOAD/[ROOTID]/[PID]/[NAME]/[SECKEY] See + * URI pattern: APP/UPLOAD/[UIID]/[PID]/[NAME]/[SECKEY] See * #createReceiverUrl */ @@ -2625,20 +2625,20 @@ public abstract class AbstractCommunicationManager implements Serializable { .indexOf(ServletPortletHelper.UPLOAD_URL_PREFIX) + ServletPortletHelper.UPLOAD_URL_PREFIX.length(); String uppUri = pathInfo.substring(startOfData); - String[] parts = uppUri.split("/", 4); // 0= rootid, 1 = cid, 2= name, 3 + String[] parts = uppUri.split("/", 4); // 0= UIid, 1 = cid, 2= name, 3 // = sec key - String rootId = parts[0]; + String uiId = parts[0]; String connectorId = parts[1]; String variableName = parts[2]; - Root root = application.getRootById(Integer.parseInt(rootId)); - Root.setCurrent(root); + UI uI = application.getUIById(Integer.parseInt(uiId)); + UI.setCurrent(uI); StreamVariable streamVariable = getStreamVariable(connectorId, variableName); String secKey = streamVariableToSeckey.get(streamVariable); if (secKey.equals(parts[3])) { - ClientConnector source = getConnector(root, connectorId); + ClientConnector source = getConnector(uI, connectorId); String contentType = request.getContentType(); if (contentType.contains("boundary")) { // Multipart requests contain boundary string @@ -2660,11 +2660,11 @@ public abstract class AbstractCommunicationManager implements Serializable { /** * Handles a heartbeat request. Heartbeat requests are periodically sent by - * the client-side to inform the server that the root sending the heartbeat - * is still alive (the browser window is open, the connection is up) even - * when there are no UIDL requests for a prolonged period of time. Roots - * that do not receive either heartbeat or UIDL requests are eventually - * removed from the application and garbage collected. + * the client-side to inform the server that the UI sending the heartbeat is + * still alive (the browser window is open, the connection is up) even when + * there are no UIDL requests for a prolonged period of time. UIs that do + * not receive either heartbeat or UIDL requests are eventually removed from + * the application and garbage collected. * * @param request * @param response @@ -2674,19 +2674,18 @@ public abstract class AbstractCommunicationManager implements Serializable { public void handleHeartbeatRequest(WrappedRequest request, WrappedResponse response, Application application) throws IOException { - Root root = null; + UI ui = null; try { - int rootId = Integer.parseInt(request - .getParameter(ApplicationConstants.ROOT_ID_PARAMETER)); - root = application.getRootById(rootId); + int uiId = Integer.parseInt(request + .getParameter(UIConstants.UI_ID_PARAMETER)); + ui = application.getUIById(uiId); } catch (NumberFormatException nfe) { // null-check below handles this as well } - if (root != null) { - root.setLastHeartbeatTime(System.currentTimeMillis()); + if (ui != null) { + ui.setLastHeartbeatTime(System.currentTimeMillis()); } else { - response.sendError(HttpServletResponse.SC_NOT_FOUND, - "Root not found"); + response.sendError(HttpServletResponse.SC_NOT_FOUND, "UI not found"); } } diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java b/server/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java index 30ba82f664..4052f5a400 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java +++ b/server/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java @@ -45,7 +45,7 @@ public abstract class AbstractDeploymentConfiguration implements checkXsrfProtection(); checkResourceCacheTime(); checkHeartbeatInterval(); - checkIdleRootCleanup(); + checkIdleUICleanup(); } @Override @@ -207,7 +207,7 @@ public abstract class AbstractDeploymentConfiguration implements } @Override - public boolean isIdleRootCleanupEnabled() { + public boolean isIdleUICleanupEnabled() { return idleRootCleanupEnabled; } @@ -263,9 +263,9 @@ public abstract class AbstractDeploymentConfiguration implements } } - private void checkIdleRootCleanup() { + private void checkIdleUICleanup() { idleRootCleanupEnabled = getApplicationOrSystemProperty( - Constants.SERVLET_PARAMETER_CLOSE_IDLE_ROOTS, "false").equals( + Constants.SERVLET_PARAMETER_CLOSE_IDLE_UIS, "false").equals( "true"); } diff --git a/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java b/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java index 52885f3fbb..857c7c738c 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java +++ b/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java @@ -20,7 +20,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import com.vaadin.Application; -import com.vaadin.terminal.DefaultRootProvider; +import com.vaadin.terminal.DefaultUIProvider; import com.vaadin.terminal.gwt.server.ServletPortletHelper.ApplicationClassException; /** @@ -70,7 +70,7 @@ public class ApplicationServlet extends AbstractApplicationServlet { // Creates a new application instance try { final Application application = getApplicationClass().newInstance(); - application.addRootProvider(new DefaultRootProvider()); + application.addUIProvider(new DefaultUIProvider()); return application; } catch (final IllegalAccessException e) { diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapFragmentResponse.java b/server/src/com/vaadin/terminal/gwt/server/BootstrapFragmentResponse.java index fabb69784f..6f69086523 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapFragmentResponse.java +++ b/server/src/com/vaadin/terminal/gwt/server/BootstrapFragmentResponse.java @@ -48,17 +48,16 @@ public class BootstrapFragmentResponse extends BootstrapResponse { * @param application * the application for which the bootstrap page should be * generated - * @param rootId - * the generated id of the Root that will be displayed on the - * page + * @param uiId + * the generated id of the UI that will be displayed on the page * @param fragmentNodes * a mutable list containing the DOM nodes that will make up the * application HTML */ public BootstrapFragmentResponse(BootstrapHandler handler, - WrappedRequest request, Application application, Integer rootId, + WrappedRequest request, Application application, Integer uiId, List<Node> fragmentNodes) { - super(handler, request, application, rootId); + super(handler, request, application, uiId); this.fragmentNodes = fragmentNodes; } diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java b/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java index de31e4e779..02005e8d22 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java +++ b/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java @@ -37,17 +37,18 @@ import org.jsoup.nodes.Node; import org.jsoup.parser.Tag; import com.vaadin.Application; -import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.UIRequiresMoreInformationException; import com.vaadin.external.json.JSONException; import com.vaadin.external.json.JSONObject; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.Version; +import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.terminal.DeploymentConfiguration; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.RequestHandler; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.WrappedResponse; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; public abstract class BootstrapHandler implements RequestHandler { @@ -78,19 +79,19 @@ public abstract class BootstrapHandler implements RequestHandler { return bootstrapResponse.getApplication(); } - public Integer getRootId() { - return bootstrapResponse.getRootId(); + public Integer getUIId() { + return bootstrapResponse.getUIId(); } - public Root getRoot() { - return bootstrapResponse.getRoot(); + public UI getUI() { + return bootstrapResponse.getUI(); } public String getWidgetsetName() { if (widgetsetName == null) { - Root root = getRoot(); - if (root != null) { - widgetsetName = getWidgetsetForRoot(this); + UI uI = getUI(); + if (uI != null) { + widgetsetName = getWidgetsetForUI(this); } } return widgetsetName; @@ -98,8 +99,8 @@ public abstract class BootstrapHandler implements RequestHandler { public String getThemeName() { if (themeName == null) { - Root root = getRoot(); - if (root != null) { + UI uI = getUI(); + if (uI != null) { themeName = findAndEscapeThemeName(this); } } @@ -125,22 +126,22 @@ public abstract class BootstrapHandler implements RequestHandler { throws IOException { // TODO Should all urls be handled here? - Integer rootId = null; + Integer uiId = null; try { - Root root = application.getRootForRequest(request); - if (root == null) { - writeError(response, new Throwable("No Root found")); + UI uI = application.getUIForRequest(request); + if (uI == null) { + writeError(response, new Throwable("No UI found")); return true; } - rootId = Integer.valueOf(root.getRootId()); - } catch (RootRequiresMoreInformationException e) { - // Just keep going without rootId + uiId = Integer.valueOf(uI.getUIId()); + } catch (UIRequiresMoreInformationException e) { + // Just keep going without uiId } try { BootstrapContext context = createContext(request, response, - application, rootId); + application, uiId); setupMainDiv(context); BootstrapFragmentResponse fragmentResponse = context @@ -170,8 +171,8 @@ public abstract class BootstrapHandler implements RequestHandler { Map<String, Object> headers = new LinkedHashMap<String, Object>(); Document document = Document.createShell(""); BootstrapPageResponse pageResponse = new BootstrapPageResponse( - this, request, context.getApplication(), - context.getRootId(), document, headers); + this, request, context.getApplication(), context.getUIId(), + document, headers); List<Node> fragmentNodes = fragmentResponse.getFragmentNodes(); Element body = document.body(); for (Node node : fragmentNodes) { @@ -246,8 +247,8 @@ public abstract class BootstrapHandler implements RequestHandler { head.appendElement("meta").attr("http-equiv", "X-UA-Compatible") .attr("content", "chrome=1"); - Root root = context.getRoot(); - String title = ((root == null || root.getCaption() == null) ? "" : root + UI uI = context.getUI(); + String title = ((uI == null || uI.getCaption() == null) ? "" : uI .getCaption()); head.appendElement("title").appendText(title); @@ -272,10 +273,10 @@ public abstract class BootstrapHandler implements RequestHandler { } public BootstrapContext createContext(WrappedRequest request, - WrappedResponse response, Application application, Integer rootId) { + WrappedResponse response, Application application, Integer uiId) { BootstrapContext context = new BootstrapContext(response, - new BootstrapFragmentResponse(this, request, application, - rootId, new ArrayList<Node>())); + new BootstrapFragmentResponse(this, request, application, uiId, + new ArrayList<Node>())); return context; } @@ -293,11 +294,11 @@ public abstract class BootstrapHandler implements RequestHandler { */ protected abstract String getApplicationId(BootstrapContext context); - public String getWidgetsetForRoot(BootstrapContext context) { - Root root = context.getRoot(); + public String getWidgetsetForUI(BootstrapContext context) { + UI uI = context.getUI(); WrappedRequest request = context.getRequest(); - String widgetset = root.getApplication().getWidgetsetForRoot(root); + String widgetset = uI.getApplication().getWidgetsetForUI(uI); if (widgetset == null) { widgetset = request.getDeploymentConfiguration() .getConfiguredWidgetset(request); @@ -417,12 +418,12 @@ public abstract class BootstrapHandler implements RequestHandler { protected JSONObject getApplicationParameters(BootstrapContext context) throws JSONException, PaintException { Application application = context.getApplication(); - Integer rootId = context.getRootId(); + Integer uiId = context.getUIId(); JSONObject appConfig = new JSONObject(); - if (rootId != null) { - appConfig.put(ApplicationConstants.ROOT_ID_PARAMETER, rootId); + if (uiId != null) { + appConfig.put(UIConstants.UI_ID_PARAMETER, uiId); } if (context.getThemeName() != null) { @@ -437,7 +438,7 @@ public abstract class BootstrapHandler implements RequestHandler { appConfig.put("widgetset", context.getWidgetsetName()); - if (rootId == null || application.isRootInitPending(rootId.intValue())) { + if (uiId == null || application.isUIInitPending(uiId.intValue())) { appConfig.put("initialPath", context.getRequest() .getRequestPathInfo()); @@ -447,7 +448,7 @@ public abstract class BootstrapHandler implements RequestHandler { } else { // write the initial UIDL into the config appConfig.put("uidl", - getInitialUIDL(context.getRequest(), context.getRoot())); + getInitialUIDL(context.getRequest(), context.getUI())); } return appConfig; @@ -536,7 +537,7 @@ public abstract class BootstrapHandler implements RequestHandler { * @return */ public String getThemeName(BootstrapContext context) { - return context.getApplication().getThemeForRoot(context.getRoot()); + return context.getApplication().getThemeForUI(context.getUI()); } /** @@ -571,15 +572,15 @@ public abstract class BootstrapHandler implements RequestHandler { * * @param request * the originating request - * @param root - * the root for which the UIDL should be generated + * @param ui + * the UI for which the UIDL should be generated * @return a string with the initial UIDL message * @throws PaintException * if an exception occurs while painting the components * @throws JSONException * if an exception occurs while formatting the output */ - protected abstract String getInitialUIDL(WrappedRequest request, Root root) + protected abstract String getInitialUIDL(WrappedRequest request, UI ui) throws PaintException, JSONException; } diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapPageResponse.java b/server/src/com/vaadin/terminal/gwt/server/BootstrapPageResponse.java index e7440f4c22..847578ef97 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapPageResponse.java +++ b/server/src/com/vaadin/terminal/gwt/server/BootstrapPageResponse.java @@ -51,8 +51,8 @@ public class BootstrapPageResponse extends BootstrapResponse { * @param application * the application for which the bootstrap page should be * generated - * @param rootId - * the generated id of the Root that will be displayed on the + * @param uiId + * the generated id of the UI that will be displayed on the * page * @param document * the DOM document making up the HTML page @@ -60,9 +60,9 @@ public class BootstrapPageResponse extends BootstrapResponse { * a map into which header data can be added */ public BootstrapPageResponse(BootstrapHandler handler, - WrappedRequest request, Application application, Integer rootId, + WrappedRequest request, Application application, Integer uiId, Document document, Map<String, Object> headers) { - super(handler, request, application, rootId); + super(handler, request, application, uiId); this.headers = headers; this.document = document; } diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java b/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java index 10f97e7e79..a422cba345 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java +++ b/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java @@ -19,9 +19,9 @@ package com.vaadin.terminal.gwt.server; import java.util.EventObject; import com.vaadin.Application; -import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.UIRequiresMoreInformationException; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * Base class providing common functionality used in different bootstrap @@ -33,7 +33,7 @@ import com.vaadin.ui.Root; public abstract class BootstrapResponse extends EventObject { private final WrappedRequest request; private final Application application; - private final Integer rootId; + private final Integer uiId; /** * Creates a new bootstrap event. @@ -46,16 +46,15 @@ public abstract class BootstrapResponse extends EventObject { * @param application * the application for which the bootstrap page should be * generated - * @param rootId - * the generated id of the Root that will be displayed on the - * page + * @param uiId + * the generated id of the UI that will be displayed on the page */ public BootstrapResponse(BootstrapHandler handler, WrappedRequest request, - Application application, Integer rootId) { + Application application, Integer uiId) { super(handler); this.request = request; this.application = application; - this.rootId = rootId; + this.uiId = uiId; } /** @@ -91,32 +90,32 @@ public abstract class BootstrapResponse extends EventObject { } /** - * Gets the root id that has been generated for this response. Please note - * that if {@link Application#isRootPreserved()} is enabled, a previously - * created Root with a different id might eventually end up being used. + * Gets the UI id that has been generated for this response. Please note + * that if {@link Application#isUiPreserved()} is enabled, a previously + * created UI with a different id might eventually end up being used. * - * @return the root id + * @return the UI id */ - public Integer getRootId() { - return rootId; + public Integer getUIId() { + return uiId; } /** - * Gets the Root for which this page is being rendered, if available. Some - * features of the framework will postpone the Root selection until after - * the bootstrap page has been rendered and required information from the + * Gets the UI for which this page is being rendered, if available. Some + * features of the framework will postpone the UI selection until after the + * bootstrap page has been rendered and required information from the * browser has been sent back. This method will return <code>null</code> if - * no Root instance is yet available. + * no UI instance is yet available. * - * @see Application#isRootPreserved() - * @see Application#getRoot(WrappedRequest) - * @see RootRequiresMoreInformationException + * @see Application#isUiPreserved() + * @see Application#getUI(WrappedRequest) + * @see UIRequiresMoreInformationException * - * @return The Root that will be displayed in the page being generated, or + * @return The UI that will be displayed in the page being generated, or * <code>null</code> if all required information is not yet * available. */ - public Root getRoot() { - return Root.getCurrent(); + public UI getUI() { + return UI.getCurrent(); } } diff --git a/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java b/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java index c9fe2563f9..c2fbbe37d4 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java +++ b/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java @@ -18,13 +18,15 @@ package com.vaadin.terminal.gwt.server; import java.util.Collection; import java.util.List; +import com.vaadin.external.json.JSONException; +import com.vaadin.external.json.JSONObject; import com.vaadin.shared.Connector; import com.vaadin.shared.communication.SharedState; import com.vaadin.terminal.AbstractClientConnector; import com.vaadin.terminal.Extension; import com.vaadin.ui.Component; import com.vaadin.ui.ComponentContainer; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * Interface implemented by all connectors that are capable of communicating @@ -63,17 +65,39 @@ public interface ClientConnector extends Connector, RpcTarget { public ClientConnector getParent(); /** - * Requests that the connector should be repainted as soon as possible. + * @deprecated As of 7.0.0, use {@link #markAsDirty()} instead */ + @Deprecated public void requestRepaint(); /** - * Causes a repaint of this connector, and all connectors below it. + * Marks that this connector's state might have changed. When the framework + * is about to send new data to the client-side, it will run + * {@link #beforeClientResponse(boolean)} followed by {@link #encodeState()} + * for all connectors that are marked as dirty and send any updated state + * info to the client. * + * @since 7.0.0 + */ + public void markAsDirty(); + + /** + * @deprecated As of 7.0.0, use {@link #markAsDirtyRecursive()} instead + */ + @Deprecated + public void requestRepaintAll(); + + /** + * Causes this connector and all connectors below it to be marked as dirty. + * <p> * This should only be used in special cases, e.g when the state of a * descendant depends on the state of an ancestor. + * + * @see #markAsDirty() + * + * @since 7.0.0 */ - public void requestRepaintAll(); + public void markAsDirtyRecursive(); /** * Sets the parent connector of the connector. @@ -151,12 +175,12 @@ public interface ClientConnector extends Connector, RpcTarget { public void removeExtension(Extension extension); /** - * Returns the root this connector is attached to + * Returns the UI this connector is attached to * - * @return The Root this connector is attached to or null if it is not - * attached to any Root + * @return The UI this connector is attached to or null if it is not + * attached to any UI */ - public Root getRoot(); + public UI getUI(); /** * Called before the shared state and RPC invocations are sent to the @@ -177,4 +201,16 @@ public interface ClientConnector extends Connector, RpcTarget { * @since 7.0 */ public void beforeClientResponse(boolean initial); + + /** + * Called by the framework to encode the state to a JSONObject. This is + * typically done by calling the static method + * {@link AbstractCommunicationManager#encodeState(ClientConnector, SharedState)} + * . + * + * @return a JSON object with the encoded connector state + * @throws JSONException + * if the state can not be encoded + */ + public JSONObject encodeState() throws JSONException; } diff --git a/server/src/com/vaadin/terminal/gwt/server/ClientMethodInvocation.java b/server/src/com/vaadin/terminal/gwt/server/ClientMethodInvocation.java index 25d0b23725..7cc5159bc0 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ClientMethodInvocation.java +++ b/server/src/com/vaadin/terminal/gwt/server/ClientMethodInvocation.java @@ -34,7 +34,7 @@ public class ClientMethodInvocation implements Serializable, private final Object[] parameters; private Type[] parameterTypes; - // used for sorting calls between different connectors in the same Root + // used for sorting calls between different connectors in the same UI private final long sequenceNumber; // TODO may cause problems when clustering etc. private static long counter = 0; diff --git a/server/src/com/vaadin/terminal/gwt/server/CommunicationManager.java b/server/src/com/vaadin/terminal/gwt/server/CommunicationManager.java index e0386b51b4..7551e849a1 100644 --- a/server/src/com/vaadin/terminal/gwt/server/CommunicationManager.java +++ b/server/src/com/vaadin/terminal/gwt/server/CommunicationManager.java @@ -25,7 +25,7 @@ import com.vaadin.Application; import com.vaadin.external.json.JSONException; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * Application manager processes changes and paints for single application @@ -111,17 +111,17 @@ public class CommunicationManager extends AbstractCommunicationManager { } @Override - protected String getInitialUIDL(WrappedRequest request, Root root) + protected String getInitialUIDL(WrappedRequest request, UI uI) throws PaintException, JSONException { - return CommunicationManager.this.getInitialUIDL(request, root); + return CommunicationManager.this.getInitialUIDL(request, uI); } }; } @Override - protected InputStream getThemeResourceAsStream(Root root, String themeName, + protected InputStream getThemeResourceAsStream(UI uI, String themeName, String resource) { - WebApplicationContext context = (WebApplicationContext) root + WebApplicationContext context = (WebApplicationContext) uI .getApplication().getContext(); ServletContext servletContext = context.getHttpSession() .getServletContext(); diff --git a/server/src/com/vaadin/terminal/gwt/server/Constants.java b/server/src/com/vaadin/terminal/gwt/server/Constants.java index adf26bf7f7..9640216488 100644 --- a/server/src/com/vaadin/terminal/gwt/server/Constants.java +++ b/server/src/com/vaadin/terminal/gwt/server/Constants.java @@ -65,7 +65,7 @@ public interface Constants { static final String SERVLET_PARAMETER_DISABLE_XSRF_PROTECTION = "disable-xsrf-protection"; static final String SERVLET_PARAMETER_RESOURCE_CACHE_TIME = "resourceCacheTime"; static final String SERVLET_PARAMETER_HEARTBEAT_RATE = "heartbeatRate"; - static final String SERVLET_PARAMETER_CLOSE_IDLE_ROOTS = "closeIdleRoots"; + static final String SERVLET_PARAMETER_CLOSE_IDLE_UIS = "closeIdleUIs"; // Configurable parameter names static final String PARAMETER_VAADIN_RESOURCES = "Resources"; @@ -86,7 +86,7 @@ public interface Constants { // Widget set parameter name static final String PARAMETER_WIDGETSET = "widgetset"; - static final String ERROR_NO_ROOT_FOUND = "Application did not return a root for the request and did not request extra information either. Something is wrong."; + static final String ERROR_NO_UI_FOUND = "No UIProvider returned a UI for the request."; static final String DEFAULT_THEME_NAME = "reindeer"; diff --git a/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java b/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java index 56d5ed1393..0106f466fc 100644 --- a/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java +++ b/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java @@ -31,6 +31,8 @@ import com.vaadin.event.dd.DropTarget; import com.vaadin.event.dd.TargetDetails; import com.vaadin.event.dd.TargetDetailsImpl; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; +import com.vaadin.external.json.JSONException; +import com.vaadin.external.json.JSONObject; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.communication.SharedState; import com.vaadin.shared.ui.dd.DragEventType; @@ -38,7 +40,7 @@ import com.vaadin.terminal.Extension; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.VariableOwner; import com.vaadin.ui.Component; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; public class DragAndDropService implements VariableOwner, ClientConnector { @@ -235,12 +237,6 @@ public class DragAndDropService implements VariableOwner, ClientConnector { } @Override - public SharedState getState() { - // TODO Auto-generated method stub - return null; - } - - @Override public String getConnectorId() { return ApplicationConstants.DRAG_AND_DROP_CONNECTOR_ID; } @@ -268,7 +264,13 @@ public class DragAndDropService implements VariableOwner, ClientConnector { } @Override + @Deprecated public void requestRepaint() { + markAsDirty(); + } + + @Override + public void markAsDirty() { // TODO Auto-generated method stub } @@ -280,7 +282,13 @@ public class DragAndDropService implements VariableOwner, ClientConnector { } @Override + @Deprecated public void requestRepaintAll() { + markAsDirtyRecursive(); + } + + @Override + public void markAsDirtyRecursive() { // TODO Auto-generated method stub } @@ -319,7 +327,7 @@ public class DragAndDropService implements VariableOwner, ClientConnector { } @Override - public Root getRoot() { + public UI getUI() { return null; } @@ -327,4 +335,10 @@ public class DragAndDropService implements VariableOwner, ClientConnector { public void beforeClientResponse(boolean initial) { // Nothing to do } + + @Override + public JSONObject encodeState() throws JSONException { + // TODO Auto-generated method stub + return null; + } } diff --git a/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java b/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java index 892f7ec526..1eee9c4f52 100644 --- a/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java +++ b/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java @@ -21,9 +21,10 @@ import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.io.Serializable; import java.lang.reflect.Array; +import java.lang.reflect.Field; import java.lang.reflect.GenericArrayType; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.lang.reflect.WildcardType; @@ -55,6 +56,107 @@ import com.vaadin.ui.ConnectorTracker; */ public class JsonCodec implements Serializable { + public static interface BeanProperty { + public Object getValue(Object bean) throws Exception; + + public void setValue(Object bean, Object value) throws Exception; + + public String getName(); + + public Type getType(); + } + + private static class FieldProperty implements BeanProperty { + private final Field field; + + public FieldProperty(Field field) { + this.field = field; + } + + @Override + public Object getValue(Object bean) throws Exception { + return field.get(bean); + } + + @Override + public void setValue(Object bean, Object value) throws Exception { + field.set(bean, value); + } + + @Override + public String getName() { + return field.getName(); + } + + @Override + public Type getType() { + return field.getGenericType(); + } + + public static Collection<FieldProperty> find(Class<?> type) + throws IntrospectionException { + Collection<FieldProperty> properties = new ArrayList<FieldProperty>(); + + Field[] fields = type.getFields(); + for (Field field : fields) { + if (!Modifier.isStatic(field.getModifiers())) { + properties.add(new FieldProperty(field)); + } + } + + return properties; + } + + } + + private static class MethodProperty implements BeanProperty { + private final PropertyDescriptor pd; + + public MethodProperty(PropertyDescriptor pd) { + this.pd = pd; + } + + @Override + public Object getValue(Object bean) throws Exception { + Method readMethod = pd.getReadMethod(); + return readMethod.invoke(bean); + } + + @Override + public void setValue(Object bean, Object value) throws Exception { + pd.getWriteMethod().invoke(bean, value); + } + + @Override + public String getName() { + String fieldName = pd.getWriteMethod().getName().substring(3); + fieldName = Character.toLowerCase(fieldName.charAt(0)) + + fieldName.substring(1); + return fieldName; + } + + public static Collection<MethodProperty> find(Class<?> type) + throws IntrospectionException { + Collection<MethodProperty> properties = new ArrayList<MethodProperty>(); + + for (PropertyDescriptor pd : Introspector.getBeanInfo(type) + .getPropertyDescriptors()) { + if (pd.getReadMethod() == null || pd.getWriteMethod() == null) { + continue; + } + + properties.add(new MethodProperty(pd)); + } + return properties; + } + + @Override + public Type getType() { + return pd.getReadMethod().getGenericReturnType(); + } + + } + private static Map<Class<?>, String> typeToTransportType = new HashMap<Class<?>, String>(); /** @@ -468,27 +570,6 @@ public class JsonCodec implements Serializable { return set; } - /** - * Returns the name that should be used as field name in the JSON. We strip - * "set" from the setter, keeping the result - this is easy to do on both - * server and client, avoiding some issues with cASE. E.g setZIndex() - * becomes "zIndex". Also ensures that both getter and setter are present, - * returning null otherwise. - * - * @param pd - * @return the name to be used or null if both getter and setter are not - * found. - */ - static String getTransportFieldName(PropertyDescriptor pd) { - if (pd.getReadMethod() == null || pd.getWriteMethod() == null) { - return null; - } - String fieldName = pd.getWriteMethod().getName().substring(3); - fieldName = Character.toLowerCase(fieldName.charAt(0)) - + fieldName.substring(1); - return fieldName; - } - private static Object decodeObject(Type targetType, JSONObject serializedObject, ConnectorTracker connectorTracker) throws JSONException { @@ -497,31 +578,19 @@ public class JsonCodec implements Serializable { try { Object decodedObject = targetClass.newInstance(); - for (PropertyDescriptor pd : Introspector.getBeanInfo(targetClass) - .getPropertyDescriptors()) { + for (BeanProperty property : getProperties(targetClass)) { - String fieldName = getTransportFieldName(pd); - if (fieldName == null) { - continue; - } + String fieldName = property.getName(); Object encodedFieldValue = serializedObject.get(fieldName); - Type fieldType = pd.getReadMethod().getGenericReturnType(); + Type fieldType = property.getType(); Object decodedFieldValue = decodeInternalOrCustomType( fieldType, encodedFieldValue, connectorTracker); - pd.getWriteMethod().invoke(decodedObject, decodedFieldValue); + property.setValue(decodedObject, decodedFieldValue); } return decodedObject; - } catch (IllegalArgumentException e) { - throw new JSONException(e); - } catch (IllegalAccessException e) { - throw new JSONException(e); - } catch (InvocationTargetException e) { - throw new JSONException(e); - } catch (InstantiationException e) { - throw new JSONException(e); - } catch (IntrospectionException e) { + } catch (Exception e) { throw new JSONException(e); } } @@ -602,22 +671,27 @@ public class JsonCodec implements Serializable { return JSONObject.NULL; } + public static Collection<BeanProperty> getProperties(Class<?> type) + throws IntrospectionException { + Collection<BeanProperty> properties = new ArrayList<BeanProperty>(); + + properties.addAll(MethodProperty.find(type)); + properties.addAll(FieldProperty.find(type)); + + return properties; + } + private static Object encodeObject(Object value, JSONObject diffState, ConnectorTracker connectorTracker) throws JSONException { JSONObject jsonMap = new JSONObject(); try { - for (PropertyDescriptor pd : Introspector.getBeanInfo( - value.getClass()).getPropertyDescriptors()) { - String fieldName = getTransportFieldName(pd); - if (fieldName == null) { - continue; - } - Method getterMethod = pd.getReadMethod(); + for (BeanProperty property : getProperties(value.getClass())) { + String fieldName = property.getName(); // We can't use PropertyDescriptor.getPropertyType() as it does // not support generics - Type fieldType = getterMethod.getGenericReturnType(); - Object fieldValue = getterMethod.invoke(value, (Object[]) null); + Type fieldType = property.getType(); + Object fieldValue = property.getValue(value); boolean equals = false; Object diffStateValue = null; if (diffState != null && diffState.has(fieldName)) { diff --git a/server/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java b/server/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java index a7ee5be96d..3e0f8d6b99 100644 --- a/server/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java +++ b/server/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java @@ -46,7 +46,7 @@ import javax.xml.namespace.QName; import com.vaadin.Application; import com.vaadin.terminal.ExternalResource; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * TODO Write documentation, fix JavaDoc tags. @@ -180,18 +180,18 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { } } - public void firePortletRenderRequest(Application app, Root root, + public void firePortletRenderRequest(Application app, UI uI, RenderRequest request, RenderResponse response) { Set<PortletListener> listeners = portletListeners.get(app); if (listeners != null) { for (PortletListener l : listeners) { l.handleRenderRequest(request, new RestrictedRenderResponse( - response), root); + response), uI); } } } - public void firePortletActionRequest(Application app, Root root, + public void firePortletActionRequest(Application app, UI uI, ActionRequest request, ActionResponse response) { String key = request.getParameter(ActionRequest.ACTION_NAME); if (eventActionDestinationMap.containsKey(key)) { @@ -213,28 +213,28 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { Set<PortletListener> listeners = portletListeners.get(app); if (listeners != null) { for (PortletListener l : listeners) { - l.handleActionRequest(request, response, root); + l.handleActionRequest(request, response, uI); } } } } - public void firePortletEventRequest(Application app, Root root, + public void firePortletEventRequest(Application app, UI uI, EventRequest request, EventResponse response) { Set<PortletListener> listeners = portletListeners.get(app); if (listeners != null) { for (PortletListener l : listeners) { - l.handleEventRequest(request, response, root); + l.handleEventRequest(request, response, uI); } } } - public void firePortletResourceRequest(Application app, Root root, + public void firePortletResourceRequest(Application app, UI uI, ResourceRequest request, ResourceResponse response) { Set<PortletListener> listeners = portletListeners.get(app); if (listeners != null) { for (PortletListener l : listeners) { - l.handleResourceRequest(request, response, root); + l.handleResourceRequest(request, response, uI); } } } @@ -242,16 +242,16 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { public interface PortletListener extends Serializable { public void handleRenderRequest(RenderRequest request, - RenderResponse response, Root root); + RenderResponse response, UI uI); public void handleActionRequest(ActionRequest request, - ActionResponse response, Root root); + ActionResponse response, UI uI); public void handleEventRequest(EventRequest request, - EventResponse response, Root root); + EventResponse response, UI uI); public void handleResourceRequest(ResourceRequest request, - ResourceResponse response, Root root); + ResourceResponse response, UI uI); } /** @@ -295,7 +295,7 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { * Event names for events sent and received by a portlet need to be declared * in portlet.xml . * - * @param root + * @param uI * a window in which a temporary action URL can be opened if * necessary * @param name @@ -304,7 +304,7 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { * event value object that is Serializable and, if appropriate, * has a valid JAXB annotation */ - public void sendPortletEvent(Root root, QName name, Serializable value) + public void sendPortletEvent(UI uI, QName name, Serializable value) throws IllegalStateException { if (response instanceof MimeResponse) { String actionKey = "" + System.currentTimeMillis(); @@ -315,7 +315,7 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { if (actionUrl != null) { eventActionDestinationMap.put(actionKey, name); eventActionValueMap.put(actionKey, value); - root.getPage().open(new ExternalResource(actionUrl.toString())); + uI.getPage().open(new ExternalResource(actionUrl.toString())); } else { // this should never happen as we already know the response is a // MimeResponse @@ -342,7 +342,7 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { * Shared parameters set or read by a portlet need to be declared in * portlet.xml . * - * @param root + * @param uI * a window in which a temporary action URL can be opened if * necessary * @param name @@ -350,7 +350,7 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { * @param value * parameter value */ - public void setSharedRenderParameter(Root root, String name, String value) + public void setSharedRenderParameter(UI uI, String name, String value) throws IllegalStateException { if (response instanceof MimeResponse) { String actionKey = "" + System.currentTimeMillis(); @@ -361,7 +361,7 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { if (actionUrl != null) { sharedParameterActionNameMap.put(actionKey, name); sharedParameterActionValueMap.put(actionKey, value); - root.getPage().open(new ExternalResource(actionUrl.toString())); + uI.getPage().open(new ExternalResource(actionUrl.toString())); } else { // this should never happen as we already know the response is a // MimeResponse @@ -381,7 +381,7 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { * * Portlet modes used by a portlet need to be declared in portlet.xml . * - * @param root + * @param uI * a window in which the render URL can be opened if necessary * @param portletMode * the portlet mode to switch to @@ -389,13 +389,13 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { * if the portlet mode is not allowed for some reason * (configuration, permissions etc.) */ - public void setPortletMode(Root root, PortletMode portletMode) + public void setPortletMode(UI uI, PortletMode portletMode) throws IllegalStateException, PortletModeException { if (response instanceof MimeResponse) { PortletURL url = ((MimeResponse) response).createRenderURL(); url.setPortletMode(portletMode); - throw new RuntimeException("Root.open has not yet been implemented"); - // root.open(new ExternalResource(url.toString())); + throw new RuntimeException("UI.open has not yet been implemented"); + // UI.open(new ExternalResource(url.toString())); } else if (response instanceof StateAwareResponse) { ((StateAwareResponse) response).setPortletMode(portletMode); } else { diff --git a/server/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java b/server/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java index b6fbbec298..e127425786 100644 --- a/server/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java +++ b/server/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java @@ -34,7 +34,7 @@ import com.vaadin.terminal.DeploymentConfiguration; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.WrappedResponse; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * TODO document me! @@ -142,10 +142,10 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { } @Override - protected String getInitialUIDL(WrappedRequest request, Root root) + protected String getInitialUIDL(WrappedRequest request, UI uI) throws PaintException, JSONException { return PortletCommunicationManager.this.getInitialUIDL(request, - root); + uI); } @Override @@ -168,9 +168,9 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { } @Override - protected InputStream getThemeResourceAsStream(Root root, String themeName, + protected InputStream getThemeResourceAsStream(UI uI, String themeName, String resource) { - PortletApplicationContext2 context = (PortletApplicationContext2) root + PortletApplicationContext2 context = (PortletApplicationContext2) uI .getApplication().getContext(); PortletContext portletContext = context.getPortletSession() .getPortletContext(); diff --git a/server/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java b/server/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java index 6911101920..1d35785a57 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java +++ b/server/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java @@ -6,7 +6,7 @@ import com.vaadin.Application; import com.vaadin.shared.ApplicationConstants; import com.vaadin.terminal.DeploymentConfiguration; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /* * Copyright 2011 Vaadin Ltd. @@ -43,14 +43,14 @@ class ServletPortletHelper implements Serializable { throws ApplicationClassException { String applicationParameter = deploymentConfiguration .getInitParameters().getProperty("application"); - String rootParameter = deploymentConfiguration.getInitParameters() - .getProperty(Application.ROOT_PARAMETER); + String uiParameter = deploymentConfiguration.getInitParameters() + .getProperty(Application.UI_PARAMETER); ClassLoader classLoader = deploymentConfiguration.getClassLoader(); if (applicationParameter == null) { // Validate the parameter value - verifyRootClass(rootParameter, classLoader); + verifyUIClass(uiParameter, classLoader); // Application can be used if a valid rootLayout is defined return Application.class; @@ -66,22 +66,22 @@ class ServletPortletHelper implements Serializable { } } - private static void verifyRootClass(String className, - ClassLoader classLoader) throws ApplicationClassException { + private static void verifyUIClass(String className, ClassLoader classLoader) + throws ApplicationClassException { if (className == null) { - throw new ApplicationClassException(Application.ROOT_PARAMETER + throw new ApplicationClassException(Application.UI_PARAMETER + " init parameter not defined"); } - // Check that the root layout class can be found + // Check that the UI layout class can be found try { - Class<?> rootClass = classLoader.loadClass(className); - if (!Root.class.isAssignableFrom(rootClass)) { + Class<?> uiClass = classLoader.loadClass(className); + if (!UI.class.isAssignableFrom(uiClass)) { throw new ApplicationClassException(className - + " does not implement Root"); + + " does not implement UI"); } // Try finding a default constructor, else throw exception - rootClass.getConstructor(); + uiClass.getConstructor(); } catch (ClassNotFoundException e) { throw new ApplicationClassException(className + " could not be loaded", e); diff --git a/server/src/com/vaadin/ui/AbsoluteLayout.java b/server/src/com/vaadin/ui/AbsoluteLayout.java index a3bc577fe3..56bbd19852 100644 --- a/server/src/com/vaadin/ui/AbsoluteLayout.java +++ b/server/src/com/vaadin/ui/AbsoluteLayout.java @@ -61,7 +61,7 @@ public class AbsoluteLayout extends AbstractLayout implements } @Override - public AbsoluteLayoutState getState() { + protected AbsoluteLayoutState getState() { return (AbsoluteLayoutState) super.getState(); } @@ -153,7 +153,7 @@ public class AbsoluteLayout extends AbstractLayout implements internalRemoveComponent(c); throw e; } - requestRepaint(); + markAsDirty(); } /** @@ -197,7 +197,7 @@ public class AbsoluteLayout extends AbstractLayout implements public void removeComponent(Component c) { internalRemoveComponent(c); super.removeComponent(c); - requestRepaint(); + markAsDirty(); } /** @@ -245,7 +245,7 @@ public class AbsoluteLayout extends AbstractLayout implements private void internalSetPosition(Component component, ComponentPosition position) { componentToCoordinates.put(component, position); - requestRepaint(); + markAsDirty(); } /** @@ -322,7 +322,7 @@ public class AbsoluteLayout extends AbstractLayout implements } } } - requestRepaint(); + markAsDirty(); } /** @@ -363,7 +363,7 @@ public class AbsoluteLayout extends AbstractLayout implements public void setTop(Float topValue, Unit topUnits) { this.topValue = topValue; this.topUnits = topUnits; - requestRepaint(); + markAsDirty(); } /** @@ -379,7 +379,7 @@ public class AbsoluteLayout extends AbstractLayout implements public void setRight(Float rightValue, Unit rightUnits) { this.rightValue = rightValue; this.rightUnits = rightUnits; - requestRepaint(); + markAsDirty(); } /** @@ -395,7 +395,7 @@ public class AbsoluteLayout extends AbstractLayout implements public void setBottom(Float bottomValue, Unit bottomUnits) { this.bottomValue = bottomValue; this.bottomUnits = bottomUnits; - requestRepaint(); + markAsDirty(); } /** @@ -411,7 +411,7 @@ public class AbsoluteLayout extends AbstractLayout implements public void setLeft(Float leftValue, Unit leftUnits) { this.leftValue = leftValue; this.leftUnits = leftUnits; - requestRepaint(); + markAsDirty(); } /** @@ -422,7 +422,7 @@ public class AbsoluteLayout extends AbstractLayout implements */ public void setZIndex(int zIndex) { this.zIndex = zIndex; - requestRepaint(); + markAsDirty(); } /** @@ -434,7 +434,7 @@ public class AbsoluteLayout extends AbstractLayout implements */ public void setTopValue(Float topValue) { this.topValue = topValue; - requestRepaint(); + markAsDirty(); } /** @@ -468,7 +468,7 @@ public class AbsoluteLayout extends AbstractLayout implements */ public void setRightValue(Float rightValue) { this.rightValue = rightValue; - requestRepaint(); + markAsDirty(); } /** @@ -492,7 +492,7 @@ public class AbsoluteLayout extends AbstractLayout implements */ public void setBottomValue(Float bottomValue) { this.bottomValue = bottomValue; - requestRepaint(); + markAsDirty(); } /** @@ -516,7 +516,7 @@ public class AbsoluteLayout extends AbstractLayout implements */ public void setLeftValue(Float leftValue) { this.leftValue = leftValue; - requestRepaint(); + markAsDirty(); } /** @@ -538,7 +538,7 @@ public class AbsoluteLayout extends AbstractLayout implements */ public void setTopUnits(Unit topUnits) { this.topUnits = topUnits; - requestRepaint(); + markAsDirty(); } /** @@ -560,7 +560,7 @@ public class AbsoluteLayout extends AbstractLayout implements */ public void setRightUnits(Unit rightUnits) { this.rightUnits = rightUnits; - requestRepaint(); + markAsDirty(); } /** @@ -582,7 +582,7 @@ public class AbsoluteLayout extends AbstractLayout implements */ public void setBottomUnits(Unit bottomUnits) { this.bottomUnits = bottomUnits; - requestRepaint(); + markAsDirty(); } /** @@ -604,7 +604,7 @@ public class AbsoluteLayout extends AbstractLayout implements */ public void setLeftUnits(Unit leftUnits) { this.leftUnits = leftUnits; - requestRepaint(); + markAsDirty(); } /** diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index cde5217ca1..a52a07f266 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -121,34 +121,6 @@ public abstract class AbstractComponent extends AbstractClientConnector return getState().getDebugId(); } - /** - * Gets style for component. Multiple styles are joined with spaces. - * - * @return the component's styleValue of property style. - * @deprecated Use getStyleName() instead; renamed for consistency and to - * indicate that "style" should not be used to switch client - * side implementation, only to style the component. - */ - @Deprecated - public String getStyle() { - return getStyleName(); - } - - /** - * Sets and replaces all previous style names of the component. This method - * will trigger a {@link RepaintRequestEvent}. - * - * @param style - * the new style of the component. - * @deprecated Use setStyleName() instead; renamed for consistency and to - * indicate that "style" should not be used to switch client - * side implementation, only to style the component. - */ - @Deprecated - public void setStyle(String style) { - setStyleName(style); - } - /* * Gets the component's style. Don't add a JavaDoc comment here, we use the * default documentation from implemented interface. @@ -176,7 +148,6 @@ public abstract class AbstractComponent extends AbstractClientConnector public void setStyleName(String style) { if (style == null || "".equals(style)) { getState().setStyles(null); - requestRepaint(); return; } if (getState().getStyles() == null) { @@ -190,7 +161,6 @@ public abstract class AbstractComponent extends AbstractClientConnector styles.add(part); } } - requestRepaint(); } @Override @@ -212,7 +182,6 @@ public abstract class AbstractComponent extends AbstractClientConnector List<String> styles = getState().getStyles(); if (!styles.contains(style)) { styles.add(style); - requestRepaint(); } } @@ -225,7 +194,6 @@ public abstract class AbstractComponent extends AbstractClientConnector getState().getStyles().remove(part); } } - requestRepaint(); } } @@ -249,7 +217,6 @@ public abstract class AbstractComponent extends AbstractClientConnector @Override public void setCaption(String caption) { getState().setCaption(caption); - requestRepaint(); } /* @@ -295,7 +262,7 @@ public abstract class AbstractComponent extends AbstractClientConnector this.locale = locale; // FIXME: Reload value if there is a converter - requestRepaint(); + markAsDirty(); } /* @@ -317,7 +284,6 @@ public abstract class AbstractComponent extends AbstractClientConnector @Override public void setIcon(Resource icon) { getState().setIcon(ResourceReference.create(icon)); - requestRepaint(); } /* @@ -337,10 +303,7 @@ public abstract class AbstractComponent extends AbstractClientConnector */ @Override public void setEnabled(boolean enabled) { - if (getState().isEnabled() != enabled) { - getState().setEnabled(enabled); - requestRepaint(); - } + getState().setEnabled(enabled); } /* @@ -383,7 +346,6 @@ public abstract class AbstractComponent extends AbstractClientConnector */ public void setImmediate(boolean immediate) { getState().setImmediate(immediate); - requestRepaint(); } /* @@ -408,11 +370,10 @@ public abstract class AbstractComponent extends AbstractClientConnector } getState().setVisible(visible); - requestRepaint(); if (getParent() != null) { // Must always repaint the parent (at least the hierarchy) when // visibility of a child component changes. - getParent().requestRepaint(); + getParent().markAsDirty(); } } @@ -491,7 +452,6 @@ public abstract class AbstractComponent extends AbstractClientConnector */ public void setDescription(String description) { getState().setDescription(description); - requestRepaint(); } /* @@ -575,7 +535,7 @@ public abstract class AbstractComponent extends AbstractClientConnector public void setComponentError(ErrorMessage componentError) { this.componentError = componentError; fireComponentErrorEvent(); - requestRepaint(); + markAsDirty(); } /* @@ -594,17 +554,6 @@ public abstract class AbstractComponent extends AbstractClientConnector @Override public void setReadOnly(boolean readOnly) { getState().setReadOnly(readOnly); - requestRepaint(); - } - - /* - * Gets the parent window of the component. Don't add a JavaDoc comment - * here, we use the default documentation from implemented interface. - */ - @Override - public Root getRoot() { - // Just make method from implemented Component interface public - return super.getRoot(); } /* @@ -629,9 +578,9 @@ public abstract class AbstractComponent extends AbstractClientConnector public void detach() { super.detach(); if (actionManager != null) { - // Remove any existing viewer. Root cast is just to make the + // Remove any existing viewer. UI cast is just to make the // compiler happy - actionManager.setViewer((Root) null); + actionManager.setViewer((UI) null); } } @@ -642,7 +591,7 @@ public abstract class AbstractComponent extends AbstractClientConnector if (this instanceof Focusable) { final Application app = getApplication(); if (app != null) { - getRoot().setFocusedComponent((Focusable) this); + getUI().setFocusedComponent((Focusable) this); delayedFocus = false; } else { delayedFocus = true; @@ -713,7 +662,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * @return updated component shared state */ @Override - public ComponentState getState() { + protected ComponentState getState() { return (ComponentState) super.getState(); } @@ -746,17 +695,6 @@ public abstract class AbstractComponent extends AbstractClientConnector } } - /* Documentation copied from interface */ - @Override - public void requestRepaint() { - // Invisible components (by flag in this particular component) do not - // need repaints - if (!getState().isVisible()) { - return; - } - super.requestRepaint(); - } - /* General event framework */ private static final Method COMPONENT_EVENT_METHOD = ReflectTools @@ -803,7 +741,6 @@ public abstract class AbstractComponent extends AbstractClientConnector if (needRepaint) { getState().addRegisteredEventListener(eventIdentifier); - requestRepaint(); } } @@ -852,7 +789,6 @@ public abstract class AbstractComponent extends AbstractClientConnector eventRouter.removeListener(eventType, target); if (!eventRouter.hasListeners(eventType)) { getState().removeRegisteredEventListener(eventIdentifier); - requestRepaint(); } } } @@ -1159,7 +1095,7 @@ public abstract class AbstractComponent extends AbstractClientConnector } this.height = height; heightUnit = unit; - requestRepaint(); + markAsDirty(); // ComponentSizeValidator.setHeightLocation(this); } @@ -1197,7 +1133,7 @@ public abstract class AbstractComponent extends AbstractClientConnector } this.width = width; widthUnit = unit; - requestRepaint(); + markAsDirty(); // ComponentSizeValidator.setWidthLocation(this); } @@ -1358,19 +1294,19 @@ public abstract class AbstractComponent extends AbstractClientConnector /** * Set a viewer for the action manager to be the parent sub window (if the - * component is in a window) or the root (otherwise). This is still a + * component is in a window) or the UI (otherwise). This is still a * simplification of the real case as this should be handled by the parent * VOverlay (on the client side) if the component is inside an VOverlay * component. */ private void setActionManagerViewer() { - if (actionManager != null && getRoot() != null) { + if (actionManager != null && getUI() != null) { // Attached and has action manager Window w = findAncestor(Window.class); if (w != null) { actionManager.setViewer(w); } else { - actionManager.setViewer(getRoot()); + actionManager.setViewer(getUI()); } } diff --git a/server/src/com/vaadin/ui/AbstractComponentContainer.java b/server/src/com/vaadin/ui/AbstractComponentContainer.java index 7450c76fda..4939eb1265 100644 --- a/server/src/com/vaadin/ui/AbstractComponentContainer.java +++ b/server/src/com/vaadin/ui/AbstractComponentContainer.java @@ -212,7 +212,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent // If the visibility state is toggled it might affect all children // aswell, e.g. make container visible should make children visible if // they were only hidden because the container was hidden. - requestRepaintAll(); + markAsDirtyRecursive(); } @Override @@ -306,12 +306,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent private void repaintChildTrees(Collection<Component> dirtyChildren) { for (Component c : dirtyChildren) { - if (c instanceof ComponentContainer) { - ComponentContainer cc = (ComponentContainer) c; - cc.requestRepaintAll(); - } else { - c.requestRepaint(); - } + c.markAsDirtyRecursive(); } } diff --git a/server/src/com/vaadin/ui/AbstractEmbedded.java b/server/src/com/vaadin/ui/AbstractEmbedded.java new file mode 100644 index 0000000000..9396af5c44 --- /dev/null +++ b/server/src/com/vaadin/ui/AbstractEmbedded.java @@ -0,0 +1,84 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.ui; + +import com.vaadin.shared.ui.AbstractEmbeddedState; +import com.vaadin.terminal.Resource; +import com.vaadin.terminal.gwt.server.ResourceReference; + +/** + * Abstract base for embedding components. + * + * @author Vaadin Ltd. + * @version + * @VERSION@ + * @since 7.0 + */ +@SuppressWarnings("serial") +public abstract class AbstractEmbedded extends AbstractComponent { + + @Override + public AbstractEmbeddedState getState() { + return (AbstractEmbeddedState) super.getState(); + } + + /** + * Sets the object source resource. The dimensions are assumed if possible. + * The type is guessed from resource. + * + * @param source + * the source to set. + */ + public void setSource(Resource source) { + if (source == null) { + getState().setSource(null); + } else { + getState().setSource(new ResourceReference(source)); + } + requestRepaint(); + } + + /** + * Get the object source resource. + * + * @return the source + */ + public Resource getSource() { + ResourceReference ref = ((ResourceReference) getState().getSource()); + if (ref == null) { + return null; + } else { + return ref.getResource(); + } + } + + /** + * Sets this component's alternate text that can be presented instead of the + * component's normal content for accessibility purposes. + * + * @param altText + * A short, human-readable description of this component's + * content. + */ + public void setAlternateText(String altText) { + if (altText != getState().getAlternateText() + || (altText != null && !altText.equals(getState() + .getAlternateText()))) { + getState().setAlternateText(altText); + requestRepaint(); + } + } + + /** + * Gets this component's alternate text that can be presented instead of the + * component's normal content for accessibility purposes. + * + * @returns Alternate text + */ + public String getAlternateText() { + return getState().getAlternateText(); + } + +} diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java index b914fb4c46..5123d08da9 100644 --- a/server/src/com/vaadin/ui/AbstractField.java +++ b/server/src/com/vaadin/ui/AbstractField.java @@ -97,14 +97,9 @@ public abstract class AbstractField<T> extends AbstractComponent implements private LinkedList<Validator> validators = null; /** - * Auto commit mode. + * True if field is in buffered mode, false otherwise */ - private boolean writeThroughMode = true; - - /** - * Reads the value from data-source, when it is not modified. - */ - private boolean readThroughMode = true; + private boolean buffered; /** * Flag to indicate that the field is currently committing its value to the @@ -306,7 +301,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements // Sets the buffering state currentBufferedSourceException = new Buffered.SourceException( this, e); - requestRepaint(); + markAsDirty(); // Throws the source exception throw currentBufferedSourceException; @@ -321,7 +316,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements fireValueChange(false); } else if (wasModified) { // If the value did not change, but the modification status did - requestRepaint(); + markAsDirty(); } } } @@ -345,7 +340,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements */ private T getFieldValue() { // Give the value from abstract buffers if the field if possible - if (dataSource == null || !isReadThrough() || isModified()) { + if (dataSource == null || isBuffered() || isModified()) { return getInternalValue(); } @@ -365,92 +360,6 @@ public abstract class AbstractField<T> extends AbstractComponent implements private void setModified(boolean modified) { getState().setModified(modified); - requestRepaint(); - } - - /* - * Tests if the field is in write-through mode. Don't add a JavaDoc comment - * here, we use the default documentation from the implemented interface. - */ - @Override - public boolean isWriteThrough() { - return writeThroughMode; - } - - /** - * Sets the field's write-through mode to the specified status. When - * switching the write-through mode on, a {@link #commit()} will be - * performed. - * - * @see #setBuffered(boolean) for an easier way to control read through and - * write through modes - * - * @param writeThrough - * Boolean value to indicate if the object should be in - * write-through mode after the call. - * @throws SourceException - * If the operation fails because of an exception is thrown by - * the data source. - * @throws InvalidValueException - * If the implicit commit operation fails because of a - * validation error. - * @deprecated As of 7.0, use {@link #setBuffered(boolean)} instead. Note - * that setReadThrough(true), setWriteThrough(true) equals - * setBuffered(false) - */ - @Override - @Deprecated - public void setWriteThrough(boolean writeThrough) - throws Buffered.SourceException, InvalidValueException { - if (writeThroughMode == writeThrough) { - return; - } - writeThroughMode = writeThrough; - if (writeThroughMode) { - commit(); - } - } - - /* - * Tests if the field is in read-through mode. Don't add a JavaDoc comment - * here, we use the default documentation from the implemented interface. - */ - @Override - public boolean isReadThrough() { - return readThroughMode; - } - - /** - * Sets the field's read-through mode to the specified status. When - * switching read-through mode on, the object's value is updated from the - * data source. - * - * @see #setBuffered(boolean) for an easier way to control read through and - * write through modes - * - * @param readThrough - * Boolean value to indicate if the object should be in - * read-through mode after the call. - * - * @throws SourceException - * If the operation fails because of an exception is thrown by - * the data source. The cause is included in the exception. - * @deprecated As of 7.0, use {@link #setBuffered(boolean)} instead. Note - * that setReadThrough(true), setWriteThrough(true) equals - * setBuffered(false) - */ - @Override - @Deprecated - public void setReadThrough(boolean readThrough) - throws Buffered.SourceException { - if (readThroughMode == readThrough) { - return; - } - readThroughMode = readThrough; - if (!isModified() && readThroughMode && getPropertyDataSource() != null) { - setInternalValue(convertFromDataSource(getDataSourceValue())); - fireValueChange(false); - } } /** @@ -460,34 +369,35 @@ public abstract class AbstractField<T> extends AbstractComponent implements * property data source until {@link #commit()} is called. * </p> * <p> - * Changing buffered mode will change the read through and write through - * state for the field. + * Setting buffered mode from true to false will commit any pending changes. * </p> * <p> - * Mixing calls to {@link #setBuffered(boolean)} and - * {@link #setReadThrough(boolean)} or {@link #setWriteThrough(boolean)} is - * generally a bad idea. + * * </p> * + * @since 7.0.0 * @param buffered * true if buffered mode should be turned on, false otherwise */ @Override public void setBuffered(boolean buffered) { - setReadThrough(!buffered); - setWriteThrough(!buffered); + if (this.buffered == buffered) { + return; + } + this.buffered = buffered; + if (!buffered) { + commit(); + } } /** * Checks the buffered mode of this Field. - * <p> - * This method only returns true if both read and write buffering is used. * * @return true if buffered mode is on, false otherwise */ @Override public boolean isBuffered() { - return !isReadThrough() && !isWriteThrough(); + return buffered; } /* Property interface implementation */ @@ -607,8 +517,8 @@ public abstract class AbstractField<T> extends AbstractComponent implements setModified(dataSource != null); valueWasModifiedByDataSourceDuringCommit = false; - // In write through mode , try to commit - if (isWriteThrough() && dataSource != null + // In not buffering, try to commit + if (!isBuffered() && dataSource != null && (isInvalidCommitted() || isValid())) { try { @@ -625,7 +535,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements // Sets the buffering state currentBufferedSourceException = new Buffered.SourceException( this, e); - requestRepaint(); + markAsDirty(); // Throws the source exception throw currentBufferedSourceException; @@ -895,7 +805,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements validators = new LinkedList<Validator>(); } validators.add(validator); - requestRepaint(); + markAsDirty(); } /** @@ -923,7 +833,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements if (validators != null) { validators.remove(validator); } - requestRepaint(); + markAsDirty(); } /** @@ -933,7 +843,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements if (validators != null) { validators.clear(); } - requestRepaint(); + markAsDirty(); } /** @@ -1160,7 +1070,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements protected void fireValueChange(boolean repaintIsNotNeeded) { fireEvent(new AbstractField.ValueChangeEvent(this)); if (!repaintIsNotNeeded) { - requestRepaint(); + markAsDirty(); } } @@ -1190,7 +1100,6 @@ public abstract class AbstractField<T> extends AbstractComponent implements @Override public void readOnlyStatusChange(Property.ReadOnlyStatusChangeEvent event) { getState().setPropertyReadOnly(event.getProperty().isReadOnly()); - requestRepaint(); } /** @@ -1267,7 +1176,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements */ @Override public void valueChange(Property.ValueChangeEvent event) { - if (isReadThrough()) { + if (!isBuffered()) { if (committingValueToDataSource) { boolean propertyNotifiesOfTheBufferedValue = equals(event .getProperty().getValue(), getInternalValue()); @@ -1322,7 +1231,6 @@ public abstract class AbstractField<T> extends AbstractComponent implements @Override public void setTabIndex(int tabIndex) { getState().setTabIndex(tabIndex); - requestRepaint(); } /** @@ -1356,7 +1264,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements protected void setInternalValue(T newValue) { value = newValue; if (validators != null && !validators.isEmpty()) { - requestRepaint(); + markAsDirty(); } } @@ -1371,7 +1279,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements if (!isListeningToPropertyEvents) { addPropertyListeners(); - if (!isModified() && isReadThrough()) { + if (!isModified() && !isBuffered()) { // Update value from data source discard(); } @@ -1425,7 +1333,6 @@ public abstract class AbstractField<T> extends AbstractComponent implements @Override public void setRequired(boolean required) { getState().setRequired(required); - requestRepaint(); } /** @@ -1440,7 +1347,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements @Override public void setRequiredError(String requiredMessage) { requiredError = requiredMessage; - requestRepaint(); + markAsDirty(); } @Override @@ -1468,7 +1375,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements */ public void setConversionError(String valueConversionError) { this.conversionError = valueConversionError; - requestRepaint(); + markAsDirty(); } /** @@ -1510,7 +1417,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements */ public void setValidationVisible(boolean validateAutomatically) { if (validationVisible != validateAutomatically) { - requestRepaint(); + markAsDirty(); validationVisible = validateAutomatically; } } @@ -1523,7 +1430,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements public void setCurrentBufferedSourceException( Buffered.SourceException currentBufferedSourceException) { this.currentBufferedSourceException = currentBufferedSourceException; - requestRepaint(); + markAsDirty(); } /** @@ -1611,11 +1518,11 @@ public abstract class AbstractField<T> extends AbstractComponent implements */ public void setConverter(Converter<T, ?> converter) { this.converter = (Converter<T, Object>) converter; - requestRepaint(); + markAsDirty(); } @Override - public AbstractFieldState getState() { + protected AbstractFieldState getState() { return (AbstractFieldState) super.getState(); } diff --git a/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java b/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java index c442bf2204..e19bdf1b2b 100644 --- a/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java +++ b/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java @@ -34,9 +34,10 @@ import com.vaadin.terminal.JavaScriptCallbackHelper; * , then <code>com_example_SuperComponent</code> will also be attempted if * <code>com_example_MyComponent</code> has not been defined. * <p> - * JavaScript components have a very simple GWT widget ({@link JavaScriptWidget} - * ) just consisting of a <code>div</code> element to which the JavaScript code - * should initialize its own user interface. + * JavaScript components have a very simple GWT widget ( + * {@link com.vaadin.terminal.gwt.client.ui.JavaScriptWidget} ) just consisting + * of a <code>div</code> element to which the JavaScript code should initialize + * its own user interface. * <p> * The initialization function will be called with <code>this</code> pointing to * a connector wrapper object providing integration to Vaadin with the following @@ -79,7 +80,8 @@ import com.vaadin.terminal.JavaScriptCallbackHelper; * functions is described bellow.</li> * <li><code>translateVaadinUri(uri)</code> - Translates a Vaadin URI to a URL * that can be used in the browser. This is just way of accessing - * {@link ApplicationConnection#translateVaadinUri(String)}</li> + * {@link com.vaadin.terminal.gwt.client.ApplicationConnection#translateVaadinUri(String)} + * </li> * </ul> * The connector wrapper also supports these special functions: * <ul> @@ -90,9 +92,8 @@ import com.vaadin.terminal.JavaScriptCallbackHelper; * {@link #addFunction(String, JavaScriptFunction)} on the server will * automatically be present as a function that triggers the registered function * on the server.</li> - * <li>Any field name referred to using - * {@link #callFunction(String, Object...)} on the server will be called if a - * function has been assigned to the field.</li> + * <li>Any field name referred to using {@link #callFunction(String, Object...)} + * on the server will be called if a function has been assigned to the field.</li> * </ul> * <p> * @@ -168,7 +169,7 @@ public abstract class AbstractJavaScriptComponent extends AbstractComponent { } @Override - public JavaScriptComponentState getState() { + protected JavaScriptComponentState getState() { return (JavaScriptComponentState) super.getState(); } } diff --git a/server/src/com/vaadin/ui/AbstractLayout.java b/server/src/com/vaadin/ui/AbstractLayout.java index dd1d5eab12..6743b09211 100644 --- a/server/src/com/vaadin/ui/AbstractLayout.java +++ b/server/src/com/vaadin/ui/AbstractLayout.java @@ -29,7 +29,7 @@ public abstract class AbstractLayout extends AbstractComponentContainer implements Layout { @Override - public AbstractLayoutState getState() { + protected AbstractLayoutState getState() { return (AbstractLayoutState) super.getState(); } diff --git a/server/src/com/vaadin/ui/AbstractMedia.java b/server/src/com/vaadin/ui/AbstractMedia.java index 51a3bcd2be..77c12ac045 100644 --- a/server/src/com/vaadin/ui/AbstractMedia.java +++ b/server/src/com/vaadin/ui/AbstractMedia.java @@ -33,7 +33,7 @@ import com.vaadin.terminal.gwt.server.ResourceReference; public abstract class AbstractMedia extends AbstractComponent { @Override - public AbstractMediaState getState() { + protected AbstractMediaState getState() { return (AbstractMediaState) super.getState(); } @@ -66,7 +66,6 @@ public abstract class AbstractMedia extends AbstractComponent { if (source != null) { getState().getSources().add(new ResourceReference(source)); getState().getSourceTypes().add(source.getMIMEType()); - requestRepaint(); } } @@ -103,7 +102,6 @@ public abstract class AbstractMedia extends AbstractComponent { */ public void setShowControls(boolean showControls) { getState().setShowControls(showControls); - requestRepaint(); } /** @@ -126,7 +124,6 @@ public abstract class AbstractMedia extends AbstractComponent { */ public void setAltText(String altText) { getState().setAltText(altText); - requestRepaint(); } /** @@ -145,7 +142,6 @@ public abstract class AbstractMedia extends AbstractComponent { */ public void setHtmlContentAllowed(boolean htmlContentAllowed) { getState().setHtmlContentAllowed(htmlContentAllowed); - requestRepaint(); } /** @@ -164,7 +160,6 @@ public abstract class AbstractMedia extends AbstractComponent { */ public void setAutoplay(boolean autoplay) { getState().setAutoplay(autoplay); - requestRepaint(); } /** @@ -181,7 +176,6 @@ public abstract class AbstractMedia extends AbstractComponent { */ public void setMuted(boolean muted) { getState().setMuted(muted); - requestRepaint(); } /** diff --git a/server/src/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java index 3ac4e76bdb..596bbb7ee2 100644 --- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java @@ -63,7 +63,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements } @Override - public AbstractOrderedLayoutState getState() { + protected AbstractOrderedLayoutState getState() { return (AbstractOrderedLayoutState) super.getState(); } @@ -144,13 +144,10 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements private void componentRemoved(Component c) { getState().getChildData().remove(c); - requestRepaint(); } private void componentAdded(Component c) { getState().getChildData().put(c, new ChildComponentData()); - requestRepaint(); - } /** @@ -228,23 +225,10 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements components.add(newLocation, oldComponent); } - requestRepaint(); + markAsDirty(); } } - /* - * (non-Javadoc) - * - * @see com.vaadin.ui.Layout.AlignmentHandler#setComponentAlignment(com - * .vaadin.ui.Component, int, int) - */ - @Override - public void setComponentAlignment(Component childComponent, - int horizontalAlignment, int verticalAlignment) { - Alignment a = new Alignment(horizontalAlignment + verticalAlignment); - setComponentAlignment(childComponent, a); - } - @Override public void setComponentAlignment(Component childComponent, Alignment alignment) { @@ -253,7 +237,6 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements if (childData != null) { // Alignments are bit masks childData.setAlignmentBitmask(alignment.getBitMask()); - requestRepaint(); } else { throw new IllegalArgumentException( "Component must be added to layout before using setComponentAlignment()"); @@ -287,7 +270,6 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements @Override public void setSpacing(boolean spacing) { getState().setSpacing(spacing); - requestRepaint(); } /* @@ -337,8 +319,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements } childData.setExpandRatio(ratio); - requestRepaint(); - }; + } /** * Returns the expand ratio of given component. @@ -394,6 +375,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements return components.get(index); } + @Override public void setMargin(boolean enabled) { setMargin(new MarginInfo(enabled)); } @@ -403,6 +385,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements * * @see com.vaadin.ui.Layout.MarginHandler#getMargin() */ + @Override public MarginInfo getMargin() { return new MarginInfo(getState().getMarginsBitmask()); } @@ -412,8 +395,8 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements * * @see com.vaadin.ui.Layout.MarginHandler#setMargin(MarginInfo) */ + @Override public void setMargin(MarginInfo marginInfo) { getState().setMarginsBitmask(marginInfo.getBitMask()); - requestRepaint(); } } diff --git a/server/src/com/vaadin/ui/AbstractSelect.java b/server/src/com/vaadin/ui/AbstractSelect.java index 19a74782c4..21ff7ba948 100644 --- a/server/src/com/vaadin/ui/AbstractSelect.java +++ b/server/src/com/vaadin/ui/AbstractSelect.java @@ -462,7 +462,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements if (!isNullSelectionAllowed() && (id == null || id == getNullSelectionItemId())) { // skip empty selection if nullselection is not allowed - requestRepaint(); + markAsDirty(); } else if (id != null && containsId(id)) { acceptedSelections.add(id); } @@ -470,7 +470,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements if (!isNullSelectionAllowed() && acceptedSelections.size() < 1) { // empty selection not allowed, keep old value - requestRepaint(); + markAsDirty(); return; } @@ -498,7 +498,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements if (!isNullSelectionAllowed() && (clientSideSelectedKeys.length == 0 || clientSideSelectedKeys[0] == null || clientSideSelectedKeys[0] == getNullSelectionItemId())) { - requestRepaint(); + markAsDirty(); return; } if (clientSideSelectedKeys.length == 0) { @@ -513,7 +513,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements final Object id = itemIdMapper .get(clientSideSelectedKeys[0]); if (!isNullSelectionAllowed() && id == null) { - requestRepaint(); + markAsDirty(); } else if (id != null && id.equals(getNullSelectionItemId())) { setValue(null, true); @@ -975,7 +975,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements */ setValue(null); - requestRepaint(); + markAsDirty(); } } @@ -1042,7 +1042,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements } } - requestRepaint(); + markAsDirty(); } } @@ -1071,7 +1071,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements this.allowNewOptions = allowNewOptions; - requestRepaint(); + markAsDirty(); } } @@ -1087,7 +1087,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements public void setItemCaption(Object itemId, String caption) { if (itemId != null) { itemCaptions.put(itemId, caption); - requestRepaint(); + markAsDirty(); } } @@ -1173,7 +1173,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements } else { itemIcons.put(itemId, icon); } - requestRepaint(); + markAsDirty(); } } @@ -1239,7 +1239,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements public void setItemCaptionMode(ItemCaptionMode mode) { if (mode != null) { itemCaptionMode = mode; - requestRepaint(); + markAsDirty(); } } @@ -1302,13 +1302,13 @@ public abstract class AbstractSelect extends AbstractField<Object> implements if (propertyId != null) { itemCaptionPropertyId = propertyId; setItemCaptionMode(ITEM_CAPTION_MODE_PROPERTY); - requestRepaint(); + markAsDirty(); } else { itemCaptionPropertyId = null; if (getItemCaptionMode() == ITEM_CAPTION_MODE_PROPERTY) { setItemCaptionMode(ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID); } - requestRepaint(); + markAsDirty(); } } @@ -1360,7 +1360,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements throw new IllegalArgumentException( "Property type must be assignable to Resource"); } - requestRepaint(); + markAsDirty(); } /** @@ -1579,7 +1579,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements .containerPropertySetChange(event); } } - requestRepaint(); + markAsDirty(); } /** @@ -1594,7 +1594,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements .containerItemSetChange(event); } } - requestRepaint(); + markAsDirty(); } /** @@ -1665,7 +1665,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements public void setNullSelectionAllowed(boolean nullSelectionAllowed) { if (nullSelectionAllowed != this.nullSelectionAllowed) { this.nullSelectionAllowed = nullSelectionAllowed; - requestRepaint(); + markAsDirty(); } } @@ -1824,13 +1824,13 @@ public abstract class AbstractSelect extends AbstractField<Object> implements @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { - requestRepaint(); + markAsDirty(); } @Override public void itemPropertySetChange( com.vaadin.data.Item.PropertySetChangeEvent event) { - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/AbstractSplitPanel.java b/server/src/com/vaadin/ui/AbstractSplitPanel.java index 03e8a2dfb6..8b7499115c 100644 --- a/server/src/com/vaadin/ui/AbstractSplitPanel.java +++ b/server/src/com/vaadin/ui/AbstractSplitPanel.java @@ -154,8 +154,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { if (c != null) { super.addComponent(c); } - - requestRepaint(); } /** @@ -179,7 +177,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { if (c != null) { super.addComponent(c); } - requestRepaint(); } /** @@ -217,7 +214,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { } else if (c == getSecondComponent()) { getState().setSecondChild(null); } - requestRepaint(); + markAsDirty(); } /* @@ -259,7 +256,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { } else if (oldComponent == getSecondComponent()) { setSecondComponent(newComponent); } - requestRepaint(); + markAsDirty(); } /** @@ -329,8 +326,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { splitterState.setPositionUnit(unit.getSymbol()); splitterState.setPositionReversed(reverse); posUnit = unit; - - requestRepaint(); } /** @@ -452,8 +447,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { state.setMaxPosition(maxPos); state.setMaxPositionUnit(maxPosUnit.getSymbol()); posMaxUnit = maxPosUnit; - - requestRepaint(); } /** @@ -465,7 +458,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { */ public void setLocked(boolean locked) { getSplitterState().setLocked(locked); - requestRepaint(); } /** @@ -520,7 +512,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { } @Override - public AbstractSplitPanelState getState() { + protected AbstractSplitPanelState getState() { return (AbstractSplitPanelState) super.getState(); } diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java index 86315f801f..1bd61023a4 100644 --- a/server/src/com/vaadin/ui/AbstractTextField.java +++ b/server/src/com/vaadin/ui/AbstractTextField.java @@ -92,7 +92,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements } @Override - public AbstractTextFieldState getState() { + protected AbstractTextFieldState getState() { return (AbstractTextFieldState) super.getState(); } @@ -184,7 +184,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements // If the modified status changes, or if we have a // formatter, repaint is needed after all. if (wasModified != isModified()) { - requestRepaint(); + markAsDirty(); } } } @@ -271,7 +271,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements */ public void setNullRepresentation(String nullRepresentation) { this.nullRepresentation = nullRepresentation; - requestRepaint(); + markAsDirty(); } /** @@ -297,7 +297,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements */ public void setNullSettingAllowed(boolean nullSettingAllowed) { this.nullSettingAllowed = nullSettingAllowed; - requestRepaint(); + markAsDirty(); } @Override @@ -324,7 +324,6 @@ public abstract class AbstractTextField extends AbstractField<String> implements */ public void setMaxLength(int maxLength) { getState().setMaxLength(maxLength); - requestRepaint(); } /** @@ -351,7 +350,6 @@ public abstract class AbstractTextField extends AbstractField<String> implements columns = 0; } getState().setColumns(columns); - requestRepaint(); } /** @@ -372,7 +370,6 @@ public abstract class AbstractTextField extends AbstractField<String> implements */ public void setInputPrompt(String inputPrompt) { getState().setInputPrompt(inputPrompt); - requestRepaint(); } /* ** Text Change Events ** */ @@ -443,7 +440,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements */ if (lastKnownTextContent != null) { lastKnownTextContent = null; - requestRepaint(); + markAsDirty(); } } @@ -468,7 +465,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements */ public void setTextChangeEventMode(TextChangeEventMode inputEventMode) { textChangeEventMode = inputEventMode; - requestRepaint(); + markAsDirty(); } /** @@ -539,7 +536,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements */ public void setTextChangeTimeout(int timeout) { textChangeEventTimeout = timeout; - requestRepaint(); + markAsDirty(); } /** @@ -630,7 +627,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements selectionPosition = pos; selectionLength = length; focus(); - requestRepaint(); + markAsDirty(); } /** diff --git a/server/src/com/vaadin/ui/Button.java b/server/src/com/vaadin/ui/Button.java index f568d770e8..8546d8f830 100644 --- a/server/src/com/vaadin/ui/Button.java +++ b/server/src/com/vaadin/ui/Button.java @@ -478,7 +478,6 @@ public class Button extends AbstractComponent implements */ public void setDisableOnClick(boolean disableOnClick) { getState().setDisableOnClick(disableOnClick); - requestRepaint(); } /* @@ -499,7 +498,6 @@ public class Button extends AbstractComponent implements @Override public void setTabIndex(int tabIndex) { getState().setTabIndex(tabIndex); - requestRepaint(); } @Override @@ -509,7 +507,7 @@ public class Button extends AbstractComponent implements } @Override - public ButtonState getState() { + protected ButtonState getState() { return (ButtonState) super.getState(); } @@ -526,10 +524,7 @@ public class Button extends AbstractComponent implements * <code>false</code> otherwise */ public void setHtmlContentAllowed(boolean htmlContentAllowed) { - if (getState().isHtmlContentAllowed() != htmlContentAllowed) { - getState().setHtmlContentAllowed(htmlContentAllowed); - requestRepaint(); - } + getState().setHtmlContentAllowed(htmlContentAllowed); } /** diff --git a/server/src/com/vaadin/ui/CheckBox.java b/server/src/com/vaadin/ui/CheckBox.java index 158c9d0032..6da86b9711 100644 --- a/server/src/com/vaadin/ui/CheckBox.java +++ b/server/src/com/vaadin/ui/CheckBox.java @@ -106,7 +106,7 @@ public class CheckBox extends AbstractField<Boolean> { } @Override - public CheckBoxState getState() { + protected CheckBoxState getState() { return (CheckBoxState) super.getState(); } diff --git a/server/src/com/vaadin/ui/ComboBox.java b/server/src/com/vaadin/ui/ComboBox.java index e2655be405..af19ca5b96 100644 --- a/server/src/com/vaadin/ui/ComboBox.java +++ b/server/src/com/vaadin/ui/ComboBox.java @@ -81,7 +81,7 @@ public class ComboBox extends Select { */ public void setInputPrompt(String inputPrompt) { this.inputPrompt = inputPrompt; - requestRepaint(); + markAsDirty(); } @Override @@ -110,7 +110,7 @@ public class ComboBox extends Select { */ public void setTextInputAllowed(boolean textInputAllowed) { this.textInputAllowed = textInputAllowed; - requestRepaint(); + markAsDirty(); } /** diff --git a/server/src/com/vaadin/ui/Component.java b/server/src/com/vaadin/ui/Component.java index ff7ed47930..400dd66cac 100644 --- a/server/src/com/vaadin/ui/Component.java +++ b/server/src/com/vaadin/ui/Component.java @@ -23,7 +23,6 @@ import java.util.Locale; import com.vaadin.Application; import com.vaadin.event.FieldEvents; -import com.vaadin.shared.ComponentState; import com.vaadin.terminal.ErrorMessage; import com.vaadin.terminal.Resource; import com.vaadin.terminal.Sizeable; @@ -508,18 +507,18 @@ public interface Component extends ClientConnector, Sizeable, Serializable { public void setIcon(Resource icon); /** - * Gets the Root the component is attached to. + * Gets the UI the component is attached to. * * <p> - * If the component is not attached to a Root through a component + * If the component is not attached to a UI through a component * containment hierarchy, <code>null</code> is returned. * </p> * - * @return the Root of the component or <code>null</code> if it is not - * attached to a Root + * @return the UI of the component or <code>null</code> if it is not + * attached to a UI */ @Override - public Root getRoot(); + public UI getUI(); /** * Gets the application object to which the component is attached. @@ -549,7 +548,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable { * <p> * Reimplementing the {@code attach()} method is useful for tasks that need * to get a reference to the parent, window, or application object with the - * {@link #getParent()}, {@link #getRoot()}, and {@link #getApplication()} + * {@link #getParent()}, {@link #getUI()}, and {@link #getApplication()} * methods. A component does not yet know these objects in the constructor, * so in such case, the methods will return {@code null}. For example, the * following is invalid: @@ -575,8 +574,8 @@ public interface Component extends ClientConnector, Sizeable, Serializable { * {@link #setParent(Component)}. * </p> * <p> - * This method must call {@link Root#componentAttached(Component)} to let - * the Root know that a new Component has been attached. + * This method must call {@link UI#componentAttached(Component)} to let + * the UI know that a new Component has been attached. * </p> * * @@ -624,19 +623,6 @@ public interface Component extends ClientConnector, Sizeable, Serializable { public Locale getLocale(); /** - * Returns the current shared state bean for the component. The state (or - * changes to it) is communicated from the server to the client. - * - * Subclasses can use a more specific return type for this method. - * - * @return The state object for the component - * - * @since 7.0 - */ - @Override - public ComponentState getState(); - - /** * Adds an unique id for component that get's transferred to terminal for * testing purposes. Keeping identifiers unique is the responsibility of the * programmer. diff --git a/server/src/com/vaadin/ui/ConnectorTracker.java b/server/src/com/vaadin/ui/ConnectorTracker.java index 2afe7f9025..ad5990137c 100644 --- a/server/src/com/vaadin/ui/ConnectorTracker.java +++ b/server/src/com/vaadin/ui/ConnectorTracker.java @@ -30,7 +30,7 @@ import com.vaadin.terminal.gwt.server.ClientConnector; /** * A class which takes care of book keeping of {@link ClientConnector}s for a - * Root. + * UI. * <p> * Provides {@link #getConnector(String)} which can be used to lookup a * connector from its id. This is for framework use only and should not be @@ -54,7 +54,7 @@ public class ConnectorTracker implements Serializable { private Set<ClientConnector> dirtyConnectors = new HashSet<ClientConnector>(); private Set<ClientConnector> uninitializedConnectors = new HashSet<ClientConnector>(); - private Root root; + private UI uI; private Map<ClientConnector, Object> diffStates = new HashMap<ClientConnector, Object>(); /** @@ -68,15 +68,15 @@ public class ConnectorTracker implements Serializable { } /** - * Creates a new ConnectorTracker for the given root. A tracker is always - * attached to a root and the root cannot be changed during the lifetime of + * Creates a new ConnectorTracker for the given uI. A tracker is always + * attached to a uI and the uI cannot be changed during the lifetime of * a {@link ConnectorTracker}. * - * @param root - * The root to attach to. Cannot be null. + * @param uI + * The uI to attach to. Cannot be null. */ - public ConnectorTracker(Root root) { - this.root = root; + public ConnectorTracker(UI uI) { + this.uI = uI; } /** @@ -210,8 +210,8 @@ public class ConnectorTracker implements Serializable { while (iterator.hasNext()) { String connectorId = iterator.next(); ClientConnector connector = connectorIdToConnector.get(connectorId); - if (getRootForConnector(connector) != root) { - // If connector is no longer part of this root, + if (getUIForConnector(connector) != uI) { + // If connector is no longer part of this uI, // remove it from the map. If it is re-attached to the // application at some point it will be re-added through // registerConnector(connector) @@ -232,22 +232,22 @@ public class ConnectorTracker implements Serializable { } /** - * Finds the root that the connector is attached to. + * Finds the uI that the connector is attached to. * * @param connector * The connector to lookup - * @return The root the connector is attached to or null if it is not - * attached to any root. + * @return The uI the connector is attached to or null if it is not + * attached to any uI. */ - private Root getRootForConnector(ClientConnector connector) { + private UI getUIForConnector(ClientConnector connector) { if (connector == null) { return null; } if (connector instanceof Component) { - return ((Component) connector).getRoot(); + return ((Component) connector).getUI(); } - return getRootForConnector(connector.getParent()); + return getUIForConnector(connector.getParent()); } /** @@ -330,15 +330,15 @@ public class ConnectorTracker implements Serializable { } /** - * Mark all connectors in this root as dirty. + * Mark all connectors in this uI as dirty. */ public void markAllConnectorsDirty() { - markConnectorsDirtyRecursively(root); + markConnectorsDirtyRecursively(uI); getLogger().fine("All connectors are now dirty"); } /** - * Mark all connectors in this root as clean. + * Mark all connectors in this uI as clean. */ public void markAllConnectorsClean() { dirtyConnectors.clear(); @@ -370,7 +370,7 @@ public class ConnectorTracker implements Serializable { * client in the following request. * </p> * - * @return A collection of all dirty connectors for this root. This list may + * @return A collection of all dirty connectors for this uI. This list may * contain invisible connectors. */ public Collection<ClientConnector> getDirtyConnectors() { @@ -385,4 +385,8 @@ public class ConnectorTracker implements Serializable { diffStates.put(connector, diffState); } + public boolean isDirty(ClientConnector connector) { + return dirtyConnectors.contains(connector); + } + } diff --git a/server/src/com/vaadin/ui/CssLayout.java b/server/src/com/vaadin/ui/CssLayout.java index 0192debc4a..b16bcf31df 100644 --- a/server/src/com/vaadin/ui/CssLayout.java +++ b/server/src/com/vaadin/ui/CssLayout.java @@ -102,7 +102,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { components.add(c); try { super.addComponent(c); - requestRepaint(); + markAsDirty(); } catch (IllegalArgumentException e) { components.remove(c); throw e; @@ -125,7 +125,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { components.addFirst(c); try { super.addComponent(c); - requestRepaint(); + markAsDirty(); } catch (IllegalArgumentException e) { components.remove(c); throw e; @@ -154,7 +154,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { components.add(index, c); try { super.addComponent(c); - requestRepaint(); + markAsDirty(); } catch (IllegalArgumentException e) { components.remove(c); throw e; @@ -171,7 +171,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { public void removeComponent(Component c) { components.remove(c); super.removeComponent(c); - requestRepaint(); + markAsDirty(); } /** @@ -211,7 +211,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { } @Override - public CssLayoutState getState() { + protected CssLayoutState getState() { return (CssLayoutState) super.getState(); } @@ -276,7 +276,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { components.add(newLocation, oldComponent); } - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/CustomComponent.java b/server/src/com/vaadin/ui/CustomComponent.java index 88f7b162c1..b67fa89ecb 100644 --- a/server/src/com/vaadin/ui/CustomComponent.java +++ b/server/src/com/vaadin/ui/CustomComponent.java @@ -100,7 +100,7 @@ public class CustomComponent extends AbstractComponentContainer { super.addComponent(compositionRoot); } root = compositionRoot; - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/CustomField.java b/server/src/com/vaadin/ui/CustomField.java index 794e472dae..9ac5e2defb 100644 --- a/server/src/com/vaadin/ui/CustomField.java +++ b/server/src/com/vaadin/ui/CustomField.java @@ -120,13 +120,13 @@ public abstract class CustomField<T> extends AbstractField<T> implements @Override public void setHeight(float height, Unit unit) { super.setHeight(height, unit); - requestRepaintAll(); + markAsDirtyRecursive(); } @Override public void setWidth(float height, Unit unit) { super.setWidth(height, unit); - requestRepaintAll(); + markAsDirtyRecursive(); } // ComponentContainer methods diff --git a/server/src/com/vaadin/ui/CustomLayout.java b/server/src/com/vaadin/ui/CustomLayout.java index d47b2f92b3..54308b99c3 100644 --- a/server/src/com/vaadin/ui/CustomLayout.java +++ b/server/src/com/vaadin/ui/CustomLayout.java @@ -123,7 +123,7 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { } @Override - public CustomLayoutState getState() { + protected CustomLayoutState getState() { return (CustomLayoutState) super.getState(); } @@ -145,7 +145,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { getState().getChildLocations().put(c, location); c.setParent(this); fireComponentAttachEvent(c); - requestRepaint(); } /** @@ -176,7 +175,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { slots.values().remove(c); getState().getChildLocations().remove(c); super.removeComponent(c); - requestRepaint(); } /** @@ -251,7 +249,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { slots.put(oldLocation, newComponent); getState().getChildLocations().put(newComponent, oldLocation); getState().getChildLocations().put(oldComponent, newLocation); - requestRepaint(); } } @@ -277,7 +274,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { public void setTemplateName(String templateName) { getState().setTemplateName(templateName); getState().setTemplateContents(null); - requestRepaint(); } /** @@ -288,7 +284,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { public void setTemplateContents(String templateContents) { getState().setTemplateContents(templateContents); getState().setTemplateName(null); - requestRepaint(); } @Override diff --git a/server/src/com/vaadin/ui/DateField.java b/server/src/com/vaadin/ui/DateField.java index 790f3568d5..828fa3b21d 100644 --- a/server/src/com/vaadin/ui/DateField.java +++ b/server/src/com/vaadin/ui/DateField.java @@ -429,7 +429,7 @@ public class DateField extends AbstractField<Date> implements * if handleUnparsableDateString throws an exception. In * this case the invalid text remains in the DateField. */ - requestRepaint(); + markAsDirty(); } catch (Converter.ConversionException e) { /* @@ -471,7 +471,7 @@ public class DateField extends AbstractField<Date> implements * change and form depends on this implementation detail. */ notifyFormOfValidityChange(); - requestRepaint(); + markAsDirty(); } } else if (newDate != oldDate && (newDate == null || !newDate.equals(oldDate))) { @@ -562,7 +562,7 @@ public class DateField extends AbstractField<Date> implements * this. */ notifyFormOfValidityChange(); - requestRepaint(); + markAsDirty(); return; } @@ -588,7 +588,7 @@ public class DateField extends AbstractField<Date> implements * thing as form does in its value change listener that * it registers to all fields. */ - f.requestRepaint(); + f.markAsDirty(); formFound = true; break; } @@ -639,7 +639,7 @@ public class DateField extends AbstractField<Date> implements */ public void setResolution(Resolution resolution) { this.resolution = resolution; - requestRepaint(); + markAsDirty(); } /** @@ -699,7 +699,7 @@ public class DateField extends AbstractField<Date> implements */ public void setDateFormat(String dateFormat) { this.dateFormat = dateFormat; - requestRepaint(); + markAsDirty(); } /** @@ -725,7 +725,7 @@ public class DateField extends AbstractField<Date> implements */ public void setLenient(boolean lenient) { this.lenient = lenient; - requestRepaint(); + markAsDirty(); } /** @@ -781,7 +781,7 @@ public class DateField extends AbstractField<Date> implements */ public void setShowISOWeekNumbers(boolean showWeekNumbers) { showISOWeekNumbers = showWeekNumbers; - requestRepaint(); + markAsDirty(); } /** @@ -850,7 +850,7 @@ public class DateField extends AbstractField<Date> implements */ public void setTimeZone(TimeZone timeZone) { this.timeZone = timeZone; - requestRepaint(); + markAsDirty(); } /** diff --git a/server/src/com/vaadin/ui/DragAndDropWrapper.java b/server/src/com/vaadin/ui/DragAndDropWrapper.java index 3fd94210d8..ec805ecf46 100644 --- a/server/src/com/vaadin/ui/DragAndDropWrapper.java +++ b/server/src/com/vaadin/ui/DragAndDropWrapper.java @@ -60,7 +60,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, String id = (String) rawVariables.get("fi" + i); files[i] = file; receivers.put(id, file); - requestRepaint(); // paint Receivers + markAsDirty(); // paint Receivers } } } @@ -156,22 +156,6 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, .valueOf((String) getData("horizontalLocation")); } - /** - * @deprecated use {@link #getVerticalDropLocation()} instead - */ - @Deprecated - public VerticalDropLocation verticalDropLocation() { - return getVerticalDropLocation(); - } - - /** - * @deprecated use {@link #getHorizontalDropLocation()} instead - */ - @Deprecated - public HorizontalDropLocation horizontalDropLocation() { - return getHorizontalDropLocation(); - } - } public enum DragStartMode { @@ -223,7 +207,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, */ public void setHTML5DataFlavor(String type, Object value) { html5DataFlavors.put(type, value); - requestRepaint(); + markAsDirty(); } @Override @@ -270,7 +254,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, public void setDropHandler(DropHandler dropHandler) { this.dropHandler = dropHandler; - requestRepaint(); + markAsDirty(); } @Override @@ -286,7 +270,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, public void setDragStartMode(DragStartMode dragStartMode) { this.dragStartMode = dragStartMode; - requestRepaint(); + markAsDirty(); } public DragStartMode getDragStartMode() { diff --git a/server/src/com/vaadin/ui/Embedded.java b/server/src/com/vaadin/ui/Embedded.java index d019ea3b0b..41b93d0b27 100644 --- a/server/src/com/vaadin/ui/Embedded.java +++ b/server/src/com/vaadin/ui/Embedded.java @@ -196,7 +196,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { if (altText != this.altText || (altText != null && !altText.equals(this.altText))) { this.altText = altText; - requestRepaint(); + markAsDirty(); } } @@ -222,7 +222,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { */ public void setParameter(String name, String value) { parameters.put(name, value); - requestRepaint(); + markAsDirty(); } /** @@ -244,7 +244,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { */ public void removeParameter(String name) { parameters.remove(name); - requestRepaint(); + markAsDirty(); } /** @@ -307,7 +307,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { if (codebase != this.codebase || (codebase != null && !codebase.equals(this.codebase))) { this.codebase = codebase; - requestRepaint(); + markAsDirty(); } } @@ -325,7 +325,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { if (codetype != this.codetype || (codetype != null && !codetype.equals(this.codetype))) { this.codetype = codetype; - requestRepaint(); + markAsDirty(); } } @@ -350,7 +350,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { setParameter("wmode", "transparent"); } } - requestRepaint(); + markAsDirty(); } } @@ -365,7 +365,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { if (standby != this.standby || (standby != null && !standby.equals(this.standby))) { this.standby = standby; - requestRepaint(); + markAsDirty(); } } @@ -390,7 +390,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { if (classId != this.classId || (classId != null && !classId.equals(this.classId))) { this.classId = classId; - requestRepaint(); + markAsDirty(); } } @@ -443,7 +443,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { } else { // Keep previous type } - requestRepaint(); + markAsDirty(); } } @@ -467,7 +467,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { } if (type != this.type) { this.type = type; - requestRepaint(); + markAsDirty(); } } @@ -502,7 +502,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { if (archive != this.archive || (archive != null && !archive.equals(this.archive))) { this.archive = archive; - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/EmbeddedBrowser.java b/server/src/com/vaadin/ui/EmbeddedBrowser.java new file mode 100644 index 0000000000..4e2ae18de8 --- /dev/null +++ b/server/src/com/vaadin/ui/EmbeddedBrowser.java @@ -0,0 +1,19 @@ +package com.vaadin.ui; + +import com.vaadin.shared.ui.embeddedbrowser.EmbeddedBrowserState; + +/** + * Component for embedding browser "iframe". + * + * @author Vaadin Ltd. + * @version + * @VERSION@ + * @since 7.0 + */ +public class EmbeddedBrowser extends AbstractEmbedded { + + @Override + public EmbeddedBrowserState getState() { + return (EmbeddedBrowserState) super.getState(); + } +} diff --git a/server/src/com/vaadin/ui/Flash.java b/server/src/com/vaadin/ui/Flash.java new file mode 100644 index 0000000000..0e6cf63a91 --- /dev/null +++ b/server/src/com/vaadin/ui/Flash.java @@ -0,0 +1,136 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.ui; + +import java.util.HashMap; + +import com.vaadin.shared.ui.flash.FlashState; + +/** + * Component for embedding flash objects. + * + * @author Vaadin Ltd. + * @version + * @VERSION@ + * @since 7.0 + */ +@SuppressWarnings("serial") +public class Flash extends AbstractEmbedded { + + @Override + public FlashState getState() { + return (FlashState) super.getState(); + } + + /** + * This attribute specifies the base path used to resolve relative URIs + * specified by the classid, data, and archive attributes. When absent, its + * default value is the base URI of the current document. + * + * @param codebase + * The base path + */ + public void setCodebase(String codebase) { + if (codebase != getState().getCodebase() + || (codebase != null && !codebase.equals(getState() + .getCodebase()))) { + getState().setCodebase(codebase); + requestRepaint(); + } + } + + /** + * This attribute specifies the content type of data expected when + * downloading the object specified by classid. This attribute is optional + * but recommended when classid is specified since it allows the user agent + * to avoid loading information for unsupported content types. When absent, + * it defaults to the value of the type attribute. + * + * @param codetype + * the codetype to set. + */ + public void setCodetype(String codetype) { + if (codetype != getState().getCodetype() + || (codetype != null && !codetype.equals(getState() + .getCodetype()))) { + getState().setCodetype(codetype); + requestRepaint(); + } + } + + /** + * This attribute may be used to specify a space-separated list of URIs for + * archives containing resources relevant to the object, which may include + * the resources specified by the classid and data attributes. Preloading + * archives will generally result in reduced load times for objects. + * Archives specified as relative URIs should be interpreted relative to the + * codebase attribute. + * + * @param archive + * Space-separated list of URIs with resources relevant to the + * object + */ + public void setArchive(String archive) { + if (archive != getState().getArchive() + || (archive != null && !archive.equals(getState().getArchive()))) { + getState().setArchive(archive); + requestRepaint(); + } + } + + public void setStandby(String standby) { + if (standby != getState().getStandby() + || (standby != null && !standby.equals(getState().getStandby()))) { + getState().setStandby(standby); + requestRepaint(); + } + } + + /** + * Sets an object parameter. Parameters are optional information, and they + * are passed to the instantiated object. Parameters are are stored as name + * value pairs. This overrides the previous value assigned to this + * parameter. + * + * @param name + * the name of the parameter. + * @param value + * the value of the parameter. + */ + public void setParameter(String name, String value) { + if (getState().getEmbedParams() == null) { + getState().setEmbedParams(new HashMap<String, String>()); + } + getState().getEmbedParams().put(name, value); + requestRepaint(); + } + + /** + * Gets the value of an object parameter. Parameters are optional + * information, and they are passed to the instantiated object. Parameters + * are are stored as name value pairs. + * + * @return the Value of parameter or null if not found. + */ + public String getParameter(String name) { + return getState().getEmbedParams() != null ? getState() + .getEmbedParams().get(name) : null; + } + + /** + * Removes an object parameter from the list. + * + * @param name + * the name of the parameter to remove. + */ + public void removeParameter(String name) { + if (getState().getEmbedParams() == null) { + return; + } + getState().getEmbedParams().remove(name); + requestRepaint(); + } + +} diff --git a/server/src/com/vaadin/ui/Form.java b/server/src/com/vaadin/ui/Form.java index a1ec0f9917..55404b2e6b 100644 --- a/server/src/com/vaadin/ui/Form.java +++ b/server/src/com/vaadin/ui/Form.java @@ -99,14 +99,9 @@ public class Form extends AbstractField<Object> implements Item.Editor, private Buffered.SourceException currentBufferedSourceException = null; /** - * Is the form in write trough mode. + * Is the form in buffered mode. */ - private boolean writeThrough = true; - - /** - * Is the form in read trough mode. - */ - private boolean readThrough = true; + private boolean buffered = false; /** * Mapping from propertyName to corresponding field. @@ -138,7 +133,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, private final ValueChangeListener fieldValueChangeListener = new ValueChangeListener() { @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { - requestRepaint(); + markAsDirty(); } }; @@ -200,7 +195,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, } @Override - public FormState getState() { + protected FormState getState() { return (FormState) super.getState(); } @@ -347,7 +342,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, if (problems == null) { if (currentBufferedSourceException != null) { currentBufferedSourceException = null; - requestRepaint(); + markAsDirty(); } return; } @@ -362,7 +357,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, final Buffered.SourceException e = new Buffered.SourceException(this, causes); currentBufferedSourceException = e; - requestRepaint(); + markAsDirty(); throw e; } @@ -391,7 +386,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, if (problems == null) { if (currentBufferedSourceException != null) { currentBufferedSourceException = null; - requestRepaint(); + markAsDirty(); } return; } @@ -406,7 +401,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, final Buffered.SourceException e = new Buffered.SourceException(this, causes); currentBufferedSourceException = e; - requestRepaint(); + markAsDirty(); throw e; } @@ -427,50 +422,15 @@ public class Form extends AbstractField<Object> implements Item.Editor, } /* - * Is the editor in a read-through mode? Don't add a JavaDoc comment here, - * we use the default one from the interface. - */ - @Override - @Deprecated - public boolean isReadThrough() { - return readThrough; - } - - /* - * Is the editor in a write-through mode? Don't add a JavaDoc comment here, - * we use the default one from the interface. - */ - @Override - @Deprecated - public boolean isWriteThrough() { - return writeThrough; - } - - /* - * Sets the editor's read-through mode to the specified status. Don't add a + * Sets the editor's buffered mode to the specified status. Don't add a * JavaDoc comment here, we use the default one from the interface. */ @Override - public void setReadThrough(boolean readThrough) { - if (readThrough != this.readThrough) { - this.readThrough = readThrough; + public void setBuffered(boolean buffered) { + if (buffered != this.buffered) { + this.buffered = buffered; for (final Iterator<Object> i = propertyIds.iterator(); i.hasNext();) { - (fields.get(i.next())).setReadThrough(readThrough); - } - } - } - - /* - * Sets the editor's read-through mode to the specified status. Don't add a - * JavaDoc comment here, we use the default one from the interface. - */ - @Override - public void setWriteThrough(boolean writeThrough) throws SourceException, - InvalidValueException { - if (writeThrough != this.writeThrough) { - this.writeThrough = writeThrough; - for (final Iterator<Object> i = propertyIds.iterator(); i.hasNext();) { - (fields.get(i.next())).setWriteThrough(writeThrough); + (fields.get(i.next())).setBuffered(buffered); } } } @@ -531,7 +491,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, public void addField(Object propertyId, Field<?> field) { registerField(propertyId, field); attachField(propertyId, field); - requestRepaint(); + markAsDirty(); } /** @@ -560,11 +520,10 @@ public class Form extends AbstractField<Object> implements Item.Editor, propertyIds.addLast(propertyId); } - // Update the read and write through status and immediate to match the + // Update the buffered mode and immediate to match the // form. // Should this also include invalidCommitted (#3993)? - field.setReadThrough(readThrough); - field.setWriteThrough(writeThrough); + field.setBuffered(buffered); if (isImmediate() && field instanceof AbstractComponent) { ((AbstractComponent) field).setImmediate(true); } @@ -761,7 +720,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, // If the new datasource is null, just set null datasource if (itemDatasource == null) { - requestRepaint(); + markAsDirty(); return; } @@ -861,10 +820,6 @@ public class Form extends AbstractField<Object> implements Item.Editor, // Replace the previous layout layout.setParent(this); getState().setLayout(layout); - - // Hierarchy has changed so we need to repaint (this could be a - // hierarchy repaint only) - requestRepaint(); } /** @@ -949,8 +904,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, : new Select(); newField.setCaption(oldField.getCaption()); newField.setReadOnly(oldField.isReadOnly()); - newField.setReadThrough(oldField.isReadThrough()); - newField.setWriteThrough(oldField.isWriteThrough()); + newField.setBuffered(oldField.isBuffered()); // Creates the options list newField.addContainerProperty("desc", String.class, ""); @@ -1281,11 +1235,6 @@ public class Form extends AbstractField<Object> implements Item.Editor, getState().setFooter(footer); footer.setParent(this); - - // Hierarchy has changed so we need to repaint (this could be a - // hierarchy repaint only) - requestRepaint(); - } @Override @@ -1295,7 +1244,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, // some ancestor still disabled, don't update children return; } else { - getLayout().requestRepaintAll(); + getLayout().markAsDirtyRecursive(); } } diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java index b31ab82741..3870b71611 100644 --- a/server/src/com/vaadin/ui/GridLayout.java +++ b/server/src/com/vaadin/ui/GridLayout.java @@ -141,7 +141,7 @@ public class GridLayout extends AbstractLayout implements } @Override - public GridLayoutState getState() { + protected GridLayoutState getState() { return (GridLayoutState) super.getState(); } @@ -254,7 +254,7 @@ public class GridLayout extends AbstractLayout implements } } - requestRepaint(); + markAsDirty(); } /** @@ -400,7 +400,7 @@ public class GridLayout extends AbstractLayout implements super.removeComponent(component); - requestRepaint(); + markAsDirty(); } /** @@ -806,14 +806,6 @@ public class GridLayout extends AbstractLayout implements } /** - * @deprecated Use {@link #getColumn1()} instead. - */ - @Deprecated - public int getX1() { - return getColumn1(); - } - - /** * Gets the column of the top-left corner cell. * * @return the column of the top-left corner cell. @@ -823,14 +815,6 @@ public class GridLayout extends AbstractLayout implements } /** - * @deprecated Use {@link #getColumn2()} instead. - */ - @Deprecated - public int getX2() { - return getColumn2(); - } - - /** * Gets the column of the bottom-right corner cell. * * @return the column of the bottom-right corner cell. @@ -840,14 +824,6 @@ public class GridLayout extends AbstractLayout implements } /** - * @deprecated Use {@link #getRow1()} instead. - */ - @Deprecated - public int getY1() { - return getRow1(); - } - - /** * Gets the row of the top-left corner cell. * * @return the row of the top-left corner cell. @@ -857,14 +833,6 @@ public class GridLayout extends AbstractLayout implements } /** - * @deprecated Use {@link #getRow2()} instead. - */ - @Deprecated - public int getY2() { - return getRow2(); - } - - /** * Gets the row of the bottom-right corner cell. * * @return the row of the bottom-right corner cell. @@ -994,8 +962,6 @@ public class GridLayout extends AbstractLayout implements } getState().setColumns(columns); - - requestRepaint(); } /** @@ -1038,8 +1004,6 @@ public class GridLayout extends AbstractLayout implements } getState().setRows(rows); - - requestRepaint(); } /** @@ -1132,7 +1096,7 @@ public class GridLayout extends AbstractLayout implements } else { oldLocation.setComponent(newComponent); newLocation.setComponent(oldComponent); - requestRepaint(); + markAsDirty(); } } @@ -1149,25 +1113,11 @@ public class GridLayout extends AbstractLayout implements cursorY = 0; } - /* - * (non-Javadoc) - * - * @see com.vaadin.ui.Layout.AlignmentHandler#setComponentAlignment(com - * .vaadin.ui.Component, int, int) - */ - @Override - public void setComponentAlignment(Component childComponent, - int horizontalAlignment, int verticalAlignment) { - componentToAlignment.put(childComponent, new Alignment( - horizontalAlignment + verticalAlignment)); - requestRepaint(); - } - @Override public void setComponentAlignment(Component childComponent, Alignment alignment) { componentToAlignment.put(childComponent, alignment); - requestRepaint(); + markAsDirty(); } /* @@ -1178,7 +1128,6 @@ public class GridLayout extends AbstractLayout implements @Override public void setSpacing(boolean spacing) { getState().setSpacing(spacing); - requestRepaint(); } /* @@ -1224,7 +1173,7 @@ public class GridLayout extends AbstractLayout implements setRows(getRows() + 1); structuralChange = true; - requestRepaint(); + markAsDirty(); } /** @@ -1283,7 +1232,7 @@ public class GridLayout extends AbstractLayout implements } structuralChange = true; - requestRepaint(); + markAsDirty(); } @@ -1308,7 +1257,7 @@ public class GridLayout extends AbstractLayout implements */ public void setColumnExpandRatio(int columnIndex, float ratio) { columnExpandRatio.put(columnIndex, ratio); - requestRepaint(); + markAsDirty(); } /** @@ -1346,7 +1295,7 @@ public class GridLayout extends AbstractLayout implements */ public void setRowExpandRatio(int rowIndex, float ratio) { rowExpandRatio.put(rowIndex, ratio); - requestRepaint(); + markAsDirty(); } /** @@ -1437,7 +1386,6 @@ public class GridLayout extends AbstractLayout implements @Override public void setMargin(MarginInfo marginInfo) { getState().setMarginsBitmask(marginInfo.getBitMask()); - requestRepaint(); } /* diff --git a/server/src/com/vaadin/ui/Image.java b/server/src/com/vaadin/ui/Image.java new file mode 100644 index 0000000000..b0dbc9e629 --- /dev/null +++ b/server/src/com/vaadin/ui/Image.java @@ -0,0 +1,94 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.ui; + +import com.vaadin.event.MouseEvents.ClickEvent; +import com.vaadin.event.MouseEvents.ClickListener; +import com.vaadin.shared.EventId; +import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.ui.image.ImageServerRpc; +import com.vaadin.shared.ui.image.ImageState; +import com.vaadin.terminal.Resource; + +/** + * Component for embedding images. + * + * @author Vaadin Ltd. + * @version + * @VERSION@ + * @since 7.0 + */ +@SuppressWarnings("serial") +public class Image extends AbstractEmbedded { + + protected ImageServerRpc rpc = new ImageServerRpc() { + @Override + public void click(MouseEventDetails mouseDetails) { + fireEvent(new ClickEvent(Image.this, mouseDetails)); + } + }; + + /** + * Creates a new empty Image. + */ + public Image() { + registerRpc(rpc); + } + + /** + * Creates a new empty Image with caption. + * + * @param caption + */ + public Image(String caption) { + this(); + setCaption(caption); + } + + /** + * Creates a new Image whose contents is loaded from given resource. The + * dimensions are assumed if possible. The type is guessed from resource. + * + * @param caption + * @param source + * the Source of the embedded object. + */ + public Image(String caption, Resource source) { + this(caption); + setSource(source); + } + + @Override + public ImageState getState() { + return (ImageState) super.getState(); + } + + /** + * Add a click listener to the component. The listener is called whenever + * the user clicks inside the component. Depending on the content the event + * may be blocked and in that case no event is fired. + * + * Use {@link #removeListener(ClickListener)} to remove the listener. + * + * @param listener + * The listener to add + */ + public void addListener(ClickListener listener) { + addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, listener, + ClickListener.clickMethod); + } + + /** + * Remove a click listener from the component. The listener should earlier + * have been added using {@link #addListener(ClickListener)}. + * + * @param listener + * The listener to remove + */ + public void removeListener(ClickListener listener) { + removeListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, + listener); + } +} diff --git a/server/src/com/vaadin/ui/JavaScript.java b/server/src/com/vaadin/ui/JavaScript.java index 35cc1893f6..e34ccae82a 100644 --- a/server/src/com/vaadin/ui/JavaScript.java +++ b/server/src/com/vaadin/ui/JavaScript.java @@ -66,7 +66,7 @@ public class JavaScript extends AbstractExtension { } @Override - public JavaScriptManagerState getState() { + protected JavaScriptManagerState getState() { return (JavaScriptManagerState) super.getState(); } @@ -93,9 +93,7 @@ public class JavaScript extends AbstractExtension { */ public void addFunction(String name, JavaScriptFunction function) { functions.put(name, function); - if (getState().getNames().add(name)) { - requestRepaint(); - } + getState().getNames().add(name); } /** @@ -111,9 +109,7 @@ public class JavaScript extends AbstractExtension { */ public void removeFunction(String name) { functions.remove(name); - if (getState().getNames().remove(name)) { - requestRepaint(); - } + getState().getNames().remove(name); } /** diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java index 668b99a74c..81a343e937 100644 --- a/server/src/com/vaadin/ui/Label.java +++ b/server/src/com/vaadin/ui/Label.java @@ -151,7 +151,7 @@ public class Label extends AbstractComponent implements Property<String>, } @Override - public LabelState getState() { + protected LabelState getState() { return (LabelState) super.getState(); } @@ -168,7 +168,7 @@ public class Label extends AbstractComponent implements Property<String>, public String getValue() { if (getPropertyDataSource() == null) { // Use internal value if we are running without a data source - return getState().getText(); + return getState().text; } return ConverterUtil.convertFromModel(getPropertyDataSource() .getValue(), String.class, getConverter(), getLocale()); @@ -189,8 +189,7 @@ public class Label extends AbstractComponent implements Property<String>, + String.class.getName()); } if (getPropertyDataSource() == null) { - getState().setText((String) newStringValue); - requestRepaint(); + getState().text = (String) newStringValue; } else { throw new IllegalStateException( "Label is only a Property.Viewer and cannot update its data source"); @@ -266,7 +265,7 @@ public class Label extends AbstractComponent implements Property<String>, .isAssignableFrom(dataSource.getClass())) { ((Property.ValueChangeNotifier) dataSource).addListener(this); } - requestRepaint(); + markAsDirty(); } /** @@ -277,7 +276,7 @@ public class Label extends AbstractComponent implements Property<String>, * @see ContentMode */ public ContentMode getContentMode() { - return getState().getContentMode(); + return getState().contentMode; } /** @@ -293,8 +292,7 @@ public class Label extends AbstractComponent implements Property<String>, throw new IllegalArgumentException("Content mode can not be null"); } - getState().setContentMode(contentMode); - requestRepaint(); + getState().contentMode = contentMode; } /* Value change events */ @@ -384,8 +382,7 @@ public class Label extends AbstractComponent implements Property<String>, @Override public void valueChange(Property.ValueChangeEvent event) { // Update the internal value from the data source - getState().setText(getValue()); - requestRepaint(); + getState().text = getValue(); fireValueChange(); } @@ -485,7 +482,7 @@ public class Label extends AbstractComponent implements Property<String>, */ public void setConverter(Converter<String, ?> converter) { this.converter = (Converter<String, Object>) converter; - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/Layout.java b/server/src/com/vaadin/ui/Layout.java index 9c7cd2b477..b32cf8c47d 100644 --- a/server/src/com/vaadin/ui/Layout.java +++ b/server/src/com/vaadin/ui/Layout.java @@ -18,7 +18,6 @@ package com.vaadin.ui; import java.io.Serializable; -import com.vaadin.shared.ui.AlignmentInfo.Bits; import com.vaadin.shared.ui.MarginInfo; /** @@ -39,74 +38,6 @@ public interface Layout extends ComponentContainer, Serializable { public interface AlignmentHandler extends Serializable { /** - * Contained component should be aligned horizontally to the left. - * - * @deprecated Use of {@link Alignment} class and its constants - */ - @Deprecated - public static final int ALIGNMENT_LEFT = Bits.ALIGNMENT_LEFT; - - /** - * Contained component should be aligned horizontally to the right. - * - * @deprecated Use of {@link Alignment} class and its constants - */ - @Deprecated - public static final int ALIGNMENT_RIGHT = Bits.ALIGNMENT_RIGHT; - - /** - * Contained component should be aligned vertically to the top. - * - * @deprecated Use of {@link Alignment} class and its constants - */ - @Deprecated - public static final int ALIGNMENT_TOP = Bits.ALIGNMENT_TOP; - - /** - * Contained component should be aligned vertically to the bottom. - * - * @deprecated Use of {@link Alignment} class and its constants - */ - @Deprecated - public static final int ALIGNMENT_BOTTOM = Bits.ALIGNMENT_BOTTOM; - - /** - * Contained component should be horizontally aligned to center. - * - * @deprecated Use of {@link Alignment} class and its constants - */ - @Deprecated - public static final int ALIGNMENT_HORIZONTAL_CENTER = Bits.ALIGNMENT_HORIZONTAL_CENTER; - - /** - * Contained component should be vertically aligned to center. - * - * @deprecated Use of {@link Alignment} class and its constants - */ - @Deprecated - public static final int ALIGNMENT_VERTICAL_CENTER = Bits.ALIGNMENT_VERTICAL_CENTER; - - /** - * Set alignment for one contained component in this layout. Alignment - * is calculated as a bit mask of the two passed values. - * - * @deprecated Use {@link #setComponentAlignment(Component, Alignment)} - * instead - * - * @param childComponent - * the component to align within it's layout cell. - * @param horizontalAlignment - * the horizontal alignment for the child component (left, - * center, right). Use ALIGNMENT constants. - * @param verticalAlignment - * the vertical alignment for the child component (top, - * center, bottom). Use ALIGNMENT constants. - */ - @Deprecated - public void setComponentAlignment(Component childComponent, - int horizontalAlignment, int verticalAlignment); - - /** * Set alignment for one contained component in this layout. Use * predefined alignments from Alignment class. * diff --git a/server/src/com/vaadin/ui/Link.java b/server/src/com/vaadin/ui/Link.java index ae2934f878..f98a2b0d2d 100644 --- a/server/src/com/vaadin/ui/Link.java +++ b/server/src/com/vaadin/ui/Link.java @@ -188,7 +188,7 @@ public class Link extends AbstractComponent implements Vaadin6Component { */ public void setTargetBorder(BorderStyle targetBorder) { this.targetBorder = targetBorder; - requestRepaint(); + markAsDirty(); } /** @@ -199,7 +199,7 @@ public class Link extends AbstractComponent implements Vaadin6Component { */ public void setTargetHeight(int targetHeight) { this.targetHeight = targetHeight; - requestRepaint(); + markAsDirty(); } /** @@ -210,7 +210,7 @@ public class Link extends AbstractComponent implements Vaadin6Component { */ public void setTargetName(String targetName) { this.targetName = targetName; - requestRepaint(); + markAsDirty(); } /** @@ -221,7 +221,7 @@ public class Link extends AbstractComponent implements Vaadin6Component { */ public void setTargetWidth(int targetWidth) { this.targetWidth = targetWidth; - requestRepaint(); + markAsDirty(); } /** @@ -241,7 +241,7 @@ public class Link extends AbstractComponent implements Vaadin6Component { */ public void setResource(Resource resource) { this.resource = resource; - requestRepaint(); + markAsDirty(); } @Override diff --git a/server/src/com/vaadin/ui/ListSelect.java b/server/src/com/vaadin/ui/ListSelect.java index eb54183164..da78e24fa8 100644 --- a/server/src/com/vaadin/ui/ListSelect.java +++ b/server/src/com/vaadin/ui/ListSelect.java @@ -62,7 +62,7 @@ public class ListSelect extends AbstractSelect { } if (this.columns != columns) { this.columns = columns; - requestRepaint(); + markAsDirty(); } } @@ -88,7 +88,7 @@ public class ListSelect extends AbstractSelect { } if (this.rows != rows) { this.rows = rows; - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/LoginForm.java b/server/src/com/vaadin/ui/LoginForm.java index c8634ea81a..1c154699d8 100644 --- a/server/src/com/vaadin/ui/LoginForm.java +++ b/server/src/com/vaadin/ui/LoginForm.java @@ -99,6 +99,9 @@ public class LoginForm extends CustomComponent { throws IOException { String requestPathInfo = request.getRequestPathInfo(); if ("/loginHandler".equals(requestPathInfo)) { + // Ensure UI.getCurrent() works in listeners + UI.setCurrent(getUI()); + response.setCacheTime(-1); response.setContentType("text/html; charset=utf-8"); response.getWriter() diff --git a/server/src/com/vaadin/ui/MenuBar.java b/server/src/com/vaadin/ui/MenuBar.java index 37728ee69b..51c06cf934 100644 --- a/server/src/com/vaadin/ui/MenuBar.java +++ b/server/src/com/vaadin/ui/MenuBar.java @@ -223,7 +223,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { } MenuItem newItem = new MenuItem(caption, icon, command); menuItems.add(newItem); - requestRepaint(); + markAsDirty(); return newItem; @@ -259,7 +259,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { menuItems.add(newItem); } - requestRepaint(); + markAsDirty(); return newItem; } @@ -283,7 +283,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { if (item != null) { menuItems.remove(item); } - requestRepaint(); + markAsDirty(); } /** @@ -291,7 +291,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { */ public void removeItems() { menuItems.clear(); - requestRepaint(); + markAsDirty(); } /** @@ -318,7 +318,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { } else { moreItem = new MenuItem("", null, null); } - requestRepaint(); + markAsDirty(); } /** @@ -345,7 +345,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { public void setAutoOpen(boolean autoOpenTopLevelMenu) { if (autoOpenTopLevelMenu != openRootOnHover) { openRootOnHover = autoOpenTopLevelMenu; - requestRepaint(); + markAsDirty(); } } @@ -373,7 +373,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { */ public void setHtmlContentAllowed(boolean htmlContentAllowed) { this.htmlContentAllowed = htmlContentAllowed; - requestRepaint(); + markAsDirty(); } /** @@ -521,7 +521,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { newItem.setParent(this); itsChildren.add(newItem); - requestRepaint(); + markAsDirty(); return newItem; } @@ -560,7 +560,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { newItem = addItem(caption, icon, command); } - requestRepaint(); + markAsDirty(); return newItem; } @@ -651,7 +651,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { */ public void setIcon(Resource icon) { itsIcon = icon; - requestRepaint(); + markAsDirty(); } /** @@ -664,7 +664,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { if (text != null) { itsText = text; } - requestRepaint(); + markAsDirty(); } /** @@ -679,7 +679,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { if (itsChildren.isEmpty()) { itsChildren = null; } - requestRepaint(); + markAsDirty(); } } @@ -690,7 +690,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { if (itsChildren != null) { itsChildren.clear(); itsChildren = null; - requestRepaint(); + markAsDirty(); } } @@ -706,7 +706,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { public void setEnabled(boolean enabled) { this.enabled = enabled; - requestRepaint(); + markAsDirty(); } public boolean isEnabled() { @@ -715,7 +715,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { public void setVisible(boolean visible) { this.visible = visible; - requestRepaint(); + markAsDirty(); } public boolean isVisible() { @@ -724,7 +724,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { private void setSeparator(boolean isSeparator) { this.isSeparator = isSeparator; - requestRepaint(); + markAsDirty(); } public boolean isSeparator() { @@ -733,7 +733,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { public void setStyleName(String styleName) { this.styleName = styleName; - requestRepaint(); + markAsDirty(); } public String getStyleName() { @@ -750,7 +750,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { */ public void setDescription(String description) { this.description = description; - requestRepaint(); + markAsDirty(); } /** @@ -855,7 +855,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { "A menu item with children cannot be checkable"); } this.checkable = checkable; - requestRepaint(); + markAsDirty(); } /** @@ -897,7 +897,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { */ public void setChecked(boolean checked) { this.checked = checked; - requestRepaint(); + markAsDirty(); } }// class MenuItem diff --git a/server/src/com/vaadin/ui/NativeSelect.java b/server/src/com/vaadin/ui/NativeSelect.java index 53c225a256..c2969874b0 100644 --- a/server/src/com/vaadin/ui/NativeSelect.java +++ b/server/src/com/vaadin/ui/NativeSelect.java @@ -64,7 +64,7 @@ public class NativeSelect extends AbstractSelect { } if (this.columns != columns) { this.columns = columns; - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/Notification.java b/server/src/com/vaadin/ui/Notification.java index d408889519..22ad31dffe 100644 --- a/server/src/com/vaadin/ui/Notification.java +++ b/server/src/com/vaadin/ui/Notification.java @@ -18,6 +18,7 @@ package com.vaadin.ui; import java.io.Serializable; +import com.vaadin.shared.Position; import com.vaadin.terminal.Page; import com.vaadin.terminal.Resource; @@ -61,18 +62,33 @@ import com.vaadin.terminal.Resource; * */ public class Notification implements Serializable { - public static final int TYPE_HUMANIZED_MESSAGE = 1; - public static final int TYPE_WARNING_MESSAGE = 2; - public static final int TYPE_ERROR_MESSAGE = 3; - public static final int TYPE_TRAY_NOTIFICATION = 4; - - public static final int POSITION_CENTERED = 1; - public static final int POSITION_CENTERED_TOP = 2; - public static final int POSITION_CENTERED_BOTTOM = 3; - public static final int POSITION_TOP_LEFT = 4; - public static final int POSITION_TOP_RIGHT = 5; - public static final int POSITION_BOTTOM_LEFT = 6; - public static final int POSITION_BOTTOM_RIGHT = 7; + public enum Type { + HUMANIZED_MESSAGE, WARNING_MESSAGE, ERROR_MESSAGE, TRAY_NOTIFICATION; + } + + @Deprecated + public static final Type TYPE_HUMANIZED_MESSAGE = Type.HUMANIZED_MESSAGE; + @Deprecated + public static final Type TYPE_WARNING_MESSAGE = Type.WARNING_MESSAGE; + @Deprecated + public static final Type TYPE_ERROR_MESSAGE = Type.ERROR_MESSAGE; + @Deprecated + public static final Type TYPE_TRAY_NOTIFICATION = Type.TRAY_NOTIFICATION; + + @Deprecated + public static final Position POSITION_CENTERED = Position.MIDDLE_CENTER; + @Deprecated + public static final Position POSITION_CENTERED_TOP = Position.TOP_CENTER; + @Deprecated + public static final Position POSITION_CENTERED_BOTTOM = Position.BOTTOM_CENTER; + @Deprecated + public static final Position POSITION_TOP_LEFT = Position.TOP_LEFT; + @Deprecated + public static final Position POSITION_TOP_RIGHT = Position.TOP_RIGHT; + @Deprecated + public static final Position POSITION_BOTTOM_LEFT = Position.BOTTOM_LEFT; + @Deprecated + public static final Position POSITION_BOTTOM_RIGHT = Position.BOTTOM_RIGHT; public static final int DELAY_FOREVER = -1; public static final int DELAY_NONE = 0; @@ -80,7 +96,7 @@ public class Notification implements Serializable { private String caption; private String description; private Resource icon; - private int position = POSITION_CENTERED; + private Position position = Position.MIDDLE_CENTER; private int delayMsec = 0; private String styleName; private boolean htmlContentAllowed; @@ -107,7 +123,7 @@ public class Notification implements Serializable { * @param type * The type of message */ - public Notification(String caption, int type) { + public Notification(String caption, Type type) { this(caption, null, type); } @@ -141,7 +157,7 @@ public class Notification implements Serializable { * @param type * The type of message */ - public Notification(String caption, String description, int type) { + public Notification(String caption, String description, Type type) { this(caption, description, type, false); } @@ -161,7 +177,7 @@ public class Notification implements Serializable { * Whether html in the caption and description should be * displayed as html or as plain text */ - public Notification(String caption, String description, int type, + public Notification(String caption, String description, Type type, boolean htmlContentAllowed) { this.caption = caption; this.description = description; @@ -169,22 +185,22 @@ public class Notification implements Serializable { setType(type); } - private void setType(int type) { + private void setType(Type type) { switch (type) { - case TYPE_WARNING_MESSAGE: + case WARNING_MESSAGE: delayMsec = 1500; styleName = "warning"; break; - case TYPE_ERROR_MESSAGE: + case ERROR_MESSAGE: delayMsec = -1; styleName = "error"; break; - case TYPE_TRAY_NOTIFICATION: + case TRAY_NOTIFICATION: delayMsec = 3000; - position = POSITION_BOTTOM_RIGHT; + position = Position.BOTTOM_RIGHT; styleName = "tray"; - case TYPE_HUMANIZED_MESSAGE: + case HUMANIZED_MESSAGE: default: break; } @@ -233,7 +249,7 @@ public class Notification implements Serializable { * * @return The position */ - public int getPosition() { + public Position getPosition() { return position; } @@ -243,7 +259,7 @@ public class Notification implements Serializable { * @param position * The desired notification position */ - public void setPosition(int position) { + public void setPosition(Position position) { this.position = position; } @@ -373,7 +389,7 @@ public class Notification implements Serializable { * @param type * The message type */ - public static void show(String caption, int type) { + public static void show(String caption, Type type) { new Notification(caption, type).show(Page.getCurrent()); } }
\ No newline at end of file diff --git a/server/src/com/vaadin/ui/OptionGroup.java b/server/src/com/vaadin/ui/OptionGroup.java index dfb5019331..12507442c9 100644 --- a/server/src/com/vaadin/ui/OptionGroup.java +++ b/server/src/com/vaadin/ui/OptionGroup.java @@ -125,14 +125,14 @@ public class OptionGroup extends AbstractSelect implements Set<?> newValueSet = (Set<?>) newValue; for (Object itemId : currentValueSet) { if (!isItemEnabled(itemId) && !newValueSet.contains(itemId)) { - requestRepaint(); + markAsDirty(); return; } } for (Object itemId : newValueSet) { if (!isItemEnabled(itemId) && !currentValueSet.contains(itemId)) { - requestRepaint(); + markAsDirty(); return; } } @@ -141,7 +141,7 @@ public class OptionGroup extends AbstractSelect implements newValue = getNullSelectionItemId(); } if (!isItemEnabled(newValue)) { - requestRepaint(); + markAsDirty(); return; } } @@ -169,7 +169,7 @@ public class OptionGroup extends AbstractSelect implements } else { disabledItemIds.add(itemId); } - requestRepaint(); + markAsDirty(); } } @@ -200,7 +200,7 @@ public class OptionGroup extends AbstractSelect implements */ public void setHtmlContentAllowed(boolean htmlContentAllowed) { this.htmlContentAllowed = htmlContentAllowed; - requestRepaint(); + markAsDirty(); } /** diff --git a/server/src/com/vaadin/ui/Panel.java b/server/src/com/vaadin/ui/Panel.java index ba68238707..00810b83db 100644 --- a/server/src/com/vaadin/ui/Panel.java +++ b/server/src/com/vaadin/ui/Panel.java @@ -176,7 +176,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, .addListener((ComponentContainer.ComponentDetachListener) this); content = newContent; - requestRepaint(); + markAsDirty(); } /** @@ -318,7 +318,6 @@ public class Panel extends AbstractComponentContainer implements Scrollable, "Scroll offset must be at least 0"); } getState().setScrollLeft(scrollLeft); - requestRepaint(); } /* @@ -333,7 +332,6 @@ public class Panel extends AbstractComponentContainer implements Scrollable, "Scroll offset must be at least 0"); } getState().setScrollTop(scrollTop); - requestRepaint(); } /* Documented in superclass */ @@ -465,7 +463,6 @@ public class Panel extends AbstractComponentContainer implements Scrollable, @Override public void setTabIndex(int tabIndex) { getState().setTabIndex(tabIndex); - requestRepaint(); } /** @@ -489,7 +486,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, } @Override - public PanelState getState() { + protected PanelState getState() { return (PanelState) super.getState(); } diff --git a/server/src/com/vaadin/ui/PopupDateField.java b/server/src/com/vaadin/ui/PopupDateField.java index a4304faaf9..acff49a142 100644 --- a/server/src/com/vaadin/ui/PopupDateField.java +++ b/server/src/com/vaadin/ui/PopupDateField.java @@ -84,7 +84,7 @@ public class PopupDateField extends DateField { */ public void setInputPrompt(String inputPrompt) { this.inputPrompt = inputPrompt; - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/PopupView.java b/server/src/com/vaadin/ui/PopupView.java index 4a5814f660..786257c240 100644 --- a/server/src/com/vaadin/ui/PopupView.java +++ b/server/src/com/vaadin/ui/PopupView.java @@ -147,7 +147,7 @@ public class PopupView extends AbstractComponentContainer implements throw new IllegalArgumentException("Content must not be null"); } content = newContent; - requestRepaint(); + markAsDirty(); } /** @@ -160,22 +160,6 @@ public class PopupView extends AbstractComponentContainer implements } /** - * @deprecated Use {@link #setPopupVisible()} instead. - */ - @Deprecated - public void setPopupVisibility(boolean visible) { - setPopupVisible(visible); - } - - /** - * @deprecated Use {@link #isPopupVisible()} instead. - */ - @Deprecated - public boolean getPopupVisibility() { - return isPopupVisible(); - } - - /** * Set the visibility of the popup. Does not hide the minimal * representation. * @@ -195,7 +179,7 @@ public class PopupView extends AbstractComponentContainer implements visibleComponent = null; } fireEvent(new PopupVisibilityEvent(this)); - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/ProgressIndicator.java b/server/src/com/vaadin/ui/ProgressIndicator.java index d3e292a3e1..528c404ab9 100644 --- a/server/src/com/vaadin/ui/ProgressIndicator.java +++ b/server/src/com/vaadin/ui/ProgressIndicator.java @@ -226,7 +226,7 @@ public class ProgressIndicator extends AbstractField<Number> implements */ public void setIndeterminate(boolean newValue) { indeterminate = newValue; - requestRepaint(); + markAsDirty(); } /** @@ -246,7 +246,7 @@ public class ProgressIndicator extends AbstractField<Number> implements */ public void setPollingInterval(int newValue) { pollingInterval = newValue; - requestRepaint(); + markAsDirty(); } /** diff --git a/server/src/com/vaadin/ui/RichTextArea.java b/server/src/com/vaadin/ui/RichTextArea.java index e3d1168559..51caa82136 100644 --- a/server/src/com/vaadin/ui/RichTextArea.java +++ b/server/src/com/vaadin/ui/RichTextArea.java @@ -16,7 +16,6 @@ package com.vaadin.ui; -import java.text.Format; import java.util.Map; import com.vaadin.data.Property; @@ -35,12 +34,6 @@ public class RichTextArea extends AbstractField<String> implements Vaadin6Component { /** - * Value formatter used to format the string contents. - */ - @Deprecated - private Format format; - - /** * Null representation. */ private String nullRepresentation = "null"; @@ -123,7 +116,7 @@ public class RichTextArea extends AbstractField<String> implements } // Adds the content as variable - String value = getFormattedValue(); + String value = getValue(); if (value == null) { value = getNullRepresentation(); } @@ -164,38 +157,7 @@ public class RichTextArea extends AbstractField<String> implements */ selectAll = true; focus(); - requestRepaint(); - } - - /** - * Gets the formatted string value. Sets the field value by using the - * assigned Format. - * - * @return the Formatted value. - * @see #setFormat(Format) - * @see Format - * @deprecated - */ - @Deprecated - protected String getFormattedValue() { - Object v = getValue(); - if (v == null) { - return null; - } - return v.toString(); - } - - @Override - public String getValue() { - String v = super.getValue(); - if (format == null || v == null) { - return v; - } - try { - return format.format(v); - } catch (final IllegalArgumentException e) { - return v; - } + markAsDirty(); } @Override @@ -207,7 +169,7 @@ public class RichTextArea extends AbstractField<String> implements // has been updated String newValue = (String) variables.get("text"); - final String oldValue = getFormattedValue(); + final String oldValue = getValue(); if (newValue != null && (oldValue == null || isNullSettingAllowed()) && newValue.equals(getNullRepresentation())) { @@ -218,10 +180,10 @@ public class RichTextArea extends AbstractField<String> implements boolean wasModified = isModified(); setValue(newValue, true); - // If the modified status changes, or if we have a formatter, + // If the modified status changes, // repaint is needed after all. - if (format != null || wasModified != isModified()) { - requestRepaint(); + if (wasModified != isModified()) { + markAsDirty(); } } } @@ -323,31 +285,6 @@ public class RichTextArea extends AbstractField<String> implements this.nullSettingAllowed = nullSettingAllowed; } - /** - * Gets the value formatter of TextField. - * - * @return the Format used to format the value. - * @deprecated replaced by {@link com.vaadin.data.util.PropertyFormatter} - */ - @Deprecated - public Format getFormat() { - return format; - } - - /** - * Gets the value formatter of TextField. - * - * @param format - * the Format used to format the value. Null disables the - * formatting. - * @deprecated replaced by {@link com.vaadin.data.util.PropertyFormatter} - */ - @Deprecated - public void setFormat(Format format) { - this.format = format; - requestRepaint(); - } - @Override protected boolean isEmpty() { return super.isEmpty() || getValue().length() == 0; diff --git a/server/src/com/vaadin/ui/Select.java b/server/src/com/vaadin/ui/Select.java index 698350cb30..20345b55e0 100644 --- a/server/src/com/vaadin/ui/Select.java +++ b/server/src/com/vaadin/ui/Select.java @@ -676,15 +676,21 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, } @Override + @Deprecated public void requestRepaint() { - super.requestRepaint(); + markAsDirty(); + } + + @Override + public void markAsDirty() { + super.markAsDirty(); optionRequest = false; prevfilterstring = filterstring; filterstring = null; } private void optionRepaint() { - super.requestRepaint(); + super.markAsDirty(); } @Override @@ -697,40 +703,6 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, return filteringMode; } - /** - * Note, one should use more generic setWidth(String) method instead of - * this. This now days actually converts columns to width with em css unit. - * - * Sets the number of columns in the editor. If the number of columns is set - * 0, the actual number of displayed columns is determined implicitly by the - * adapter. - * - * @deprecated - * - * @param columns - * the number of columns to set. - */ - @Deprecated - public void setColumns(int columns) { - if (columns < 0) { - columns = 0; - } - if (this.columns != columns) { - this.columns = columns; - setWidth(columns, Select.UNITS_EM); - requestRepaint(); - } - } - - /** - * @deprecated see setter function - * @return - */ - @Deprecated - public int getColumns() { - return columns; - } - @Override public void addListener(BlurListener listener) { addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, diff --git a/server/src/com/vaadin/ui/Slider.java b/server/src/com/vaadin/ui/Slider.java index f7672f617c..a0b1d01b01 100644 --- a/server/src/com/vaadin/ui/Slider.java +++ b/server/src/com/vaadin/ui/Slider.java @@ -16,11 +16,9 @@ package com.vaadin.ui; -import java.util.Map; - -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Vaadin6Component; +import com.vaadin.shared.ui.slider.SliderOrientation; +import com.vaadin.shared.ui.slider.SliderServerRpc; +import com.vaadin.shared.ui.slider.SliderState; /** * A component for selecting a numerical value within a range. @@ -41,9 +39,9 @@ import com.vaadin.terminal.Vaadin6Component; * vl.addComponent(volumeIndicator); * volumeIndicator.setValue("Current volume:" + 50.0); * slider.addListener(this); - * + * * } - * + * * public void setVolume(double d) { * volumeIndicator.setValue("Current volume: " + d); * } @@ -58,28 +56,29 @@ import com.vaadin.terminal.Vaadin6Component; * * @author Vaadin Ltd. */ -public class Slider extends AbstractField<Double> implements Vaadin6Component { - - public static final int ORIENTATION_HORIZONTAL = 0; - - public static final int ORIENTATION_VERTICAL = 1; +public class Slider extends AbstractField<Double> { - /** Minimum value of slider */ - private double min = 0; + private SliderServerRpc rpc = new SliderServerRpc() { - /** Maximum value of slider */ - private double max = 100; + @Override + public void valueChanged(double value) { - /** - * Resolution, how many digits are considered relevant after the decimal - * point. Must be a non-negative value - */ - private int resolution = 0; + try { + setValue(value, true); + } catch (final ValueOutOfBoundsException e) { + // Convert to nearest bound + double out = e.getValue().doubleValue(); + if (out < getState().getMinValue()) { + out = getState().getMinValue(); + } + if (out > getState().getMaxValue()) { + out = getState().getMaxValue(); + } + Slider.super.setValue(new Double(out), false); + } + } - /** - * Slider orientation (horizontal/vertical), defaults . - */ - private int orientation = ORIENTATION_HORIZONTAL; + }; /** * Default slider constructor. Sets all values to defaults and the slide @@ -88,7 +87,8 @@ public class Slider extends AbstractField<Double> implements Vaadin6Component { */ public Slider() { super(); - super.setValue(new Double(min)); + registerRpc(rpc); + super.setValue(new Double(getState().getMinValue())); } /** @@ -153,13 +153,18 @@ public class Slider extends AbstractField<Double> implements Vaadin6Component { setCaption(caption); } + @Override + public SliderState getState() { + return (SliderState) super.getState(); + } + /** * Gets the maximum slider value * * @return the largest value the slider can have */ public double getMax() { - return max; + return getState().getMaxValue(); } /** @@ -170,11 +175,10 @@ public class Slider extends AbstractField<Double> implements Vaadin6Component { * The new maximum slider value */ public void setMax(double max) { - this.max = max; + getState().setMaxValue(max); if (getValue() > max) { setValue(max); } - requestRepaint(); } /** @@ -183,7 +187,7 @@ public class Slider extends AbstractField<Double> implements Vaadin6Component { * @return the smallest value the slider can have */ public double getMin() { - return min; + return getState().getMinValue(); } /** @@ -194,33 +198,32 @@ public class Slider extends AbstractField<Double> implements Vaadin6Component { * The new minimum slider value */ public void setMin(double min) { - this.min = min; + getState().setMinValue(min); if (getValue() < min) { setValue(min); } - requestRepaint(); } /** * Get the current orientation of the slider (horizontal or vertical). * - * @return {@link #ORIENTATION_HORIZONTAL} or - * {@link #ORIENTATION_HORIZONTAL} + * @return {@link SliderOrientation#HORIZONTAL} or + * {@link SliderOrientation#VERTICAL} */ - public int getOrientation() { - return orientation; + public SliderOrientation getOrientation() { + return getState().getOrientation(); } /** * Set the orientation of the slider. * - * @param The - * new orientation, either {@link #ORIENTATION_HORIZONTAL} or - * {@link #ORIENTATION_VERTICAL} + * @param orientation + * The new orientation, either + * {@link SliderOrientation#HORIZONTAL} or + * {@link SliderOrientation#VERTICAL} */ - public void setOrientation(int orientation) { - this.orientation = orientation; - requestRepaint(); + public void setOrientation(SliderOrientation orientation) { + getState().setOrientation(orientation); } /** @@ -230,21 +233,24 @@ public class Slider extends AbstractField<Double> implements Vaadin6Component { * @return resolution */ public int getResolution() { - return resolution; + return getState().getResolution(); } /** * Set a new resolution for the slider. The resolution is the number of * digits after the decimal point. * + * @throws IllegalArgumentException + * if resolution is negative. + * * @param resolution */ public void setResolution(int resolution) { if (resolution < 0) { - return; + throw new IllegalArgumentException( + "Cannot set a negative resolution to Slider"); } - this.resolution = resolution; - requestRepaint(); + getState().setResolution(resolution); } /** @@ -261,87 +267,36 @@ public class Slider extends AbstractField<Double> implements Vaadin6Component { @Override protected void setValue(Double value, boolean repaintIsNotNeeded) { final double v = value.doubleValue(); + final int resolution = getResolution(); double newValue; + if (resolution > 0) { // Round up to resolution newValue = (int) (v * Math.pow(10, resolution)); newValue = newValue / Math.pow(10, resolution); - if (min > newValue || max < newValue) { + if (getMin() > newValue || getMax() < newValue) { throw new ValueOutOfBoundsException(value); } } else { newValue = (int) v; - if (min > newValue || max < newValue) { + if (getMin() > newValue || getMax() < newValue) { throw new ValueOutOfBoundsException(value); } } + + getState().setValue(newValue); super.setValue(newValue, repaintIsNotNeeded); } @Override - public void setValue(Object newFieldValue) - throws com.vaadin.data.Property.ReadOnlyException { - if (newFieldValue != null && newFieldValue instanceof Number - && !(newFieldValue instanceof Double)) { + public void setValue(Object newFieldValue) { + if (newFieldValue instanceof Number) { // Support setting all types of Numbers newFieldValue = ((Number) newFieldValue).doubleValue(); } - - super.setValue(newFieldValue); - } - - @Override - public void paintContent(PaintTarget target) throws PaintException { - - target.addAttribute("min", min); - if (max > min) { - target.addAttribute("max", max); - } else { - target.addAttribute("max", min); - } - target.addAttribute("resolution", resolution); - - if (resolution > 0) { - target.addVariable(this, "value", getValue().doubleValue()); - } else { - target.addVariable(this, "value", getValue().intValue()); - } - - if (orientation == ORIENTATION_VERTICAL) { - target.addAttribute("vertical", true); - } - - } - - /** - * Invoked when the value of a variable has changed. Slider listeners are - * notified if the slider value has changed. - * - * @param source - * @param variables - */ - @Override - public void changeVariables(Object source, Map<String, Object> variables) { - if (variables.containsKey("value")) { - final Object value = variables.get("value"); - final Double newValue = new Double(value.toString()); - if (newValue != null && newValue != getValue() - && !newValue.equals(getValue())) { - try { - setValue(newValue, true); - } catch (final ValueOutOfBoundsException e) { - // Convert to nearest bound - double out = e.getValue().doubleValue(); - if (out < min) { - out = min; - } - if (out > max) { - out = max; - } - super.setValue(new Double(out), false); - } - } - } + setValue(newFieldValue); + // The cast is safe if the above call returned without throwing + getState().setValue((Double) newFieldValue); } /** @@ -373,7 +328,6 @@ public class Slider extends AbstractField<Double> implements Vaadin6Component { public Double getValue() { return value; } - } @Override diff --git a/server/src/com/vaadin/ui/TabSheet.java b/server/src/com/vaadin/ui/TabSheet.java index 5a1aa02845..82faedcc41 100644 --- a/server/src/com/vaadin/ui/TabSheet.java +++ b/server/src/com/vaadin/ui/TabSheet.java @@ -176,7 +176,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, fireSelectedTabChange(); } } - requestRepaint(); + markAsDirty(); } } @@ -301,7 +301,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, fireSelectedTabChange(); } super.addComponent(c); - requestRepaint(); + markAsDirty(); return tab; } } @@ -361,8 +361,9 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, String caption = null; Resource icon = null; if (TabSheet.class.isAssignableFrom(source.getClass())) { - caption = ((TabSheet) source).getTabCaption(c); - icon = ((TabSheet) source).getTabIcon(c); + Tab tab = ((TabSheet) source).getTab(c); + caption = tab.getCaption(); + icon = tab.getIcon(); } source.removeComponent(c); addTab(c, caption, icon); @@ -474,83 +475,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, */ public void hideTabs(boolean tabsHidden) { this.tabsHidden = tabsHidden; - requestRepaint(); - } - - /** - * Gets tab caption. The tab is identified by the tab content component. - * - * @param c - * the component in the tab - * @deprecated Use {@link #getTab(Component)} and {@link Tab#getCaption()} - * instead. - */ - @Deprecated - public String getTabCaption(Component c) { - Tab info = tabs.get(c); - if (info == null) { - return ""; - } else { - return info.getCaption(); - } - } - - /** - * Sets tab caption. The tab is identified by the tab content component. - * - * @param c - * the component in the tab - * @param caption - * the caption to set. - * @deprecated Use {@link #getTab(Component)} and - * {@link Tab#setCaption(String)} instead. - */ - @Deprecated - public void setTabCaption(Component c, String caption) { - Tab info = tabs.get(c); - if (info != null) { - info.setCaption(caption); - requestRepaint(); - } - } - - /** - * Gets the icon for a tab. The tab is identified by the tab content - * component. - * - * @param c - * the component in the tab - * @deprecated Use {@link #getTab(Component)} and {@link Tab#getIcon()} - * instead. - */ - @Deprecated - public Resource getTabIcon(Component c) { - Tab info = tabs.get(c); - if (info == null) { - return null; - } else { - return info.getIcon(); - } - } - - /** - * Sets icon for the given component. The tab is identified by the tab - * content component. - * - * @param c - * the component in the tab - * @param icon - * the icon to set - * @deprecated Use {@link #getTab(Component)} and - * {@link Tab#setIcon(Resource)} instead. - */ - @Deprecated - public void setTabIcon(Component c, Resource icon) { - Tab info = tabs.get(c); - if (info != null) { - info.setIcon(icon); - requestRepaint(); - } + markAsDirty(); } /** @@ -594,7 +519,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, setSelected(c); updateSelection(); fireSelectedTabChange(); - requestRepaint(); + markAsDirty(); } } @@ -612,13 +537,13 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, // "cached" update even though the client knows nothing about the // connector if (selected instanceof ComponentContainer) { - ((ComponentContainer) selected).requestRepaintAll(); + ((ComponentContainer) selected).markAsDirtyRecursive(); } else if (selected instanceof Table) { // Workaround until there's a generic way of telling a component // that there is no client side state to rely on. See #8642 ((Table) selected).refreshRowCache(); } else if (selected != null) { - selected.requestRepaint(); + selected.markAsDirty(); } } @@ -791,7 +716,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, copyTabMetadata(oldTab, newTab); copyTabMetadata(tmp, oldTab); - requestRepaint(); + markAsDirty(); } } @@ -1103,7 +1028,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, @Override public void setCaption(String caption) { this.caption = caption; - requestRepaint(); + markAsDirty(); } @Override @@ -1114,7 +1039,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, @Override public void setIcon(Resource icon) { this.icon = icon; - requestRepaint(); + markAsDirty(); } @Override @@ -1128,7 +1053,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, if (updateSelection()) { fireSelectedTabChange(); } - requestRepaint(); + markAsDirty(); } @Override @@ -1142,7 +1067,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, if (updateSelection()) { fireSelectedTabChange(); } - requestRepaint(); + markAsDirty(); } @Override @@ -1153,7 +1078,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, @Override public void setClosable(boolean closable) { this.closable = closable; - requestRepaint(); + markAsDirty(); } public void close() { @@ -1168,7 +1093,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, @Override public void setDescription(String description) { this.description = description; - requestRepaint(); + markAsDirty(); } @Override @@ -1179,7 +1104,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, @Override public void setComponentError(ErrorMessage componentError) { this.componentError = componentError; - requestRepaint(); + markAsDirty(); } @Override @@ -1195,7 +1120,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, @Override public void setStyleName(String styleName) { this.styleName = styleName; - requestRepaint(); + markAsDirty(); } @Override @@ -1255,7 +1180,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, int oldPosition = getTabPosition(tab); components.remove(oldPosition); components.add(position, tab.getComponent()); - requestRepaint(); + markAsDirty(); } /** @@ -1282,7 +1207,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, @Override public void setTabIndex(int tabIndex) { this.tabIndex = tabIndex; - requestRepaint(); + markAsDirty(); } @Override diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java index 2bbb69beaf..8fc3fc2572 100644 --- a/server/src/com/vaadin/ui/Table.java +++ b/server/src/com/vaadin/ui/Table.java @@ -729,7 +729,7 @@ public class Table extends AbstractSelect implements Action.Container, this.columnHeaders.put(it.next(), columnHeaders[i]); } - requestRepaint(); + markAsDirty(); } /** @@ -788,7 +788,7 @@ public class Table extends AbstractSelect implements Action.Container, this.columnIcons.put(it.next(), columnIcons[i]); } - requestRepaint(); + markAsDirty(); } /** @@ -888,7 +888,7 @@ public class Table extends AbstractSelect implements Action.Container, } else { columnWidths.put(propertyId, Integer.valueOf(width)); } - requestRepaint(); + markAsDirty(); } /** @@ -1026,7 +1026,7 @@ public class Table extends AbstractSelect implements Action.Container, } if (this.cacheRate != cacheRate) { this.cacheRate = cacheRate; - requestRepaint(); + markAsDirty(); } } @@ -1158,7 +1158,7 @@ public class Table extends AbstractSelect implements Action.Container, columnIcons.put(propertyId, icon); } - requestRepaint(); + markAsDirty(); } /** @@ -1198,7 +1198,7 @@ public class Table extends AbstractSelect implements Action.Container, columnHeaders.put(propertyId, header); } - requestRepaint(); + markAsDirty(); } /** @@ -1361,7 +1361,7 @@ public class Table extends AbstractSelect implements Action.Container, public void setColumnReorderingAllowed(boolean columnReorderingAllowed) { if (columnReorderingAllowed != this.columnReorderingAllowed) { this.columnReorderingAllowed = columnReorderingAllowed; - requestRepaint(); + markAsDirty(); } } @@ -1507,31 +1507,6 @@ public class Table extends AbstractSelect implements Action.Container, } /** - * Getter for property pageBuffering. - * - * @deprecated functionality is not needed in ajax rendering model - * - * @return the Value of property pageBuffering. - */ - @Deprecated - public boolean isPageBufferingEnabled() { - return true; - } - - /** - * Setter for property pageBuffering. - * - * @deprecated functionality is not needed in ajax rendering model - * - * @param pageBuffering - * the New value of property pageBuffering. - */ - @Deprecated - public void setPageBufferingEnabled(boolean pageBuffering) { - - } - - /** * Getter for property selectable. * * <p> @@ -1557,7 +1532,7 @@ public class Table extends AbstractSelect implements Action.Container, public void setSelectable(boolean selectable) { if (this.selectable != selectable) { this.selectable = selectable; - requestRepaint(); + markAsDirty(); } } @@ -1583,7 +1558,7 @@ public class Table extends AbstractSelect implements Action.Container, } if (columnHeaderMode != this.columnHeaderMode) { this.columnHeaderMode = columnHeaderMode; - requestRepaint(); + markAsDirty(); } } @@ -1652,7 +1627,7 @@ public class Table extends AbstractSelect implements Action.Container, } setRowCacheInvalidated(true); - requestRepaint(); + markAsDirty(); } /** @@ -1661,17 +1636,39 @@ public class Table extends AbstractSelect implements Action.Container, * Note that a {@code Table} does not necessarily repaint its contents when * this method has been called. See {@link #refreshRowCache()} for forcing * an update of the contents. + * + * @deprecated As of 7.0.0, use {@link #markAsDirty()} instead */ + @Deprecated @Override public void requestRepaint() { + markAsDirty(); + } + + /** + * Requests that the Table should be repainted as soon as possible. + * + * Note that a {@code Table} does not necessarily repaint its contents when + * this method has been called. See {@link #refreshRowCache()} for forcing + * an update of the contents. + */ + + @Override + public void markAsDirty() { // Overridden only for javadoc - super.requestRepaint(); + super.markAsDirty(); } + @Deprecated @Override public void requestRepaintAll() { - super.requestRepaintAll(); + markAsDirtyRecursive(); + } + + @Override + public void markAsDirtyRecursive() { + super.markAsDirtyRecursive(); // Avoid sending a partial repaint (#8714) refreshRowCache(); @@ -2230,16 +2227,6 @@ public class Table extends AbstractSelect implements Action.Container, } /** - * Refreshes the current page contents. - * - * @deprecated should not need to be used - */ - @Deprecated - public void refreshCurrentPage() { - - } - - /** * Sets the row header mode. * <p> * The mode can be one of the following ones: @@ -2471,7 +2458,7 @@ public class Table extends AbstractSelect implements Action.Container, if (!isNullSelectionAllowed() && (id == null || id == getNullSelectionItemId())) { // skip empty selection if nullselection is not allowed - requestRepaint(); + markAsDirty(); } else if (id != null && containsId(id)) { newValue.add(id); renderedButNotSelectedItemIds.remove(id); @@ -2498,7 +2485,7 @@ public class Table extends AbstractSelect implements Action.Container, if (!isNullSelectionAllowed() && newValue.isEmpty()) { // empty selection not allowed, keep old value - requestRepaint(); + markAsDirty(); return; } @@ -2837,7 +2824,7 @@ public class Table extends AbstractSelect implements Action.Container, if (refreshContent) { refreshRenderedCells(); // Ensure that client gets a response - requestRepaint(); + markAsDirty(); } } @@ -3786,7 +3773,7 @@ public class Table extends AbstractSelect implements Action.Container, refreshRowCache(); containerChangeToBeRendered = true; } - requestRepaint(); + markAsDirty(); } /** @@ -4511,7 +4498,7 @@ public class Table extends AbstractSelect implements Action.Container, public void setSortEnabled(boolean sortEnabled) { if (this.sortEnabled != sortEnabled) { this.sortEnabled = sortEnabled; - requestRepaint(); + markAsDirty(); } } @@ -4608,7 +4595,7 @@ public class Table extends AbstractSelect implements Action.Container, // some ancestor still disabled, don't update children return; } else { - requestRepaintAll(); + markAsDirtyRecursive(); } } @@ -4620,7 +4607,7 @@ public class Table extends AbstractSelect implements Action.Container, */ public void setDragMode(TableDragMode newDragMode) { dragMode = newDragMode; - requestRepaint(); + markAsDirty(); } /** @@ -4704,7 +4691,7 @@ public class Table extends AbstractSelect implements Action.Container, */ public void setMultiSelectMode(MultiSelectMode mode) { multiSelectMode = mode; - requestRepaint(); + markAsDirty(); } /** @@ -5012,7 +4999,7 @@ public class Table extends AbstractSelect implements Action.Container, columnFooters.put(propertyId, footer); } - requestRepaint(); + markAsDirty(); } /** @@ -5028,7 +5015,7 @@ public class Table extends AbstractSelect implements Action.Container, public void setFooterVisible(boolean visible) { if (visible != columnFootersVisible) { columnFootersVisible = visible; - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/TextArea.java b/server/src/com/vaadin/ui/TextArea.java index fed06b561a..0dc9722eb3 100644 --- a/server/src/com/vaadin/ui/TextArea.java +++ b/server/src/com/vaadin/ui/TextArea.java @@ -81,7 +81,7 @@ public class TextArea extends AbstractTextField { } @Override - public TextAreaState getState() { + protected TextAreaState getState() { return (TextAreaState) super.getState(); } @@ -96,7 +96,6 @@ public class TextArea extends AbstractTextField { rows = 0; } getState().setRows(rows); - requestRepaint(); } /** @@ -117,7 +116,6 @@ public class TextArea extends AbstractTextField { */ public void setWordwrap(boolean wordwrap) { getState().setWordwrap(wordwrap); - requestRepaint(); } /** diff --git a/server/src/com/vaadin/ui/Tree.java b/server/src/com/vaadin/ui/Tree.java index dda0a78aff..2d6673a67d 100644 --- a/server/src/com/vaadin/ui/Tree.java +++ b/server/src/com/vaadin/ui/Tree.java @@ -184,7 +184,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, */ public boolean expandItem(Object itemId) { boolean success = expandItem(itemId, true); - requestRepaint(); + markAsDirty(); return success; } @@ -215,7 +215,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, expandedItemId = itemId; if (initialPaint) { - requestRepaint(); + markAsDirty(); } else if (sendChildTree) { requestPartialRepaint(); } @@ -225,13 +225,13 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, } @Override - public void requestRepaint() { - super.requestRepaint(); + public void markAsDirty() { + super.markAsDirty(); partialUpdate = false; } private void requestPartialRepaint() { - super.requestRepaint(); + super.markAsDirty(); partialUpdate = true; } @@ -262,7 +262,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, todo.addAll(getChildren(id)); } } - requestRepaint(); + markAsDirty(); return result; } @@ -282,7 +282,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, // Collapse expanded.remove(itemId); - requestRepaint(); + markAsDirty(); fireCollapseEvent(itemId); return true; @@ -349,7 +349,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, public void setSelectable(boolean selectable) { if (this.selectable != selectable) { this.selectable = selectable; - requestRepaint(); + markAsDirty(); } } @@ -362,7 +362,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, public void setMultiselectMode(MultiSelectMode mode) { if (multiSelectMode != mode && mode != null) { multiSelectMode = mode; - requestRepaint(); + markAsDirty(); } } @@ -478,7 +478,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, if (!isNullSelectionAllowed() && (id == null || id == getNullSelectionItemId())) { // skip empty selection if nullselection is not allowed - requestRepaint(); + markAsDirty(); } else if (id != null && containsId(id)) { s.add(id); } @@ -486,7 +486,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, if (!isNullSelectionAllowed() && s.size() < 1) { // empty selection not allowed, keep old value - requestRepaint(); + markAsDirty(); return; } @@ -796,7 +796,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, final boolean success = ((Container.Hierarchical) items) .setChildrenAllowed(itemId, areChildrenAllowed); if (success) { - requestRepaint(); + markAsDirty(); } return success; } @@ -812,7 +812,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, final boolean success = ((Container.Hierarchical) items).setParent( itemId, newParentId); if (success) { - requestRepaint(); + markAsDirty(); } return success; } @@ -1036,7 +1036,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, if (!actionHandlers.contains(actionHandler)) { actionHandlers.add(actionHandler); - requestRepaint(); + markAsDirty(); } } } @@ -1058,7 +1058,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, actionMapper = null; } - requestRepaint(); + markAsDirty(); } } @@ -1068,7 +1068,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, public void removeAllActionHandlers() { actionHandlers = null; actionMapper = null; - requestRepaint(); + markAsDirty(); } /** @@ -1182,7 +1182,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, public void setItemStyleGenerator(ItemStyleGenerator itemStyleGenerator) { if (this.itemStyleGenerator != itemStyleGenerator) { this.itemStyleGenerator = itemStyleGenerator; - requestRepaint(); + markAsDirty(); } } @@ -1342,7 +1342,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, */ public void setDragMode(TreeDragMode dragMode) { this.dragMode = dragMode; - requestRepaint(); + markAsDirty(); } /** @@ -1601,7 +1601,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, public void setItemDescriptionGenerator(ItemDescriptionGenerator generator) { if (generator != itemDescriptionGenerator) { itemDescriptionGenerator = generator; - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/TreeTable.java b/server/src/com/vaadin/ui/TreeTable.java index 7548a4840b..05757a6d09 100644 --- a/server/src/com/vaadin/ui/TreeTable.java +++ b/server/src/com/vaadin/ui/TreeTable.java @@ -463,7 +463,7 @@ public class TreeTable extends Table implements Hierarchical { // been processed clearFocusedRowPending = true; } - requestRepaint(); + markAsDirty(); } @Override @@ -561,7 +561,7 @@ public class TreeTable extends Table implements Hierarchical { } if (containerSupportsPartialUpdates && !forceFullRefresh) { - requestRepaint(); + markAsDirty(); } else { // For containers that do not send item set change events, always do // full repaint instead of partial row update. @@ -826,7 +826,7 @@ public class TreeTable extends Table implements Hierarchical { */ public void setAnimationsEnabled(boolean animationsEnabled) { this.animationsEnabled = animationsEnabled; - requestRepaint(); + markAsDirty(); } private static final Logger getLogger() { diff --git a/server/src/com/vaadin/ui/TwinColSelect.java b/server/src/com/vaadin/ui/TwinColSelect.java index 80f4ae49c8..891e695a5f 100644 --- a/server/src/com/vaadin/ui/TwinColSelect.java +++ b/server/src/com/vaadin/ui/TwinColSelect.java @@ -79,7 +79,7 @@ public class TwinColSelect extends AbstractSelect { } if (this.columns != columns) { this.columns = columns; - requestRepaint(); + markAsDirty(); } } @@ -111,7 +111,7 @@ public class TwinColSelect extends AbstractSelect { } if (this.rows != rows) { this.rows = rows; - requestRepaint(); + markAsDirty(); } } @@ -159,7 +159,7 @@ public class TwinColSelect extends AbstractSelect { */ public void setRightColumnCaption(String rightColumnCaption) { this.rightColumnCaption = rightColumnCaption; - requestRepaint(); + markAsDirty(); } /** @@ -179,7 +179,7 @@ public class TwinColSelect extends AbstractSelect { */ public void setLeftColumnCaption(String leftColumnCaption) { this.leftColumnCaption = leftColumnCaption; - requestRepaint(); + markAsDirty(); } /** diff --git a/server/src/com/vaadin/ui/Root.java b/server/src/com/vaadin/ui/UI.java index 98c200cd34..17a028bcdf 100644 --- a/server/src/com/vaadin/ui/Root.java +++ b/server/src/com/vaadin/ui/UI.java @@ -37,9 +37,9 @@ import com.vaadin.event.MouseEvents.ClickListener; import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.BorderStyle; -import com.vaadin.shared.ui.root.RootConstants; -import com.vaadin.shared.ui.root.RootServerRpc; -import com.vaadin.shared.ui.root.RootState; +import com.vaadin.shared.ui.ui.UIConstants; +import com.vaadin.shared.ui.ui.UIServerRpc; +import com.vaadin.shared.ui.ui.UIState; import com.vaadin.terminal.Page; import com.vaadin.terminal.Page.BrowserWindowResizeEvent; import com.vaadin.terminal.Page.BrowserWindowResizeListener; @@ -49,27 +49,28 @@ import com.vaadin.terminal.Resource; import com.vaadin.terminal.Vaadin6Component; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.WrappedRequest.BrowserDetails; +import com.vaadin.terminal.gwt.server.AbstractApplicationServlet; import com.vaadin.tools.ReflectTools; /** - * The topmost component in any component hierarchy. There is one root for every - * Vaadin instance in a browser window. A root may either represent an entire + * The topmost component in any component hierarchy. There is one UI for every + * Vaadin instance in a browser window. A UI may either represent an entire * browser window (or tab) or some part of a html page where a Vaadin * application is embedded. * <p> - * The root is the server side entry point for various client side features that + * The UI is the server side entry point for various client side features that * are not represented as components added to a layout, e.g notifications, sub * windows, and executing javascript in the browser. * </p> * <p> - * When a new application instance is needed, typically because the user opens - * the application in a browser window, - * {@link Application#gerRoot(WrappedRequest)} is invoked to get a root. That - * method does by default create a root according to the - * {@value Application#ROOT_PARAMETER} parameter from web.xml. + * When a new UI instance is needed, typically because the user opens a URL in a + * browser window which points to {@link AbstractApplicationServlet}, + * {@link Application#getUIForRequest(WrappedRequest)} is invoked to get a UI. + * That method does by default create a UI according to the + * {@value Application#UI_PARAMETER} parameter from web.xml. * </p> * <p> - * After a root has been created by the application, it is initialized using + * After a UI has been created by the application, it is initialized using * {@link #init(WrappedRequest)}. This method is intended to be overridden by * the developer to add components to the user interface and initialize * non-component functionality. The component hierarchy is initialized by @@ -78,27 +79,27 @@ import com.vaadin.tools.ReflectTools; * </p> * <p> * If a {@link EagerInit} annotation is present on a class extending - * <code>Root</code>, the framework will use a faster initialization method - * which will not ensure that {@link BrowserDetails} are present in the + * <code>UI</code>, the framework will use a faster initialization method which + * will not ensure that {@link BrowserDetails} are present in the * {@link WrappedRequest} passed to the init method. * </p> * * @see #init(WrappedRequest) - * @see Application#getRoot(WrappedRequest) + * @see Application#getUI(WrappedRequest) * * @since 7.0 */ -public abstract class Root extends AbstractComponentContainer implements +public abstract class UI extends AbstractComponentContainer implements Action.Container, Action.Notifier, Vaadin6Component { /** - * Helper class to emulate the main window from Vaadin 6 using roots. This + * Helper class to emulate the main window from Vaadin 6 using UIs. This * class should be used in the same way as Window used as a browser level * window in Vaadin 6 with {@link com.vaadin.Application.LegacyApplication} */ @Deprecated @EagerInit - public static class LegacyWindow extends Root { + public static class LegacyWindow extends UI { private String name; /** @@ -212,11 +213,11 @@ public abstract class Root extends AbstractComponentContainer implements } /** - * Opens the given resource in this root. The contents of this Root is + * 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 root + * the resource to show in this UI * * @deprecated As of 7.0, use getPage().open instead */ @@ -296,9 +297,9 @@ public abstract class Root extends AbstractComponentContainer implements } /** - * Adds a new {@link BrowserWindowResizeListener} to this root. The + * Adds a new {@link BrowserWindowResizeListener} to this UI. The * listener will be notified whenever the browser window within which - * this root resides is resized. + * this UI resides is resized. * * @param resizeListener * the listener to add @@ -314,7 +315,7 @@ public abstract class Root extends AbstractComponentContainer implements } /** - * Removes a {@link BrowserWindowResizeListener} from this root. The + * Removes a {@link BrowserWindowResizeListener} from this UI. The * listener will no longer be notified when the browser window is * resized. * @@ -328,7 +329,7 @@ public abstract class Root extends AbstractComponentContainer implements } /** - * Gets the last known height of the browser window in which this root + * Gets the last known height of the browser window in which this UI * resides. * * @return the browser window height in pixels @@ -340,7 +341,7 @@ public abstract class Root extends AbstractComponentContainer implements } /** - * Gets the last known width of the browser window in which this root + * Gets the last known width of the browser window in which this UI * resides. * * @return the browser window width in pixels @@ -391,23 +392,23 @@ public abstract class Root extends AbstractComponentContainer implements } /** - * Event fired when a Root is removed from the application. + * Event fired when a UI is removed from the application. */ public static class CloseEvent extends Event { - private static final String CLOSE_EVENT_IDENTIFIER = "rootClose"; + private static final String CLOSE_EVENT_IDENTIFIER = "uiClose"; - public CloseEvent(Root source) { + public CloseEvent(UI source) { super(source); } - public Root getRoot() { - return (Root) getSource(); + public UI getUI() { + return (UI) getSource(); } } /** - * Interface for listening {@link Root.CloseEvent root close events}. + * Interface for listening {@link UI.CloseEvent UI close events}. * */ public interface CloseListener extends EventListener { @@ -417,7 +418,7 @@ public abstract class Root extends AbstractComponentContainer implements /** * Called when a CloseListener is notified of a CloseEvent. - * {@link Root#getCurrent()} returns <code>event.getRoot()</code> within + * {@link UI#getCurrent()} returns <code>event.getUI()</code> within * this method. * * @param event @@ -427,12 +428,12 @@ public abstract class Root extends AbstractComponentContainer implements } /** - * The application to which this root belongs + * The application to which this UI belongs */ private Application application; /** - * List of windows in this root. + * List of windows in this UI. */ private final LinkedHashSet<Window> windows = new LinkedHashSet<Window>(); @@ -443,13 +444,13 @@ public abstract class Root extends AbstractComponentContainer implements private Component scrollIntoView; /** - * The id of this root, used to find the server side instance of the root - * form which a request originates. A negative value indicates that the root - * id has not yet been assigned by the Application. + * The id of this UI, used to find the server side instance of the UI form + * which a request originates. A negative value indicates that the UI id has + * not yet been assigned by the Application. * - * @see Application#nextRootId + * @see Application#nextUIId */ - private int rootId = -1; + private int uiId = -1; /** * Keeps track of the Actions added to this component, and manages the @@ -458,19 +459,19 @@ public abstract class Root extends AbstractComponentContainer implements protected ActionManager actionManager; /** - * Thread local for keeping track of the current root. + * Thread local for keeping track of the current UI. */ - private static final ThreadLocal<Root> currentRoot = new ThreadLocal<Root>(); + private static final ThreadLocal<UI> currentUI = new ThreadLocal<UI>(); /** Identifies the click event */ private ConnectorTracker connectorTracker = new ConnectorTracker(this); private Page page = new Page(this); - private RootServerRpc rpc = new RootServerRpc() { + private UIServerRpc rpc = new UIServerRpc() { @Override public void click(MouseEventDetails mouseDetails) { - fireEvent(new ClickEvent(Root.this, mouseDetails)); + fireEvent(new ClickEvent(UI.this, mouseDetails)); } @Override @@ -482,89 +483,89 @@ public abstract class Root extends AbstractComponentContainer implements }; /** - * Timestamp keeping track of the last heartbeat of this Root. Updated to - * the current time whenever the application receives a heartbeat or UIDL - * request from the client for this Root. + * Timestamp keeping track of the last heartbeat of this UI. Updated to the + * current time whenever the application receives a heartbeat or UIDL + * request from the client for this UI. */ private long lastHeartbeat = System.currentTimeMillis(); private long lastUidlRequest = System.currentTimeMillis(); /** - * Creates a new empty root without a caption. This root will have a + * Creates a new empty UI without a caption. This UI will have a * {@link VerticalLayout} with margins enabled as its content. */ - public Root() { + public UI() { this((ComponentContainer) null); } /** - * Creates a new root with the given component container as its content. + * Creates a new UI with the given component container as its content. * * @param content - * the content container to use as this roots content. + * the content container to use as this UIs content. * * @see #setContent(ComponentContainer) */ - public Root(ComponentContainer content) { + public UI(ComponentContainer content) { registerRpc(rpc); setSizeFull(); setContent(content); } /** - * Creates a new empty root with the given caption. This root will have a + * Creates a new empty UI with the given caption. This UI will have a * {@link VerticalLayout} with margins enabled as its content. * * @param caption - * the caption of the root, used as the page title if there's + * the caption of the UI, used as the page title if there's * nothing but the application on the web page * * @see #setCaption(String) */ - public Root(String caption) { + public UI(String caption) { this((ComponentContainer) null); setCaption(caption); } /** - * Creates a new root with the given caption and content. + * Creates a new UI with the given caption and content. * * @param caption - * the caption of the root, used as the page title if there's + * the caption of the UI, used as the page title if there's * nothing but the application on the web page * @param content - * the content container to use as this roots content. + * the content container to use as this UIs content. * * @see #setContent(ComponentContainer) * @see #setCaption(String) */ - public Root(String caption, ComponentContainer content) { + public UI(String caption, ComponentContainer content) { this(content); setCaption(caption); } @Override - public RootState getState() { - return (RootState) super.getState(); + protected UIState getState() { + return (UIState) super.getState(); } @Override - public Class<? extends RootState> getStateType() { + public Class<? extends UIState> getStateType() { // This is a workaround for a problem with creating the correct state // object during build - return RootState.class; + return UIState.class; } /** * Overridden to return a value instead of referring to the parent. * - * @return this root + * @return this UI * - * @see com.vaadin.ui.AbstractComponent#getRoot() + * @see com.vaadin.ui.AbstractComponent#getUI() */ @Override - public Root getRoot() { + public UI getUI() { return this; } @@ -589,9 +590,9 @@ public abstract class Root extends AbstractComponentContainer implements if (pendingFocus != null) { // ensure focused component is still attached to this main window - if (pendingFocus.getRoot() == this - || (pendingFocus.getRoot() != null && pendingFocus - .getRoot().getParent() == this)) { + if (pendingFocus.getUI() == this + || (pendingFocus.getUI() != null && pendingFocus.getUI() + .getParent() == this)) { target.addAttribute("focused", pendingFocus); } pendingFocus = null; @@ -602,7 +603,7 @@ public abstract class Root extends AbstractComponentContainer implements } if (isResizeLazy()) { - target.addAttribute(RootConstants.RESIZE_LAZY, true); + target.addAttribute(UIConstants.RESIZE_LAZY, true); } } @@ -622,10 +623,10 @@ public abstract class Root extends AbstractComponentContainer implements * For internal use only. */ public void fireCloseEvent() { - Root current = Root.getCurrent(); - Root.setCurrent(this); + UI current = UI.getCurrent(); + UI.setCurrent(this); fireEvent(new CloseEvent(this)); - Root.setCurrent(current); + UI.setCurrent(current); } @Override @@ -641,9 +642,9 @@ public abstract class Root extends AbstractComponentContainer implements actionManager.handleActions(variables, this); } - if (variables.containsKey(RootConstants.FRAGMENT_VARIABLE)) { + if (variables.containsKey(UIConstants.FRAGMENT_VARIABLE)) { String fragment = (String) variables - .get(RootConstants.FRAGMENT_VARIABLE); + .get(UIConstants.FRAGMENT_VARIABLE); getPage().setFragment(fragment, true); } } @@ -679,7 +680,7 @@ public abstract class Root extends AbstractComponentContainer implements } /** - * Sets the application to which this root is assigned. It is not legal to + * Sets the application to which this UI is assigned. It is not legal to * change the application once it has been set nor to set a * <code>null</code> application. * <p> @@ -709,46 +710,46 @@ public abstract class Root extends AbstractComponentContainer implements } /** - * Sets the id of this root within its application. The root id is used to - * route requests to the right root. + * Sets the id of this UI within its application. The UI id is used to route + * requests to the right UI. * <p> * This method is mainly intended for internal use by the framework. * </p> * - * @param rootId - * the id of this root + * @param uiId + * the id of this UI * * @throws IllegalStateException - * if the root id has already been set + * if the UI id has already been set * - * @see #getRootId() + * @see #getUIId() */ - public void setRootId(int rootId) { - if (this.rootId != -1) { - throw new IllegalStateException("Root id has already been defined"); + public void setUIId(int uiId) { + if (this.uiId != -1) { + throw new IllegalStateException("UI id has already been defined"); } - this.rootId = rootId; + this.uiId = uiId; } /** - * Gets the id of the root, used to identify this root within its - * application when processing requests. The root id should be present in - * every request to the server that originates from this root. - * {@link Application#getRootForRequest(WrappedRequest)} uses this id to - * find the route to which the request belongs. + * Gets the id of the UI, used to identify this UI within its application + * when processing requests. The UI id should be present in every request to + * the server that originates from this UI. + * {@link Application#getUIForRequest(WrappedRequest)} uses this id to find + * the route to which the request belongs. * * @return */ - public int getRootId() { - return rootId; + public int getUIId() { + return uiId; } /** - * Adds a window as a subwindow inside this root. To open a new browser - * window or tab, you should instead use {@link open(Resource)} with an url + * Adds a window as a subwindow inside this UI. To open a new browser window + * or tab, you should instead use {@link open(Resource)} with an url * pointing to this application and ensure - * {@link Application#getRoot(WrappedRequest)} returns an appropriate root - * for the request. + * {@link Application#getUI(WrappedRequest)} returns an appropriate UI for + * the request. * * @param window * @throws IllegalArgumentException @@ -780,11 +781,11 @@ public abstract class Root extends AbstractComponentContainer implements private void attachWindow(Window w) { windows.add(w); w.setParent(this); - requestRepaint(); + markAsDirty(); } /** - * Remove the given subwindow from this root. + * Remove the given subwindow from this UI. * * Since Vaadin 6.5, {@link CloseListener}s are called also when explicitly * removing a window by calling this method. @@ -798,18 +799,18 @@ public abstract class Root extends AbstractComponentContainer implements */ public boolean removeWindow(Window window) { if (!windows.remove(window)) { - // Window window is not a subwindow of this root. + // Window window is not a subwindow of this UI. return false; } window.setParent(null); window.fireClose(); - requestRepaint(); + markAsDirty(); return true; } /** - * Gets all the windows added to this root. + * Gets all the windows added to this UI. * * @return an unmodifiable collection of windows */ @@ -845,32 +846,32 @@ public abstract class Root extends AbstractComponentContainer implements */ public void setFocusedComponent(Focusable focusable) { pendingFocus = focusable; - requestRepaint(); + markAsDirty(); } /** - * Scrolls any component between the component and root to a suitable - * position so the component is visible to the user. The given component - * must belong to this root. + * Scrolls any component between the component and UI to a suitable position + * so the component is visible to the user. The given component must belong + * to this UI. * * @param component * the component to be scrolled into view * @throws IllegalArgumentException - * if {@code component} does not belong to this root + * if {@code component} does not belong to this UI */ public void scrollIntoView(Component component) throws IllegalArgumentException { - if (component.getRoot() != this) { + if (component.getUI() != this) { throw new IllegalArgumentException( - "The component where to scroll must belong to this root."); + "The component where to scroll must belong to this UI."); } scrollIntoView = component; - requestRepaint(); + markAsDirty(); } /** - * Gets the content of this root. The content is a component container that - * serves as the outermost item of the visual contents of this root. + * Gets the content of this UI. The content is a component container that + * serves as the outermost item of the visual contents of this UI. * * @return a component container to use as content * @@ -894,15 +895,15 @@ public abstract class Root extends AbstractComponentContainer implements } /** - * Sets the content of this root. The content is a component container that - * serves as the outermost item of the visual contents of this root. If no + * Sets the content of this UI. The content is a component container that + * serves as the outermost item of the visual contents of this UI. If no * content has been set, a {@link VerticalLayout} with margins enabled will * be used by default - see {@link #createDefaultLayout()}. The content can * also be set in a constructor. * * @return a component container to use as content * - * @see #Root(ComponentContainer) + * @see #UI(ComponentContainer) * @see #createDefaultLayout() */ public void setContent(ComponentContainer content) { @@ -917,16 +918,14 @@ public abstract class Root extends AbstractComponentContainer implements if (content != null) { super.addComponent(content); } - - requestRepaint(); } /** - * Adds a component to this root. The component is not added directly to the - * root, but instead to the content container ({@link #getContent()}). + * Adds a component to this UI. The component is not added directly to the + * UI, but instead to the content container ({@link #getContent()}). * * @param component - * the component to add to this root + * the component to add to this UI * * @see #getContent() */ @@ -937,7 +936,7 @@ public abstract class Root extends AbstractComponentContainer implements /** * This implementation removes the component from the content container ( - * {@link #getContent()}) instead of from the actual root. + * {@link #getContent()}) instead of from the actual UI. */ @Override public void removeComponent(Component component) { @@ -946,7 +945,7 @@ public abstract class Root extends AbstractComponentContainer implements /** * This implementation removes the components from the content container ( - * {@link #getContent()}) instead of from the actual root. + * {@link #getContent()}) instead of from the actual UI. */ @Override public void removeAllComponents() { @@ -969,56 +968,55 @@ public abstract class Root extends AbstractComponentContainer implements } /** - * Initializes this root. This method is intended to be overridden by + * Initializes this UI. This method is intended to be overridden by * subclasses to build the view and configure non-component functionality. * Performing the initialization in a constructor is not suggested as the - * state of the root is not properly set up when the constructor is invoked. + * state of the UI is not properly set up when the constructor is invoked. * <p> * The {@link WrappedRequest} can be used to get information about the - * request that caused this root to be created. By default, the + * request that caused this UI to be created. By default, the * {@link BrowserDetails} will be available in the request. If the browser * details are not required, loading the application in the browser can take * some shortcuts giving a faster initial rendering. This can be indicated - * by adding the {@link EagerInit} annotation to the Root class. + * by adding the {@link EagerInit} annotation to the UI class. * </p> * * @param request - * the wrapped request that caused this root to be created + * the wrapped request that caused this UI to be created */ protected abstract void init(WrappedRequest request); /** - * Sets the thread local for the current root. This method is used by the + * Sets the thread local for the current UI. This method is used by the * framework to set the current application whenever a new request is * processed and it is cleared when the request has been processed. * <p> * The application developer can also use this method to define the current - * root outside the normal request handling, e.g. when initiating custom + * UI outside the normal request handling, e.g. when initiating custom * background threads. * </p> * - * @param root - * the root to register as the current root + * @param uI + * the UI to register as the current UI * * @see #getCurrent() * @see ThreadLocal */ - public static void setCurrent(Root root) { - currentRoot.set(root); + public static void setCurrent(UI ui) { + currentUI.set(ui); } /** - * Gets the currently used root. The current root is automatically defined - * when processing requests to the server. In other cases, (e.g. from - * background threads), the current root is not automatically defined. + * Gets the currently used UI. The current UI is automatically defined when + * processing requests to the server. In other cases, (e.g. from background + * threads), the current UI is not automatically defined. * - * @return the current root instance if available, otherwise - * <code>null</code> + * @return the current UI instance if available, otherwise <code>null</code> * - * @see #setCurrent(Root) + * @see #setCurrent(UI) */ - public static Root getCurrent() { - return currentRoot.get(); + public static UI getCurrent() { + return currentUI.get(); } public void setScrollTop(int scrollTop) { @@ -1072,7 +1070,7 @@ public abstract class Root extends AbstractComponentContainer implements */ public void setResizeLazy(boolean resizeLazy) { this.resizeLazy = resizeLazy; - requestRepaint(); + markAsDirty(); } /** @@ -1086,10 +1084,10 @@ public abstract class Root extends AbstractComponentContainer implements } /** - * Add a click listener to the Root. The listener is called whenever the - * user clicks inside the Root. Also when the click targets a component - * inside the Root, provided the targeted component does not prevent the - * click event from propagating. + * Add a click listener to the UI. The listener is called whenever the user + * clicks inside the UI. Also when the click targets a component inside the + * UI, provided the targeted component does not prevent the click event from + * propagating. * * Use {@link #removeListener(ClickListener)} to remove the listener. * @@ -1102,7 +1100,7 @@ public abstract class Root extends AbstractComponentContainer implements } /** - * Remove a click listener from the Root. The listener should earlier have + * Remove a click listener from the UI. The listener should earlier have * been added using {@link #addListener(ClickListener)}. * * @param listener @@ -1114,8 +1112,8 @@ public abstract class Root extends AbstractComponentContainer implements } /** - * Adds a close listener to the Root. The listener is called when the Root - * is removed from the application. + * Adds a close listener to the UI. The listener is called when the UI is + * removed from the application. * * @param listener * The listener to add. @@ -1126,8 +1124,8 @@ public abstract class Root extends AbstractComponentContainer implements } /** - * Removes a close listener from the Root if it has previously been added - * with {@link #addListener(ClickListener)}. Otherwise, has no effect. + * Removes a close listener from the UI if it has previously been added with + * {@link #addListener(ClickListener)}. Otherwise, has no effect. * * @param listener * The listener to remove. @@ -1139,7 +1137,7 @@ public abstract class Root extends AbstractComponentContainer implements @Override public boolean isConnectorEnabled() { - // TODO How can a Root be invisible? What does it mean? + // TODO How can a UI be invisible? What does it mean? return isVisible() && isEnabled(); } @@ -1152,7 +1150,7 @@ public abstract class Root extends AbstractComponentContainer implements } /** - * Setting the caption of a Root is not supported. To set the title of the + * Setting the caption of a UI is not supported. To set the title of the * HTML page, use Page.setTitle * * @deprecated as of 7.0.0, use {@link Page#setTitle(String)} @@ -1161,11 +1159,11 @@ public abstract class Root extends AbstractComponentContainer implements @Deprecated public void setCaption(String caption) { throw new IllegalStateException( - "You can not set the title of a Root. To set the title of the HTML page, use Page.setTitle"); + "You can not set the title of a UI. To set the title of the HTML page, use Page.setTitle"); } /** - * Shows a notification message on the middle of the root. The message + * Shows a notification message on the middle of the UI. The message * automatically disappears ("humanized message"). * * Care should be taken to to avoid XSS vulnerabilities as the caption is @@ -1188,7 +1186,7 @@ public abstract class Root extends AbstractComponentContainer implements } /** - * Shows a notification message the root. The position and behavior of the + * Shows a notification message the UI. 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. * @@ -1207,7 +1205,7 @@ public abstract class Root extends AbstractComponentContainer implements * Notification.show does not allow HTML. */ @Deprecated - public void showNotification(String caption, int type) { + public void showNotification(String caption, Notification.Type type) { Notification notification = new Notification(caption, type); notification.setHtmlContentAllowed(true);// Backwards compatibility getPage().showNotification(notification); @@ -1215,8 +1213,8 @@ public abstract class Root extends AbstractComponentContainer implements /** * Shows a notification consisting of a bigger caption and a smaller - * description on the middle of the root. The message automatically - * disappears ("humanized message"). + * description on the middle of the UI. The message automatically disappears + * ("humanized message"). * * Care should be taken to to avoid XSS vulnerabilities as the caption and * description are rendered as html. @@ -1262,7 +1260,8 @@ public abstract class Root extends AbstractComponentContainer implements * be aware that HTML by default not allowed. */ @Deprecated - public void showNotification(String caption, String description, int type) { + public void showNotification(String caption, String description, + Notification.Type type) { Notification notification = new Notification(caption, description, type); notification.setHtmlContentAllowed(true);// Backwards compatibility getPage().showNotification(notification); @@ -1293,8 +1292,8 @@ public abstract class Root extends AbstractComponentContainer implements * @deprecated As of 7.0, use new Notification(...).show(Page). */ @Deprecated - public void showNotification(String caption, String description, int type, - boolean htmlContentAllowed) { + public void showNotification(String caption, String description, + Notification.Type type, boolean htmlContentAllowed) { getPage() .showNotification( new Notification(caption, description, type, @@ -1322,10 +1321,10 @@ public abstract class Root extends AbstractComponentContainer implements /** * Returns the timestamp (milliseconds since the epoch) of the last received - * heartbeat for this Root. + * heartbeat for this UI. * * @see #heartbeat() - * @see Application#closeInactiveRoots() + * @see Application#closeInactiveUIs() * * @return The time the last heartbeat request occurred. */ @@ -1335,7 +1334,7 @@ public abstract class Root extends AbstractComponentContainer implements /** * Returns the timestamp (milliseconds since the epoch) of the last received - * UIDL request for this Root. + * UIDL request for this UI. * * @return */ @@ -1344,18 +1343,17 @@ public abstract class Root extends AbstractComponentContainer implements } /** - * Sets the last heartbeat request timestamp for this Root. Called by the + * Sets the last heartbeat request timestamp for this UI. Called by the * framework whenever the application receives a valid heartbeat request for - * this Root. + * this UI. */ public void setLastHeartbeatTime(long lastHeartbeat) { this.lastHeartbeat = lastHeartbeat; } /** - * Sets the last UIDL request timestamp for this Root. Called by the - * framework whenever the application receives a valid UIDL request for this - * Root. + * Sets the last UIDL request timestamp for this UI. Called by the framework + * whenever the application receives a valid UIDL request for this UI. */ public void setLastUidlRequestTime(long lastUidlRequest) { this.lastUidlRequest = lastUidlRequest; diff --git a/server/src/com/vaadin/ui/Upload.java b/server/src/com/vaadin/ui/Upload.java index c4f15ebea9..619db07eea 100644 --- a/server/src/com/vaadin/ui/Upload.java +++ b/server/src/com/vaadin/ui/Upload.java @@ -138,7 +138,7 @@ public class Upload extends AbstractComponent implements Component.Focusable, int id = (Integer) variables.get("pollForStart"); if (!isUploading && id == nextid) { notStarted = true; - requestRepaint(); + markAsDirty(); } else { } } @@ -829,7 +829,7 @@ public class Upload extends AbstractComponent implements Component.Focusable, isUploading = false; contentLength = -1; interrupted = false; - requestRepaint(); + markAsDirty(); } public boolean isUploading() { @@ -856,33 +856,6 @@ public class Upload extends AbstractComponent implements Component.Focusable, } /** - * This method is deprecated, use addListener(ProgressListener) instead. - * - * @deprecated Use addListener(ProgressListener) instead. - * @param progressListener - */ - @Deprecated - public void setProgressListener(ProgressListener progressListener) { - addListener(progressListener); - } - - /** - * This method is deprecated. - * - * @deprecated Replaced with addListener/removeListener - * @return listener - * - */ - @Deprecated - public ProgressListener getProgressListener() { - if (progressListeners == null || progressListeners.isEmpty()) { - return null; - } else { - return progressListeners.iterator().next(); - } - } - - /** * ProgressListener receives events to track progress of upload. */ public interface ProgressListener extends Serializable { @@ -928,7 +901,7 @@ public class Upload extends AbstractComponent implements Component.Focusable, */ public void setButtonCaption(String buttonCaption) { this.buttonCaption = buttonCaption; - requestRepaint(); + markAsDirty(); } /** @@ -949,14 +922,14 @@ public class Upload extends AbstractComponent implements Component.Focusable, * fired. */ public void submitUpload() { - requestRepaint(); + markAsDirty(); forceSubmit = true; } @Override - public void requestRepaint() { + public void markAsDirty() { forceSubmit = false; - super.requestRepaint(); + super.markAsDirty(); } /* @@ -1009,7 +982,7 @@ public class Upload extends AbstractComponent implements Component.Focusable, fireUploadSuccess(event.getFileName(), event.getMimeType(), event.getContentLength()); endUpload(); - requestRepaint(); + markAsDirty(); } @Override diff --git a/server/src/com/vaadin/ui/Video.java b/server/src/com/vaadin/ui/Video.java index 95a38c59d5..b54d404da6 100644 --- a/server/src/com/vaadin/ui/Video.java +++ b/server/src/com/vaadin/ui/Video.java @@ -44,7 +44,7 @@ import com.vaadin.terminal.gwt.server.ResourceReference; public class Video extends AbstractMedia { @Override - public VideoState getState() { + protected VideoState getState() { return (VideoState) super.getState(); } @@ -80,7 +80,6 @@ public class Video extends AbstractMedia { */ public void setPoster(Resource poster) { getState().setPoster(ResourceReference.create(poster)); - requestRepaint(); } /** diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java index d1d2c25d8b..6102350566 100644 --- a/server/src/com/vaadin/ui/Window.java +++ b/server/src/com/vaadin/ui/Window.java @@ -40,8 +40,8 @@ import com.vaadin.terminal.Vaadin6Component; /** * A component that represents a floating popup window that can be added to a - * {@link Root}. A window is added to a {@code Root} using - * {@link Root#addWindow(Window)}. </p> + * {@link UI}. A window is added to a {@code UI} using + * {@link UI#addWindow(Window)}. </p> * <p> * The contents of a window is set using {@link #setContent(ComponentContainer)} * or by using the {@link #Window(String, ComponentContainer)} constructor. The @@ -57,7 +57,7 @@ import com.vaadin.terminal.Vaadin6Component; * </p> * <p> * In Vaadin versions prior to 7.0.0, Window was also used as application level - * windows. This function is now covered by the {@link Root} class. + * windows. This function is now covered by the {@link UI} class. * </p> * * @author Vaadin Ltd. @@ -174,14 +174,14 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, 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); + setPositionX(x < 0 ? -1 : x); } 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); + setPositionY(y < 0 ? -1 : y); } if (isClosable()) { @@ -222,14 +222,14 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * </p> */ public void close() { - Root root = getRoot(); + UI uI = getUI(); - // Don't do anything if not attached to a root - if (root != null) { + // Don't do anything if not attached to a UI + if (uI != null) { // focus is restored to the parent window - root.focus(); - // subwindow is removed from the root - root.removeWindow(this); + uI.focus(); + // subwindow is removed from the UI + uI.removeWindow(this); } } @@ -255,26 +255,8 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @since 4.0.0 */ public void setPositionX(int positionX) { - setPositionX(positionX, true); - } - - /** - * Sets the distance of Window left border in pixels from left border of the - * containing (main window). - * - * @param positionX - * the Distance of Window left border in pixels from left border - * of the containing (main window). or -1 if unspecified. - * @param repaintRequired - * true if the window needs to be repainted, false otherwise - * @since 6.3.4 - */ - private void setPositionX(int positionX, boolean repaintRequired) { getState().setPositionX(positionX); getState().setCentered(false); - if (repaintRequired) { - requestRepaint(); - } } /** @@ -301,27 +283,8 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @since 4.0.0 */ public void setPositionY(int positionY) { - setPositionY(positionY, true); - } - - /** - * Sets the distance of Window top border in pixels from top border of the - * containing (main window). - * - * @param positionY - * the Distance of Window top border in pixels from top border of - * the containing (main window). or -1 if unspecified - * @param repaintRequired - * true if the window needs to be repainted, false otherwise - * - * @since 6.3.4 - */ - private void setPositionY(int positionY, boolean repaintRequired) { getState().setPositionY(positionY); getState().setCentered(false); - if (repaintRequired) { - requestRepaint(); - } } private static final Method WINDOW_CLOSE_METHOD; @@ -507,22 +470,22 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * If there are currently several windows visible, calling this method makes * this window topmost. * <p> - * This method can only be called if this window connected a root. Else an + * This method can only be called if this window connected a UI. 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> */ public void bringToFront() { - Root root = getRoot(); - if (root == null) { + UI uI = getUI(); + if (uI == null) { throw new IllegalStateException( "Window must be attached to parent before calling bringToFront method."); } int maxBringToFront = -1; - for (Window w : root.getWindows()) { + for (Window w : uI.getWindows()) { if (!isModal() && w.isModal()) { throw new IllegalStateException( - "The root contains modal windows, non-modal window cannot be brought to front."); + "The UI contains modal windows, non-modal window cannot be brought to front."); } if (w.bringToFront != null) { maxBringToFront = Math.max(maxBringToFront, @@ -530,7 +493,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, } } bringToFront = Integer.valueOf(maxBringToFront + 1); - requestRepaint(); + markAsDirty(); } /** @@ -543,7 +506,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, public void setModal(boolean modal) { getState().setModal(modal); center(); - requestRepaint(); } /** @@ -561,7 +523,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, */ public void setResizable(boolean resizable) { getState().setResizable(resizable); - requestRepaint(); } /** @@ -595,7 +556,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, */ public void setResizeLazy(boolean resizeLazy) { getState().setResizeLazy(resizeLazy); - requestRepaint(); } /** @@ -609,7 +569,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, */ public void center() { getState().setCentered(true); - requestRepaint(); } /** @@ -674,7 +633,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, */ public void setDraggable(boolean draggable) { getState().setDraggable(draggable); - requestRepaint(); } /* @@ -838,7 +796,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, } @Override - public WindowState getState() { + protected WindowState getState() { return (WindowState) super.getState(); } } diff --git a/server/src/com/vaadin/ui/themes/BaseTheme.java b/server/src/com/vaadin/ui/themes/BaseTheme.java index bdb0087d2e..9e95627eec 100644 --- a/server/src/com/vaadin/ui/themes/BaseTheme.java +++ b/server/src/com/vaadin/ui/themes/BaseTheme.java @@ -45,18 +45,6 @@ public class BaseTheme { public static final String BUTTON_LINK = "link"; /** - * Removes extra decorations from the panel. - * - * @deprecated Base theme does not implement this style, but it is defined - * here since it has been a part of the framework before - * multiple themes were available. Use the constant provided by - * the theme you're using instead, e.g. - * {@link Reindeer#PANEL_LIGHT} or {@link Runo#PANEL_LIGHT}. - */ - @Deprecated - public static final String PANEL_LIGHT = "light"; - - /** * Adds the connector lines between a parent node and its child nodes to * indicate the tree hierarchy better. */ diff --git a/server/src/com/vaadin/ui/themes/Reindeer.java b/server/src/com/vaadin/ui/themes/Reindeer.java index 7bc6720465..037f59d7b4 100644 --- a/server/src/com/vaadin/ui/themes/Reindeer.java +++ b/server/src/com/vaadin/ui/themes/Reindeer.java @@ -48,12 +48,6 @@ public class Reindeer extends BaseTheme { */ public static final String LABEL_SMALL = "light"; - /** - * @deprecated Use {@link #LABEL_SMALL} instead. - */ - @Deprecated - public static final String LABEL_LIGHT = "small"; - /*************************************************************************** * * Button styles @@ -68,12 +62,6 @@ public class Reindeer extends BaseTheme { public static final String BUTTON_DEFAULT = "primary"; /** - * @deprecated Use {@link #BUTTON_DEFAULT} instead - */ - @Deprecated - public static final String BUTTON_PRIMARY = BUTTON_DEFAULT; - - /** * Small sized button, use for context specific actions for example */ public static final String BUTTON_SMALL = "small"; @@ -129,12 +117,6 @@ public class Reindeer extends BaseTheme { public static final String TABSHEET_SMALL = "bar"; /** - * @deprecated Use {@link #TABSHEET_SMALL} instead. - */ - @Deprecated - public static final String TABSHEET_BAR = TABSHEET_SMALL; - - /** * Removes borders and background color from the tab sheet. The tabs are * presented with minimal lines indicating the selected tab. */ diff --git a/server/src/org/jsoup/select/Evaluator.java b/server/src/org/jsoup/select/Evaluator.java index 16a083bd77..bd0cee481d 100644 --- a/server/src/org/jsoup/select/Evaluator.java +++ b/server/src/org/jsoup/select/Evaluator.java @@ -18,7 +18,7 @@ public abstract class Evaluator { /** * Test if the element meets the evaluator's requirements. * - * @param root Root of the matching subtree + * @param root UI of the matching subtree * @param element tested element */ public abstract boolean matches(Element root, Element element); |