From: Leif Åstrand Date: Mon, 25 Jun 2012 13:07:03 +0000 (+0300) Subject: Rename setCurrentXyz() to setCurrent() (#9029) X-Git-Tag: 7.0.0.alpha3~64 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=086a297997e82453eb3b3e0f2dddb856d0db5bcb;p=vaadin-framework.git Rename setCurrentXyz() to setCurrent() (#9029) --- diff --git a/src/com/vaadin/Application.java b/src/com/vaadin/Application.java index 3da314a11e..84a8df5053 100644 --- a/src/com/vaadin/Application.java +++ b/src/com/vaadin/Application.java @@ -2119,11 +2119,11 @@ public class Application implements Terminal.ErrorListener, Serializable { * @return the current application instance if available, otherwise * null * - * @see #setCurrentApplication(Application) + * @see #setCurrent(Application) * * @since 7.0 */ - public static Application getCurrentApplication() { + public static Application getCurrent() { return currentApplication.get(); } @@ -2139,12 +2139,12 @@ public class Application implements Terminal.ErrorListener, Serializable { * * @param application * - * @see #getCurrentApplication() + * @see #getCurrent() * @see ThreadLocal * * @since 7.0 */ - public static void setCurrentApplication(Application application) { + public static void setCurrent(Application application) { currentApplication.set(application); } @@ -2188,7 +2188,7 @@ public class Application implements Terminal.ErrorListener, Serializable { */ public Root getRootForRequest(WrappedRequest request) throws RootRequiresMoreInformationException { - Root root = Root.getCurrentRoot(); + Root root = Root.getCurrent(); if (root != null) { return root; } @@ -2240,7 +2240,7 @@ public class Application implements Terminal.ErrorListener, Serializable { } // Set thread local here so it is available in init - Root.setCurrentRoot(root); + Root.setCurrent(root); if (!initedRoots.contains(rootId)) { boolean initRequiresBrowserDetails = isRootPreserved() diff --git a/src/com/vaadin/data/util/converter/ConverterUtil.java b/src/com/vaadin/data/util/converter/ConverterUtil.java index 206295b293..7011496ed7 100644 --- a/src/com/vaadin/data/util/converter/ConverterUtil.java +++ b/src/com/vaadin/data/util/converter/ConverterUtil.java @@ -14,7 +14,7 @@ public class ConverterUtil implements Serializable { * Finds a converter that can convert from the given presentation type to * the given model type and back. Uses the given application to find a * {@link ConverterFactory} or, if application is null, uses the - * {@link Application#getCurrentApplication()}. + * {@link Application#getCurrent()}. * * @param * The presentation type @@ -35,7 +35,7 @@ public class ConverterUtil implements Serializable { Class modelType, Application application) { Converter converter = null; if (application == null) { - application = Application.getCurrentApplication(); + application = Application.getCurrent(); } if (application != null) { diff --git a/src/com/vaadin/terminal/CombinedRequest.java b/src/com/vaadin/terminal/CombinedRequest.java index ccef6d8963..abf5e0412a 100644 --- a/src/com/vaadin/terminal/CombinedRequest.java +++ b/src/com/vaadin/terminal/CombinedRequest.java @@ -129,7 +129,7 @@ public class CombinedRequest implements WrappedRequest { public WebBrowser getWebBrowser() { WebApplicationContext context = (WebApplicationContext) Application - .getCurrentApplication().getContext(); + .getCurrent().getContext(); return context.getBrowser(); } }; diff --git a/src/com/vaadin/terminal/Page.java b/src/com/vaadin/terminal/Page.java index 8506e17898..e6d06a837a 100644 --- a/src/com/vaadin/terminal/Page.java +++ b/src/com/vaadin/terminal/Page.java @@ -615,7 +615,7 @@ public class Page implements Serializable { } public static Page getCurrent() { - Root currentRoot = Root.getCurrentRoot(); + Root currentRoot = Root.getCurrent(); if (currentRoot == null) { return null; } diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java index b7be6fd394..c2f887674a 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java @@ -540,7 +540,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet if (application == null) { return; } - Application.setCurrentApplication(application); + Application.setCurrent(application); /* * Get or create an application context and an application @@ -689,8 +689,8 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet } } finally { - Root.setCurrentRoot(null); - Application.setCurrentApplication(null); + Root.setCurrent(null); + Application.setCurrent(null); PortletSession session = request .getPortletSession(false); diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java index 0e548f61c8..9750c0611b 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java @@ -385,7 +385,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements if (application == null) { return; } - Application.setCurrentApplication(application); + Application.setCurrent(application); /* * Get or create a WebApplicationContext and an ApplicationManager @@ -477,8 +477,8 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements .onRequestEnd(request, response); } } finally { - Root.setCurrentRoot(null); - Application.setCurrentApplication(null); + Root.setCurrent(null); + Application.setCurrent(null); HttpSession session = request.getSession(false); if (session != null) { diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index 1ea713b4f6..e37dfc59af 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -2194,7 +2194,7 @@ public abstract class AbstractCommunicationManager implements Serializable { // if we do not yet have a currentRoot, it should be initialized // shortly, and we should send the initial UIDL - boolean sendUIDL = Root.getCurrentRoot() == null; + boolean sendUIDL = Root.getCurrent() == null; try { CombinedRequest combinedRequest = new CombinedRequest(request); diff --git a/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java b/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java index ae1fadd91b..69f033c8cd 100644 --- a/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java +++ b/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java @@ -83,7 +83,7 @@ public abstract class BootstrapHandler implements RequestHandler { public Root getRoot() { if (!rootFetched) { - root = Root.getCurrentRoot(); + root = Root.getCurrent(); rootFetched = true; } return root; diff --git a/src/com/vaadin/terminal/gwt/server/WrappedHttpServletRequest.java b/src/com/vaadin/terminal/gwt/server/WrappedHttpServletRequest.java index b6f1a192cb..0774a79990 100644 --- a/src/com/vaadin/terminal/gwt/server/WrappedHttpServletRequest.java +++ b/src/com/vaadin/terminal/gwt/server/WrappedHttpServletRequest.java @@ -82,7 +82,7 @@ public class WrappedHttpServletRequest extends HttpServletRequestWrapper public WebBrowser getWebBrowser() { WebApplicationContext context = (WebApplicationContext) Application - .getCurrentApplication().getContext(); + .getCurrent().getContext(); return context.getBrowser(); } }; diff --git a/src/com/vaadin/terminal/gwt/server/WrappedPortletRequest.java b/src/com/vaadin/terminal/gwt/server/WrappedPortletRequest.java index 3838695aa3..85d8d5c69c 100644 --- a/src/com/vaadin/terminal/gwt/server/WrappedPortletRequest.java +++ b/src/com/vaadin/terminal/gwt/server/WrappedPortletRequest.java @@ -130,7 +130,7 @@ public class WrappedPortletRequest implements WrappedRequest { public WebBrowser getWebBrowser() { PortletApplicationContext2 context = (PortletApplicationContext2) Application - .getCurrentApplication().getContext(); + .getCurrent().getContext(); return context.getBrowser(); } }; diff --git a/src/com/vaadin/ui/Component.java b/src/com/vaadin/ui/Component.java index 2394d0f307..81e0319880 100644 --- a/src/com/vaadin/ui/Component.java +++ b/src/com/vaadin/ui/Component.java @@ -520,7 +520,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable { *

* Getting a null value is often a problem in constructors of regular * components and in the initializers of custom composite components. A - * standard workaround is to use {@link Application#getCurrentApplication()} + * standard workaround is to use {@link Application#getCurrent()} * to retrieve the application instance that the current request relates to. * Another way is to move the problematic initialization to * {@link #attach()}, as described in the documentation of the method. diff --git a/src/com/vaadin/ui/Root.java b/src/com/vaadin/ui/Root.java index 37cd646d82..7ae687be79 100644 --- a/src/com/vaadin/ui/Root.java +++ b/src/com/vaadin/ui/Root.java @@ -923,10 +923,10 @@ public abstract class Root extends AbstractComponentContainer implements * @param root * the root to register as the current root * - * @see #getCurrentRoot() + * @see #getCurrent() * @see ThreadLocal */ - public static void setCurrentRoot(Root root) { + public static void setCurrent(Root root) { currentRoot.set(root); } @@ -938,9 +938,9 @@ public abstract class Root extends AbstractComponentContainer implements * @return the current root instance if available, otherwise * null * - * @see #setCurrentRoot(Root) + * @see #setCurrent(Root) */ - public static Root getCurrentRoot() { + public static Root getCurrent() { return currentRoot.get(); } diff --git a/tests/server-side/com/vaadin/tests/data/converter/ConverterFactory.java b/tests/server-side/com/vaadin/tests/data/converter/ConverterFactory.java index b97f987ae3..4bd9cf0cf7 100644 --- a/tests/server-side/com/vaadin/tests/data/converter/ConverterFactory.java +++ b/tests/server-side/com/vaadin/tests/data/converter/ConverterFactory.java @@ -49,7 +49,7 @@ public class ConverterFactory extends TestCase { } public void testApplicationConverterFactoryInBackgroundThread() { - Application.setCurrentApplication(null); + Application.setCurrent(null); final Application appWithCustomIntegerConverter = new Application(); appWithCustomIntegerConverter .setConverterFactory(new ConverterFactory42()); @@ -70,7 +70,7 @@ public class ConverterFactory extends TestCase { final Application appWithCustomIntegerConverter = new Application(); appWithCustomIntegerConverter .setConverterFactory(new ConverterFactory42()); - Application.setCurrentApplication(appWithCustomIntegerConverter); + Application.setCurrent(appWithCustomIntegerConverter); TextField tf = new TextField("", "123"); tf.setConverter(Integer.class); @@ -83,7 +83,7 @@ public class ConverterFactory extends TestCase { final Application fieldAppWithCustomIntegerConverter = new Application(); fieldAppWithCustomIntegerConverter .setConverterFactory(new ConverterFactory42()); - Application.setCurrentApplication(new Application()); + Application.setCurrent(new Application()); TextField tf = new TextField("", "123") { @Override diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java b/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java index 7305e022ee..446228583a 100644 --- a/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java +++ b/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java @@ -175,7 +175,7 @@ public class AbstractFieldValueConversions extends TestCase { public void testNumberDoubleConverterChange() { final Application a = new Application(); - Application.setCurrentApplication(a); + Application.setCurrent(a); TextField tf = new TextField() { @Override public Application getApplication() { diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java b/tests/server-side/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java index e39b5d6629..25430fc9a5 100644 --- a/tests/server-side/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java +++ b/tests/server-side/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java @@ -27,7 +27,7 @@ public class DefaultConverterFactory extends TestCase { public void testDefaultNumberConversion() { Application app = new Application(); - Application.setCurrentApplication(app); + Application.setCurrent(app); TextField tf = new TextField(); tf.setLocale(new Locale("en", "US")); tf.setPropertyDataSource(new MethodProperty(paulaBean, diff --git a/tests/server-side/com/vaadin/tests/server/component/label/LabelConverters.java b/tests/server-side/com/vaadin/tests/server/component/label/LabelConverters.java index e79bd84741..5ba15cac6c 100644 --- a/tests/server-side/com/vaadin/tests/server/component/label/LabelConverters.java +++ b/tests/server-side/com/vaadin/tests/server/component/label/LabelConverters.java @@ -25,7 +25,7 @@ public class LabelConverters extends TestCase { } public void testIntegerDataSource() { - Application.setCurrentApplication(new Application()); + Application.setCurrent(new Application()); Label l = new Label("Foo"); Property ds = new MethodProperty(Person.createTestPerson1(), "age"); diff --git a/tests/testbench/com/vaadin/tests/TestForWindowOpen.java b/tests/testbench/com/vaadin/tests/TestForWindowOpen.java index 76154f2419..75395f0d5c 100644 --- a/tests/testbench/com/vaadin/tests/TestForWindowOpen.java +++ b/tests/testbench/com/vaadin/tests/TestForWindowOpen.java @@ -24,7 +24,7 @@ public class TestForWindowOpen extends CustomComponent { public void buttonClick(ClickEvent event) { final ExternalResource r = new ExternalResource( "http://www.google.com"); - Root.getCurrentRoot().getPage().open(r); + Root.getCurrent().getPage().open(r); } @@ -36,7 +36,7 @@ public class TestForWindowOpen extends CustomComponent { public void buttonClick(ClickEvent event) { final ExternalResource r = new ExternalResource( "http://www.google.com"); - Root.getCurrentRoot().getPage().open(r, "mytarget"); + Root.getCurrent().getPage().open(r, "mytarget"); } @@ -48,7 +48,7 @@ public class TestForWindowOpen extends CustomComponent { public void buttonClick(ClickEvent event) { final ExternalResource r = new ExternalResource( "http://www.google.com"); - Root.getCurrentRoot().getPage().open(r, "secondtarget"); + Root.getCurrent().getPage().open(r, "secondtarget"); } diff --git a/tests/testbench/com/vaadin/tests/TestForWindowing.java b/tests/testbench/com/vaadin/tests/TestForWindowing.java index f97ea33d61..b9e14608f5 100644 --- a/tests/testbench/com/vaadin/tests/TestForWindowing.java +++ b/tests/testbench/com/vaadin/tests/TestForWindowing.java @@ -85,7 +85,7 @@ public class TestForWindowing extends CustomComponent { w.addComponent(s); - Root.getCurrentRoot().addWindow(w); + Root.getCurrent().addWindow(w); } diff --git a/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java b/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java index 68a0bb3805..fd65adf209 100644 --- a/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java +++ b/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java @@ -16,8 +16,8 @@ import com.vaadin.ui.Root; public class ThreadLocalInstances extends AbstractTestApplication { private static final Application staticInitApplication = Application - .getCurrentApplication(); - private static final Root staticInitRoot = Root.getCurrentRoot(); + .getCurrent(); + private static final Root staticInitRoot = Root.getCurrent(); private final Root mainWindow = new Root() { boolean paintReported = false; @@ -92,8 +92,8 @@ public class ThreadLocalInstances extends AbstractTestApplication { } private void reportCurrentStatus(String phase) { - reportStatus(phase, Application.getCurrentApplication(), - Root.getCurrentRoot()); + reportStatus(phase, Application.getCurrent(), + Root.getCurrent()); } private void reportStatus(String phase, Application application, Root root) { diff --git a/tests/testbench/com/vaadin/tests/components/AbstractTestRoot.java b/tests/testbench/com/vaadin/tests/components/AbstractTestRoot.java index 72cbcd386e..875d2b1df8 100644 --- a/tests/testbench/com/vaadin/tests/components/AbstractTestRoot.java +++ b/tests/testbench/com/vaadin/tests/components/AbstractTestRoot.java @@ -57,7 +57,7 @@ public abstract class AbstractTestRoot extends Root { protected abstract Integer getTicketNumber(); protected WebBrowser getBrowser() { - ApplicationContext context = Application.getCurrentApplication() + ApplicationContext context = Application.getCurrent() .getContext(); if (context instanceof AbstractWebApplicationContext) { AbstractWebApplicationContext webContext = (AbstractWebApplicationContext) context; diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentRootAndApplication.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentRootAndApplication.java index c6e609c5ee..b237666caa 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentRootAndApplication.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentRootAndApplication.java @@ -29,10 +29,10 @@ public class FindCurrentRootAndApplication extends Root { helloButton.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { String msg = "Running in "; - msg += Application.getCurrentApplication().isProductionMode() ? "production" + msg += Application.getCurrent().isProductionMode() ? "production" : "debug"; msg += " mode in a Root with the caption " - + Root.getCurrentRoot().getCaption(); + + Root.getCurrent().getCaption(); Notification.show(msg); }