From: Leif Åstrand Date: Tue, 11 Sep 2012 12:53:39 +0000 (+0300) Subject: Tweak UIProvider API based on review (#9443) X-Git-Tag: 7.0.0.beta1~40 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=501977762dee21abb14822e5d38f2260a056175e;p=vaadin-framework.git Tweak UIProvider API based on review (#9443) --- diff --git a/server/src/com/vaadin/LegacyApplication.java b/server/src/com/vaadin/LegacyApplication.java index a1aeb037fd..ca9b196ff1 100644 --- a/server/src/com/vaadin/LegacyApplication.java +++ b/server/src/com/vaadin/LegacyApplication.java @@ -100,24 +100,24 @@ public abstract class LegacyApplication extends AbstractUIProvider implements } @Override - public UI createInstance(Class type, WrappedRequest request) { + public UI createInstance(WrappedRequest request, Class type) { return getUIInstance(request); } @Override - public String getThemeForUI(WrappedRequest request, + public String getTheme(WrappedRequest request, Class uiClass) { return theme; } @Override - public String getPageTitleForUI(WrappedRequest request, + public String getPageTitle(WrappedRequest request, Class uiClass) { UI uiInstance = getUIInstance(request); if (uiInstance != null) { return uiInstance.getCaption(); } else { - return super.getPageTitleForUI(request, uiClass); + return super.getPageTitle(request, uiClass); } } diff --git a/server/src/com/vaadin/server/AbstractUIProvider.java b/server/src/com/vaadin/server/AbstractUIProvider.java index 321ca75f65..5208997a65 100644 --- a/server/src/com/vaadin/server/AbstractUIProvider.java +++ b/server/src/com/vaadin/server/AbstractUIProvider.java @@ -27,8 +27,8 @@ import com.vaadin.ui.UI; public abstract class AbstractUIProvider implements UIProvider { @Override - public UI createInstance(Class type, - WrappedRequest request) { + public UI createInstance(WrappedRequest request, + Class type) { try { return type.newInstance(); } catch (InstantiationException e) { @@ -75,7 +75,7 @@ public abstract class AbstractUIProvider implements UIProvider { } @Override - public String getThemeForUI(WrappedRequest request, + public String getTheme(WrappedRequest request, Class uiClass) { Theme uiTheme = getAnnotationFor(uiClass, Theme.class); if (uiTheme != null) { @@ -86,7 +86,7 @@ public abstract class AbstractUIProvider implements UIProvider { } @Override - public String getWidgetsetForUI(WrappedRequest request, + public String getWidgetset(WrappedRequest request, Class uiClass) { Widgetset uiWidgetset = getAnnotationFor(uiClass, Widgetset.class); if (uiWidgetset != null) { @@ -97,7 +97,7 @@ public abstract class AbstractUIProvider implements UIProvider { } @Override - public boolean isUiPreserved(WrappedRequest request, + public boolean isPreservedOnRefresh(WrappedRequest request, Class uiClass) { PreserveOnRefresh preserveOnRefresh = getAnnotationFor(uiClass, PreserveOnRefresh.class); @@ -105,7 +105,7 @@ public abstract class AbstractUIProvider implements UIProvider { } @Override - public String getPageTitleForUI(WrappedRequest request, + public String getPageTitle(WrappedRequest request, Class uiClass) { Title titleAnnotation = getAnnotationFor(uiClass, Title.class); if (titleAnnotation == null) { diff --git a/server/src/com/vaadin/server/BootstrapHandler.java b/server/src/com/vaadin/server/BootstrapHandler.java index 1417889d00..a25c1860ef 100644 --- a/server/src/com/vaadin/server/BootstrapHandler.java +++ b/server/src/com/vaadin/server/BootstrapHandler.java @@ -225,7 +225,7 @@ public abstract class BootstrapHandler implements RequestHandler { String title = context.getVaadinSession() .getUiProvider(context.getRequest(), context.getUIClass()) - .getPageTitleForUI(context.getRequest(), context.getUIClass()); + .getPageTitle(context.getRequest(), context.getUIClass()); if (title != null) { head.appendElement("title").appendText(title); } @@ -278,7 +278,7 @@ public abstract class BootstrapHandler implements RequestHandler { String widgetset = context.getVaadinSession() .getUiProvider(context.getRequest(), context.getUIClass()) - .getWidgetsetForUI(context.getRequest(), context.getUIClass()); + .getWidgetset(context.getRequest(), context.getUIClass()); if (widgetset == null) { widgetset = request.getVaadinService().getConfiguredWidgetset( request); @@ -502,7 +502,7 @@ public abstract class BootstrapHandler implements RequestHandler { public String getThemeName(BootstrapContext context) { return context.getVaadinSession() .getUiProvider(context.getRequest(), context.getUIClass()) - .getThemeForUI(context.getRequest(), context.getUIClass()); + .getTheme(context.getRequest(), context.getUIClass()); } /** diff --git a/server/src/com/vaadin/server/UIProvider.java b/server/src/com/vaadin/server/UIProvider.java index 752da3aafc..a15a50a42a 100644 --- a/server/src/com/vaadin/server/UIProvider.java +++ b/server/src/com/vaadin/server/UIProvider.java @@ -22,10 +22,10 @@ import com.vaadin.ui.UI; public interface UIProvider { public Class getUIClass(WrappedRequest request); - public UI createInstance(Class type, - WrappedRequest request); + public UI createInstance(WrappedRequest request, + Class type); - public String getPageTitleForUI(WrappedRequest request, + public String getPageTitle(WrappedRequest request, Class uiClass); /** @@ -40,7 +40,7 @@ public interface UIProvider { * @return trueif the same UI instance should be reused e.g. * when the browser window is refreshed. */ - public boolean isUiPreserved(WrappedRequest request, + public boolean isPreservedOnRefresh(WrappedRequest request, Class uiClass); /** @@ -58,7 +58,7 @@ public interface UIProvider { * widgetset should be used * */ - public String getWidgetsetForUI(WrappedRequest request, + public String getWidgetset(WrappedRequest request, Class uiClass); /** @@ -73,7 +73,7 @@ public interface UIProvider { * should be used * */ - public String getThemeForUI(WrappedRequest request, + public String getTheme(WrappedRequest request, Class uiClass); /** @@ -85,7 +85,7 @@ public interface UIProvider { *

* If no UI provider returns an existing UI, the framework does also check * the window.name for an existing instance with - * {@link #isUiPreserved(WrappedRequest, Class)} before falling back to + * {@link #isPreservedOnRefresh(WrappedRequest, Class)} before falling back to * bootstrapping and creating a new UI instance. * * @param request diff --git a/server/src/com/vaadin/server/VaadinSession.java b/server/src/com/vaadin/server/VaadinSession.java index 3a379fdc76..4f4ba23640 100644 --- a/server/src/com/vaadin/server/VaadinSession.java +++ b/server/src/com/vaadin/server/VaadinSession.java @@ -716,7 +716,7 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable { protected T createUIInstance(WrappedRequest request, Class uiClass) { UIProvider uiProvider = getUiProvider(request, uiClass); - return uiClass.cast(uiProvider.createInstance(uiClass, request)); + return uiClass.cast(uiProvider.createInstance(request, uiClass)); } /** @@ -1027,7 +1027,7 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable { ui.doInit(request, uiId.intValue()); - if (getUiProvider(request, uiClass).isUiPreserved(request, uiClass)) { + if (getUiProvider(request, uiClass).isPreservedOnRefresh(request, uiClass)) { // Remember this UI String windowName = request.getBrowserDetails().getWindowName(); if (windowName == null) { diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index adb2a63c2e..41d0c43399 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -981,7 +981,7 @@ public abstract class UI extends AbstractComponentContainer implements throw new IllegalStateException("UI id has already been defined"); } this.uiId = uiId; - theme = getSession().getUiProvider(request, getClass()).getThemeForUI( + theme = getSession().getUiProvider(request, getClass()).getTheme( request, getClass()); getPage().init(request); diff --git a/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java b/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java index cfcf0e1996..f8f7a16c4d 100644 --- a/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java +++ b/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java @@ -20,8 +20,8 @@ public class LazyInitUIs extends AbstractTestUIProvider { } @Override - public UI createInstance(Class type, - WrappedRequest request) { + public UI createInstance(WrappedRequest request, + Class type) { return getUI(request); } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java index 5a8d8a8ea1..821660e9e6 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java @@ -45,8 +45,8 @@ public class DifferentFeaturesForDifferentClients extends AbstractUIProvider { // Must override as default implementation isn't allowed to // instantiate our non-public classes @Override - public UI createInstance(Class type, - WrappedRequest request) { + public UI createInstance(WrappedRequest request, + Class type) { try { return type.newInstance(); } catch (Exception e) {