summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-10-11 13:36:35 +0300
committerLeif Åstrand <leif@vaadin.com>2012-10-11 13:36:35 +0300
commit6f485e39df17aba6271956294ed6cc3e27337e92 (patch)
tree707fbf78adb0dfb63b51174210018936143791ee
parent0e5fe9d46fbb3c32aa2ceae22f29253c5bf45342 (diff)
downloadvaadin-framework-6f485e39df17aba6271956294ed6cc3e27337e92.tar.gz
vaadin-framework-6f485e39df17aba6271956294ed6cc3e27337e92.zip
Mini tutorial code update
-rw-r--r--uitest/src/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java60
-rw-r--r--uitest/src/com/vaadin/tests/minitutorials/v7a1/UsingUriFragments.java4
-rw-r--r--uitest/src/com/vaadin/tests/minitutorials/v7a2/ResourceInStateComponent.java9
-rw-r--r--uitest/src/com/vaadin/tests/minitutorials/v7a2/ResourceInStateUI.java2
-rw-r--r--uitest/src/com/vaadin/tests/minitutorials/v7a3/Refresher.java61
-rw-r--r--uitest/src/com/vaadin/tests/minitutorials/v7a3/RefresherTestUI.java52
-rw-r--r--uitest/src/com/vaadin/tests/minitutorials/v7b1/AxessingWebPageAndBrowserInfoUI.java67
-rw-r--r--uitest/src/com/vaadin/tests/minitutorials/v7b1/BootstrapListenerCode.java91
-rw-r--r--uitest/src/com/vaadin/tests/minitutorials/v7b2/CleanupUI.java47
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateConnector.java11
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateState.java7
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a3/ClientSideModule.java52
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a3/RefresherConnector.java40
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a3/RefresherRpc.java7
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a3/RefresherState.java7
15 files changed, 457 insertions, 60 deletions
diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java
index b5057dd9c2..61cbd94f3a 100644
--- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java
+++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java
@@ -2,56 +2,36 @@ package com.vaadin.tests.minitutorials.v7a1;
import java.awt.image.BufferedImage;
import java.io.IOException;
+import java.util.HashMap;
import javax.imageio.ImageIO;
-import com.vaadin.server.ExternalResource;
-import com.vaadin.server.RequestHandler;
+import com.vaadin.server.DynamicConnectorResource;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinResponse;
-import com.vaadin.server.VaadinServiceSession;
import com.vaadin.tests.components.AbstractTestUI;
-import com.vaadin.ui.Embedded;
+import com.vaadin.ui.Image;
public class DynamicImageUI extends AbstractTestUI {
+ public static final String IMAGE_URL = "myimage.png";
@Override
public void setup(VaadinRequest request) {
- // Add the request handler that handles our dynamic image
- getSession().addRequestHandler(new DynamicImageRequestHandler());
-
- // Create a URL that we can handle in DynamicImageRequestHandler
- String imageUrl = "app://" + DynamicImageRequestHandler.IMAGE_URL
- + "?text=Hello!";
+ HashMap<String, String> parameters = new HashMap<String, String>();
+ parameters.put("text", "Hello!");
+ DynamicConnectorResource resource = new DynamicConnectorResource(this,
+ IMAGE_URL, parameters);
- // Add an embedded using the created URL
- Embedded embedded = new Embedded("A dynamically generated image",
- new ExternalResource(imageUrl));
- embedded.setType(Embedded.TYPE_IMAGE);
- getContent().addComponent(embedded);
-
- }
+ // Add an image using the resource
+ Image image = new Image("A dynamically generated image", resource);
- @Override
- protected String getTestDescription() {
- return "Mini tutorial for https://vaadin.com/wiki/-/wiki/Main/Generating%20dynamic%20resources%20based%20on%20URI%20or%20parameters";
+ getContent().addComponent(image);
}
@Override
- protected Integer getTicketNumber() {
- return null;
- }
-}
-
-class DynamicImageRequestHandler implements RequestHandler {
-
- public static final String IMAGE_URL = "myimage.png";
-
- @Override
- public boolean handleRequest(VaadinServiceSession session,
- VaadinRequest request, VaadinResponse response) throws IOException {
- String pathInfo = request.getRequestPathInfo();
- if (("/" + IMAGE_URL).equals(pathInfo)) {
+ public boolean handleConnectorRequest(VaadinRequest request,
+ VaadinResponse response, String path) throws IOException {
+ if ((IMAGE_URL).equals(path)) {
// Create an image, draw the "text" parameter to it and output it to
// the browser.
String text = request.getParameter("text");
@@ -68,4 +48,14 @@ class DynamicImageRequestHandler implements RequestHandler {
// handlers handle it
return false;
}
-}
+
+ @Override
+ protected String getTestDescription() {
+ return "Mini tutorial for https://vaadin.com/wiki/-/wiki/Main/Generating%20dynamic%20resources%20based%20on%20URI%20or%20parameters";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return null;
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/UsingUriFragments.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/UsingUriFragments.java
index 6d9890a21c..5d7555a952 100644
--- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/UsingUriFragments.java
+++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/UsingUriFragments.java
@@ -36,7 +36,7 @@ public class UsingUriFragments extends UI {
@Override
protected void init(VaadinRequest request) {
Label label = new Label("Hello, your fragment is "
- + getPage().getLocation().getFragment());
+ + getPage().getFragment());
getContent().addComponent(label);
// React to fragment changes
@@ -48,7 +48,7 @@ public class UsingUriFragments extends UI {
});
// Handle the fragment received in the initial request
- handleFragment(getPage().getLocation().getFragment());
+ handleFragment(getPage().getFragment());
addComponent(new Button("Show and set fragment",
new Button.ClickListener() {
diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a2/ResourceInStateComponent.java b/uitest/src/com/vaadin/tests/minitutorials/v7a2/ResourceInStateComponent.java
index cf0c5a3e2b..caaca14ae8 100644
--- a/uitest/src/com/vaadin/tests/minitutorials/v7a2/ResourceInStateComponent.java
+++ b/uitest/src/com/vaadin/tests/minitutorials/v7a2/ResourceInStateComponent.java
@@ -17,20 +17,15 @@
package com.vaadin.tests.minitutorials.v7a2;
import com.vaadin.server.Resource;
-import com.vaadin.tests.widgetset.client.minitutorials.v7a2.ResourceInStateState;
import com.vaadin.ui.AbstractComponent;
public class ResourceInStateComponent extends AbstractComponent {
- @Override
- public ResourceInStateState getState() {
- return (ResourceInStateState) super.getState();
- }
public void setMyIcon(Resource icon) {
- setResource(ResourceInStateState.MY_ICON_RESOURCE, icon);
+ setResource("myIcon", icon);
}
public Resource getMyIcon() {
- return getResource(ResourceInStateState.MY_ICON_RESOURCE);
+ return getResource("myIcon");
}
}
diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a2/ResourceInStateUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a2/ResourceInStateUI.java
index 2a64792646..155c1d9ded 100644
--- a/uitest/src/com/vaadin/tests/minitutorials/v7a2/ResourceInStateUI.java
+++ b/uitest/src/com/vaadin/tests/minitutorials/v7a2/ResourceInStateUI.java
@@ -35,7 +35,7 @@ public class ResourceInStateUI extends UI {
@Override
protected void init(VaadinRequest request) {
ResourceInStateComponent component = new ResourceInStateComponent();
- component.setIcon(new ThemeResource("../runo/icons/32/calendar.png"));
+ component.setMyIcon(new ThemeResource("../runo/icons/32/calendar.png"));
addComponent(component);
}
diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a3/Refresher.java b/uitest/src/com/vaadin/tests/minitutorials/v7a3/Refresher.java
new file mode 100644
index 0000000000..408b04b3b4
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/minitutorials/v7a3/Refresher.java
@@ -0,0 +1,61 @@
+package com.vaadin.tests.minitutorials.v7a3;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.vaadin.server.AbstractExtension;
+import com.vaadin.tests.widgetset.client.minitutorials.v7a3.RefresherRpc;
+import com.vaadin.tests.widgetset.client.minitutorials.v7a3.RefresherState;
+import com.vaadin.ui.UI;
+
+public class Refresher extends AbstractExtension {
+ public interface RefreshListener {
+ public void refresh(Refresher source);
+ }
+
+ private List<RefreshListener> listeners = new ArrayList<RefreshListener>();
+
+ public Refresher() {
+ registerRpc(new RefresherRpc() {
+ @Override
+ public void refresh() {
+ for (RefreshListener listener : listeners) {
+ listener.refresh(Refresher.this);
+ }
+ }
+ });
+ }
+
+ @Override
+ public RefresherState getState() {
+ return (RefresherState) super.getState();
+ }
+
+ public void setInterval(int millis) {
+ getState().interval = millis;
+ }
+
+ public int getInterval() {
+ return getState().interval;
+ }
+
+ public void setEnabled(boolean enabled) {
+ getState().enabled = enabled;
+ }
+
+ public boolean isEnabled() {
+ return getState().enabled;
+ }
+
+ public void addListener(RefreshListener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeListener(RefreshListener listener) {
+ listeners.remove(listener);
+ }
+
+ public void extend(UI target) {
+ super.extend(target);
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a3/RefresherTestUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a3/RefresherTestUI.java
new file mode 100644
index 0000000000..430da55fa1
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/minitutorials/v7a3/RefresherTestUI.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2012 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.tests.minitutorials.v7a3;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.minitutorials.v7a3.Refresher.RefreshListener;
+import com.vaadin.tests.widgetset.TestingWidgetSet;
+
+@Widgetset(TestingWidgetSet.NAME)
+public class RefresherTestUI extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Refresher refresher = new Refresher();
+ refresher.extend(this);
+ refresher.addListener(new RefreshListener() {
+ @Override
+ public void refresh(Refresher source) {
+ System.out.println("Got refresh");
+ }
+ });
+ }
+
+ @Override
+ protected String getTestDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b1/AxessingWebPageAndBrowserInfoUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7b1/AxessingWebPageAndBrowserInfoUI.java
new file mode 100644
index 0000000000..8623dd0b73
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/minitutorials/v7b1/AxessingWebPageAndBrowserInfoUI.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2012 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.tests.minitutorials.v7b1;
+
+import com.vaadin.server.Page;
+import com.vaadin.server.Page.BrowserWindowResizeEvent;
+import com.vaadin.server.Page.BrowserWindowResizeListener;
+import com.vaadin.server.Page.FragmentChangedEvent;
+import com.vaadin.server.Page.FragmentChangedListener;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Notification;
+import com.vaadin.ui.UI;
+
+public class AxessingWebPageAndBrowserInfoUI extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ UI someUI = this;
+
+ Page page = someUI.getPage();
+ page.setBrowserWindowSize(page.getBrowserWindowWidth() + 10,
+ page.getBrowserWindowHeight() + 10);
+ page.addBrowserWindowResizeListener(new BrowserWindowResizeListener() {
+ @Override
+ public void browserWindowResized(BrowserWindowResizeEvent event) {
+ Notification.show("Window width=" + event.getWidth()
+ + ", height=" + event.getHeight());
+ }
+ });
+
+ page.setFragment(page.getFragment() + "foo");
+ page.addFragmentChangedListener(new FragmentChangedListener() {
+ @Override
+ public void fragmentChanged(FragmentChangedEvent event) {
+ Notification.show("Fragment=" + event.getFragment());
+ }
+ });
+ }
+
+ @Override
+ protected String getTestDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b1/BootstrapListenerCode.java b/uitest/src/com/vaadin/tests/minitutorials/v7b1/BootstrapListenerCode.java
new file mode 100644
index 0000000000..422e44e402
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/minitutorials/v7b1/BootstrapListenerCode.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2012 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.tests.minitutorials.v7b1;
+
+import java.util.List;
+
+import javax.portlet.PortletException;
+import javax.servlet.ServletException;
+
+import org.jsoup.nodes.Comment;
+import org.jsoup.nodes.Element;
+import org.jsoup.nodes.Node;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.server.BootstrapFragmentResponse;
+import com.vaadin.server.BootstrapListener;
+import com.vaadin.server.BootstrapPageResponse;
+import com.vaadin.server.ServiceException;
+import com.vaadin.server.SessionInitEvent;
+import com.vaadin.server.SessionInitListener;
+import com.vaadin.server.VaadinPortlet;
+import com.vaadin.server.VaadinServlet;
+
+public class BootstrapListenerCode {
+ public static BootstrapListener listener = new BootstrapListener() {
+ @Override
+ public void modifyBootstrapPage(BootstrapPageResponse response) {
+ response.getDocument().body()
+ .appendChild(new Comment("Powered by Vaadin!", ""));
+ response.setHeader("X-Powered-By", "Vaadin 7");
+ }
+
+ @Override
+ public void modifyBootstrapFragment(BootstrapFragmentResponse response) {
+ // Wrap the fragment in a custom div element
+ Element myDiv = new Element(Tag.valueOf("div"), "");
+ List<Node> nodes = response.getFragmentNodes();
+ for (Node node : nodes) {
+ myDiv.appendChild(node);
+ }
+ nodes.clear();
+ nodes.add(myDiv);
+ }
+ };
+}
+
+class MyVaadinServlet extends VaadinServlet {
+ @Override
+ protected void servletInitialized() throws ServletException {
+ super.servletInitialized();
+ getService().addSessionInitListener(new SessionInitListener() {
+ @Override
+ public void sessionInit(SessionInitEvent event)
+ throws ServiceException {
+ event.getSession().addBootstrapListener(
+ BootstrapListenerCode.listener);
+ }
+ });
+ }
+}
+
+// Or...
+
+class MyVaadinPortlet extends VaadinPortlet {
+ @Override
+ protected void portletInitialized() throws PortletException {
+ super.portletInitialized();
+ getService().addSessionInitListener(new SessionInitListener() {
+ @Override
+ public void sessionInit(SessionInitEvent event)
+ throws ServiceException {
+ event.getSession().addBootstrapListener(
+ BootstrapListenerCode.listener);
+ }
+ });
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b2/CleanupUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7b2/CleanupUI.java
new file mode 100644
index 0000000000..9e89d65811
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/minitutorials/v7b2/CleanupUI.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2012 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.tests.minitutorials.v7b2;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.ui.UI;
+
+public class CleanupUI extends UI implements UI.CleanupListener {
+ @Override
+ protected void init(VaadinRequest request) {
+ addCleanupListener(new UI.CleanupListener() {
+ @Override
+ public void cleanup(UI.CleanupEvent event) {
+ releaseSomeResources();
+ }
+ });
+
+ // ...
+ addCleanupListener(this);
+ }
+
+ private void releaseSomeResources() {
+ // ...
+ }
+
+ @Override
+ public void cleanup(UI.CleanupEvent event) {
+ // do cleanup
+ event.getUI();
+ // or equivalent:
+ UI.getCurrent();
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateConnector.java
index 93b12dbc68..a4b816e47e 100644
--- a/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateConnector.java
+++ b/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateConnector.java
@@ -27,10 +27,10 @@ public class ResourceInStateConnector extends AbstractComponentConnector {
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
super.onStateChanged(stateChangeEvent);
- String icon = getResourceUrl(ResourceInStateState.MY_ICON_RESOURCE);
+ String iconUrl = getResourceUrl("myIcon");
- if (icon != null) {
- getWidget().setUrl(icon);
+ if (iconUrl != null) {
+ getWidget().setUrl(iconUrl);
} else {
getWidget().setUrl("");
}
@@ -38,11 +38,6 @@ public class ResourceInStateConnector extends AbstractComponentConnector {
}
@Override
- public ResourceInStateState getState() {
- return (ResourceInStateState) super.getState();
- }
-
- @Override
public Image getWidget() {
return (Image) super.getWidget();
}
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateState.java b/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateState.java
deleted file mode 100644
index 728f0ba5e1..0000000000
--- a/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateState.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.vaadin.tests.widgetset.client.minitutorials.v7a2;
-
-import com.vaadin.shared.ComponentState;
-
-public class ResourceInStateState extends ComponentState {
- public static final String MY_ICON_RESOURCE = "myIcon";
-} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a3/ClientSideModule.java b/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a3/ClientSideModule.java
new file mode 100644
index 0000000000..48bd8a76fb
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a3/ClientSideModule.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2012 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.tests.widgetset.client.minitutorials.v7a3;
+
+import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+public class ClientSideModule implements EntryPoint {
+
+ @Override
+ public void onModuleLoad() {
+ final TextBox nameField = new TextBox();
+ nameField.setText("GWT User");
+ final Button button = new Button("Check");
+
+ VerticalPanel vp = new VerticalPanel();
+ vp.add(nameField);
+ vp.add(button);
+ RootPanel.get().add(vp);
+
+ button.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ if ("GWT User".equals(nameField.getText())) {
+ Window.alert("User OK");
+ } else {
+ Window.alert("Unauthorized user");
+ }
+ }
+ });
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a3/RefresherConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a3/RefresherConnector.java
new file mode 100644
index 0000000000..26fa22a667
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a3/RefresherConnector.java
@@ -0,0 +1,40 @@
+package com.vaadin.tests.widgetset.client.minitutorials.v7a3;
+
+import com.google.gwt.user.client.Timer;
+import com.vaadin.client.communication.RpcProxy;
+import com.vaadin.client.communication.StateChangeEvent;
+import com.vaadin.client.extensions.AbstractExtensionConnector;
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.tests.minitutorials.v7a3.Refresher;
+
+@Connect(Refresher.class)
+public class RefresherConnector extends AbstractExtensionConnector {
+
+ private RefresherRpc rpc = RpcProxy.create(RefresherRpc.class, this);
+
+ private Timer timer = new Timer() {
+ @Override
+ public void run() {
+ rpc.refresh();
+ }
+ };
+
+ @Override
+ public void onStateChanged(StateChangeEvent event) {
+ super.onStateChanged(event);
+ timer.cancel();
+ if (isEnabled()) {
+ timer.scheduleRepeating(getState().interval);
+ }
+ }
+
+ @Override
+ public void onUnregister() {
+ timer.cancel();
+ }
+
+ @Override
+ public RefresherState getState() {
+ return (RefresherState) super.getState();
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a3/RefresherRpc.java b/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a3/RefresherRpc.java
new file mode 100644
index 0000000000..df9c9733f7
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a3/RefresherRpc.java
@@ -0,0 +1,7 @@
+package com.vaadin.tests.widgetset.client.minitutorials.v7a3;
+
+import com.vaadin.shared.communication.ServerRpc;
+
+public interface RefresherRpc extends ServerRpc {
+ public void refresh();
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a3/RefresherState.java b/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a3/RefresherState.java
new file mode 100644
index 0000000000..769f6330a9
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a3/RefresherState.java
@@ -0,0 +1,7 @@
+package com.vaadin.tests.widgetset.client.minitutorials.v7a3;
+
+import com.vaadin.shared.communication.SharedState;
+
+public class RefresherState extends SharedState {
+ public int interval = 1000;
+} \ No newline at end of file