diff options
author | Leif Åstrand <leif@vaadin.com> | 2014-04-10 11:47:29 +0300 |
---|---|---|
committer | Jonatan Kronqvist <jonatan@vaadin.com> | 2014-05-14 07:52:04 +0000 |
commit | 023568931d8eca775a9f6ab2e584e7ccfae83bd4 (patch) | |
tree | 43e8dd48515d3063cd33a58d3ad6d0b739b86cc8 /uitest/src | |
parent | da11bda0a3583922ad1f338f4d12c0aa821ad796 (diff) | |
download | vaadin-framework-023568931d8eca775a9f6ab2e584e7ccfae83bd4.tar.gz vaadin-framework-023568931d8eca775a9f6ab2e584e7ccfae83bd4.zip |
Update tutorial code to show more user-friendly API
Change-Id: I95c82d2256221b0068d6c2762f6dbb8a1e29b6b8
Diffstat (limited to 'uitest/src')
6 files changed, 14 insertions, 23 deletions
diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a3/Analytics.java b/uitest/src/com/vaadin/tests/minitutorials/v7a3/Analytics.java index db4a88ab7a..338fb20893 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a3/Analytics.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a3/Analytics.java @@ -18,13 +18,13 @@ package com.vaadin.tests.minitutorials.v7a3; import com.vaadin.annotations.JavaScript; import com.vaadin.server.AbstractJavaScriptExtension; -import com.vaadin.server.ClientConnector; import com.vaadin.ui.UI; @JavaScript("analytics_connector.js") public class Analytics extends AbstractJavaScriptExtension { - public Analytics(String account) { + public Analytics(UI ui, String account) { + extend(ui); pushCommand("_setAccount", account); } @@ -37,13 +37,4 @@ public class Analytics extends AbstractJavaScriptExtension { // varargs argument instead of as the full varargs argument array. callFunction("pushCommand", (Object) commandAndArguments); } - - protected void extend(UI uI) { - super.extend(uI); - } - - @Override - protected Class<? extends ClientConnector> getSupportedParentType() { - return UI.class; - } } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a3/AnalyticsUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a3/AnalyticsUI.java index 19a7ce8a19..b12f5829fc 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a3/AnalyticsUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a3/AnalyticsUI.java @@ -25,8 +25,7 @@ public class AnalyticsUI extends UI { @Override protected void init(VaadinRequest request) { - final Analytics analytics = new Analytics("UA-33036133-12"); - analytics.extend(this); + final Analytics analytics = new Analytics(this, "UA-33036133-12"); setContent(new Button("Track pageview", new Button.ClickListener() { @Override diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a3/CapsLockWarning.java b/uitest/src/com/vaadin/tests/minitutorials/v7a3/CapsLockWarning.java index d10bd0edf8..4165e63951 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a3/CapsLockWarning.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a3/CapsLockWarning.java @@ -20,7 +20,12 @@ import com.vaadin.server.AbstractExtension; import com.vaadin.ui.PasswordField; public class CapsLockWarning extends AbstractExtension { - public void extend(PasswordField field) { - super.extend(field); + protected CapsLockWarning(PasswordField field) { + // Non-public constructor to discourage direct instantiation + extend(field); + } + + public static CapsLockWarning warnFor(PasswordField field) { + return new CapsLockWarning(field); } } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a3/CapsLockWarningUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a3/CapsLockWarningUI.java index 88a308a9e9..19a7da7114 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a3/CapsLockWarningUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a3/CapsLockWarningUI.java @@ -28,7 +28,7 @@ public class CapsLockWarningUI extends AbstractTestUI { @Override protected void setup(VaadinRequest request) { PasswordField field = new PasswordField("Enter your password"); - new CapsLockWarning().extend(field); + CapsLockWarning.warnFor(field); addComponent(field); } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a3/Refresher.java b/uitest/src/com/vaadin/tests/minitutorials/v7a3/Refresher.java index 1b855e4e51..6878fc1bc6 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a3/Refresher.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a3/Refresher.java @@ -29,13 +29,14 @@ public class Refresher extends AbstractExtension { } - public Refresher() { + public Refresher(UI ui) { registerRpc(new RefresherRpc() { @Override public void refresh() { fireEvent(new RefreshEvent(Refresher.this)); } }); + extend(ui); } @Override @@ -67,8 +68,4 @@ public class Refresher extends AbstractExtension { super.removeListener(RefreshEvent.class, listener, RefreshListener.METHOD); } - - public void extend(UI target) { - super.extend(target); - } } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a3/RefresherTestUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a3/RefresherTestUI.java index 0b2fad21aa..e9243ac0cb 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a3/RefresherTestUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a3/RefresherTestUI.java @@ -30,8 +30,7 @@ public class RefresherTestUI extends AbstractTestUI { @Override protected void setup(VaadinRequest request) { - final Refresher refresher = new Refresher(); - refresher.extend(this); + final Refresher refresher = new Refresher(this); refresher.setInterval(1000); refresher.addRefreshListener(new RefreshListener() { @Override |