diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-09-24 15:44:08 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-09-24 16:01:46 +0300 |
commit | ded204acce46a009bac6d6562de43d5b6120e349 (patch) | |
tree | 74493e3e6e01f7f9cb600f626ee889e103003f03 /uitest | |
parent | 0cd118248d77eeb197f2480ce59b35c6c3963e5c (diff) | |
download | vaadin-framework-ded204acce46a009bac6d6562de43d5b6120e349.tar.gz vaadin-framework-ded204acce46a009bac6d6562de43d5b6120e349.zip |
Use event objects for future-proofing UIProvider API (#9721)
Diffstat (limited to 'uitest')
5 files changed, 31 insertions, 25 deletions
diff --git a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java index b121ae7992..4ff5624ba1 100644 --- a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java +++ b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java @@ -30,10 +30,10 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.vaadin.LegacyApplication; -import com.vaadin.server.UIProvider; import com.vaadin.server.DeploymentConfiguration; import com.vaadin.server.LegacyVaadinServlet; import com.vaadin.server.ServiceException; +import com.vaadin.server.UIClassSelectionEvent; import com.vaadin.server.UIProvider; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinServletRequest; @@ -144,14 +144,13 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { try { final Class<?> classToRun = getClassToRun(); if (UI.class.isAssignableFrom(classToRun)) { - getVaadinService().addUIProvider(session, - new UIProvider() { - @Override - public Class<? extends UI> getUIClass( - VaadinRequest request) { - return (Class<? extends UI>) classToRun; - } - }); + getVaadinService().addUIProvider(session, new UIProvider() { + @Override + public Class<? extends UI> getUIClass( + UIClassSelectionEvent event) { + return (Class<? extends UI>) classToRun; + } + }); } else if (LegacyApplication.class.isAssignableFrom(classToRun)) { // Avoid using own UIProvider for legacy Application } else if (UIProvider.class.isAssignableFrom(classToRun)) { diff --git a/uitest/src/com/vaadin/tests/applicationservlet/InitParamUIProvider.java b/uitest/src/com/vaadin/tests/applicationservlet/InitParamUIProvider.java index 6a2f5c500b..b4f29dda06 100644 --- a/uitest/src/com/vaadin/tests/applicationservlet/InitParamUIProvider.java +++ b/uitest/src/com/vaadin/tests/applicationservlet/InitParamUIProvider.java @@ -16,6 +16,7 @@ package com.vaadin.tests.applicationservlet; +import com.vaadin.server.UIClassSelectionEvent; import com.vaadin.server.UIProvider; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.javascriptcomponent.BasicJavaScriptComponent; @@ -24,7 +25,8 @@ import com.vaadin.ui.UI; public class InitParamUIProvider extends UIProvider { @Override - public Class<? extends UI> getUIClass(VaadinRequest request) { + public Class<? extends UI> getUIClass(UIClassSelectionEvent event) { + VaadinRequest request = event.getRequest(); String pathInfo = request.getRequestPathInfo(); if ("/test".equals(pathInfo)) { return BasicJavaScriptComponent.class; diff --git a/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java b/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java index d405a4c138..9524a41cd8 100644 --- a/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java +++ b/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java @@ -1,8 +1,11 @@ package com.vaadin.tests.components.ui; import com.vaadin.server.ExternalResource; -import com.vaadin.server.VaadinSession; +import com.vaadin.server.UIClassSelectionEvent; +import com.vaadin.server.UICreateEvent; +import com.vaadin.server.UIProviderEvent; import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinSession; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.tests.components.AbstractTestUIProvider; import com.vaadin.ui.Label; @@ -20,17 +23,17 @@ public class LazyInitUIs extends AbstractTestUIProvider { } @Override - public UI createInstance(VaadinRequest request, - Class<? extends UI> type) { - return getUI(request); + public UI createInstance(UICreateEvent event) { + return getUI(event); } @Override - public Class<? extends UI> getUIClass(VaadinRequest request) { - return getUI(request).getClass(); + public Class<? extends UI> getUIClass(UIClassSelectionEvent event) { + return getUI(event).getClass(); } - private UI getUI(VaadinRequest request) { + private UI getUI(UIProviderEvent event) { + VaadinRequest request = event.getRequest(); if (request.getParameter("lazyCreate") != null) { // UI created on second request UI uI = new UI() { diff --git a/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java b/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java index c5d997cfd4..942e5ed1ef 100644 --- a/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java +++ b/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java @@ -3,8 +3,9 @@ package com.vaadin.tests.components.ui; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; -import com.vaadin.server.VaadinSession; +import com.vaadin.server.UIClassSelectionEvent; import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinSession; import com.vaadin.tests.components.AbstractTestUIProvider; import com.vaadin.ui.Label; import com.vaadin.ui.UI; @@ -32,7 +33,7 @@ public class UIsInMultipleTabs extends AbstractTestUIProvider { } @Override - public Class<? extends UI> getUIClass(VaadinRequest request) { + public Class<? extends UI> getUIClass(UIClassSelectionEvent event) { return TabUI.class; } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java index dd152232f1..ad3a30d4ca 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java @@ -16,9 +16,11 @@ package com.vaadin.tests.minitutorials.v7a1; +import com.vaadin.server.UIClassSelectionEvent; +import com.vaadin.server.UICreateEvent; import com.vaadin.server.UIProvider; -import com.vaadin.server.WebBrowser; import com.vaadin.server.VaadinRequest; +import com.vaadin.server.WebBrowser; import com.vaadin.ui.Label; import com.vaadin.ui.UI; @@ -33,9 +35,9 @@ import com.vaadin.ui.UI; public class DifferentFeaturesForDifferentClients extends UIProvider { @Override - public Class<? extends UI> getUIClass(VaadinRequest request) { + public Class<? extends UI> getUIClass(UIClassSelectionEvent event) { // could also use browser version etc. - if (request.getHeader("user-agent").contains("mobile")) { + if (event.getRequest().getHeader("user-agent").contains("mobile")) { return TouchRoot.class; } else { return DefaultRoot.class; @@ -45,10 +47,9 @@ public class DifferentFeaturesForDifferentClients extends UIProvider { // Must override as default implementation isn't allowed to // instantiate our non-public classes @Override - public UI createInstance(VaadinRequest request, - Class<? extends UI> type) { + public UI createInstance(UICreateEvent event) { try { - return type.newInstance(); + return event.getUIClass().newInstance(); } catch (Exception e) { throw new RuntimeException(e); } |