summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin
diff options
context:
space:
mode:
authorJohn Ahlroos <john@vaadin.com>2012-09-03 11:41:06 +0300
committerJohn Ahlroos <john@vaadin.com>2012-09-03 11:41:06 +0300
commit971b0684482dd3b7eb4efac09b9c24e1ea2b305d (patch)
tree6d6a4be640837500cfaa2f805a8602a9f4803871 /server/src/com/vaadin
parent340cd7899812b444941584d383d930fe8155159b (diff)
parentf85c152a48686a8a0dca38ca12b4f3509cac056f (diff)
downloadvaadin-framework-971b0684482dd3b7eb4efac09b9c24e1ea2b305d.tar.gz
vaadin-framework-971b0684482dd3b7eb4efac09b9c24e1ea2b305d.zip
Merge branch 'master' into layoutgraph
Conflicts: shared/src/com/vaadin/shared/ComponentState.java
Diffstat (limited to 'server/src/com/vaadin')
-rw-r--r--server/src/com/vaadin/Application.java541
-rw-r--r--server/src/com/vaadin/UIRequiresMoreInformationException.java37
-rw-r--r--server/src/com/vaadin/annotations/PreserveOnRefresh.java28
-rw-r--r--server/src/com/vaadin/annotations/Title.java (renamed from server/src/com/vaadin/annotations/EagerInit.java)24
-rw-r--r--server/src/com/vaadin/data/Container.java54
-rw-r--r--server/src/com/vaadin/data/ContainerHelpers.java91
-rw-r--r--server/src/com/vaadin/data/RangeOutOfContainerBoundsException.java169
-rw-r--r--server/src/com/vaadin/data/util/AbstractInMemoryContainer.java40
-rw-r--r--server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java14
-rw-r--r--server/src/com/vaadin/navigator/NavigationStateManager.java (renamed from server/src/com/vaadin/navigator/FragmentManager.java)28
-rw-r--r--server/src/com/vaadin/navigator/Navigator.java114
-rw-r--r--server/src/com/vaadin/navigator/View.java17
-rw-r--r--server/src/com/vaadin/navigator/ViewChangeListener.java12
-rw-r--r--server/src/com/vaadin/server/AbstractApplicationPortlet.java9
-rw-r--r--server/src/com/vaadin/server/AbstractCommunicationManager.java41
-rw-r--r--server/src/com/vaadin/server/AbstractUIProvider.java70
-rw-r--r--server/src/com/vaadin/server/BootstrapFragmentResponse.java13
-rw-r--r--server/src/com/vaadin/server/BootstrapHandler.java102
-rw-r--r--server/src/com/vaadin/server/BootstrapPageResponse.java14
-rw-r--r--server/src/com/vaadin/server/BootstrapResponse.java40
-rw-r--r--server/src/com/vaadin/server/CommunicationManager.java7
-rw-r--r--server/src/com/vaadin/server/DefaultUIProvider.java101
-rw-r--r--server/src/com/vaadin/server/GlobalResourceHandler.java4
-rw-r--r--server/src/com/vaadin/server/PortletCommunicationManager.java7
-rw-r--r--server/src/com/vaadin/server/UIProvider.java57
-rw-r--r--server/src/com/vaadin/server/WrappedRequest.java9
-rw-r--r--server/src/com/vaadin/ui/AbsoluteLayout.java4
-rw-r--r--server/src/com/vaadin/ui/AbstractComponent.java73
-rw-r--r--server/src/com/vaadin/ui/AbstractComponentContainer.java8
-rw-r--r--server/src/com/vaadin/ui/AbstractEmbedded.java10
-rw-r--r--server/src/com/vaadin/ui/AbstractField.java26
-rw-r--r--server/src/com/vaadin/ui/AbstractMedia.java32
-rw-r--r--server/src/com/vaadin/ui/AbstractOrderedLayout.java30
-rw-r--r--server/src/com/vaadin/ui/AbstractSelect.java18
-rw-r--r--server/src/com/vaadin/ui/AbstractSplitPanel.java44
-rw-r--r--server/src/com/vaadin/ui/AbstractTextField.java24
-rw-r--r--server/src/com/vaadin/ui/Button.java20
-rw-r--r--server/src/com/vaadin/ui/CheckBox.java4
-rw-r--r--server/src/com/vaadin/ui/ComboBox.java62
-rw-r--r--server/src/com/vaadin/ui/CssLayout.java6
-rw-r--r--server/src/com/vaadin/ui/CustomLayout.java24
-rw-r--r--server/src/com/vaadin/ui/Flash.java38
-rw-r--r--server/src/com/vaadin/ui/Form.java12
-rw-r--r--server/src/com/vaadin/ui/GridLayout.java18
-rw-r--r--server/src/com/vaadin/ui/JavaScript.java6
-rw-r--r--server/src/com/vaadin/ui/Panel.java20
-rw-r--r--server/src/com/vaadin/ui/Slider.java36
-rw-r--r--server/src/com/vaadin/ui/Table.java277
-rw-r--r--server/src/com/vaadin/ui/TextArea.java10
-rw-r--r--server/src/com/vaadin/ui/UI.java80
-rw-r--r--server/src/com/vaadin/ui/Window.java36
51 files changed, 1338 insertions, 1223 deletions
diff --git a/server/src/com/vaadin/Application.java b/server/src/com/vaadin/Application.java
index 164f04bb79..cd34fb7540 100644
--- a/server/src/com/vaadin/Application.java
+++ b/server/src/com/vaadin/Application.java
@@ -26,10 +26,8 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
-import java.util.EventListener;
import java.util.EventObject;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -37,14 +35,14 @@ import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
-import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import com.vaadin.annotations.EagerInit;
+import com.vaadin.annotations.PreserveOnRefresh;
import com.vaadin.annotations.Theme;
+import com.vaadin.annotations.Title;
import com.vaadin.annotations.Widgetset;
import com.vaadin.data.util.converter.Converter;
import com.vaadin.data.util.converter.ConverterFactory;
@@ -211,15 +209,16 @@ public class Application implements Terminal.ErrorListener, Serializable {
* This implementation simulates the way of finding a window for a
* request by extracting a window name from the requested path and
* passes that name to {@link #getWindow(String)}.
- *
+ * <p>
* {@inheritDoc}
- *
- * @see #getWindow(String)
- * @see Application#getUI(WrappedRequest)
*/
-
@Override
- public UI.LegacyWindow getUI(WrappedRequest request) {
+ protected <T extends UI> T createUIInstance(WrappedRequest request,
+ Class<T> uiClass) {
+ return uiClass.cast(getUIInstance(request));
+ }
+
+ private UI getUIInstance(WrappedRequest request) {
String pathInfo = request.getRequestPathInfo();
String name = null;
if (pathInfo != null && pathInfo.length() > 0) {
@@ -237,6 +236,19 @@ public class Application implements Terminal.ErrorListener, Serializable {
}
/**
+ * This implementation simulates the way of finding a window for a
+ * request by extracting a window name from the requested path and
+ * passes that name to {@link #getWindow(String)}.
+ *
+ * <p>
+ * {@inheritDoc}
+ */
+ @Override
+ public Class<? extends UI> getUIClass(WrappedRequest request) {
+ return getUIInstance(request).getClass();
+ }
+
+ /**
* Sets the application's theme.
* <p>
* Note that this theme can be overridden for a specific UI with
@@ -270,9 +282,9 @@ public class Application implements Terminal.ErrorListener, Serializable {
* <p>
* {@inheritDoc}
*/
-
@Override
- public String getThemeForUI(UI uI) {
+ public String getThemeForUI(WrappedRequest request,
+ Class<? extends UI> uiClass) {
return theme;
}
@@ -430,11 +442,6 @@ public class Application implements Terminal.ErrorListener, Serializable {
private DeploymentConfiguration configuration;
/**
- * The current user or <code>null</code> if no user has logged in.
- */
- private Object user;
-
- /**
* The application's URL.
*/
private URL applicationUrl;
@@ -450,16 +457,6 @@ public class Application implements Terminal.ErrorListener, Serializable {
private Locale locale;
/**
- * List of listeners listening user changes.
- */
- private LinkedList<UserChangeListener> userChangeListeners = null;
-
- /**
- * Application resource mapping: key <-> resource.
- */
- private long lastResourceKeyNumber = 0;
-
- /**
* URL where the user is redirected to on application close, or null if
* application is just closed without redirection.
*/
@@ -492,73 +489,11 @@ public class Application implements Terminal.ErrorListener, Serializable {
private final EventRouter eventRouter = new EventRouter();
- /**
- * Keeps track of which uIs have been inited.
- * <p>
- * TODO Investigate whether this might be derived from the different states
- * in getUIForRrequest.
- * </p>
- */
- private Set<Integer> initedUIs = new HashSet<Integer>();
-
private List<UIProvider> uiProviders = new LinkedList<UIProvider>();
private GlobalResourceHandler globalResourceHandler;
/**
- * Gets the user of the application.
- *
- * <p>
- * Vaadin doesn't define of use user object in any way - it only provides
- * this getter and setter methods for convenience. The user is any object
- * that has been stored to the application with {@link #setUser(Object)}.
- * </p>
- *
- * @return the User of the application.
- */
- public Object getUser() {
- return user;
- }
-
- /**
- * <p>
- * Sets the user of the application instance. An application instance may
- * have a user associated to it. This can be set in login procedure or
- * application initialization.
- * </p>
- * <p>
- * A component performing the user login procedure can assign the user
- * property of the application and make the user object available to other
- * components of the application.
- * </p>
- * <p>
- * Vaadin doesn't define of use user object in any way - it only provides
- * getter and setter methods for convenience. The user reference stored to
- * the application can be read with {@link #getUser()}.
- * </p>
- *
- * @param user
- * the new user.
- */
- public void setUser(Object user) {
- final Object prevUser = this.user;
- if (user == prevUser || (user != null && user.equals(prevUser))) {
- return;
- }
-
- this.user = user;
- if (userChangeListeners != null) {
- final Object[] listeners = userChangeListeners.toArray();
- final UserChangeEvent event = new UserChangeEvent(this, user,
- prevUser);
- for (int i = 0; i < listeners.length; i++) {
- ((UserChangeListener) listeners[i])
- .applicationUserChanged(event);
- }
- }
- }
-
- /**
* Gets the URL of the application.
*
* <p>
@@ -720,142 +655,6 @@ public class Application implements Terminal.ErrorListener, Serializable {
}
/**
- * <p>
- * An event that characterizes a change in the current selection.
- * </p>
- * Application user change event sent when the setUser is called to change
- * the current user of the application.
- *
- * @since 3.0
- */
- public class UserChangeEvent extends java.util.EventObject {
-
- /**
- * New user of the application.
- */
- private final Object newUser;
-
- /**
- * Previous user of the application.
- */
- private final Object prevUser;
-
- /**
- * Constructor for user change event.
- *
- * @param source
- * the application source.
- * @param newUser
- * the new User.
- * @param prevUser
- * the previous User.
- */
- public UserChangeEvent(Application source, Object newUser,
- Object prevUser) {
- super(source);
- this.newUser = newUser;
- this.prevUser = prevUser;
- }
-
- /**
- * Gets the new user of the application.
- *
- * @return the new User.
- */
- public Object getNewUser() {
- return newUser;
- }
-
- /**
- * Gets the previous user of the application.
- *
- * @return the previous Vaadin user, if user has not changed ever on
- * application it returns <code>null</code>
- */
- public Object getPreviousUser() {
- return prevUser;
- }
-
- /**
- * Gets the application where the user change occurred.
- *
- * @return the Application.
- */
- public Application getApplication() {
- return (Application) getSource();
- }
- }
-
- /**
- * The <code>UserChangeListener</code> interface for listening application
- * user changes.
- *
- * @since 3.0
- */
- public interface UserChangeListener extends EventListener, Serializable {
-
- /**
- * The <code>applicationUserChanged</code> method Invoked when the
- * application user has changed.
- *
- * @param event
- * the change event.
- */
- public void applicationUserChanged(Application.UserChangeEvent event);
- }
-
- /**
- * Adds the user change listener.
- *
- * This allows one to get notification each time {@link #setUser(Object)} is
- * called.
- *
- * @param listener
- * the user change listener to add.
- */
- public void addUserChangeListener(UserChangeListener listener) {
- if (userChangeListeners == null) {
- userChangeListeners = new LinkedList<UserChangeListener>();
- }
- userChangeListeners.add(listener);
- }
-
- /**
- * @deprecated Since 7.0, replaced by
- * {@link #addUserChangeListener(UserChangeListener)}
- **/
- @Deprecated
- public void addListener(UserChangeListener listener) {
- addUserChangeListener(listener);
- }
-
- /**
- * Removes the user change listener.
- *
- * @param listener
- * the user change listener to remove.
- */
-
- public void removeUserChangeListener(UserChangeListener listener) {
- if (userChangeListeners == null) {
- return;
- }
- userChangeListeners.remove(listener);
- if (userChangeListeners.isEmpty()) {
- userChangeListeners = null;
- }
- }
-
- /**
- * @deprecated Since 7.0, replaced by
- * {@link #removeUserChangeListener(UserChangeListener)}
- **/
- @Deprecated
- public void removeListener(UserChangeListener listener) {
- removeUserChangeListener(listener);
- }
-
- /**
* Window detach event.
*
* This event is sent each time a window is removed from the application
@@ -1782,67 +1581,98 @@ public class Application implements Terminal.ErrorListener, Serializable {
}
/**
- * 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.
- *
+ * Gets the UI class 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 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>
- *
+ * logic for choosing what kind of UI to use.
* <p>
- * 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>
+ * The default implementation in {@link Application} uses the
+ * {@value #UI_PARAMETER} parameter from web.xml for finding the name of the
+ * UI class. If {@link DeploymentConfiguration#getClassLoader()} does not
+ * return <code>null</code>, the returned {@link ClassLoader} is used for
+ * loading the UI class. Otherwise the {@link ClassLoader} used to load this
+ * class is used.
*
- * <p>
- * The default implementation in {@link Application} creates a new instance
- * 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 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 UI
*
- * @see #getUIClassName(WrappedRequest)
* @see UI
- * @see UIRequiresMoreInformationException
* @see WrappedRequest#getBrowserDetails()
*
* @since 7.0
*/
- protected UI getUI(WrappedRequest request)
- throws UIRequiresMoreInformationException {
-
- // Iterate in reverse order - test check newest provider first
- for (int i = uiProviders.size() - 1; i >= 0; i--) {
+ public Class<? extends UI> getUIClass(WrappedRequest request) {
+ // Iterate in reverse order - check newest provider first
+ int providersSize = uiProviders.size();
+ if (providersSize == 0) {
+ throw new IllegalStateException("There are no UI providers");
+ }
+ for (int i = providersSize - 1; i >= 0; i--) {
UIProvider provider = uiProviders.get(i);
Class<? extends UI> uiClass = provider.getUIClass(this, request);
if (uiClass != null) {
- return provider.instantiateUI(this, uiClass, request);
+ return uiClass;
+ }
+ }
+
+ throw new RuntimeException(
+ "No UI provider returned an UI class for request");
+ }
+
+ /**
+ * Creates an UI instance 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 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>
+ *
+ * @param request
+ * @param uiClass
+ * @return
+ */
+ protected <T extends UI> T createUIInstance(WrappedRequest request,
+ Class<T> uiClass) {
+ int providersSize = uiProviders.size();
+ if (providersSize == 0) {
+ throw new IllegalStateException("There are no UI providers");
+ }
+
+ for (int i = providersSize - 1; i >= 0; i--) {
+ UIProvider provider = uiProviders.get(i);
+
+ Class<? extends UI> providerClass = provider.getUIClass(this,
+ request);
+ if (providerClass != null) {
+ if (providerClass != uiClass) {
+ getLogger().warning(
+ "Mismatching UI classes. Expected " + uiClass
+ + " but got " + providerClass + " from "
+ + provider);
+ // Try with next provider if we didn't get the expected
+ // class
+ continue;
+ }
+ return uiClass.cast(provider.instantiateUI(this, uiClass,
+ request));
}
}
throw new RuntimeException(
- "No UI providers available or providers are not able to find UI instance");
+ "No UI provider created an UI instance for request");
}
/**
@@ -1858,8 +1688,9 @@ public class Application implements Terminal.ErrorListener, Serializable {
*
* @since 7.0
*/
- public String getThemeForUI(UI uI) {
- Theme uiTheme = getAnnotationFor(uI.getClass(), Theme.class);
+ public String getThemeForUI(WrappedRequest request,
+ Class<? extends UI> uiClass) {
+ Theme uiTheme = getAnnotationFor(uiClass, Theme.class);
if (uiTheme != null) {
return uiTheme.value();
} else {
@@ -1870,18 +1701,22 @@ public class Application implements Terminal.ErrorListener, Serializable {
/**
* Finds the widgetset to use for a specific UI. If no specific widgetset is
* required, <code>null</code> is returned.
+ * <p>
+ * The default implementation uses the @{@link Widgetset} annotation if it's
+ * defined for the UI class.
*
- * TODO Tell what the default implementation does once it does something.
- *
- * @param uI
- * the UI to get a widgetset for
+ * @param request
+ * the wrapped request for which to get a widgetset
+ * @param uiClass
+ * the UI class 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 getWidgetsetForUI(UI uI) {
- Widgetset uiWidgetset = getAnnotationFor(uI.getClass(), Widgetset.class);
+ public String getWidgetsetForUI(WrappedRequest request,
+ Class<? extends UI> uiClass) {
+ Widgetset uiWidgetset = getAnnotationFor(uiClass, Widgetset.class);
if (uiWidgetset != null) {
return uiWidgetset.value();
} else {
@@ -2023,8 +1858,6 @@ public class Application implements Terminal.ErrorListener, Serializable {
*/
private static final ThreadLocal<Application> currentApplication = new ThreadLocal<Application>();
- private boolean uiPreserved = false;
-
/**
* Gets the currently used application. The current application is
* automatically defined when processing requests to the server. In other
@@ -2099,17 +1932,12 @@ public class Application implements Terminal.ErrorListener, Serializable {
* @param request
* 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 #getUI(WrappedRequest)
- * @see UIRequiresMoreInformationException
+ * @see #createUI(WrappedRequest)
*
* @since 7.0
*/
- public UI getUIForRequest(WrappedRequest request)
- throws UIRequiresMoreInformationException {
+ public UI getUIForRequest(WrappedRequest request) {
UI uI = UI.getCurrent();
if (uI != null) {
return uI;
@@ -2122,69 +1950,75 @@ public class Application implements Terminal.ErrorListener, Serializable {
&& browserDetails.getUriFragment() != null;
uI = uIs.get(uiId);
+ Class<? extends UI> uiClass = null;
+
+ if (uI == null && hasBrowserDetails
+ && !retainOnRefreshUIs.isEmpty()) {
+ uiClass = getUIClass(request);
- if (uI == null && isUiPreserved()) {
// Check for a known UI
- if (!retainOnRefreshUIs.isEmpty()) {
- Integer retainedUIId;
- if (!hasBrowserDetails) {
- throw new UIRequiresMoreInformationException();
- } else {
- String windowName = browserDetails.getWindowName();
- retainedUIId = retainOnRefreshUIs.get(windowName);
- }
+ @SuppressWarnings("null")
+ String windowName = browserDetails.getWindowName();
+ Integer retainedUIId = retainOnRefreshUIs.get(windowName);
- if (retainedUIId != null) {
+ if (retainedUIId != null) {
+ UI retainedUI = uIs.get(retainedUIId);
+ // We've had the same UI instance in a window with this
+ // name, but should we still use it?
+ if (retainedUI.getClass() == uiClass) {
uiId = retainedUIId;
- uI = uIs.get(uiId);
+ uI = retainedUI;
+ } else {
+ getLogger().info(
+ "Not using retained UI in " + windowName
+ + " because retained UI was of type "
+ + retainedUIId.getClass() + " but "
+ + uiClass
+ + " is expected for the request.");
}
}
}
- if (uI == null) {
- // Throws exception if UI can not yet be created
- uI = getUI(request);
+ } // end synchronized block
- // Initialize some fields for a newly created UI
- if (uI.getApplication() == null) {
- uI.setApplication(this);
- }
- if (uI.getUIId() < 0) {
+ UI.setCurrent(uI);
- if (uiId == null) {
- // Get the next id if none defined
- uiId = Integer.valueOf(nextUIId++);
- }
- uI.setUIId(uiId.intValue());
- uIs.put(uiId, uI);
- }
- }
+ return uI;
+ }
- // Set thread local here so it is available in init
- UI.setCurrent(uI);
+ public UI createUI(WrappedRequest request) {
+ Class<? extends UI> uiClass = getUIClass(request);
- if (!initedUIs.contains(uiId)) {
- boolean initRequiresBrowserDetails = isUiPreserved()
- || !uI.getClass().isAnnotationPresent(EagerInit.class);
- if (!initRequiresBrowserDetails || hasBrowserDetails) {
- uI.doInit(request);
+ UI ui = createUIInstance(request, uiClass);
- // Remember that this UI has been initialized
- initedUIs.add(uiId);
+ // Initialize some fields for a newly created UI
+ if (ui.getApplication() == null) {
+ ui.setApplication(this);
+ }
+ // Get the next id
+ Integer uiId = Integer.valueOf(nextUIId++);
- // init() might turn on preserve so do this afterwards
- if (isUiPreserved()) {
- // Remember this UI
- String windowName = request.getBrowserDetails()
- .getWindowName();
- retainOnRefreshUIs.put(windowName, uiId);
- }
- }
+ uIs.put(uiId, ui);
+
+ // Set thread local here so it is available in init
+ UI.setCurrent(ui);
+
+ ui.doInit(request, uiId.intValue());
+
+ if (isUiPreserved(request, uiClass)) {
+ // Remember this UI
+ String windowName = request.getBrowserDetails().getWindowName();
+ if (windowName == null) {
+ getLogger().warning(
+ "There is no window.name available for UI " + uiClass
+ + " that should be preserved.");
+ } else {
+ retainOnRefreshUIs.put(windowName, uiId);
}
- } // end synchronized block
+ }
- return uI;
+ return ui;
}
/**
@@ -2208,53 +2042,22 @@ public class Application implements Terminal.ErrorListener, Serializable {
}
/**
- * 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.
- * <p>
- * NOTE that you should avoid turning this feature on/off on-the-fly when
- * the UI is already shown, as it might not be retained as intended.
- * </p>
- *
- * @param uiPreserved
- * <code>true</code>if the same UI instance should be reused e.g.
- * when the browser window is refreshed.
- */
- public void setUiPreserved(boolean uiPreserved) {
- this.uiPreserved = uiPreserved;
- if (!uiPreserved) {
- retainOnRefreshUIs.clear();
- }
- }
-
- /**
* 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.
*
+ * @param request
+ * @param uiClass
+ *
* @return <code>true</code>if the same UI instance should be reused e.g.
* when the browser window is refreshed.
*/
- public boolean isUiPreserved() {
- return uiPreserved;
- }
-
- /**
- * Checks whether there's a pending initialization for the UI with the given
- * id.
- *
- * @param uiId
- * UI id to check for
- * @return <code>true</code> of the initialization is pending,
- * <code>false</code> if the UI id is not registered or if the UI
- * has already been initialized
- *
- * @see #getUIForRequest(WrappedRequest)
- */
- public boolean isUIInitPending(int uiId) {
- return !initedUIs.contains(Integer.valueOf(uiId));
+ public boolean isUiPreserved(WrappedRequest request,
+ Class<? extends UI> uiClass) {
+ PreserveOnRefresh preserveOnRefresh = getAnnotationFor(uiClass,
+ PreserveOnRefresh.class);
+ return preserveOnRefresh != null;
}
/**
@@ -2473,4 +2276,14 @@ public class Application implements Terminal.ErrorListener, Serializable {
return globalResourceHandler;
}
+
+ public String getPageTitleForUI(WrappedRequest request,
+ Class<? extends UI> uiClass) {
+ Title titleAnnotation = getAnnotationFor(uiClass, Title.class);
+ if (titleAnnotation == null) {
+ return null;
+ } else {
+ return titleAnnotation.value();
+ }
+ }
}
diff --git a/server/src/com/vaadin/UIRequiresMoreInformationException.java b/server/src/com/vaadin/UIRequiresMoreInformationException.java
deleted file mode 100644
index 76a31d88ef..0000000000
--- a/server/src/com/vaadin/UIRequiresMoreInformationException.java
+++ /dev/null
@@ -1,37 +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;
-
-import com.vaadin.server.WrappedRequest;
-import com.vaadin.server.WrappedRequest.BrowserDetails;
-
-/**
- * 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#getUI(WrappedRequest)
- * @see WrappedRequest#getBrowserDetails()
- *
- * @since 7.0
- */
-public class UIRequiresMoreInformationException extends Exception {
- // Nothing of interest here
-}
diff --git a/server/src/com/vaadin/annotations/PreserveOnRefresh.java b/server/src/com/vaadin/annotations/PreserveOnRefresh.java
new file mode 100644
index 0000000000..59c4abb723
--- /dev/null
+++ b/server/src/com/vaadin/annotations/PreserveOnRefresh.java
@@ -0,0 +1,28 @@
+/*
+ * 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.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface PreserveOnRefresh {
+
+}
diff --git a/server/src/com/vaadin/annotations/EagerInit.java b/server/src/com/vaadin/annotations/Title.java
index f08d46b551..fcd5d986a8 100644
--- a/server/src/com/vaadin/annotations/EagerInit.java
+++ b/server/src/com/vaadin/annotations/Title.java
@@ -13,6 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
+
package com.vaadin.annotations;
import java.lang.annotation.ElementType;
@@ -20,23 +21,18 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import com.vaadin.server.WrappedRequest;
import com.vaadin.ui.UI;
/**
- * 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 UI#init(com.vaadin.server.WrappedRequest)
- * @see WrappedRequest#getBrowserDetails()
- *
- * @since 7.0
- *
+ * Defines the HTML page title for a {@link UI}.
*/
-@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
-public @interface EagerInit {
- // No values
+@Target(ElementType.TYPE)
+public @interface Title {
+ /**
+ * Gets the HTML title that should be used if the UI is used on it's own.
+ *
+ * @return a page title string
+ */
+ public String value();
}
diff --git a/server/src/com/vaadin/data/Container.java b/server/src/com/vaadin/data/Container.java
index 155dde87ef..28d6cad18d 100644
--- a/server/src/com/vaadin/data/Container.java
+++ b/server/src/com/vaadin/data/Container.java
@@ -18,6 +18,7 @@ package com.vaadin.data;
import java.io.Serializable;
import java.util.Collection;
+import java.util.List;
import com.vaadin.data.util.filter.SimpleStringFilter;
import com.vaadin.data.util.filter.UnsupportedFilterException;
@@ -484,16 +485,61 @@ public interface Container extends Serializable {
public int indexOfId(Object itemId);
/**
- * Gets the ID of an Item by an index number.
+ * Get the item id for the item at the position given by
+ * <code>index</code>. <br>
+ * <br>
+ * <b>Throws:</b> {@link IndexOutOfBoundsException} if
+ * <code>index</code> is outside the range of the container. (i.e.
+ * <code>index &lt; 0 || container.size()-1 &lt; index</code>)
*
* @param index
- * Index of the requested id in (the filtered and sorted view
- * of) the Container
- * @return ID of the Item in the given index
+ * the index of the requested item id
+ * @return the item id of the item at the given index
*/
public Object getIdByIndex(int index);
/**
+ * Get <code>numberOfItems</code> consecutive item ids from the
+ * container, starting with the item id at <code>startIndex</code>. <br>
+ * <br>
+ *
+ * Implementations should return the exact number of item ids given by
+ * <code>numberOfItems</code>. The returned list must hence contain all
+ * of the item ids from the range: <br>
+ * <br>
+ * <code>startIndex</code> to
+ * <code>startIndex + (numberOfItems-1)</code>. <br>
+ * <br>
+ *
+ * The returned list must contain all of the requested item ids or throw
+ * a {@link RangeOutOfContainerBoundsException} to indicate that the
+ * container does not contain all the requested item ids.<br>
+ * <br>
+ * For quick migration to new API see:
+ * {@link ContainerHelpers#getItemIdsUsingGetIdByIndex(int, int, Indexed)}
+ * . <br>
+ * <br>
+ * <b>Throws:</b> {@link IllegalArgumentException} if
+ * <code>numberOfItems</code> is < 0 <br>
+ * <b>Throws:</b> {@link RangeOutOfContainerBoundsException} if all of
+ * the requested item ids cannot be fetched <br>
+ * <b>Throws:</b> {@link IndexOutOfBoundsException} if
+ * <code>startIndex</code> is outside the range of the container. (i.e.
+ * <code>startIndex &lt; 0 || container.size()-1 &lt; startIndex</code>)
+ *
+ * @param startIndex
+ * the index for the first item which id to include
+ * @param numberOfItems
+ * the number of consecutive item ids to get from the given
+ * start index, must be >= 0
+ * @return List containing all of the requested item ids or empty list
+ * if <code>numberOfItems</code> == 0; not null
+ *
+ * @since 7.0
+ */
+ public List<?> getItemIds(int startIndex, int numberOfItems);
+
+ /**
* Adds a new item at given index (in the filtered view).
* <p>
* The indices of the item currently in the given position and all the
diff --git a/server/src/com/vaadin/data/ContainerHelpers.java b/server/src/com/vaadin/data/ContainerHelpers.java
new file mode 100644
index 0000000000..9ec2da4362
--- /dev/null
+++ b/server/src/com/vaadin/data/ContainerHelpers.java
@@ -0,0 +1,91 @@
+package com.vaadin.data;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import com.vaadin.data.Container.Indexed;
+
+/**
+ * Contains helper methods for containers that can be used to ease development
+ * of containers in Vaadin.
+ *
+ * @since 7.0
+ */
+public class ContainerHelpers {
+
+ /**
+ * Get a range of item ids from the container using
+ * {@link Indexed#getIdByIndex(int)}. This is just a helper method to aid
+ * developers to quickly add the required functionality to a Container
+ * during development. This should not be used in a "finished product"
+ * unless fetching an id for an index is very inexpensive because a separate
+ * request will be performed for each index in the range.
+ *
+ * @param startIndex
+ * index of the first item id to get
+ * @param numberOfIds
+ * the number of consecutive items whose ids should be returned
+ * @param container
+ * the container from which the items should be fetched
+ * @return A list of item ids in the range specified
+ */
+ public static List<?> getItemIdsUsingGetIdByIndex(int startIndex,
+ int numberOfIds, Container.Indexed container) {
+
+ if (container == null) {
+ throw new IllegalArgumentException(
+ "The given container cannot be null!");
+ }
+
+ if (startIndex < 0) {
+ throw new IndexOutOfBoundsException(
+ "Start index cannot be negative! startIndex=" + startIndex);
+ }
+
+ if (startIndex > container.size()) {
+ throw new IndexOutOfBoundsException(
+ "Start index exceeds container size! startIndex="
+ + startIndex + " containerLastItemIndex="
+ + (container.size() - 1));
+ }
+
+ if (numberOfIds < 1) {
+ if (numberOfIds == 0) {
+ return Collections.emptyList();
+ }
+
+ throw new IllegalArgumentException(
+ "Cannot get negative amount of items! numberOfItems="
+ + numberOfIds);
+ }
+
+ // not included in the range
+ int endIndex = startIndex + numberOfIds;
+
+ if (endIndex > container.size()) {
+ throw new RangeOutOfContainerBoundsException(
+ "Cannot get all requested item ids from container. "
+ + "Container size might have changed, recalculate numberOfIds "
+ + "based on the actual container size!",
+ startIndex, numberOfIds, container.size());
+ }
+
+ ArrayList<Object> rangeOfIds = new ArrayList<Object>();
+ for (int i = startIndex; i < endIndex; i++) {
+ Object idByIndex = container.getIdByIndex(i);
+ if (idByIndex == null) {
+ throw new RuntimeException(
+ "Unable to get item id for index: "
+ + i
+ + " from container using Container.Indexed#getIdByIndex() "
+ + "even though container.size() > endIndex. "
+ + "Returned item id was null. "
+ + "Check your container implementation!");
+ }
+ rangeOfIds.add(idByIndex);
+ }
+
+ return Collections.unmodifiableList(rangeOfIds);
+ }
+}
diff --git a/server/src/com/vaadin/data/RangeOutOfContainerBoundsException.java b/server/src/com/vaadin/data/RangeOutOfContainerBoundsException.java
new file mode 100644
index 0000000000..43058e45d8
--- /dev/null
+++ b/server/src/com/vaadin/data/RangeOutOfContainerBoundsException.java
@@ -0,0 +1,169 @@
+package com.vaadin.data;
+
+/**
+ * A exception that indicates that the container is unable to return all of the
+ * consecutive item ids requested by the caller. This can happen if the
+ * container size has changed since the input parameters for
+ * {@link Container.Indexed#getItemIds(int, int)} were computed or if the
+ * requested range exceeds the containers size due to some other factor.<br>
+ * <br>
+ *
+ * The exception can contain additional parameters for easier debugging. The
+ * additional parameters are the <code>startIndex</code> and
+ * <code>numberOfIds</code> which were given to
+ * {@link Container.Indexed#getItemIds(int, int)} as well as the size of the
+ * container when the fetch was executed. The container size can be retrieved
+ * with {@link #getContainerCurrentSize()}. <br>
+ * <br>
+ *
+ * The additional parameters are optional but the party that received the
+ * exception can check whether or not these were set by calling
+ * {@link #isAdditionalParametersSet()}.
+ *
+ * @since 7.0
+ */
+public class RangeOutOfContainerBoundsException extends RuntimeException {
+
+ private final int startIndex;
+ private final int numberOfIds;
+ private final int containerCurrentSize;
+ private final boolean additionalParametersSet;
+
+ // Discourage users to create exceptions without at least some kind of
+ // message...
+ private RangeOutOfContainerBoundsException() {
+ super();
+ startIndex = -1;
+ numberOfIds = -1;
+ containerCurrentSize = -1;
+ additionalParametersSet = false;
+ }
+
+ public RangeOutOfContainerBoundsException(String message) {
+ super(message);
+ startIndex = -1;
+ numberOfIds = -1;
+ containerCurrentSize = -1;
+ additionalParametersSet = false;
+ }
+
+ public RangeOutOfContainerBoundsException(String message,
+ Throwable throwable) {
+ super(message, throwable);
+ startIndex = -1;
+ numberOfIds = -1;
+ containerCurrentSize = -1;
+ additionalParametersSet = false;
+ }
+
+ public RangeOutOfContainerBoundsException(Throwable throwable) {
+ super(throwable);
+ startIndex = -1;
+ numberOfIds = -1;
+ containerCurrentSize = -1;
+ additionalParametersSet = false;
+ }
+
+ /**
+ * Create a new {@link RangeOutOfContainerBoundsException} with the
+ * additional parameters:
+ * <ul>
+ * <li>startIndex - start index for the query</li>
+ * <li>numberOfIds - the number of consecutive item ids to get</li>
+ * <li>containerCurrentSize - the size of the container during the execution
+ * of the query</li>
+ * </ul>
+ * given.
+ *
+ * @param message
+ * @param startIndex
+ * the given startIndex for the query
+ * @param numberOfIds
+ * the number of item ids requested
+ * @param containerCurrentSize
+ * the current size of the container
+ */
+ public RangeOutOfContainerBoundsException(String message, int startIndex,
+ int numberOfIds, int containerCurrentSize) {
+ super(message);
+
+ this.startIndex = startIndex;
+ this.numberOfIds = numberOfIds;
+ this.containerCurrentSize = containerCurrentSize;
+ additionalParametersSet = true;
+ }
+
+ /**
+ * Create a new {@link RangeOutOfContainerBoundsException} with the given
+ * query parameters set in the exception along with the containers current
+ * size and a @link {@link Throwable}.
+ *
+ * @param message
+ * @param startIndex
+ * the given startIndex for the query
+ * @param numberOfIds
+ * the number of item ids queried for
+ * @param containerCurrentSize
+ * the current size of the container
+ * @param throwable
+ */
+ public RangeOutOfContainerBoundsException(String message, int startIndex,
+ int numberOfIds, int containerCurrentSize, Throwable throwable) {
+ super(message, throwable);
+
+ this.startIndex = startIndex;
+ this.numberOfIds = numberOfIds;
+ this.containerCurrentSize = containerCurrentSize;
+ additionalParametersSet = true;
+ }
+
+ /**
+ * Get the given startIndex for the query. Remember to check if this
+ * parameter is set by calling {@link #isAdditionalParametersSet()}
+ *
+ * @return the startIndex given to the container
+ */
+ public int getStartIndex() {
+ return startIndex;
+ }
+
+ /**
+ * Get the number of item ids requested. Remember to check if this parameter
+ * is set with {@link #isAdditionalParametersSet()}
+ *
+ * @return the number of item ids the container was ordered to fetch
+ */
+ public int getNumberOfIds() {
+ return numberOfIds;
+ }
+
+ /**
+ * Get the container size when the query was actually executed. Remember to
+ * check if this parameter is set with {@link #isAdditionalParametersSet()}
+ */
+ public int getContainerCurrentSize() {
+ return containerCurrentSize;
+ }
+
+ /**
+ * Check whether or not the additional parameters for the exception were set
+ * during creation or not.
+ *
+ * The additional parameters can be retrieved with: <br>
+ * <ul>
+ * <li> {@link #getStartIndex()}</li>
+ * <li> {@link #getNumberOfIds()}</li>
+ * <li> {@link #getContainerCurrentSize()}</li>
+ * </ul>
+ *
+ * @return true if parameters are set, false otherwise.
+ *
+ * @see #RangeOutOfContainerBoundsException(String, int, int, int)
+ * RangeOutOfContainerBoundsException(String, int, int, int) for more
+ * details on the additional parameters
+ */
+ public boolean isAdditionalParametersSet() {
+ return additionalParametersSet;
+ }
+
+}
diff --git a/server/src/com/vaadin/data/util/AbstractInMemoryContainer.java b/server/src/com/vaadin/data/util/AbstractInMemoryContainer.java
index 6eea9cb421..dbfcad3982 100644
--- a/server/src/com/vaadin/data/util/AbstractInMemoryContainer.java
+++ b/server/src/com/vaadin/data/util/AbstractInMemoryContainer.java
@@ -26,6 +26,7 @@ import java.util.Set;
import com.vaadin.data.Container;
import com.vaadin.data.Container.ItemSetChangeNotifier;
import com.vaadin.data.Item;
+import com.vaadin.data.RangeOutOfContainerBoundsException;
import com.vaadin.data.util.filter.SimpleStringFilter;
import com.vaadin.data.util.filter.UnsupportedFilterException;
@@ -251,6 +252,45 @@ public abstract class AbstractInMemoryContainer<ITEMIDTYPE, PROPERTYIDCLASS, ITE
}
@Override
+ public List<ITEMIDTYPE> getItemIds(int startIndex, int numberOfIds) {
+ if (startIndex < 0) {
+ throw new IndexOutOfBoundsException(
+ "Start index cannot be negative! startIndex=" + startIndex);
+ }
+
+ if (startIndex > getVisibleItemIds().size()) {
+ throw new IndexOutOfBoundsException(
+ "Start index exceeds container size! startIndex="
+ + startIndex + " containerLastItemIndex="
+ + (getVisibleItemIds().size() - 1));
+ }
+
+ if (numberOfIds < 1) {
+ if (numberOfIds == 0) {
+ return Collections.emptyList();
+ }
+
+ throw new IllegalArgumentException(
+ "Cannot get negative amount of items! numberOfItems="
+ + numberOfIds);
+ }
+
+ int endIndex = startIndex + numberOfIds;
+
+ if (endIndex > getVisibleItemIds().size()) {
+ throw new RangeOutOfContainerBoundsException(
+ "Cannot get all requested item ids from container. "
+ + "Container size might have changed, recalculate numberOfIds "
+ + "based on the actual container size!",
+ startIndex, numberOfIds, getVisibleItemIds().size());
+ }
+
+ return Collections.unmodifiableList(getVisibleItemIds().subList(
+ startIndex, endIndex));
+
+ }
+
+ @Override
public int indexOfId(Object itemId) {
return getVisibleItemIds().indexOf(itemId);
}
diff --git a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java
index a53f32b96e..7a63e8c6c2 100644
--- a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java
+++ b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java
@@ -33,6 +33,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.vaadin.data.Container;
+import com.vaadin.data.ContainerHelpers;
import com.vaadin.data.Item;
import com.vaadin.data.Property;
import com.vaadin.data.util.filter.Compare.Equal;
@@ -656,9 +657,11 @@ public class SQLContainer implements Container, Container.Filterable,
@Override
public Object getIdByIndex(int index) {
- if (index < 0 || index > size() - 1) {
- return null;
+ if (index < 0) {
+ throw new IndexOutOfBoundsException("Index is negative! index="
+ + index);
}
+
if (index < size) {
if (itemIndexes.keySet().contains(index)) {
return itemIndexes.get(index);
@@ -672,6 +675,13 @@ public class SQLContainer implements Container, Container.Filterable,
}
}
+ @Override
+ public List<Object> getItemIds(int startIndex, int numberOfIds) {
+ // TODO create a better implementation
+ return (List<Object>) ContainerHelpers.getItemIdsUsingGetIdByIndex(
+ startIndex, numberOfIds, this);
+ }
+
/**********************************************/
/** Methods from interface Container.Ordered **/
/**********************************************/
diff --git a/server/src/com/vaadin/navigator/FragmentManager.java b/server/src/com/vaadin/navigator/NavigationStateManager.java
index a42456a163..cbbeb59c30 100644
--- a/server/src/com/vaadin/navigator/FragmentManager.java
+++ b/server/src/com/vaadin/navigator/NavigationStateManager.java
@@ -19,32 +19,34 @@ package com.vaadin.navigator;
import java.io.Serializable;
/**
- * Fragment manager that handles interaction between Navigator and URI fragments
- * or other similar view identification and bookmarking system.
- *
- * Alternative implementations can be created for HTML5 pushState, for portlet
- * URL navigation and other similar systems.
- *
+ * An interface for handling interaction between Navigator and the browser
+ * location URI or other similar view identification and bookmarking system. The
+ * state is limited to a single string because in the usual cases it forms a
+ * part of a URI.
+ * <p>
+ * Different implementations can be created for hashbang URIs, HTML5 pushState,
+ * portlet URL navigation and other similar systems.
+ * <p>
* This interface is mostly for internal use by {@link Navigator}.
*
* @author Vaadin Ltd
* @since 7.0
*/
-public interface FragmentManager extends Serializable {
+public interface NavigationStateManager extends Serializable {
/**
- * Return the current fragment (location string) including view name and any
- * optional parameters.
+ * Returns the current navigation state including view name and any optional
+ * parameters.
*
* @return current view and parameter string, not null
*/
- public String getFragment();
+ public String getState();
/**
- * Set the current fragment (location string) in the application URL or
- * similar location, including view name and any optional parameters.
+ * Set the current navigation state in the location URI or similar location,
+ * including view name and any optional parameters.
*
* @param fragment
* new view and parameter string, not null
*/
- public void setFragment(String fragment);
+ public void setState(String state);
} \ No newline at end of file
diff --git a/server/src/com/vaadin/navigator/Navigator.java b/server/src/com/vaadin/navigator/Navigator.java
index cef27c221d..bda422379c 100644
--- a/server/src/com/vaadin/navigator/Navigator.java
+++ b/server/src/com/vaadin/navigator/Navigator.java
@@ -67,19 +67,24 @@ public class Navigator implements Serializable {
}
@Override
- public void navigateTo(String fragmentParameters) {
+ public void enter(ViewChangeEvent event) {
// nothing to do
}
}
/**
- * Fragment manager using URI fragments of a Page to track views and enable
- * listening to view changes.
- *
+ * A {@link NavigationStateManager} using hashbang fragments in the Page
+ * location URI to track views and enable listening to view changes.
+ * <p>
+ * A hashbang URI is one where the optional fragment or "hash" part - the
+ * part following a # sign - is used to encode navigation state in a web
+ * application. The advantage of this is that the fragment can be
+ * dynamically manipulated by javascript without causing page reloads.
+ * <p>
* This class is mostly for internal use by Navigator, and is only public
* and static to enable testing.
*/
- public static class UriFragmentManager implements FragmentManager,
+ public static class UriFragmentManager implements NavigationStateManager,
FragmentChangedListener {
private final Page page;
private final Navigator navigator;
@@ -102,18 +107,18 @@ public class Navigator implements Serializable {
}
@Override
- public String getFragment() {
+ public String getState() {
return page.getFragment();
}
@Override
- public void setFragment(String fragment) {
- page.setFragment(fragment, false);
+ public void setState(String state) {
+ page.setFragment(state, false);
}
@Override
public void fragmentChanged(FragmentChangedEvent event) {
- UriFragmentManager.this.navigator.navigateTo(getFragment());
+ UriFragmentManager.this.navigator.navigateTo(getState());
}
}
@@ -209,11 +214,11 @@ public class Navigator implements Serializable {
}
@Override
- public String getViewName(String viewAndParameters) {
- if (null == viewAndParameters) {
+ public String getViewName(String navigationState) {
+ if (null == navigationState) {
return null;
}
- if (viewAndParameters.startsWith(viewName)) {
+ if (navigationState.startsWith(viewName)) {
return viewName;
}
return null;
@@ -271,12 +276,12 @@ public class Navigator implements Serializable {
}
@Override
- public String getViewName(String viewAndParameters) {
- if (null == viewAndParameters) {
+ public String getViewName(String navigationState) {
+ if (null == navigationState) {
return null;
}
- if (viewAndParameters.equals(viewName)
- || viewAndParameters.startsWith(viewName + "/")) {
+ if (navigationState.equals(viewName)
+ || navigationState.startsWith(viewName + "/")) {
return viewName;
}
return null;
@@ -318,7 +323,7 @@ public class Navigator implements Serializable {
}
}
- private final FragmentManager fragmentManager;
+ private final NavigationStateManager stateManager;
private final ViewDisplay display;
private View currentView = null;
private List<ViewChangeListener> listeners = new LinkedList<ViewChangeListener>();
@@ -352,7 +357,7 @@ public class Navigator implements Serializable {
*/
public Navigator(ComponentContainer container) {
display = new ComponentContainerViewDisplay(container);
- fragmentManager = new UriFragmentManager(Page.getCurrent(), this);
+ stateManager = new UriFragmentManager(Page.getCurrent(), this);
}
/**
@@ -374,36 +379,37 @@ public class Navigator implements Serializable {
*/
public Navigator(Page page, ViewDisplay display) {
this.display = display;
- fragmentManager = new UriFragmentManager(page, this);
+ stateManager = new UriFragmentManager(page, this);
}
/**
* Create a navigator.
*
- * When a custom fragment manager is not needed, use the constructor
+ * When a custom navigation state manager is not needed, use the constructor
* {@link #Navigator(Page, ViewDisplay)} which uses a URI fragment based
- * fragment manager.
+ * state manager.
*
* Note that navigation to the initial view must be performed explicitly by
* the application after creating a Navigator using this constructor.
*
- * @param fragmentManager
- * fragment manager keeping track of the active view and enabling
- * bookmarking and direct navigation
+ * @param stateManager
+ * {@link NavigationStateManager} keeping track of the active
+ * view and enabling bookmarking and direct navigation
* @param display
- * where to display the views
+ * {@ViewDisplay} used to display the views handled
+ * by this navigator
*/
- public Navigator(FragmentManager fragmentManager, ViewDisplay display) {
+ public Navigator(NavigationStateManager stateManager, ViewDisplay display) {
this.display = display;
- this.fragmentManager = fragmentManager;
+ this.stateManager = stateManager;
}
/**
* Navigate to a view and initialize the view with given parameters.
*
* The view string consists of a view name optionally followed by a slash
- * and (fragment) parameters. ViewProviders are used to find and create the
- * correct type of view.
+ * and a parameters part that is passed as-is to the view. ViewProviders are
+ * used to find and create the correct type of view.
*
* If multiple providers return a matching view, the view with the longest
* name is selected. This way, e.g. hierarchies of subviews can be
@@ -416,14 +422,14 @@ public class Navigator implements Serializable {
* Registered {@link ViewChangeListener}s are called upon successful view
* change.
*
- * @param viewAndParameters
+ * @param navigationState
* view name and parameters
*/
- public void navigateTo(String viewAndParameters) {
+ public void navigateTo(String navigationState) {
String longestViewName = null;
View viewWithLongestName = null;
for (ViewProvider provider : providers) {
- String viewName = provider.getViewName(viewAndParameters);
+ String viewName = provider.getViewName(navigationState);
if (null != viewName
&& (longestViewName == null || viewName.length() > longestViewName
.length())) {
@@ -436,9 +442,9 @@ public class Navigator implements Serializable {
}
if (viewWithLongestName != null) {
String parameters = "";
- if (viewAndParameters.length() > longestViewName.length() + 1) {
- parameters = viewAndParameters.substring(longestViewName
- .length() + 1);
+ if (navigationState.length() > longestViewName.length() + 1) {
+ parameters = navigationState
+ .substring(longestViewName.length() + 1);
}
navigateTo(viewWithLongestName, longestViewName, parameters);
}
@@ -455,29 +461,29 @@ public class Navigator implements Serializable {
* @param view
* view to activate
* @param viewName
- * (optional) name of the view or null not to set the fragment
- * @param fragmentParameters
- * parameters passed in the fragment for the view
+ * (optional) name of the view or null not to change the
+ * navigation state
+ * @param parameters
+ * parameters passed in the navigation state to the view
*/
- protected void navigateTo(View view, String viewName,
- String fragmentParameters) {
+ protected void navigateTo(View view, String viewName, String parameters) {
ViewChangeEvent event = new ViewChangeEvent(this, currentView, view,
- viewName, fragmentParameters);
+ viewName, parameters);
if (!isViewChangeAllowed(event)) {
return;
}
- if (null != viewName && getFragmentManager() != null) {
- String currentFragment = viewName;
- if (!fragmentParameters.equals("")) {
- currentFragment += "/" + fragmentParameters;
+ if (null != viewName && getStateManager() != null) {
+ String navigationState = viewName;
+ if (!parameters.equals("")) {
+ navigationState += "/" + parameters;
}
- if (!currentFragment.equals(getFragmentManager().getFragment())) {
- getFragmentManager().setFragment(currentFragment);
+ if (!navigationState.equals(getStateManager().getState())) {
+ getStateManager().setState(navigationState);
}
}
- view.navigateTo(fragmentParameters);
+ view.enter(event);
currentView = view;
if (display != null) {
@@ -512,17 +518,17 @@ public class Navigator implements Serializable {
}
/**
- * Return the fragment manager that is used to get, listen to and manipulate
- * the URI fragment or other source of navigation information.
+ * Returns the {@link NavigationStateManager} that is used to get, listen to
+ * and manipulate the navigation state used by this Navigator.
*
- * @return fragment manager in use
+ * @return NavigationStateManager in use
*/
- protected FragmentManager getFragmentManager() {
- return fragmentManager;
+ protected NavigationStateManager getStateManager() {
+ return stateManager;
}
/**
- * Returns the ViewDisplay used by the navigator. Unless another display is
+ * Return the ViewDisplay used by the navigator. Unless another display is
* specified, a {@link SimpleViewDisplay} (which is a {@link Component}) is
* used by default.
*
diff --git a/server/src/com/vaadin/navigator/View.java b/server/src/com/vaadin/navigator/View.java
index caee801f0c..53dbf01319 100644
--- a/server/src/com/vaadin/navigator/View.java
+++ b/server/src/com/vaadin/navigator/View.java
@@ -18,6 +18,7 @@ package com.vaadin.navigator;
import java.io.Serializable;
+import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.ui.Component;
/**
@@ -34,13 +35,15 @@ public interface View extends Serializable {
/**
* This view is navigated to.
*
- * This method is always called before the view is shown on screen. If there
- * is any additional id to data what should be shown in the view, it is also
- * optionally passed as parameter.
+ * This method is always called before the view is shown on screen.
+ * {@link ViewChangeEvent#getParameters() event.getParameters()} may contain
+ * extra parameters relevant to the view.
+ *
+ * @param event
+ * ViewChangeEvent representing the view change that is
+ * occurring. {@link ViewChangeEvent#getNewView()
+ * event.getNewView()} returns <code>this</code>.
*
- * @param fragmentParameters
- * parameters to the view or empty string if none given. This is
- * the string that appears e.g. in URI after "viewname/"
*/
- public void navigateTo(String fragmentParameters);
+ public void enter(ViewChangeEvent event);
} \ No newline at end of file
diff --git a/server/src/com/vaadin/navigator/ViewChangeListener.java b/server/src/com/vaadin/navigator/ViewChangeListener.java
index d2d4a091c6..aa09f64ad8 100644
--- a/server/src/com/vaadin/navigator/ViewChangeListener.java
+++ b/server/src/com/vaadin/navigator/ViewChangeListener.java
@@ -37,7 +37,7 @@ public interface ViewChangeListener extends Serializable {
private final View oldView;
private final View newView;
private final String viewName;
- private final String fragmentParameters;
+ private final String parameters;
/**
* Create a new view change event.
@@ -46,12 +46,12 @@ public interface ViewChangeListener extends Serializable {
* Navigator that triggered the event, not null
*/
public ViewChangeEvent(Navigator navigator, View oldView, View newView,
- String viewName, String fragmentParameters) {
+ String viewName, String parameters) {
super(navigator);
this.oldView = oldView;
this.newView = newView;
this.viewName = viewName;
- this.fragmentParameters = fragmentParameters;
+ this.parameters = parameters;
}
/**
@@ -93,11 +93,11 @@ public interface ViewChangeListener extends Serializable {
/**
* Returns the parameters for the view being activated.
*
- * @return fragment parameters (potentially bookmarkable) for the new
+ * @return navigation parameters (potentially bookmarkable) for the new
* view
*/
- public String getFragmentParameters() {
- return fragmentParameters;
+ public String getParameters() {
+ return parameters;
}
}
diff --git a/server/src/com/vaadin/server/AbstractApplicationPortlet.java b/server/src/com/vaadin/server/AbstractApplicationPortlet.java
index e47e00577b..e8151462aa 100644
--- a/server/src/com/vaadin/server/AbstractApplicationPortlet.java
+++ b/server/src/com/vaadin/server/AbstractApplicationPortlet.java
@@ -56,7 +56,6 @@ import com.liferay.portal.kernel.util.PropsUtil;
import com.vaadin.Application;
import com.vaadin.Application.ApplicationStartEvent;
import com.vaadin.Application.SystemMessages;
-import com.vaadin.UIRequiresMoreInformationException;
import com.vaadin.server.AbstractCommunicationManager.Callback;
import com.vaadin.ui.UI;
@@ -501,12 +500,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
// Both action requests and render requests are ok
// without a UI as they render the initial HTML
// and then do a second request
- try {
- uI = application
- .getUIForRequest(wrappedRequest);
- } catch (UIRequiresMoreInformationException e) {
- // Ignore problem and continue without UI
- }
+ uI = application.getUIForRequest(wrappedRequest);
break;
case BROWSER_DETAILS:
// Should not try to find a UI here as the
@@ -902,7 +896,6 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
throws PortletException {
try {
final Application application = getApplicationClass().newInstance();
- application.setUiPreserved(true);
return application;
} catch (final IllegalAccessException e) {
throw new PortletException("getNewApplication failed", e);
diff --git a/server/src/com/vaadin/server/AbstractCommunicationManager.java b/server/src/com/vaadin/server/AbstractCommunicationManager.java
index 2655ee9a00..72406e629d 100644
--- a/server/src/com/vaadin/server/AbstractCommunicationManager.java
+++ b/server/src/com/vaadin/server/AbstractCommunicationManager.java
@@ -60,13 +60,11 @@ import javax.servlet.http.HttpServletResponse;
import com.vaadin.Application;
import com.vaadin.Application.SystemMessages;
-import com.vaadin.UIRequiresMoreInformationException;
import com.vaadin.annotations.JavaScript;
import com.vaadin.annotations.StyleSheet;
import com.vaadin.external.json.JSONArray;
import com.vaadin.external.json.JSONException;
import com.vaadin.external.json.JSONObject;
-import com.vaadin.server.BootstrapHandler.BootstrapContext;
import com.vaadin.server.ComponentSizeValidator.InvalidLayout;
import com.vaadin.server.RpcManager.RpcInvocationException;
import com.vaadin.server.StreamVariable.StreamingEndEvent;
@@ -832,7 +830,6 @@ public abstract class AbstractCommunicationManager implements Serializable {
.isClientSideInitialized(connector);
connector.beforeClientResponse(!initialized);
}
- uiConnectorTracker.markAllConnectorsClean();
outWriter.print("\"changes\":[");
@@ -943,6 +940,8 @@ public abstract class AbstractCommunicationManager implements Serializable {
outWriter.append(hierarchyInfo.toString());
outWriter.print(", "); // close hierarchy
+ uiConnectorTracker.markAllConnectorsClean();
+
// send server to client RPC calls for components in the UI, in call
// order
@@ -1233,6 +1232,8 @@ public abstract class AbstractCommunicationManager implements Serializable {
uiConnectorTracker.markClientSideInitialized(connector);
}
+ assert (uiConnectorTracker.getDirtyConnectors().isEmpty()) : "Connectors have been marked as dirty during the end of the paint phase. This is most certainly not intended.";
+
writePerformanceData(outWriter);
}
@@ -1509,7 +1510,7 @@ public abstract class AbstractCommunicationManager implements Serializable {
}
private String getTheme(UI uI) {
- String themeName = uI.getApplication().getThemeForUI(uI);
+ String themeName = uI.getTheme();
String requestThemeName = getRequestTheme();
if (requestThemeName != null) {
@@ -2407,36 +2408,22 @@ public abstract class AbstractCommunicationManager implements Serializable {
WrappedResponse response, Application application)
throws IOException {
- // if we do not yet have a currentUI, it should be initialized
- // shortly, and we should send the initial UIDL
- boolean sendUIDL = UI.getCurrent() == null;
+ assert UI.getCurrent() == null;
try {
CombinedRequest combinedRequest = new CombinedRequest(request);
- UI uI = application.getUIForRequest(combinedRequest);
response.setContentType("application/json; charset=UTF-8");
- // Use the same logic as for determined UIs
- BootstrapHandler bootstrapHandler = getBootstrapHandler();
- BootstrapContext context = bootstrapHandler.createContext(
- combinedRequest, response, application, uI.getUIId());
-
- String widgetset = context.getWidgetsetName();
- String theme = context.getThemeName();
- String themeUri = bootstrapHandler.getThemeUri(context, theme);
+ UI uI = application.getUIForRequest(combinedRequest);
+ if (uI == null) {
+ uI = application.createUI(combinedRequest);
+ }
- // 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);
- // 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, uI);
- params.put("uidl", initialUIDL);
- }
+ String initialUIDL = getInitialUIDL(combinedRequest, uI);
+ params.put("uidl", initialUIDL);
// NOTE! GateIn requires, for some weird reason, getOutputStream
// to be used instead of getWriter() (it seems to interpret
@@ -2449,10 +2436,6 @@ public abstract class AbstractCommunicationManager implements Serializable {
// NOTE GateIn requires the buffers to be flushed to work
outWriter.flush();
out.flush();
- } catch (UIRequiresMoreInformationException e) {
- // Requiring more information at this point is not allowed
- // TODO handle in a better way
- throw new RuntimeException(e);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
diff --git a/server/src/com/vaadin/server/AbstractUIProvider.java b/server/src/com/vaadin/server/AbstractUIProvider.java
index 07b95fc713..f383368d91 100644
--- a/server/src/com/vaadin/server/AbstractUIProvider.java
+++ b/server/src/com/vaadin/server/AbstractUIProvider.java
@@ -1,35 +1,35 @@
-/*
- * 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.server;
-
-import com.vaadin.Application;
-import com.vaadin.ui.UI;
-
-public abstract class AbstractUIProvider implements UIProvider {
-
- @Override
- public UI instantiateUI(Application application, Class<? extends UI> type,
- WrappedRequest request) {
- try {
- return type.newInstance();
- } catch (InstantiationException e) {
- throw new RuntimeException("Could not instantiate root class", e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException("Could not access root class", e);
- }
- }
-}
+/*
+ * 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.server;
+
+import com.vaadin.Application;
+import com.vaadin.ui.UI;
+
+public abstract class AbstractUIProvider implements UIProvider {
+
+ @Override
+ public UI instantiateUI(Application application, Class<? extends UI> type,
+ WrappedRequest request) {
+ try {
+ return type.newInstance();
+ } catch (InstantiationException e) {
+ throw new RuntimeException("Could not instantiate root class", e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("Could not access root class", e);
+ }
+ }
+}
diff --git a/server/src/com/vaadin/server/BootstrapFragmentResponse.java b/server/src/com/vaadin/server/BootstrapFragmentResponse.java
index 16f7bc653b..149f59e7a5 100644
--- a/server/src/com/vaadin/server/BootstrapFragmentResponse.java
+++ b/server/src/com/vaadin/server/BootstrapFragmentResponse.java
@@ -21,6 +21,7 @@ import java.util.List;
import org.jsoup.nodes.Node;
import com.vaadin.Application;
+import com.vaadin.ui.UI;
/**
* A representation of a bootstrap fragment being generated. The bootstrap
@@ -37,7 +38,7 @@ public class BootstrapFragmentResponse extends BootstrapResponse {
* Crate a new bootstrap fragment response.
*
* @see BootstrapResponse#BootstrapResponse(BootstrapHandler,
- * WrappedRequest, Application, Integer)
+ * WrappedRequest, Application, Class)
*
* @param handler
* the bootstrap handler that is firing the event
@@ -47,16 +48,16 @@ public class BootstrapFragmentResponse extends BootstrapResponse {
* @param application
* the application for which the bootstrap page should be
* generated
- * @param uiId
- * the generated id of the UI that will be displayed on the page
+ * @param uiClass
+ * the class 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 uiId,
- List<Node> fragmentNodes) {
- super(handler, request, application, uiId);
+ WrappedRequest request, Application application,
+ Class<? extends UI> uiClass, List<Node> fragmentNodes) {
+ super(handler, request, application, uiClass);
this.fragmentNodes = fragmentNodes;
}
diff --git a/server/src/com/vaadin/server/BootstrapHandler.java b/server/src/com/vaadin/server/BootstrapHandler.java
index 280372a5e5..60ac40916c 100644
--- a/server/src/com/vaadin/server/BootstrapHandler.java
+++ b/server/src/com/vaadin/server/BootstrapHandler.java
@@ -37,12 +37,10 @@ import org.jsoup.nodes.Node;
import org.jsoup.parser.Tag;
import com.vaadin.Application;
-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.ui.UI;
public abstract class BootstrapHandler implements RequestHandler {
@@ -74,30 +72,20 @@ public abstract class BootstrapHandler implements RequestHandler {
return bootstrapResponse.getApplication();
}
- public Integer getUIId() {
- return bootstrapResponse.getUIId();
- }
-
- public UI getUI() {
- return bootstrapResponse.getUI();
+ public Class<? extends UI> getUIClass() {
+ return bootstrapResponse.getUiClass();
}
public String getWidgetsetName() {
if (widgetsetName == null) {
- UI uI = getUI();
- if (uI != null) {
- widgetsetName = getWidgetsetForUI(this);
- }
+ widgetsetName = getWidgetsetForUI(this);
}
return widgetsetName;
}
public String getThemeName() {
if (themeName == null) {
- UI uI = getUI();
- if (uI != null) {
- themeName = findAndEscapeThemeName(this);
- }
+ themeName = findAndEscapeThemeName(this);
}
return themeName;
}
@@ -120,23 +108,11 @@ public abstract class BootstrapHandler implements RequestHandler {
WrappedRequest request, WrappedResponse response)
throws IOException {
- // TODO Should all urls be handled here?
- Integer uiId = null;
try {
- UI uI = application.getUIForRequest(request);
- if (uI == null) {
- writeError(response, new Throwable("No UI found"));
- return true;
- }
+ Class<? extends UI> uiClass = application.getUIClass(request);
- uiId = Integer.valueOf(uI.getUIId());
- } catch (UIRequiresMoreInformationException e) {
- // Just keep going without uiId
- }
-
- try {
BootstrapContext context = createContext(request, response,
- application, uiId);
+ application, uiClass);
setupMainDiv(context);
BootstrapFragmentResponse fragmentResponse = context
@@ -166,8 +142,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.getUIId(),
- document, headers);
+ this, request, context.getApplication(),
+ context.getUIClass(), document, headers);
List<Node> fragmentNodes = fragmentResponse.getFragmentNodes();
Element body = document.body();
for (Node node : fragmentNodes) {
@@ -242,10 +218,11 @@ public abstract class BootstrapHandler implements RequestHandler {
head.appendElement("meta").attr("http-equiv", "X-UA-Compatible")
.attr("content", "chrome=1");
- UI uI = context.getUI();
- String title = ((uI == null || uI.getCaption() == null) ? "" : uI
- .getCaption());
- head.appendElement("title").appendText(title);
+ String title = context.getApplication().getPageTitleForUI(
+ context.getRequest(), context.getUIClass());
+ if (title != null) {
+ head.appendElement("title").appendText(title);
+ }
head.appendElement("style").attr("type", "text/css")
.appendText("html, body {height:100%;margin:0;}");
@@ -267,11 +244,12 @@ public abstract class BootstrapHandler implements RequestHandler {
body.addClass(ApplicationConstants.GENERATED_BODY_CLASSNAME);
}
- public BootstrapContext createContext(WrappedRequest request,
- WrappedResponse response, Application application, Integer uiId) {
+ private BootstrapContext createContext(WrappedRequest request,
+ WrappedResponse response, Application application,
+ Class<? extends UI> uiClass) {
BootstrapContext context = new BootstrapContext(response,
- new BootstrapFragmentResponse(this, request, application, uiId,
- new ArrayList<Node>()));
+ new BootstrapFragmentResponse(this, request, application,
+ uiClass, new ArrayList<Node>()));
return context;
}
@@ -290,10 +268,10 @@ public abstract class BootstrapHandler implements RequestHandler {
protected abstract String getApplicationId(BootstrapContext context);
public String getWidgetsetForUI(BootstrapContext context) {
- UI uI = context.getUI();
WrappedRequest request = context.getRequest();
- String widgetset = uI.getApplication().getWidgetsetForUI(uI);
+ String widgetset = context.getApplication().getWidgetsetForUI(
+ context.getRequest(), context.getUIClass());
if (widgetset == null) {
widgetset = request.getDeploymentConfiguration()
.getConfiguredWidgetset(request);
@@ -413,14 +391,9 @@ public abstract class BootstrapHandler implements RequestHandler {
protected JSONObject getApplicationParameters(BootstrapContext context)
throws JSONException, PaintException {
Application application = context.getApplication();
- Integer uiId = context.getUIId();
JSONObject appConfig = new JSONObject();
- if (uiId != null) {
- appConfig.put(UIConstants.UI_ID_PARAMETER, uiId);
- }
-
if (context.getThemeName() != null) {
appConfig.put("themeUri",
getThemeUri(context, context.getThemeName()));
@@ -433,18 +406,11 @@ public abstract class BootstrapHandler implements RequestHandler {
appConfig.put("widgetset", context.getWidgetsetName());
- if (uiId == null || application.isUIInitPending(uiId.intValue())) {
- appConfig.put("initialPath", context.getRequest()
- .getRequestPathInfo());
+ appConfig.put("initialPath", context.getRequest().getRequestPathInfo());
- Map<String, String[]> parameterMap = context.getRequest()
- .getParameterMap();
- appConfig.put("initialParams", parameterMap);
- } else {
- // write the initial UIDL into the config
- appConfig.put("uidl",
- getInitialUIDL(context.getRequest(), context.getUI()));
- }
+ Map<String, String[]> parameterMap = context.getRequest()
+ .getParameterMap();
+ appConfig.put("initialParams", parameterMap);
return appConfig;
}
@@ -532,7 +498,8 @@ public abstract class BootstrapHandler implements RequestHandler {
* @return
*/
public String getThemeName(BootstrapContext context) {
- return context.getApplication().getThemeForUI(context.getUI());
+ return context.getApplication().getThemeForUI(context.getRequest(),
+ context.getUIClass());
}
/**
@@ -561,21 +528,4 @@ public abstract class BootstrapHandler implements RequestHandler {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
e.getLocalizedMessage());
}
-
- /**
- * Gets the initial UIDL message to send to the client.
- *
- * @param request
- * the originating request
- * @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, UI ui)
- throws PaintException, JSONException;
-
}
diff --git a/server/src/com/vaadin/server/BootstrapPageResponse.java b/server/src/com/vaadin/server/BootstrapPageResponse.java
index d6df145728..a5fdfe4707 100644
--- a/server/src/com/vaadin/server/BootstrapPageResponse.java
+++ b/server/src/com/vaadin/server/BootstrapPageResponse.java
@@ -21,6 +21,7 @@ import java.util.Map;
import org.jsoup.nodes.Document;
import com.vaadin.Application;
+import com.vaadin.ui.UI;
/**
* A representation of a bootstrap page being generated. The bootstrap page
@@ -39,7 +40,7 @@ public class BootstrapPageResponse extends BootstrapResponse {
* Crate a new bootstrap page response.
*
* @see BootstrapResponse#BootstrapResponse(BootstrapHandler,
- * WrappedRequest, Application, Integer)
+ * WrappedRequest, Application, Class)
*
* @param handler
* the bootstrap handler that is firing the event
@@ -49,17 +50,18 @@ public class BootstrapPageResponse extends BootstrapResponse {
* @param application
* the application for which the bootstrap page should be
* generated
- * @param uiId
- * the generated id of the UI that will be displayed on the page
+ * @param uiClass
+ * the class of the UI that will be displayed on the page
* @param document
* the DOM document making up the HTML page
* @param headers
* a map into which header data can be added
*/
public BootstrapPageResponse(BootstrapHandler handler,
- WrappedRequest request, Application application, Integer uiId,
- Document document, Map<String, Object> headers) {
- super(handler, request, application, uiId);
+ WrappedRequest request, Application application,
+ Class<? extends UI> uiClass, Document document,
+ Map<String, Object> headers) {
+ super(handler, request, application, uiClass);
this.headers = headers;
this.document = document;
}
diff --git a/server/src/com/vaadin/server/BootstrapResponse.java b/server/src/com/vaadin/server/BootstrapResponse.java
index 962b48dc31..3173569059 100644
--- a/server/src/com/vaadin/server/BootstrapResponse.java
+++ b/server/src/com/vaadin/server/BootstrapResponse.java
@@ -19,7 +19,6 @@ package com.vaadin.server;
import java.util.EventObject;
import com.vaadin.Application;
-import com.vaadin.UIRequiresMoreInformationException;
import com.vaadin.ui.UI;
/**
@@ -32,7 +31,7 @@ import com.vaadin.ui.UI;
public abstract class BootstrapResponse extends EventObject {
private final WrappedRequest request;
private final Application application;
- private final Integer uiId;
+ private final Class<? extends UI> uiClass;
/**
* Creates a new bootstrap event.
@@ -45,15 +44,15 @@ public abstract class BootstrapResponse extends EventObject {
* @param application
* the application for which the bootstrap page should be
* generated
- * @param uiId
- * the generated id of the UI that will be displayed on the page
+ * @param uiClass
+ * the class of the UI that will be displayed on the page
*/
public BootstrapResponse(BootstrapHandler handler, WrappedRequest request,
- Application application, Integer uiId) {
+ Application application, Class<? extends UI> uiClass) {
super(handler);
this.request = request;
this.application = application;
- this.uiId = uiId;
+ this.uiClass = uiClass;
}
/**
@@ -89,32 +88,13 @@ public abstract class BootstrapResponse extends EventObject {
}
/**
- * 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.
+ * Gets the class of the UI that will be displayed on the generated
+ * bootstrap page.
*
- * @return the UI id
+ * @return the class of the UI
*/
- public Integer getUIId() {
- return uiId;
+ public Class<? extends UI> getUiClass() {
+ return uiClass;
}
- /**
- * 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 UI instance is yet available.
- *
- * @see Application#isUiPreserved()
- * @see Application#getUI(WrappedRequest)
- * @see UIRequiresMoreInformationException
- *
- * @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 UI getUI() {
- return UI.getCurrent();
- }
}
diff --git a/server/src/com/vaadin/server/CommunicationManager.java b/server/src/com/vaadin/server/CommunicationManager.java
index 9b56e20fd4..3c594eaf02 100644
--- a/server/src/com/vaadin/server/CommunicationManager.java
+++ b/server/src/com/vaadin/server/CommunicationManager.java
@@ -22,7 +22,6 @@ import java.net.URL;
import javax.servlet.ServletContext;
import com.vaadin.Application;
-import com.vaadin.external.json.JSONException;
import com.vaadin.ui.UI;
/**
@@ -107,12 +106,6 @@ public class CommunicationManager extends AbstractCommunicationManager {
}
return themeName;
}
-
- @Override
- protected String getInitialUIDL(WrappedRequest request, UI uI)
- throws PaintException, JSONException {
- return CommunicationManager.this.getInitialUIDL(request, uI);
- }
};
}
diff --git a/server/src/com/vaadin/server/DefaultUIProvider.java b/server/src/com/vaadin/server/DefaultUIProvider.java
index 913402c89f..93128aad28 100644
--- a/server/src/com/vaadin/server/DefaultUIProvider.java
+++ b/server/src/com/vaadin/server/DefaultUIProvider.java
@@ -1,51 +1,50 @@
-/*
- * 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.server;
-
-import com.vaadin.Application;
-import com.vaadin.UIRequiresMoreInformationException;
-import com.vaadin.ui.UI;
-
-public class DefaultUIProvider extends AbstractUIProvider {
-
- @Override
- public Class<? extends UI> getUIClass(Application application,
- WrappedRequest request) throws UIRequiresMoreInformationException {
- Object uiClassNameObj = application
- .getProperty(Application.UI_PARAMETER);
-
- if (uiClassNameObj instanceof String) {
- String uiClassName = uiClassNameObj.toString();
-
- ClassLoader classLoader = request.getDeploymentConfiguration()
- .getClassLoader();
- if (classLoader == null) {
- classLoader = getClass().getClassLoader();
- }
- try {
- Class<? extends UI> uiClass = Class.forName(uiClassName, true,
- classLoader).asSubclass(UI.class);
-
- return uiClass;
- } catch (ClassNotFoundException e) {
- throw new RuntimeException("Could not find UI class", e);
- }
- }
-
- return null;
- }
-}
+/*
+ * 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.server;
+
+import com.vaadin.Application;
+import com.vaadin.ui.UI;
+
+public class DefaultUIProvider extends AbstractUIProvider {
+
+ @Override
+ public Class<? extends UI> getUIClass(Application application,
+ WrappedRequest request) {
+ Object uiClassNameObj = application
+ .getProperty(Application.UI_PARAMETER);
+
+ if (uiClassNameObj instanceof String) {
+ String uiClassName = uiClassNameObj.toString();
+
+ ClassLoader classLoader = request.getDeploymentConfiguration()
+ .getClassLoader();
+ if (classLoader == null) {
+ classLoader = getClass().getClassLoader();
+ }
+ try {
+ Class<? extends UI> uiClass = Class.forName(uiClassName, true,
+ classLoader).asSubclass(UI.class);
+
+ return uiClass;
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("Could not find UI class", e);
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/server/src/com/vaadin/server/GlobalResourceHandler.java b/server/src/com/vaadin/server/GlobalResourceHandler.java
index f3a72a0efc..441d884f58 100644
--- a/server/src/com/vaadin/server/GlobalResourceHandler.java
+++ b/server/src/com/vaadin/server/GlobalResourceHandler.java
@@ -123,8 +123,8 @@ public class GlobalResourceHandler implements RequestHandler {
/**
* Registers a resource to be served with a global URL.
* <p>
- * A {@link ConnectorResource} registered for a {@link Vaadin6Component}
- * will be set to be served with a global URL. Other resource types will be
+ * A {@link ConnectorResource} registered for a {@link LegacyComponent} will
+ * be set to be served with a global URL. Other resource types will be
* ignored and thus not served by this handler.
*
* @param resource
diff --git a/server/src/com/vaadin/server/PortletCommunicationManager.java b/server/src/com/vaadin/server/PortletCommunicationManager.java
index f7d9371022..697095d691 100644
--- a/server/src/com/vaadin/server/PortletCommunicationManager.java
+++ b/server/src/com/vaadin/server/PortletCommunicationManager.java
@@ -138,13 +138,6 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
}
@Override
- protected String getInitialUIDL(WrappedRequest request, UI uI)
- throws PaintException, JSONException {
- return PortletCommunicationManager.this.getInitialUIDL(request,
- uI);
- }
-
- @Override
protected JSONObject getApplicationParameters(
BootstrapContext context) throws JSONException,
PaintException {
diff --git a/server/src/com/vaadin/server/UIProvider.java b/server/src/com/vaadin/server/UIProvider.java
index f262a3e225..36bb164845 100644
--- a/server/src/com/vaadin/server/UIProvider.java
+++ b/server/src/com/vaadin/server/UIProvider.java
@@ -1,29 +1,28 @@
-/*
- * 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.server;
-
-import com.vaadin.Application;
-import com.vaadin.UIRequiresMoreInformationException;
-import com.vaadin.ui.UI;
-
-public interface UIProvider {
- public Class<? extends UI> getUIClass(Application application,
- WrappedRequest request) throws UIRequiresMoreInformationException;
-
- public UI instantiateUI(Application application, Class<? extends UI> type,
- WrappedRequest request);
-}
+/*
+ * 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.server;
+
+import com.vaadin.Application;
+import com.vaadin.ui.UI;
+
+public interface UIProvider {
+ public Class<? extends UI> getUIClass(Application application,
+ WrappedRequest request);
+
+ public UI instantiateUI(Application application, Class<? extends UI> type,
+ WrappedRequest request);
+}
diff --git a/server/src/com/vaadin/server/WrappedRequest.java b/server/src/com/vaadin/server/WrappedRequest.java
index 8ae5335763..0714f73cad 100644
--- a/server/src/com/vaadin/server/WrappedRequest.java
+++ b/server/src/com/vaadin/server/WrappedRequest.java
@@ -26,9 +26,6 @@ import javax.portlet.PortletRequest;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
-import com.vaadin.Application;
-import com.vaadin.UIRequiresMoreInformationException;
-import com.vaadin.annotations.EagerInit;
import com.vaadin.ui.UI;
/**
@@ -218,11 +215,7 @@ 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#getUIForRequest(WrappedRequest)} is called again after
- * throwing {@link UIRequiresMoreInformationException} or in
- * {@link UI#init(WrappedRequest)} for a UI class not annotated with
- * {@link EagerInit}
+ * cases, for instance in {@link UI#init(WrappedRequest)}.
*
* @return the browser details, or <code>null</code> if details are not
* available
diff --git a/server/src/com/vaadin/ui/AbsoluteLayout.java b/server/src/com/vaadin/ui/AbsoluteLayout.java
index 794de49671..e3eecaac12 100644
--- a/server/src/com/vaadin/ui/AbsoluteLayout.java
+++ b/server/src/com/vaadin/ui/AbsoluteLayout.java
@@ -182,7 +182,7 @@ public class AbsoluteLayout extends AbstractLayout implements
connectorToPosition.put(c.getConnectorId(), getPosition(c)
.getCSSString());
}
- getState().setConnectorToCssPosition(connectorToPosition);
+ getState().connectorToCssPosition = connectorToPosition;
}
@@ -639,6 +639,7 @@ public class AbsoluteLayout extends AbstractLayout implements
* @deprecated Since 7.0, replaced by
* {@link #addLayoutClickListener(LayoutClickListener)}
**/
+ @Override
@Deprecated
public void addListener(LayoutClickListener listener) {
addLayoutClickListener(listener);
@@ -654,6 +655,7 @@ public class AbsoluteLayout extends AbstractLayout implements
* @deprecated Since 7.0, replaced by
* {@link #removeLayoutClickListener(LayoutClickListener)}
**/
+ @Override
@Deprecated
public void removeListener(LayoutClickListener listener) {
removeLayoutClickListener(listener);
diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java
index 045173036e..97883b780f 100644
--- a/server/src/com/vaadin/ui/AbstractComponent.java
+++ b/server/src/com/vaadin/ui/AbstractComponent.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2011 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -40,6 +40,7 @@ import com.vaadin.server.Resource;
import com.vaadin.server.Terminal;
import com.vaadin.shared.ComponentConstants;
import com.vaadin.shared.ComponentState;
+import com.vaadin.shared.ui.ComponentStateUtil;
import com.vaadin.tools.ReflectTools;
/**
@@ -118,7 +119,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
*/
@Override
public void setId(String id) {
- getState().setId(id);
+ getState().id = id;
}
/*
@@ -128,7 +129,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
*/
@Override
public String getId() {
- return getState().getId();
+ return getState().id;
}
/**
@@ -154,8 +155,8 @@ public abstract class AbstractComponent extends AbstractClientConnector
@Override
public String getStyleName() {
String s = "";
- if (getState().getStyles() != null) {
- for (final Iterator<String> it = getState().getStyles().iterator(); it
+ if (ComponentStateUtil.hasStyles(getState())) {
+ for (final Iterator<String> it = getState().styles.iterator(); it
.hasNext();) {
s += it.next();
if (it.hasNext()) {
@@ -173,13 +174,13 @@ public abstract class AbstractComponent extends AbstractClientConnector
@Override
public void setStyleName(String style) {
if (style == null || "".equals(style)) {
- getState().setStyles(null);
+ getState().styles = null;
return;
}
- if (getState().getStyles() == null) {
- getState().setStyles(new ArrayList<String>());
+ if (getState().styles == null) {
+ getState().styles = new ArrayList<String>();
}
- List<String> styles = getState().getStyles();
+ List<String> styles = getState().styles;
styles.clear();
String[] styleParts = style.split(" +");
for (String part : styleParts) {
@@ -202,10 +203,10 @@ public abstract class AbstractComponent extends AbstractClientConnector
return;
}
- if (getState().getStyles() == null) {
- getState().setStyles(new ArrayList<String>());
+ if (getState().styles == null) {
+ getState().styles = new ArrayList<String>();
}
- List<String> styles = getState().getStyles();
+ List<String> styles = getState().styles;
if (!styles.contains(style)) {
styles.add(style);
}
@@ -213,11 +214,11 @@ public abstract class AbstractComponent extends AbstractClientConnector
@Override
public void removeStyleName(String style) {
- if (getState().getStyles() != null) {
+ if (ComponentStateUtil.hasStyles(getState())) {
String[] styleParts = style.split(" +");
for (String part : styleParts) {
if (part.length() > 0) {
- getState().getStyles().remove(part);
+ getState().styles.remove(part);
}
}
}
@@ -229,7 +230,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
*/
@Override
public String getCaption() {
- return getState().getCaption();
+ return getState().caption;
}
/**
@@ -242,7 +243,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
*/
@Override
public void setCaption(String caption) {
- getState().setCaption(caption);
+ getState().caption = caption;
}
/*
@@ -319,7 +320,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
*/
@Override
public boolean isEnabled() {
- return getState().isEnabled();
+ return getState().enabled;
}
/*
@@ -329,7 +330,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
*/
@Override
public void setEnabled(boolean enabled) {
- getState().setEnabled(enabled);
+ getState().enabled = enabled;
}
/*
@@ -358,7 +359,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
* interface.
*/
public boolean isImmediate() {
- return getState().isImmediate();
+ return getState().immediate;
}
/**
@@ -371,7 +372,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
* @see Component#isImmediate()
*/
public void setImmediate(boolean immediate) {
- getState().setImmediate(immediate);
+ getState().immediate = immediate;
}
/*
@@ -381,7 +382,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
*/
@Override
public boolean isVisible() {
- return getState().isVisible();
+ return getState().visible;
}
/*
@@ -391,11 +392,11 @@ public abstract class AbstractComponent extends AbstractClientConnector
*/
@Override
public void setVisible(boolean visible) {
- if (getState().isVisible() == visible) {
+ if (getState().visible == visible) {
return;
}
- getState().setVisible(visible);
+ getState().visible = visible;
if (getParent() != null) {
// Must always repaint the parent (at least the hierarchy) when
// visibility of a child component changes.
@@ -461,7 +462,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
* @return component's description <code>String</code>
*/
public String getDescription() {
- return getState().getDescription();
+ return getState().description;
}
/**
@@ -477,7 +478,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
* the new description string for the component.
*/
public void setDescription(String description) {
- getState().setDescription(description);
+ getState().description = description;
}
/*
@@ -570,7 +571,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
*/
@Override
public boolean isReadOnly() {
- return getState().isReadOnly();
+ return getState().readOnly;
}
/*
@@ -579,7 +580,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
*/
@Override
public void setReadOnly(boolean readOnly) {
- getState().setReadOnly(readOnly);
+ getState().readOnly = readOnly;
}
/*
@@ -700,24 +701,24 @@ public abstract class AbstractComponent extends AbstractClientConnector
if (getHeight() >= 0
&& (getHeightUnits() != Unit.PERCENTAGE || ComponentSizeValidator
.parentCanDefineHeight(this))) {
- getState().setHeight("" + getCSSHeight());
+ getState().height = "" + getCSSHeight();
} else {
- getState().setHeight("");
+ getState().height = "";
}
if (getWidth() >= 0
&& (getWidthUnits() != Unit.PERCENTAGE || ComponentSizeValidator
.parentCanDefineWidth(this))) {
- getState().setWidth("" + getCSSWidth());
+ getState().width = "" + getCSSWidth();
} else {
- getState().setWidth("");
+ getState().width = "";
}
ErrorMessage error = getErrorMessage();
if (null != error) {
- getState().setErrorMessage(error.getFormattedHtmlMessage());
+ getState().errorMessage = error.getFormattedHtmlMessage();
} else {
- getState().setErrorMessage(null);
+ getState().errorMessage = null;
}
}
@@ -766,7 +767,8 @@ public abstract class AbstractComponent extends AbstractClientConnector
eventRouter.addListener(eventType, target, method);
if (needRepaint) {
- getState().addRegisteredEventListener(eventIdentifier);
+ ComponentStateUtil.addRegisteredEventListener(getState(),
+ eventIdentifier);
}
}
@@ -814,7 +816,8 @@ public abstract class AbstractComponent extends AbstractClientConnector
if (eventRouter != null) {
eventRouter.removeListener(eventType, target);
if (!eventRouter.hasListeners(eventType)) {
- getState().removeRegisteredEventListener(eventIdentifier);
+ ComponentStateUtil.removeRegisteredEventListener(getState(),
+ eventIdentifier);
}
}
}
diff --git a/server/src/com/vaadin/ui/AbstractComponentContainer.java b/server/src/com/vaadin/ui/AbstractComponentContainer.java
index cf3bf1d2b9..31529ca0d6 100644
--- a/server/src/com/vaadin/ui/AbstractComponentContainer.java
+++ b/server/src/com/vaadin/ui/AbstractComponentContainer.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2011 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -115,6 +115,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent
* @deprecated Since 7.0, replaced by
* {@link #addComponentAttachListener(com.vaadin.ui.ComponentContainer.ComponentAttachListener)}
**/
+ @Override
@Deprecated
public void addListener(ComponentAttachListener listener) {
addComponentAttachListener(listener);
@@ -131,6 +132,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent
* @deprecated Since 7.0, replaced by
* {@link #addComponentDetachListener(com.vaadin.ui.ComponentContainer.ComponentDetachListener)}
**/
+ @Override
@Deprecated
public void addListener(ComponentDetachListener listener) {
addComponentDetachListener(listener);
@@ -147,6 +149,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent
* @deprecated Since 7.0, replaced by
* {@link #removeComponentAttachListener(com.vaadin.ui.ComponentContainer.ComponentAttachListener)}
**/
+ @Override
@Deprecated
public void removeListener(ComponentAttachListener listener) {
removeComponentAttachListener(listener);
@@ -163,6 +166,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent
* @deprecated Since 7.0, replaced by
* {@link #removeComponentDetachListener(com.vaadin.ui.ComponentContainer.ComponentDetachListener)}
**/
+ @Override
@Deprecated
public void removeListener(ComponentDetachListener listener) {
removeComponentDetachListener(listener);
@@ -240,7 +244,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent
@Override
public void setVisible(boolean visible) {
- if (getState().isVisible() == visible) {
+ if (getState().visible == visible) {
return;
}
diff --git a/server/src/com/vaadin/ui/AbstractEmbedded.java b/server/src/com/vaadin/ui/AbstractEmbedded.java
index d94f62120f..5c72141ef9 100644
--- a/server/src/com/vaadin/ui/AbstractEmbedded.java
+++ b/server/src/com/vaadin/ui/AbstractEmbedded.java
@@ -52,10 +52,10 @@ public abstract class AbstractEmbedded extends AbstractComponent {
* content.
*/
public void setAlternateText(String altText) {
- if (altText != getState().getAlternateText()
- || (altText != null && !altText.equals(getState()
- .getAlternateText()))) {
- getState().setAlternateText(altText);
+ if (altText != getState().alternateText
+ || (altText != null && !altText
+ .equals(getState().alternateText))) {
+ getState().alternateText = altText;
requestRepaint();
}
}
@@ -67,7 +67,7 @@ public abstract class AbstractEmbedded extends AbstractComponent {
* @returns Alternate text
*/
public String getAlternateText() {
- return getState().getAlternateText();
+ return getState().alternateText;
}
}
diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java
index b1d45ae590..548cb06c8f 100644
--- a/server/src/com/vaadin/ui/AbstractField.java
+++ b/server/src/com/vaadin/ui/AbstractField.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2011 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -355,11 +355,11 @@ public abstract class AbstractField<T> extends AbstractComponent implements
*/
@Override
public boolean isModified() {
- return getState().isModified();
+ return getState().modified;
}
private void setModified(boolean modified) {
- getState().setModified(modified);
+ getState().modified = modified;
}
/**
@@ -632,8 +632,8 @@ public abstract class AbstractField<T> extends AbstractComponent implements
// Sets the new data source
dataSource = newDataSource;
- getState().setPropertyReadOnly(
- dataSource == null ? false : dataSource.isReadOnly());
+ getState().propertyReadOnly = dataSource == null ? false : dataSource
+ .isReadOnly();
// Check if the current converter is compatible.
if (newDataSource != null
@@ -1056,6 +1056,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
* @deprecated Since 7.0, replaced by
* {@link #addValueChangeListener(com.vaadin.data.Property.ValueChangeListener)}
**/
+ @Override
@Deprecated
public void addListener(Property.ValueChangeListener listener) {
addValueChangeListener(listener);
@@ -1076,6 +1077,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
* @deprecated Since 7.0, replaced by
* {@link #removeValueChangeListener(com.vaadin.data.Property.ValueChangeListener)}
**/
+ @Override
@Deprecated
public void removeListener(Property.ValueChangeListener listener) {
removeValueChangeListener(listener);
@@ -1117,7 +1119,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
*/
@Override
public void readOnlyStatusChange(Property.ReadOnlyStatusChangeEvent event) {
- getState().setPropertyReadOnly(event.getProperty().isReadOnly());
+ getState().propertyReadOnly = event.getProperty().isReadOnly();
}
/**
@@ -1167,6 +1169,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
* @deprecated Since 7.0, replaced by
* {@link #addReadOnlyStatusChangeListener(com.vaadin.data.Property.ReadOnlyStatusChangeListener)}
**/
+ @Override
@Deprecated
public void addListener(Property.ReadOnlyStatusChangeListener listener) {
addReadOnlyStatusChangeListener(listener);
@@ -1188,6 +1191,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
* @deprecated Since 7.0, replaced by
* {@link #removeReadOnlyStatusChangeListener(com.vaadin.data.Property.ReadOnlyStatusChangeListener)}
**/
+ @Override
@Deprecated
public void removeListener(Property.ReadOnlyStatusChangeListener listener) {
removeReadOnlyStatusChangeListener(listener);
@@ -1258,7 +1262,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
*/
@Override
public int getTabIndex() {
- return getState().getTabIndex();
+ return getState().tabIndex;
}
/*
@@ -1268,7 +1272,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
*/
@Override
public void setTabIndex(int tabIndex) {
- getState().setTabIndex(tabIndex);
+ getState().tabIndex = tabIndex;
}
/**
@@ -1350,7 +1354,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
*/
@Override
public boolean isRequired() {
- return getState().isRequired();
+ return getState().required;
}
/**
@@ -1370,7 +1374,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
*/
@Override
public void setRequired(boolean required) {
- getState().setRequired(required);
+ getState().required = required;
}
/**
@@ -1569,7 +1573,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
super.beforeClientResponse(initial);
// Hide the error indicator if needed
- getState().setHideErrors(shouldHideErrors());
+ getState().hideErrors = shouldHideErrors();
}
/**
diff --git a/server/src/com/vaadin/ui/AbstractMedia.java b/server/src/com/vaadin/ui/AbstractMedia.java
index 3f59b070b7..219413974b 100644
--- a/server/src/com/vaadin/ui/AbstractMedia.java
+++ b/server/src/com/vaadin/ui/AbstractMedia.java
@@ -56,8 +56,8 @@ public abstract class AbstractMedia extends AbstractComponent {
}
private void clearSources() {
- getState().getSources().clear();
- getState().getSourceTypes().clear();
+ getState().sources.clear();
+ getState().sourceTypes.clear();
}
/**
@@ -71,10 +71,10 @@ public abstract class AbstractMedia extends AbstractComponent {
*/
public void addSource(Resource source) {
if (source != null) {
- List<URLReference> sources = getState().getSources();
+ List<URLReference> sources = getState().sources;
sources.add(new ResourceReference(source, this, Integer
.toString(sources.size())));
- getState().getSourceTypes().add(source.getMIMEType());
+ getState().sourceTypes.add(source.getMIMEType());
}
}
@@ -83,7 +83,7 @@ public abstract class AbstractMedia extends AbstractComponent {
WrappedResponse response, String path) throws IOException {
Matcher matcher = Pattern.compile("(\\d+)(/.*)?").matcher(path);
if (matcher.matches()) {
- List<URLReference> sources = getState().getSources();
+ List<URLReference> sources = getState().sources;
int sourceIndex = Integer.parseInt(matcher.group(1));
@@ -128,7 +128,7 @@ public abstract class AbstractMedia extends AbstractComponent {
*/
public List<Resource> getSources() {
ArrayList<Resource> sources = new ArrayList<Resource>();
- for (URLReference ref : getState().getSources()) {
+ for (URLReference ref : getState().sources) {
sources.add(((ResourceReference) ref).getResource());
}
return sources;
@@ -140,14 +140,14 @@ public abstract class AbstractMedia extends AbstractComponent {
* @param showControls
*/
public void setShowControls(boolean showControls) {
- getState().setShowControls(showControls);
+ getState().showControls = showControls;
}
/**
* @return true if the browser is to show native media controls.
*/
public boolean isShowControls() {
- return getState().isShowControls();
+ return getState().showControls;
}
/**
@@ -162,7 +162,7 @@ public abstract class AbstractMedia extends AbstractComponent {
* @param altText
*/
public void setAltText(String altText) {
- getState().setAltText(altText);
+ getState().altText = altText;
}
/**
@@ -170,7 +170,7 @@ public abstract class AbstractMedia extends AbstractComponent {
* HTML5.
*/
public String getAltText() {
- return getState().getAltText();
+ return getState().altText;
}
/**
@@ -180,7 +180,7 @@ public abstract class AbstractMedia extends AbstractComponent {
* @param htmlContentAllowed
*/
public void setHtmlContentAllowed(boolean htmlContentAllowed) {
- getState().setHtmlContentAllowed(htmlContentAllowed);
+ getState().htmlContentAllowed = htmlContentAllowed;
}
/**
@@ -188,7 +188,7 @@ public abstract class AbstractMedia extends AbstractComponent {
* be rendered as HTML.
*/
public boolean isHtmlContentAllowed() {
- return getState().isHtmlContentAllowed();
+ return getState().htmlContentAllowed;
}
/**
@@ -198,14 +198,14 @@ public abstract class AbstractMedia extends AbstractComponent {
* @param autoplay
*/
public void setAutoplay(boolean autoplay) {
- getState().setAutoplay(autoplay);
+ getState().autoplay = autoplay;
}
/**
* @return true if the media is set to automatically start playback.
*/
public boolean isAutoplay() {
- return getState().isAutoplay();
+ return getState().autoplay;
}
/**
@@ -214,14 +214,14 @@ public abstract class AbstractMedia extends AbstractComponent {
* @param muted
*/
public void setMuted(boolean muted) {
- getState().setMuted(muted);
+ getState().muted = muted;
}
/**
* @return true if the audio is muted.
*/
public boolean isMuted() {
- return getState().isMuted();
+ return getState().muted;
}
/**
diff --git a/server/src/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java
index 184f7c40f4..4e27dbb158 100644
--- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java
+++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java
@@ -143,11 +143,11 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
}
private void componentRemoved(Component c) {
- getState().getChildData().remove(c);
+ getState().childData.remove(c);
}
private void componentAdded(Component c) {
- getState().getChildData().put(c, new ChildComponentData());
+ getState().childData.put(c, new ChildComponentData());
}
/**
@@ -232,11 +232,11 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
@Override
public void setComponentAlignment(Component childComponent,
Alignment alignment) {
- ChildComponentData childData = getState().getChildData().get(
+ ChildComponentData childData = getState().childData.get(
childComponent);
if (childData != null) {
// Alignments are bit masks
- childData.setAlignmentBitmask(alignment.getBitMask());
+ childData.alignmentBitmask = alignment.getBitMask();
} else {
throw new IllegalArgumentException(
"Component must be added to layout before using setComponentAlignment()");
@@ -252,14 +252,14 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
*/
@Override
public Alignment getComponentAlignment(Component childComponent) {
- ChildComponentData childData = getState().getChildData().get(
+ ChildComponentData childData = getState().childData.get(
childComponent);
if (childData == null) {
throw new IllegalArgumentException(
"The given component is not a child of this layout");
}
- return new Alignment(childData.getAlignmentBitmask());
+ return new Alignment(childData.alignmentBitmask);
}
/*
@@ -269,7 +269,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
*/
@Override
public void setSpacing(boolean spacing) {
- getState().setSpacing(spacing);
+ getState().spacing = spacing;
}
/*
@@ -279,7 +279,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
*/
@Override
public boolean isSpacing() {
- return getState().isSpacing();
+ return getState().spacing;
}
/**
@@ -312,13 +312,13 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
* @param ratio
*/
public void setExpandRatio(Component component, float ratio) {
- ChildComponentData childData = getState().getChildData().get(component);
+ ChildComponentData childData = getState().childData.get(component);
if (childData == null) {
throw new IllegalArgumentException(
"The given component is not a child of this layout");
}
- childData.setExpandRatio(ratio);
+ childData.expandRatio = ratio;
}
/**
@@ -329,13 +329,13 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
* @return expand ratio of given component, 0.0f by default.
*/
public float getExpandRatio(Component component) {
- ChildComponentData childData = getState().getChildData().get(component);
+ ChildComponentData childData = getState().childData.get(component);
if (childData == null) {
throw new IllegalArgumentException(
"The given component is not a child of this layout");
}
- return childData.getExpandRatio();
+ return childData.expandRatio;
}
@Override
@@ -349,6 +349,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
* @deprecated Since 7.0, replaced by
* {@link #addLayoutClickListener(LayoutClickListener)}
**/
+ @Override
@Deprecated
public void addListener(LayoutClickListener listener) {
addLayoutClickListener(listener);
@@ -364,6 +365,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
* @deprecated Since 7.0, replaced by
* {@link #removeLayoutClickListener(LayoutClickListener)}
**/
+ @Override
@Deprecated
public void removeListener(LayoutClickListener listener) {
removeLayoutClickListener(listener);
@@ -405,7 +407,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
*/
@Override
public MarginInfo getMargin() {
- return new MarginInfo(getState().getMarginsBitmask());
+ return new MarginInfo(getState().marginsBitmask);
}
/*
@@ -415,6 +417,6 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
*/
@Override
public void setMargin(MarginInfo marginInfo) {
- getState().setMarginsBitmask(marginInfo.getBitMask());
+ getState().marginsBitmask = marginInfo.getBitMask();
}
}
diff --git a/server/src/com/vaadin/ui/AbstractSelect.java b/server/src/com/vaadin/ui/AbstractSelect.java
index 3dba5088df..2fc3bf4080 100644
--- a/server/src/com/vaadin/ui/AbstractSelect.java
+++ b/server/src/com/vaadin/ui/AbstractSelect.java
@@ -40,12 +40,11 @@ import com.vaadin.event.dd.acceptcriteria.ClientSideCriterion;
import com.vaadin.event.dd.acceptcriteria.ContainsDataFlavor;
import com.vaadin.event.dd.acceptcriteria.TargetDetailIs;
import com.vaadin.server.KeyMapper;
+import com.vaadin.server.LegacyComponent;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
import com.vaadin.server.Resource;
-import com.vaadin.server.LegacyComponent;
import com.vaadin.shared.ui.dd.VerticalDropLocation;
-import com.vaadin.ui.AbstractSelect.ItemCaptionMode;
/**
* <p>
@@ -109,43 +108,44 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
}
/**
- * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead
+ * @deprecated from 7.0, use {@link ItemCaptionMode#ID} instead
*/
@Deprecated
public static final ItemCaptionMode ITEM_CAPTION_MODE_ID = ItemCaptionMode.ID;
/**
- * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead
+ * @deprecated from 7.0, use {@link ItemCaptionMode#ITEM} instead
*/
@Deprecated
public static final ItemCaptionMode ITEM_CAPTION_MODE_ITEM = ItemCaptionMode.ITEM;
/**
- * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead
+ * @deprecated from 7.0, use {@link ItemCaptionMode#INDEX} instead
*/
@Deprecated
public static final ItemCaptionMode ITEM_CAPTION_MODE_INDEX = ItemCaptionMode.INDEX;
/**
- * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead
+ * @deprecated from 7.0, use {@link ItemCaptionMode#EXPLICIT_DEFAULTS_ID}
+ * instead
*/
@Deprecated
public static final ItemCaptionMode ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID = ItemCaptionMode.EXPLICIT_DEFAULTS_ID;
/**
- * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead
+ * @deprecated from 7.0, use {@link ItemCaptionMode#EXPLICIT} instead
*/
@Deprecated
public static final ItemCaptionMode ITEM_CAPTION_MODE_EXPLICIT = ItemCaptionMode.EXPLICIT;
/**
- * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead
+ * @deprecated from 7.0, use {@link ItemCaptionMode#ICON_ONLY} instead
*/
@Deprecated
public static final ItemCaptionMode ITEM_CAPTION_MODE_ICON_ONLY = ItemCaptionMode.ICON_ONLY;
/**
- * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead
+ * @deprecated from 7.0, use {@link ItemCaptionMode#PROPERTY} instead
*/
@Deprecated
public static final ItemCaptionMode ITEM_CAPTION_MODE_PROPERTY = ItemCaptionMode.PROPERTY;
diff --git a/server/src/com/vaadin/ui/AbstractSplitPanel.java b/server/src/com/vaadin/ui/AbstractSplitPanel.java
index f1452caacf..c5df57b36f 100644
--- a/server/src/com/vaadin/ui/AbstractSplitPanel.java
+++ b/server/src/com/vaadin/ui/AbstractSplitPanel.java
@@ -56,7 +56,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
@Override
public void setSplitterPosition(float position) {
- getSplitterState().setPosition(position);
+ getSplitterState().position = position;
}
};
@@ -150,7 +150,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
// detach old
removeComponent(getFirstComponent());
}
- getState().setFirstChild(c);
+ getState().firstChild = c;
if (c != null) {
super.addComponent(c);
}
@@ -173,7 +173,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
// detach old
removeComponent(getSecondComponent());
}
- getState().setSecondChild(c);
+ getState().secondChild = c;
if (c != null) {
super.addComponent(c);
}
@@ -186,7 +186,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
* @return the first component of this split panel
*/
public Component getFirstComponent() {
- return (Component) getState().getFirstChild();
+ return (Component) getState().firstChild;
}
/**
@@ -196,7 +196,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
* @return the second component of this split panel
*/
public Component getSecondComponent() {
- return (Component) getState().getSecondChild();
+ return (Component) getState().secondChild;
}
/**
@@ -210,9 +210,9 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
public void removeComponent(Component c) {
super.removeComponent(c);
if (c == getFirstComponent()) {
- getState().setFirstChild(null);
+ getState().firstChild = null;
} else if (c == getSecondComponent()) {
- getState().setSecondChild(null);
+ getState().secondChild = null;
}
markAsDirty();
}
@@ -322,9 +322,9 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
pos = Math.round(pos);
}
SplitterState splitterState = getSplitterState();
- splitterState.setPosition(pos);
- splitterState.setPositionUnit(unit.getSymbol());
- splitterState.setPositionReversed(reverse);
+ splitterState.position = pos;
+ splitterState.positionUnit = unit.getSymbol();
+ splitterState.positionReversed = reverse;
posUnit = unit;
}
@@ -335,7 +335,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
* @return position of the splitter
*/
public float getSplitPosition() {
- return getSplitterState().getPosition();
+ return getSplitterState().position;
}
/**
@@ -358,7 +358,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
* Allowed units are UNITS_PERCENTAGE and UNITS_PIXELS
*/
public void setMinSplitPosition(int pos, Unit unit) {
- setSplitPositionLimits(pos, unit, getSplitterState().getMaxPosition(),
+ setSplitPositionLimits(pos, unit, getSplitterState().maxPosition,
posMaxUnit);
}
@@ -369,7 +369,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
* @return the minimum position of the splitter
*/
public float getMinSplitPosition() {
- return getSplitterState().getMinPosition();
+ return getSplitterState().minPosition;
}
/**
@@ -392,7 +392,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
* Allowed units are UNITS_PERCENTAGE and UNITS_PIXELS
*/
public void setMaxSplitPosition(float pos, Unit unit) {
- setSplitPositionLimits(getSplitterState().getMinPosition(), posMinUnit,
+ setSplitPositionLimits(getSplitterState().minPosition, posMinUnit,
pos, unit);
}
@@ -403,7 +403,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
* @return the maximum position of the splitter
*/
public float getMaxSplitPosition() {
- return getSplitterState().getMaxPosition();
+ return getSplitterState().maxPosition;
}
/**
@@ -440,12 +440,12 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
SplitterState state = getSplitterState();
- state.setMinPosition(minPos);
- state.setMinPositionUnit(minPosUnit.getSymbol());
+ state.minPosition = minPos;
+ state.minPositionUnit = minPosUnit.getSymbol();
posMinUnit = minPosUnit;
- state.setMaxPosition(maxPos);
- state.setMaxPositionUnit(maxPosUnit.getSymbol());
+ state.maxPosition = maxPos;
+ state.maxPositionUnit = maxPosUnit.getSymbol();
posMaxUnit = maxPosUnit;
}
@@ -457,7 +457,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
* Set <code>true</code> if locked, <code>false</code> otherwise.
*/
public void setLocked(boolean locked) {
- getSplitterState().setLocked(locked);
+ getSplitterState().locked = locked;
}
/**
@@ -467,7 +467,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
* @return <code>true</code> if locked, <code>false</code> otherwise.
*/
public boolean isLocked() {
- return getSplitterState().isLocked();
+ return getSplitterState().locked;
}
/**
@@ -535,6 +535,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
}
private SplitterState getSplitterState() {
- return getState().getSplitterState();
+ return getState().splitterState;
}
}
diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java
index c187d9e198..0cb74dae6d 100644
--- a/server/src/com/vaadin/ui/AbstractTextField.java
+++ b/server/src/com/vaadin/ui/AbstractTextField.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2011 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -27,9 +27,9 @@ import com.vaadin.event.FieldEvents.FocusNotifier;
import com.vaadin.event.FieldEvents.TextChangeEvent;
import com.vaadin.event.FieldEvents.TextChangeListener;
import com.vaadin.event.FieldEvents.TextChangeNotifier;
+import com.vaadin.server.LegacyComponent;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
-import com.vaadin.server.LegacyComponent;
import com.vaadin.shared.ui.textfield.AbstractTextFieldState;
import com.vaadin.shared.ui.textfield.TextFieldConstants;
@@ -104,7 +104,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
if (value == null) {
value = getNullRepresentation();
}
- getState().setText(value);
+ getState().text = value;
}
@Override
@@ -312,7 +312,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* @return the maxLength
*/
public int getMaxLength() {
- return getState().getMaxLength();
+ return getState().maxLength;
}
/**
@@ -323,7 +323,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* the maxLength to set
*/
public void setMaxLength(int maxLength) {
- getState().setMaxLength(maxLength);
+ getState().maxLength = maxLength;
}
/**
@@ -334,7 +334,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* @return the number of columns in the editor.
*/
public int getColumns() {
- return getState().getColumns();
+ return getState().columns;
}
/**
@@ -349,7 +349,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
if (columns < 0) {
columns = 0;
}
- getState().setColumns(columns);
+ getState().columns = columns;
}
/**
@@ -359,7 +359,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* @return the current input prompt, or null if not enabled
*/
public String getInputPrompt() {
- return getState().getInputPrompt();
+ return getState().inputPrompt;
}
/**
@@ -369,7 +369,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* @param inputPrompt
*/
public void setInputPrompt(String inputPrompt) {
- getState().setInputPrompt(inputPrompt);
+ getState().inputPrompt = inputPrompt;
}
/* ** Text Change Events ** */
@@ -521,6 +521,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* @deprecated Since 7.0, replaced by
* {@link #addTextChangeListener(TextChangeListener)}
**/
+ @Override
@Deprecated
public void addListener(TextChangeListener listener) {
addTextChangeListener(listener);
@@ -536,6 +537,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* @deprecated Since 7.0, replaced by
* {@link #removeTextChangeListener(TextChangeListener)}
**/
+ @Override
@Deprecated
public void removeListener(TextChangeListener listener) {
removeTextChangeListener(listener);
@@ -688,6 +690,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* @deprecated Since 7.0, replaced by
* {@link #addFocusListener(FocusListener)}
**/
+ @Override
@Deprecated
public void addListener(FocusListener listener) {
addFocusListener(listener);
@@ -702,6 +705,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* @deprecated Since 7.0, replaced by
* {@link #removeFocusListener(FocusListener)}
**/
+ @Override
@Deprecated
public void removeListener(FocusListener listener) {
removeFocusListener(listener);
@@ -716,6 +720,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
/**
* @deprecated Since 7.0, replaced by {@link #addBlurListener(BlurListener)}
**/
+ @Override
@Deprecated
public void addListener(BlurListener listener) {
addBlurListener(listener);
@@ -730,6 +735,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* @deprecated Since 7.0, replaced by
* {@link #removeBlurListener(BlurListener)}
**/
+ @Override
@Deprecated
public void removeListener(BlurListener listener) {
removeBlurListener(listener);
diff --git a/server/src/com/vaadin/ui/Button.java b/server/src/com/vaadin/ui/Button.java
index 2e026ebc52..bbed7d540f 100644
--- a/server/src/com/vaadin/ui/Button.java
+++ b/server/src/com/vaadin/ui/Button.java
@@ -367,6 +367,7 @@ public class Button extends AbstractComponent implements
/**
* @deprecated Since 7.0, replaced by {@link #addBlurListener(BlurListener)}
**/
+ @Override
@Deprecated
public void addListener(BlurListener listener) {
addBlurListener(listener);
@@ -381,6 +382,7 @@ public class Button extends AbstractComponent implements
* @deprecated Since 7.0, replaced by
* {@link #removeBlurListener(BlurListener)}
**/
+ @Override
@Deprecated
public void removeListener(BlurListener listener) {
removeBlurListener(listener);
@@ -396,6 +398,7 @@ public class Button extends AbstractComponent implements
* @deprecated Since 7.0, replaced by
* {@link #addFocusListener(FocusListener)}
**/
+ @Override
@Deprecated
public void addListener(FocusListener listener) {
addFocusListener(listener);
@@ -410,6 +413,7 @@ public class Button extends AbstractComponent implements
* @deprecated Since 7.0, replaced by
* {@link #removeFocusListener(FocusListener)}
**/
+ @Override
@Deprecated
public void removeListener(FocusListener listener) {
removeFocusListener(listener);
@@ -438,7 +442,7 @@ public class Button extends AbstractComponent implements
}
clickShortcut = new ClickShortcut(this, keyCode, modifiers);
addShortcutListener(clickShortcut);
- getState().setClickShortcutKeyCode(clickShortcut.getKeyCode());
+ getState().clickShortcutKeyCode = clickShortcut.getKeyCode();
}
/**
@@ -449,7 +453,7 @@ public class Button extends AbstractComponent implements
if (clickShortcut != null) {
removeShortcutListener(clickShortcut);
clickShortcut = null;
- getState().setClickShortcutKeyCode(0);
+ getState().clickShortcutKeyCode = 0;
}
}
@@ -517,7 +521,7 @@ public class Button extends AbstractComponent implements
* @return true if the button is disabled when clicked, false otherwise
*/
public boolean isDisableOnClick() {
- return getState().isDisableOnClick();
+ return getState().disableOnClick;
}
/**
@@ -533,7 +537,7 @@ public class Button extends AbstractComponent implements
* true to disable button when it is clicked, false otherwise
*/
public void setDisableOnClick(boolean disableOnClick) {
- getState().setDisableOnClick(disableOnClick);
+ getState().disableOnClick = disableOnClick;
}
/*
@@ -543,7 +547,7 @@ public class Button extends AbstractComponent implements
*/
@Override
public int getTabIndex() {
- return getState().getTabIndex();
+ return getState().tabIndex;
}
/*
@@ -553,7 +557,7 @@ public class Button extends AbstractComponent implements
*/
@Override
public void setTabIndex(int tabIndex) {
- getState().setTabIndex(tabIndex);
+ getState().tabIndex = tabIndex;
}
@Override
@@ -580,7 +584,7 @@ public class Button extends AbstractComponent implements
* <code>false</code> otherwise
*/
public void setHtmlContentAllowed(boolean htmlContentAllowed) {
- getState().setHtmlContentAllowed(htmlContentAllowed);
+ getState().htmlContentAllowed = htmlContentAllowed;
}
/**
@@ -590,7 +594,7 @@ public class Button extends AbstractComponent implements
* <code>false</code> otherwise
*/
public boolean isHtmlContentAllowed() {
- return getState().isHtmlContentAllowed();
+ return getState().htmlContentAllowed;
}
}
diff --git a/server/src/com/vaadin/ui/CheckBox.java b/server/src/com/vaadin/ui/CheckBox.java
index 149d4779d8..8a42182598 100644
--- a/server/src/com/vaadin/ui/CheckBox.java
+++ b/server/src/com/vaadin/ui/CheckBox.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2011 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -116,7 +116,7 @@ public class CheckBox extends AbstractField<Boolean> {
if (newValue == null) {
newValue = false;
}
- getState().setChecked(newValue);
+ getState().checked = newValue;
}
public void addBlurListener(BlurListener listener) {
diff --git a/server/src/com/vaadin/ui/ComboBox.java b/server/src/com/vaadin/ui/ComboBox.java
index da3d2fd91d..2555aac339 100644
--- a/server/src/com/vaadin/ui/ComboBox.java
+++ b/server/src/com/vaadin/ui/ComboBox.java
@@ -358,39 +358,45 @@ public class ComboBox extends AbstractSelect implements
filterable.addContainerFilter(filter);
}
- Indexed indexed = (Indexed) container;
+ // try-finally to ensure that the filter is removed from container even
+ // if a exception is thrown...
+ try {
+ Indexed indexed = (Indexed) container;
- int indexToEnsureInView = -1;
+ int indexToEnsureInView = -1;
- // if not an option request (item list when user changes page), go
- // to page with the selected item after filtering if accepted by
- // filter
- Object selection = getValue();
- if (isScrollToSelectedItem() && !optionRequest && selection != null) {
- // ensure proper page
- indexToEnsureInView = indexed.indexOfId(selection);
- }
+ // if not an option request (item list when user changes page), go
+ // to page with the selected item after filtering if accepted by
+ // filter
+ Object selection = getValue();
+ if (isScrollToSelectedItem() && !optionRequest && selection != null) {
+ // ensure proper page
+ indexToEnsureInView = indexed.indexOfId(selection);
+ }
- filteredSize = container.size();
- currentPage = adjustCurrentPage(currentPage, needNullSelectOption,
- indexToEnsureInView, filteredSize);
- int first = getFirstItemIndexOnCurrentPage(needNullSelectOption,
- filteredSize);
- int last = getLastItemIndexOnCurrentPage(needNullSelectOption,
- filteredSize, first);
-
- List<Object> options = new ArrayList<Object>();
- for (int i = first; i <= last && i < filteredSize; ++i) {
- options.add(indexed.getIdByIndex(i));
- }
+ filteredSize = container.size();
+ currentPage = adjustCurrentPage(currentPage, needNullSelectOption,
+ indexToEnsureInView, filteredSize);
+ int first = getFirstItemIndexOnCurrentPage(needNullSelectOption,
+ filteredSize);
+ int last = getLastItemIndexOnCurrentPage(needNullSelectOption,
+ filteredSize, first);
- // to the outside, filtering should not be visible
- if (filter != null) {
- filterable.removeContainerFilter(filter);
- filteringContainer = false;
- }
+ // Compute the number of items to fetch from the indexes given or
+ // based on the filtered size of the container
+ int lastItemToFetch = Math.min(last, filteredSize - 1);
+ int nrOfItemsToFetch = (lastItemToFetch + 1) - first;
+
+ List<?> options = indexed.getItemIds(first, nrOfItemsToFetch);
- return options;
+ return options;
+ } finally {
+ // to the outside, filtering should not be visible
+ if (filter != null) {
+ filterable.removeContainerFilter(filter);
+ filteringContainer = false;
+ }
+ }
}
/**
diff --git a/server/src/com/vaadin/ui/CssLayout.java b/server/src/com/vaadin/ui/CssLayout.java
index b63c8573ba..9ac29c4deb 100644
--- a/server/src/com/vaadin/ui/CssLayout.java
+++ b/server/src/com/vaadin/ui/CssLayout.java
@@ -199,12 +199,12 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
@Override
public void beforeClientResponse(boolean initial) {
super.beforeClientResponse(initial);
- getState().getChildCss().clear();
+ getState().childCss.clear();
for (Iterator<Component> ci = getComponentIterator(); ci.hasNext();) {
Component child = ci.next();
String componentCssString = getCss(child);
if (componentCssString != null) {
- getState().getChildCss().put(child, componentCssString);
+ getState().childCss.put(child, componentCssString);
}
}
@@ -291,6 +291,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
* @deprecated Since 7.0, replaced by
* {@link #addLayoutClickListener(LayoutClickListener)}
**/
+ @Override
@Deprecated
public void addListener(LayoutClickListener listener) {
addLayoutClickListener(listener);
@@ -306,6 +307,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
* @deprecated Since 7.0, replaced by
* {@link #removeLayoutClickListener(LayoutClickListener)}
**/
+ @Override
@Deprecated
public void removeListener(LayoutClickListener listener) {
removeLayoutClickListener(listener);
diff --git a/server/src/com/vaadin/ui/CustomLayout.java b/server/src/com/vaadin/ui/CustomLayout.java
index f747b6ff3b..828a1b91ad 100644
--- a/server/src/com/vaadin/ui/CustomLayout.java
+++ b/server/src/com/vaadin/ui/CustomLayout.java
@@ -25,9 +25,9 @@ import java.util.Map;
import java.util.Set;
import com.vaadin.server.JsonPaintTarget;
+import com.vaadin.server.LegacyComponent;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
-import com.vaadin.server.LegacyComponent;
import com.vaadin.shared.ui.customlayout.CustomLayoutState;
/**
@@ -142,7 +142,7 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent {
removeComponent(old);
}
slots.put(location, c);
- getState().getChildLocations().put(c, location);
+ getState().childLocations.put(c, location);
c.setParent(this);
fireComponentAttachEvent(c);
}
@@ -173,7 +173,7 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent {
return;
}
slots.values().remove(c);
- getState().getChildLocations().remove(c);
+ getState().childLocations.remove(c);
super.removeComponent(c);
}
@@ -247,19 +247,19 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent {
} else {
slots.put(newLocation, oldComponent);
slots.put(oldLocation, newComponent);
- getState().getChildLocations().put(newComponent, oldLocation);
- getState().getChildLocations().put(oldComponent, newLocation);
+ getState().childLocations.put(newComponent, oldLocation);
+ getState().childLocations.put(oldComponent, newLocation);
}
}
/** Get the name of the template */
public String getTemplateName() {
- return getState().getTemplateName();
+ return getState().templateName;
}
/** Get the contents of the template */
public String getTemplateContents() {
- return getState().getTemplateContents();
+ return getState().templateContents;
}
/**
@@ -272,8 +272,8 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent {
* @param templateName
*/
public void setTemplateName(String templateName) {
- getState().setTemplateName(templateName);
- getState().setTemplateContents(null);
+ getState().templateName = templateName;
+ getState().templateContents = null;
}
/**
@@ -282,8 +282,8 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent {
* @param templateContents
*/
public void setTemplateContents(String templateContents) {
- getState().setTemplateContents(templateContents);
- getState().setTemplateName(null);
+ getState().templateContents = templateContents;
+ getState().templateName = null;
}
@Override
@@ -295,7 +295,7 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent {
public void paintContent(PaintTarget target) throws PaintException {
// Workaround to make the CommunicationManager read the template file
// and send it to the client
- String templateName = getState().getTemplateName();
+ String templateName = getState().templateName;
if (templateName != null && templateName.length() != 0) {
Set<Object> usedResources = ((JsonPaintTarget) target)
.getUsedResources();
diff --git a/server/src/com/vaadin/ui/Flash.java b/server/src/com/vaadin/ui/Flash.java
index 0e6cf63a91..d39f34634e 100644
--- a/server/src/com/vaadin/ui/Flash.java
+++ b/server/src/com/vaadin/ui/Flash.java
@@ -33,10 +33,10 @@ public class Flash extends AbstractEmbedded {
* The base path
*/
public void setCodebase(String codebase) {
- if (codebase != getState().getCodebase()
+ if (codebase != getState().codebase
|| (codebase != null && !codebase.equals(getState()
- .getCodebase()))) {
- getState().setCodebase(codebase);
+.codebase))) {
+ getState().codebase = codebase;
requestRepaint();
}
}
@@ -52,10 +52,10 @@ public class Flash extends AbstractEmbedded {
* the codetype to set.
*/
public void setCodetype(String codetype) {
- if (codetype != getState().getCodetype()
+ if (codetype != getState().codetype
|| (codetype != null && !codetype.equals(getState()
- .getCodetype()))) {
- getState().setCodetype(codetype);
+.codetype))) {
+ getState().codetype = codetype;
requestRepaint();
}
}
@@ -73,17 +73,17 @@ public class Flash extends AbstractEmbedded {
* object
*/
public void setArchive(String archive) {
- if (archive != getState().getArchive()
- || (archive != null && !archive.equals(getState().getArchive()))) {
- getState().setArchive(archive);
+ if (archive != getState().archive
+ || (archive != null && !archive.equals(getState().archive))) {
+ getState().archive = archive;
requestRepaint();
}
}
public void setStandby(String standby) {
- if (standby != getState().getStandby()
- || (standby != null && !standby.equals(getState().getStandby()))) {
- getState().setStandby(standby);
+ if (standby != getState().standby
+ || (standby != null && !standby.equals(getState().standby))) {
+ getState().standby = standby;
requestRepaint();
}
}
@@ -100,10 +100,10 @@ public class Flash extends AbstractEmbedded {
* the value of the parameter.
*/
public void setParameter(String name, String value) {
- if (getState().getEmbedParams() == null) {
- getState().setEmbedParams(new HashMap<String, String>());
+ if (getState().embedParams == null) {
+ getState().embedParams = new HashMap<String, String>();
}
- getState().getEmbedParams().put(name, value);
+ getState().embedParams.put(name, value);
requestRepaint();
}
@@ -115,8 +115,8 @@ public class Flash extends AbstractEmbedded {
* @return the Value of parameter or null if not found.
*/
public String getParameter(String name) {
- return getState().getEmbedParams() != null ? getState()
- .getEmbedParams().get(name) : null;
+ return getState().embedParams != null ? getState().embedParams
+ .get(name) : null;
}
/**
@@ -126,10 +126,10 @@ public class Flash extends AbstractEmbedded {
* the name of the parameter to remove.
*/
public void removeParameter(String name) {
- if (getState().getEmbedParams() == null) {
+ if (getState().embedParams == null) {
return;
}
- getState().getEmbedParams().remove(name);
+ getState().embedParams.remove(name);
requestRepaint();
}
diff --git a/server/src/com/vaadin/ui/Form.java b/server/src/com/vaadin/ui/Form.java
index 7e77117acb..dd804ef67a 100644
--- a/server/src/com/vaadin/ui/Form.java
+++ b/server/src/com/vaadin/ui/Form.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2011 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -39,10 +39,10 @@ import com.vaadin.event.ActionManager;
import com.vaadin.server.AbstractErrorMessage;
import com.vaadin.server.CompositeErrorMessage;
import com.vaadin.server.ErrorMessage;
+import com.vaadin.server.LegacyComponent;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
import com.vaadin.server.UserError;
-import com.vaadin.server.LegacyComponent;
import com.vaadin.shared.ui.form.FormState;
/**
@@ -776,7 +776,7 @@ public class Form extends AbstractField<Object> implements Item.Editor,
* @return the Layout of the form.
*/
public Layout getLayout() {
- return (Layout) getState().getLayout();
+ return (Layout) getState().layout;
}
/**
@@ -819,7 +819,7 @@ public class Form extends AbstractField<Object> implements Item.Editor,
// Replace the previous layout
layout.setParent(this);
- getState().setLayout(layout);
+ getState().layout = layout;
}
/**
@@ -1214,7 +1214,7 @@ public class Form extends AbstractField<Object> implements Item.Editor,
* @return layout rendered below normal form contents.
*/
public Layout getFooter() {
- return (Layout) getState().getFooter();
+ return (Layout) getState().footer;
}
/**
@@ -1233,7 +1233,7 @@ public class Form extends AbstractField<Object> implements Item.Editor,
footer = new HorizontalLayout();
}
- getState().setFooter(footer);
+ getState().footer = footer;
footer.setParent(this);
}
diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java
index 21602c6802..de167962e7 100644
--- a/server/src/com/vaadin/ui/GridLayout.java
+++ b/server/src/com/vaadin/ui/GridLayout.java
@@ -27,10 +27,10 @@ import java.util.Map.Entry;
import com.vaadin.event.LayoutEvents.LayoutClickEvent;
import com.vaadin.event.LayoutEvents.LayoutClickListener;
import com.vaadin.event.LayoutEvents.LayoutClickNotifier;
+import com.vaadin.server.LegacyComponent;
import com.vaadin.server.LegacyPaint;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
-import com.vaadin.server.LegacyComponent;
import com.vaadin.shared.Connector;
import com.vaadin.shared.EventId;
import com.vaadin.shared.MouseEventDetails;
@@ -961,7 +961,7 @@ public class GridLayout extends AbstractLayout implements
}
}
- getState().setColumns(columns);
+ getState().columns = columns;
}
/**
@@ -970,7 +970,7 @@ public class GridLayout extends AbstractLayout implements
* @return the number of columns in the grid.
*/
public int getColumns() {
- return getState().getColumns();
+ return getState().columns;
}
/**
@@ -1003,7 +1003,7 @@ public class GridLayout extends AbstractLayout implements
}
}
- getState().setRows(rows);
+ getState().rows = rows;
}
/**
@@ -1012,7 +1012,7 @@ public class GridLayout extends AbstractLayout implements
* @return the number of rows in the grid.
*/
public int getRows() {
- return getState().getRows();
+ return getState().rows;
}
/**
@@ -1127,7 +1127,7 @@ public class GridLayout extends AbstractLayout implements
*/
@Override
public void setSpacing(boolean spacing) {
- getState().setSpacing(spacing);
+ getState().spacing = spacing;
}
/*
@@ -1137,7 +1137,7 @@ public class GridLayout extends AbstractLayout implements
*/
@Override
public boolean isSpacing() {
- return getState().isSpacing();
+ return getState().spacing;
}
/**
@@ -1405,7 +1405,7 @@ public class GridLayout extends AbstractLayout implements
*/
@Override
public void setMargin(MarginInfo marginInfo) {
- getState().setMarginsBitmask(marginInfo.getBitMask());
+ getState().marginsBitmask = marginInfo.getBitMask();
}
/*
@@ -1415,7 +1415,7 @@ public class GridLayout extends AbstractLayout implements
*/
@Override
public MarginInfo getMargin() {
- return new MarginInfo(getState().getMarginsBitmask());
+ return new MarginInfo(getState().marginsBitmask);
}
}
diff --git a/server/src/com/vaadin/ui/JavaScript.java b/server/src/com/vaadin/ui/JavaScript.java
index f3e8564fab..f9324ba321 100644
--- a/server/src/com/vaadin/ui/JavaScript.java
+++ b/server/src/com/vaadin/ui/JavaScript.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2011 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -93,7 +93,7 @@ public class JavaScript extends AbstractExtension {
*/
public void addFunction(String name, JavaScriptFunction function) {
functions.put(name, function);
- getState().getNames().add(name);
+ getState().names.add(name);
}
/**
@@ -109,7 +109,7 @@ public class JavaScript extends AbstractExtension {
*/
public void removeFunction(String name) {
functions.remove(name);
- getState().getNames().remove(name);
+ getState().names.remove(name);
}
/**
diff --git a/server/src/com/vaadin/ui/Panel.java b/server/src/com/vaadin/ui/Panel.java
index 6f399bcc19..de34c0be2c 100644
--- a/server/src/com/vaadin/ui/Panel.java
+++ b/server/src/com/vaadin/ui/Panel.java
@@ -25,10 +25,10 @@ import com.vaadin.event.Action.Handler;
import com.vaadin.event.ActionManager;
import com.vaadin.event.MouseEvents.ClickEvent;
import com.vaadin.event.MouseEvents.ClickListener;
+import com.vaadin.server.LegacyComponent;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
import com.vaadin.server.Scrollable;
-import com.vaadin.server.LegacyComponent;
import com.vaadin.shared.EventId;
import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.ui.panel.PanelServerRpc;
@@ -83,7 +83,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
registerRpc(rpc);
setContent(content);
setWidth(100, Unit.PERCENTAGE);
- getState().setTabIndex(-1);
+ getState().tabIndex = -1;
}
/**
@@ -269,11 +269,11 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
final Integer newScrollY = (Integer) variables.get("scrollTop");
if (newScrollX != null && newScrollX.intValue() != getScrollLeft()) {
// set internally, not to fire request repaint
- getState().setScrollLeft(newScrollX.intValue());
+ getState().scrollLeft = newScrollX.intValue();
}
if (newScrollY != null && newScrollY.intValue() != getScrollTop()) {
// set internally, not to fire request repaint
- getState().setScrollTop(newScrollY.intValue());
+ getState().scrollTop = newScrollY.intValue();
}
// Actions
@@ -292,7 +292,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
*/
@Override
public int getScrollLeft() {
- return getState().getScrollLeft();
+ return getState().scrollLeft;
}
/*
@@ -302,7 +302,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
*/
@Override
public int getScrollTop() {
- return getState().getScrollTop();
+ return getState().scrollTop;
}
/*
@@ -316,7 +316,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
throw new IllegalArgumentException(
"Scroll offset must be at least 0");
}
- getState().setScrollLeft(scrollLeft);
+ getState().scrollLeft = scrollLeft;
}
/*
@@ -330,7 +330,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
throw new IllegalArgumentException(
"Scroll offset must be at least 0");
}
- getState().setScrollTop(scrollTop);
+ getState().scrollTop = scrollTop;
}
/* Documented in superclass */
@@ -471,7 +471,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
*/
@Override
public int getTabIndex() {
- return getState().getTabIndex();
+ return getState().tabIndex;
}
/**
@@ -479,7 +479,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
*/
@Override
public void setTabIndex(int tabIndex) {
- getState().setTabIndex(tabIndex);
+ getState().tabIndex = tabIndex;
}
/**
diff --git a/server/src/com/vaadin/ui/Slider.java b/server/src/com/vaadin/ui/Slider.java
index 660bf739ae..fe913f6b2c 100644
--- a/server/src/com/vaadin/ui/Slider.java
+++ b/server/src/com/vaadin/ui/Slider.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2011 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -25,10 +25,10 @@ import com.vaadin.shared.ui.slider.SliderState;
*
* Example code: <code>
* class MyPlayer extends CustomComponent implements ValueChangeListener {
- *
+ *
* Label volumeIndicator = new Label();
* Slider slider;
- *
+ *
* public MyPlayer() {
* VerticalLayout vl = new VerticalLayout();
* setCompositionRoot(vl);
@@ -68,11 +68,11 @@ public class Slider extends AbstractField<Double> {
} catch (final ValueOutOfBoundsException e) {
// Convert to nearest bound
double out = e.getValue().doubleValue();
- if (out < getState().getMinValue()) {
- out = getState().getMinValue();
+ if (out < getState().minValue) {
+ out = getState().minValue;
}
- if (out > getState().getMaxValue()) {
- out = getState().getMaxValue();
+ if (out > getState().maxValue) {
+ out = getState().maxValue;
}
Slider.super.setValue(new Double(out), false);
}
@@ -88,7 +88,7 @@ public class Slider extends AbstractField<Double> {
public Slider() {
super();
registerRpc(rpc);
- super.setValue(new Double(getState().getMinValue()));
+ super.setValue(new Double(getState().minValue));
}
/**
@@ -164,7 +164,7 @@ public class Slider extends AbstractField<Double> {
* @return the largest value the slider can have
*/
public double getMax() {
- return getState().getMaxValue();
+ return getState().maxValue;
}
/**
@@ -175,7 +175,7 @@ public class Slider extends AbstractField<Double> {
* The new maximum slider value
*/
public void setMax(double max) {
- getState().setMaxValue(max);
+ getState().maxValue = max;
if (getValue() > max) {
setValue(max);
}
@@ -187,7 +187,7 @@ public class Slider extends AbstractField<Double> {
* @return the smallest value the slider can have
*/
public double getMin() {
- return getState().getMinValue();
+ return getState().minValue;
}
/**
@@ -198,7 +198,7 @@ public class Slider extends AbstractField<Double> {
* The new minimum slider value
*/
public void setMin(double min) {
- getState().setMinValue(min);
+ getState().minValue = min;
if (getValue() < min) {
setValue(min);
}
@@ -211,7 +211,7 @@ public class Slider extends AbstractField<Double> {
* {@link SliderOrientation#VERTICAL}
*/
public SliderOrientation getOrientation() {
- return getState().getOrientation();
+ return getState().orientation;
}
/**
@@ -223,7 +223,7 @@ public class Slider extends AbstractField<Double> {
* {@link SliderOrientation#VERTICAL}
*/
public void setOrientation(SliderOrientation orientation) {
- getState().setOrientation(orientation);
+ getState().orientation = orientation;
}
/**
@@ -233,7 +233,7 @@ public class Slider extends AbstractField<Double> {
* @return resolution
*/
public int getResolution() {
- return getState().getResolution();
+ return getState().resolution;
}
/**
@@ -250,7 +250,7 @@ public class Slider extends AbstractField<Double> {
throw new IllegalArgumentException(
"Cannot set a negative resolution to Slider");
}
- getState().setResolution(resolution);
+ getState().resolution = resolution;
}
/**
@@ -284,7 +284,7 @@ public class Slider extends AbstractField<Double> {
}
}
- getState().setValue(newValue);
+ getState().value = newValue;
super.setValue(newValue, repaintIsNotNeeded);
}
@@ -296,7 +296,7 @@ public class Slider extends AbstractField<Double> {
}
super.setValue(newFieldValue);
// The cast is safe if the above call returned without throwing
- getState().setValue((Double) newFieldValue);
+ getState().value = (Double) newFieldValue;
}
/**
diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java
index d1bdcdd708..5eb18ee61f 100644
--- a/server/src/com/vaadin/ui/Table.java
+++ b/server/src/com/vaadin/ui/Table.java
@@ -27,6 +27,7 @@ import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
@@ -1066,6 +1067,23 @@ public class Table extends AbstractSelect implements Action.Container,
return currentPageFirstItemId;
}
+ /**
+ * Returns the item ID for the item represented by the index given. Assumes
+ * that the current container implements {@link Container.Indexed}.
+ *
+ * See {@link Container.Indexed#getIdByIndex(int)} for more information
+ * about the exceptions that can be thrown.
+ *
+ * @param index
+ * the index for which the item ID should be fetched
+ * @return the item ID for the given index
+ *
+ * @throws ClassCastException
+ * if container does not implement {@link Container.Indexed}
+ * @throws IndexOutOfBoundsException
+ * thrown by {@link Container.Indexed#getIdByIndex(int)} if the
+ * index is invalid
+ */
protected Object getIdByIndex(int index) {
return ((Container.Indexed) items).getIdByIndex(index);
}
@@ -1929,17 +1947,6 @@ public class Table extends AbstractSelect implements Action.Container,
return cells;
}
- // Gets the first item id
- Object id;
- if (items instanceof Container.Indexed) {
- id = getIdByIndex(firstIndex);
- } else {
- id = firstItemId();
- for (int i = 0; i < firstIndex; i++) {
- id = nextItemId(id);
- }
- }
-
final RowHeaderMode headmode = getRowHeaderMode();
final boolean[] iscomponent = new boolean[cols];
for (int i = 0; i < cols; i++) {
@@ -1956,120 +1963,41 @@ public class Table extends AbstractSelect implements Action.Container,
// Creates the page contents
int filledRows = 0;
- for (int i = 0; i < rows && id != null; i++) {
- cells[CELL_ITEMID][i] = id;
- cells[CELL_KEY][i] = itemIdMapper.key(id);
- if (headmode != ROW_HEADER_MODE_HIDDEN) {
- switch (headmode) {
- case INDEX:
- cells[CELL_HEADER][i] = String.valueOf(i + firstIndex + 1);
- break;
- default:
- cells[CELL_HEADER][i] = getItemCaption(id);
- }
- cells[CELL_ICON][i] = getItemIcon(id);
+ if (items instanceof Container.Indexed) {
+ // more efficient implementation for containers supporting access by
+ // index
+
+ Container.Indexed indexed = ((Container.Indexed) items);
+ List<?> itemIds = indexed.getItemIds(firstIndex, rows);
+ for (int i = 0; i < rows && i < itemIds.size(); i++) {
+ Object id = itemIds.get(i);
+ // Start by parsing the values, id should already be set
+ parseItemIdToCells(cells, id, i, firstIndex, headmode, cols,
+ colids, firstIndexNotInCache, iscomponent,
+ oldListenedProperties);
+
+ filledRows++;
}
+ } else {
+ // slow back-up implementation for cases where the container does
+ // not support access by index
- GeneratedRow generatedRow = rowGenerator != null ? rowGenerator
- .generateRow(this, id) : null;
- cells[CELL_GENERATED_ROW][i] = generatedRow;
-
- for (int j = 0; j < cols; j++) {
- if (isColumnCollapsed(colids[j])) {
- continue;
- }
- Property<?> p = null;
- Object value = "";
- boolean isGeneratedRow = generatedRow != null;
- boolean isGeneratedColumn = columnGenerators
- .containsKey(colids[j]);
- boolean isGenerated = isGeneratedRow || isGeneratedColumn;
-
- if (!isGenerated) {
- p = getContainerProperty(id, colids[j]);
- }
-
- if (isGeneratedRow) {
- if (generatedRow.isSpanColumns() && j > 0) {
- value = null;
- } else if (generatedRow.isSpanColumns() && j == 0
- && generatedRow.getValue() instanceof Component) {
- value = generatedRow.getValue();
- } else if (generatedRow.getText().length > j) {
- value = generatedRow.getText()[j];
- }
- } else {
- // check in current pageBuffer already has row
- int index = firstIndex + i;
- if (p != null || isGenerated) {
- int indexInOldBuffer = index - pageBufferFirstIndex;
- if (index < firstIndexNotInCache
- && index >= pageBufferFirstIndex
- && pageBuffer[CELL_GENERATED_ROW][indexInOldBuffer] == null
- && id.equals(pageBuffer[CELL_ITEMID][indexInOldBuffer])) {
- // we already have data in our cache,
- // recycle it instead of fetching it via
- // getValue/getPropertyValue
- value = pageBuffer[CELL_FIRSTCOL + j][indexInOldBuffer];
- if (!isGeneratedColumn && iscomponent[j]
- || !(value instanceof Component)) {
- listenProperty(p, oldListenedProperties);
- }
- } else {
- if (isGeneratedColumn) {
- ColumnGenerator cg = columnGenerators
- .get(colids[j]);
- value = cg.generateCell(this, id, colids[j]);
- if (value != null
- && !(value instanceof Component)
- && !(value instanceof String)) {
- // Avoid errors if a generator returns
- // something
- // other than a Component or a String
- value = value.toString();
- }
- } else if (iscomponent[j]) {
- value = p.getValue();
- listenProperty(p, oldListenedProperties);
- } else if (p != null) {
- value = getPropertyValue(id, colids[j], p);
- /*
- * If returned value is Component (via
- * fieldfactory or overridden getPropertyValue)
- * we excpect it to listen property value
- * changes. Otherwise if property emits value
- * change events, table will start to listen
- * them and refresh content when needed.
- */
- if (!(value instanceof Component)) {
- listenProperty(p, oldListenedProperties);
- }
- } else {
- value = getPropertyValue(id, colids[j], null);
- }
- }
- }
- }
-
- if (value instanceof Component) {
- registerComponent((Component) value);
- }
- cells[CELL_FIRSTCOL + j][i] = value;
+ // Gets the first item id
+ Object id = firstItemId();
+ for (int i = 0; i < firstIndex; i++) {
+ id = nextItemId(id);
}
+ for (int i = 0; i < rows && id != null; i++) {
+ // Start by parsing the values, id should already be set
+ parseItemIdToCells(cells, id, i, firstIndex, headmode, cols,
+ colids, firstIndexNotInCache, iscomponent,
+ oldListenedProperties);
- // Gets the next item id
- if (items instanceof Container.Indexed) {
- int index = firstIndex + i + 1;
- if (index < size()) {
- id = getIdByIndex(index);
- } else {
- id = null;
- }
- } else {
+ // Gets the next item id for non indexed container
id = nextItemId(id);
- }
- filledRows++;
+ filledRows++;
+ }
}
// Assures that all the rows of the cell-buffer are valid
@@ -2089,6 +2017,117 @@ public class Table extends AbstractSelect implements Action.Container,
return cells;
}
+ /**
+ * Update a cache array for a row, register any relevant listeners etc.
+ *
+ * This is an internal method extracted from
+ * {@link #getVisibleCellsNoCache(int, int, boolean)} and should be removed
+ * when the Table is rewritten.
+ */
+ private void parseItemIdToCells(Object[][] cells, Object id, int i,
+ int firstIndex, RowHeaderMode headmode, int cols, Object[] colids,
+ int firstIndexNotInCache, boolean[] iscomponent,
+ HashSet<Property<?>> oldListenedProperties) {
+
+ cells[CELL_ITEMID][i] = id;
+ cells[CELL_KEY][i] = itemIdMapper.key(id);
+ if (headmode != ROW_HEADER_MODE_HIDDEN) {
+ switch (headmode) {
+ case INDEX:
+ cells[CELL_HEADER][i] = String.valueOf(i + firstIndex + 1);
+ break;
+ default:
+ cells[CELL_HEADER][i] = getItemCaption(id);
+ }
+ cells[CELL_ICON][i] = getItemIcon(id);
+ }
+
+ GeneratedRow generatedRow = rowGenerator != null ? rowGenerator
+ .generateRow(this, id) : null;
+ cells[CELL_GENERATED_ROW][i] = generatedRow;
+
+ for (int j = 0; j < cols; j++) {
+ if (isColumnCollapsed(colids[j])) {
+ continue;
+ }
+ Property<?> p = null;
+ Object value = "";
+ boolean isGeneratedRow = generatedRow != null;
+ boolean isGeneratedColumn = columnGenerators.containsKey(colids[j]);
+ boolean isGenerated = isGeneratedRow || isGeneratedColumn;
+
+ if (!isGenerated) {
+ p = getContainerProperty(id, colids[j]);
+ }
+
+ if (isGeneratedRow) {
+ if (generatedRow.isSpanColumns() && j > 0) {
+ value = null;
+ } else if (generatedRow.isSpanColumns() && j == 0
+ && generatedRow.getValue() instanceof Component) {
+ value = generatedRow.getValue();
+ } else if (generatedRow.getText().length > j) {
+ value = generatedRow.getText()[j];
+ }
+ } else {
+ // check in current pageBuffer already has row
+ int index = firstIndex + i;
+ if (p != null || isGenerated) {
+ int indexInOldBuffer = index - pageBufferFirstIndex;
+ if (index < firstIndexNotInCache
+ && index >= pageBufferFirstIndex
+ && pageBuffer[CELL_GENERATED_ROW][indexInOldBuffer] == null
+ && id.equals(pageBuffer[CELL_ITEMID][indexInOldBuffer])) {
+ // we already have data in our cache,
+ // recycle it instead of fetching it via
+ // getValue/getPropertyValue
+ value = pageBuffer[CELL_FIRSTCOL + j][indexInOldBuffer];
+ if (!isGeneratedColumn && iscomponent[j]
+ || !(value instanceof Component)) {
+ listenProperty(p, oldListenedProperties);
+ }
+ } else {
+ if (isGeneratedColumn) {
+ ColumnGenerator cg = columnGenerators
+ .get(colids[j]);
+ value = cg.generateCell(this, id, colids[j]);
+ if (value != null && !(value instanceof Component)
+ && !(value instanceof String)) {
+ // Avoid errors if a generator returns
+ // something
+ // other than a Component or a String
+ value = value.toString();
+ }
+ } else if (iscomponent[j]) {
+ value = p.getValue();
+ listenProperty(p, oldListenedProperties);
+ } else if (p != null) {
+ value = getPropertyValue(id, colids[j], p);
+ /*
+ * If returned value is Component (via fieldfactory
+ * or overridden getPropertyValue) we expect it to
+ * listen property value changes. Otherwise if
+ * property emits value change events, table will
+ * start to listen them and refresh content when
+ * needed.
+ */
+ if (!(value instanceof Component)) {
+ listenProperty(p, oldListenedProperties);
+ }
+ } else {
+ value = getPropertyValue(id, colids[j], null);
+ }
+ }
+ }
+ }
+
+ if (value instanceof Component) {
+ registerComponent((Component) value);
+ }
+ cells[CELL_FIRSTCOL + j][i] = value;
+ }
+ }
+
protected void registerComponent(Component component) {
getLogger().finest(
"Registered " + component.getClass().getSimpleName() + ": "
diff --git a/server/src/com/vaadin/ui/TextArea.java b/server/src/com/vaadin/ui/TextArea.java
index 0dc9722eb3..cc8e947e24 100644
--- a/server/src/com/vaadin/ui/TextArea.java
+++ b/server/src/com/vaadin/ui/TextArea.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2011 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -95,7 +95,7 @@ public class TextArea extends AbstractTextField {
if (rows < 0) {
rows = 0;
}
- getState().setRows(rows);
+ getState().rows = rows;
}
/**
@@ -104,7 +104,7 @@ public class TextArea extends AbstractTextField {
* @return number of explicitly set rows.
*/
public int getRows() {
- return getState().getRows();
+ return getState().rows;
}
/**
@@ -115,7 +115,7 @@ public class TextArea extends AbstractTextField {
* word-wrap mode.
*/
public void setWordwrap(boolean wordwrap) {
- getState().setWordwrap(wordwrap);
+ getState().wordwrap = wordwrap;
}
/**
@@ -125,7 +125,7 @@ public class TextArea extends AbstractTextField {
* <code>false</code> if not.
*/
public boolean isWordwrap() {
- return getState().isWordwrap();
+ return getState().wordwrap;
}
}
diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java
index a59b96d27a..d1ccaacde3 100644
--- a/server/src/com/vaadin/ui/UI.java
+++ b/server/src/com/vaadin/ui/UI.java
@@ -28,21 +28,20 @@ import java.util.LinkedHashSet;
import java.util.Map;
import com.vaadin.Application;
-import com.vaadin.annotations.EagerInit;
import com.vaadin.event.Action;
import com.vaadin.event.Action.Handler;
import com.vaadin.event.ActionManager;
import com.vaadin.event.MouseEvents.ClickEvent;
import com.vaadin.event.MouseEvents.ClickListener;
import com.vaadin.server.AbstractApplicationServlet;
+import com.vaadin.server.LegacyComponent;
import com.vaadin.server.Page;
+import com.vaadin.server.Page.BrowserWindowResizeEvent;
+import com.vaadin.server.Page.BrowserWindowResizeListener;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
import com.vaadin.server.Resource;
-import com.vaadin.server.LegacyComponent;
import com.vaadin.server.WrappedRequest;
-import com.vaadin.server.Page.BrowserWindowResizeEvent;
-import com.vaadin.server.Page.BrowserWindowResizeListener;
import com.vaadin.server.WrappedRequest.BrowserDetails;
import com.vaadin.shared.EventId;
import com.vaadin.shared.MouseEventDetails;
@@ -77,15 +76,9 @@ import com.vaadin.tools.ReflectTools;
* passing a {@link ComponentContainer} with the main layout of the view to
* {@link #setContent(ComponentContainer)}.
* </p>
- * <p>
- * If a {@link EagerInit} annotation is present on a class extending
- * <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#getUI(WrappedRequest)
+ * @see Application#createUI(WrappedRequest)
*
* @since 7.0
*/
@@ -98,7 +91,6 @@ public abstract class UI extends AbstractComponentContainer implements
* window in Vaadin 6 with {@link com.vaadin.Application.LegacyApplication}
*/
@Deprecated
- @EagerInit
public static class LegacyWindow extends UI {
private String name;
@@ -385,7 +377,7 @@ public abstract class UI extends AbstractComponentContainer implements
@Override
public void setCaption(String caption) {
// Override to provide backwards compatibility
- getState().setCaption(caption);
+ getState().caption = caption;
getPage().setTitle(caption);
}
@@ -710,28 +702,6 @@ public abstract class UI extends AbstractComponentContainer implements
}
/**
- * 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 uiId
- * the id of this UI
- *
- * @throws IllegalStateException
- * if the UI id has already been set
- *
- * @see #getUIId()
- */
- public void setUIId(int uiId) {
- if (this.uiId != -1) {
- throw new IllegalStateException("UI id has already been defined");
- }
- this.uiId = uiId;
- }
-
- /**
* 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.
@@ -748,8 +718,8 @@ public abstract class UI extends AbstractComponentContainer implements
* 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#getUI(WrappedRequest)} returns an appropriate UI for
- * the request.
+ * {@link Application#createUI(WrappedRequest)} returns an appropriate UI
+ * for the request.
*
* @param window
* @throws IllegalArgumentException
@@ -831,6 +801,8 @@ public abstract class UI extends AbstractComponentContainer implements
private boolean resizeLazy = false;
+ private String theme;
+
/**
* This method is used by Component.Focusable objects to request focus to
* themselves. Focus renders must be handled at window level (instead of
@@ -879,7 +851,7 @@ public abstract class UI extends AbstractComponentContainer implements
* @see #createDefaultLayout()
*/
public ComponentContainer getContent() {
- return (ComponentContainer) getState().getContent();
+ return (ComponentContainer) getState().content;
}
/**
@@ -911,10 +883,10 @@ public abstract class UI extends AbstractComponentContainer implements
content = createDefaultLayout();
}
- if (getState().getContent() != null) {
- super.removeComponent((Component) getState().getContent());
+ if (getState().content != null) {
+ super.removeComponent((Component) getState().content);
}
- getState().setContent(content);
+ getState().content = content;
if (content != null) {
super.addComponent(content);
}
@@ -959,8 +931,16 @@ public abstract class UI extends AbstractComponentContainer implements
*
* @param request
* the initialization request
+ * @param uiId
+ * the id of the new ui
*/
- public void doInit(WrappedRequest request) {
+ public void doInit(WrappedRequest request, int uiId) {
+ if (this.uiId != -1) {
+ throw new IllegalStateException("UI id has already been defined");
+ }
+ this.uiId = uiId;
+ theme = getApplication().getThemeForUI(request, getClass());
+
getPage().init(request);
// Call the init overridden by the application developer
@@ -974,11 +954,8 @@ public abstract class UI extends AbstractComponentContainer implements
* 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 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 UI class.
+ * request that caused this UI to be created. {@link BrowserDetails} will be
+ * available in the request.
* </p>
*
* @param request
@@ -1352,4 +1329,13 @@ public abstract class UI extends AbstractComponentContainer implements
public void setLastUidlRequestTime(long lastUidlRequest) {
this.lastUidlRequest = lastUidlRequest;
}
+
+ /**
+ * Gets the theme that was used when the UI was initialized.
+ *
+ * @return the theme name
+ */
+ public String getTheme() {
+ return theme;
+ }
}
diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java
index aaf0fbc492..5c94a4c929 100644
--- a/server/src/com/vaadin/ui/Window.java
+++ b/server/src/com/vaadin/ui/Window.java
@@ -31,9 +31,9 @@ import com.vaadin.event.ShortcutAction;
import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.event.ShortcutAction.ModifierKey;
import com.vaadin.event.ShortcutListener;
+import com.vaadin.server.LegacyComponent;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
-import com.vaadin.server.LegacyComponent;
import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.ui.window.WindowServerRpc;
import com.vaadin.shared.ui.window.WindowState;
@@ -242,7 +242,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @since 4.0.0
*/
public int getPositionX() {
- return getState().getPositionX();
+ return getState().positionX;
}
/**
@@ -255,8 +255,8 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @since 4.0.0
*/
public void setPositionX(int positionX) {
- getState().setPositionX(positionX);
- getState().setCentered(false);
+ getState().positionX = positionX;
+ getState().centered = false;
}
/**
@@ -269,7 +269,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @since 4.0.0
*/
public int getPositionY() {
- return getState().getPositionY();
+ return getState().positionY;
}
/**
@@ -283,8 +283,8 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @since 4.0.0
*/
public void setPositionY(int positionY) {
- getState().setPositionY(positionY);
- getState().setCentered(false);
+ getState().positionY = positionY;
+ getState().centered = false;
}
private static final Method WINDOW_CLOSE_METHOD;
@@ -540,7 +540,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* true if modality is to be turned on
*/
public void setModal(boolean modal) {
- getState().setModal(modal);
+ getState().modal = modal;
center();
}
@@ -548,7 +548,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @return true if this window is modal.
*/
public boolean isModal() {
- return getState().isModal();
+ return getState().modal;
}
/**
@@ -558,7 +558,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* true if resizability is to be turned on
*/
public void setResizable(boolean resizable) {
- getState().setResizable(resizable);
+ getState().resizable = resizable;
}
/**
@@ -566,7 +566,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @return true if window is resizable by the end-user, otherwise false.
*/
public boolean isResizable() {
- return getState().isResizable();
+ return getState().resizable;
}
/**
@@ -575,7 +575,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* sizes are recalculated immediately.
*/
public boolean isResizeLazy() {
- return getState().isResizeLazy();
+ return getState().resizeLazy;
}
/**
@@ -591,7 +591,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* calculate immediately.
*/
public void setResizeLazy(boolean resizeLazy) {
- getState().setResizeLazy(resizeLazy);
+ getState().resizeLazy = resizeLazy;
}
/**
@@ -604,7 +604,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* Please refer to http://dev.vaadin.com/ticket/8971 for details.
*/
public void center() {
- getState().setCentered(true);
+ getState().centered = true;
}
/**
@@ -655,7 +655,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* true if the sub window can be dragged by the user
*/
public boolean isDraggable() {
- return getState().isDraggable();
+ return getState().draggable;
}
/**
@@ -668,7 +668,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* true if the sub window can be dragged by the user
*/
public void setDraggable(boolean draggable) {
- getState().setDraggable(draggable);
+ getState().draggable = draggable;
}
/*
@@ -793,6 +793,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @deprecated Since 7.0, replaced by
* {@link #addFocusListener(FocusListener)}
**/
+ @Override
@Deprecated
public void addListener(FocusListener listener) {
addFocusListener(listener);
@@ -807,6 +808,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @deprecated Since 7.0, replaced by
* {@link #removeFocusListener(FocusListener)}
**/
+ @Override
@Deprecated
public void removeListener(FocusListener listener) {
removeFocusListener(listener);
@@ -829,6 +831,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
/**
* @deprecated Since 7.0, replaced by {@link #addBlurListener(BlurListener)}
**/
+ @Override
@Deprecated
public void addListener(BlurListener listener) {
addBlurListener(listener);
@@ -843,6 +846,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @deprecated Since 7.0, replaced by
* {@link #removeBlurListener(BlurListener)}
**/
+ @Override
@Deprecated
public void removeListener(BlurListener listener) {
removeBlurListener(listener);