]> source.dussan.org Git - vaadin-framework.git/commitdiff
Add partially broken mini tutorial code for alpha 2
authorLeif Åstrand <leif@vaadin.com>
Wed, 20 Jun 2012 17:20:43 +0000 (20:20 +0300)
committerLeif Åstrand <leif@vaadin.com>
Wed, 20 Jun 2012 17:21:57 +0000 (20:21 +0300)
21 files changed:
tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateComponent.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateRoot.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponent.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponentRoot.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyPickerConnector.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyPickerWidget.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateComponent.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateRoot.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetContainer.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetcontainerRoot.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ComponentInStateState.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ComponentInStateStateConnector.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentClientRpc.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentConnector.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentServerRpc.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentState.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentWidget.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateConnector.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateState.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/VWidgetContainer.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/WidgetContainerConnector.java [new file with mode: 0644]

diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateComponent.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateComponent.java
new file mode 100644 (file)
index 0000000..78a9459
--- /dev/null
@@ -0,0 +1,26 @@
+/* 
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests.minitutorials.v7a2;
+
+import com.vaadin.tests.widgetset.client.minitutorials.v7a2.ComponentInStateState;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.Component;
+
+public class ComponentInStateComponent extends AbstractComponent {
+
+    @Override
+    public ComponentInStateState getState() {
+        return (ComponentInStateState) super.getState();
+    }
+
+    public void setOtherComponent(Component component) {
+        getState().setOtherComponent(component);
+        requestRepaint();
+    }
+
+    public Component getOtherComponent() {
+        return (Component) getState().getOtherComponent();
+    }
+}
diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateRoot.java
new file mode 100644 (file)
index 0000000..61b5f98
--- /dev/null
@@ -0,0 +1,27 @@
+package com.vaadin.tests.minitutorials.v7a2;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.terminal.WrappedRequest;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Root;
+
+/**
+ * Mini tutorial code for
+ * https://vaadin.com/wiki/-/wiki/Main/Using%20Components%
+ * 20in%20the%20shared%20state
+ * 
+ * @author Vaadin Ltd
+ * @version @VERSION@
+ * @since 7.0.0
+ */
+@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet")
+public class ComponentInStateRoot extends Root {
+    @Override
+    protected void init(WrappedRequest request) {
+        ComponentInStateComponent component = new ComponentInStateComponent();
+        component.setOtherComponent(this);
+        addComponent(component);
+        addComponent(new Label("Server-side type of other component: "
+                + component.getOtherComponent().getClass().getName()));
+    }
+}
diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponent.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponent.java
new file mode 100644 (file)
index 0000000..5c4fa9d
--- /dev/null
@@ -0,0 +1,47 @@
+/* 
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests.minitutorials.v7a2;
+
+import com.vaadin.terminal.gwt.client.MouseEventDetails;
+import com.vaadin.tests.widgetset.client.minitutorials.v7a2.MyComponentClientRpc;
+import com.vaadin.tests.widgetset.client.minitutorials.v7a2.MyComponentServerRpc;
+import com.vaadin.tests.widgetset.client.minitutorials.v7a2.MyComponentState;
+import com.vaadin.ui.AbstractComponent;
+
+public class MyComponent extends AbstractComponent {
+    private int clickCount = 0;
+
+    private MyComponentServerRpc rpc = new MyComponentServerRpc() {
+        public void clicked(MouseEventDetails mouseDetails) {
+            clickCount++;
+
+            // nag every 5:th click
+            if (clickCount % 5 == 0) {
+                getRpcProxy(MyComponentClientRpc.class).alert(
+                        "Ok, that's enough!");
+            }
+
+            setText("You have clicked " + clickCount + " times");
+        }
+    };
+
+    public MyComponent() {
+        registerRpc(rpc);
+    }
+
+    @Override
+    public MyComponentState getState() {
+        return (MyComponentState) super.getState();
+    }
+
+    public void setText(String text) {
+        getState().setText(text);
+        requestRepaint();
+    }
+
+    public String getText() {
+        return getState().getText();
+    }
+}
diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponentRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponentRoot.java
new file mode 100644 (file)
index 0000000..7779243
--- /dev/null
@@ -0,0 +1,36 @@
+/* 
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests.minitutorials.v7a2;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.terminal.WrappedRequest;
+import com.vaadin.ui.Root;
+
+/**
+ * Mini tutorial code for
+ * https://vaadin.com/wiki/-/wiki/Main/Creating%20a%20simple%20component,
+ * https://vaadin.com/wiki/-/wiki/Main/Creating%20a%20simple%20component,
+ * https://vaadin.com/wiki/-/wiki/Main/Sending%
+ * 20events%20from%20the%20client%20to%20the%20server%20using%20RPC,
+ * https://vaadin
+ * .com/wiki/-/wiki/Main/Using%20RPC%20to%20send%20events%20to%20the%20client
+ * 
+ * @author Vaadin Ltd
+ * @version @VERSION@
+ * @since 7.0.0
+ */
+@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet")
+public class MyComponentRoot extends Root {
+
+    @Override
+    protected void init(WrappedRequest request) {
+        MyComponent component = new MyComponent();
+
+        component.setText("My component text");
+
+        addComponent(component);
+    }
+
+}
\ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyPickerConnector.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyPickerConnector.java
new file mode 100644 (file)
index 0000000..ea278da
--- /dev/null
@@ -0,0 +1,61 @@
+/* 
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests.minitutorials.v7a2;
+
+import com.google.gwt.user.client.Element;
+import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector;
+import com.vaadin.terminal.gwt.client.ui.SimpleManagedLayout;
+import com.vaadin.terminal.gwt.client.ui.layout.ElementResizeEvent;
+import com.vaadin.terminal.gwt.client.ui.layout.ElementResizeListener;
+
+/**
+ * Mini tutorial code for
+ * https://vaadin.com/wiki/-/wiki/Main/Widget%20styling%20using%20only%20CSS,
+ * https
+ * ://vaadin.com/wiki/-/wiki/Main/Lightweight%20calculations%20of%20widget%20l
+ * ayout and https://vaadin.com/wiki/-/wiki/Main/Complex%20widget%20layouts
+ * 
+ * @author Vaadin Ltd
+ * @version @VERSION@
+ * @since 7.0.0
+ */
+public class MyPickerConnector extends AbstractComponentConnector implements
+        SimpleManagedLayout {
+    @Override
+    public MyPickerWidget getWidget() {
+        return (MyPickerWidget) super.getWidget();
+    }
+
+    private final ElementResizeListener listener = new ElementResizeListener() {
+        public void onElementResize(ElementResizeEvent e) {
+            int buttonWidth = getLayoutManager().getOuterWidth(e.getElement());
+            buttonWidth -= getLayoutManager().getMarginRight(e.getElement());
+            getWidget().adjustButtonSpace(buttonWidth);
+        }
+    };
+
+    @Override
+    protected void init() {
+        Element button = getWidget().getWidget(1).getElement();
+        getLayoutManager().addElementResizeListener(button, listener);
+
+        getLayoutManager().registerDependency(this, button);
+    }
+
+    @Override
+    public void onUnregister() {
+        Element button = getWidget().getWidget(1).getElement();
+        getLayoutManager().removeElementResizeListener(button, listener);
+
+        getLayoutManager().unregisterDependency(this, button);
+    }
+
+    public void layout() {
+        Element button = getWidget().getWidget(1).getElement();
+        int buttonWidth = getLayoutManager().getOuterWidth(button);
+        buttonWidth -= getLayoutManager().getMarginRight(button);
+        getWidget().adjustButtonSpace(buttonWidth);
+    }
+}
diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyPickerWidget.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyPickerWidget.java
new file mode 100644 (file)
index 0000000..213a1b9
--- /dev/null
@@ -0,0 +1,51 @@
+package com.vaadin.tests.minitutorials.v7a2;
+
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.dom.client.Style.Unit;
+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.ComplexPanel;
+import com.google.gwt.user.client.ui.PushButton;
+import com.google.gwt.user.client.ui.TextBox;
+
+public class MyPickerWidget extends ComplexPanel {
+
+    public static final String CLASSNAME = "mypicker";
+
+    private final TextBox textBox = new TextBox();
+    private final PushButton button = new PushButton("...");
+
+    public MyPickerWidget() {
+        setElement(Document.get().createDivElement());
+        setStylePrimaryName(CLASSNAME);
+
+        textBox.setStylePrimaryName(CLASSNAME + "-field");
+        button.setStylePrimaryName(CLASSNAME + "-button");
+
+        add(textBox, getElement());
+        add(button, getElement());
+
+        button.addClickHandler(new ClickHandler() {
+            public void onClick(ClickEvent event) {
+                Window.alert("Calendar picker not yet supported!");
+            }
+        });
+    }
+
+    public void setButtonText(String buttonText, boolean adjustSpace) {
+        if (buttonText == null || buttonText.length() == 0) {
+            buttonText = "...";
+        }
+        button.setText(buttonText);
+
+        if (adjustSpace) {
+            adjustButtonSpace(button.getOffsetWidth());
+        }
+    }
+
+    public void adjustButtonSpace(int width) {
+        getElement().getStyle().setPaddingRight(width, Unit.PX);
+        button.getElement().getStyle().setMarginRight(-width, Unit.PX);
+    }
+}
\ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateComponent.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateComponent.java
new file mode 100644 (file)
index 0000000..f9d4cb3
--- /dev/null
@@ -0,0 +1,30 @@
+/* 
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests.minitutorials.v7a2;
+
+import com.vaadin.terminal.Resource;
+import com.vaadin.terminal.gwt.server.ResourceReference;
+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) {
+        getState().setMyIcon(new ResourceReference(icon));
+    }
+
+    public Resource getMyIcon() {
+        ResourceReference ref = ((ResourceReference) getState().getMyIcon());
+        if (ref != null) {
+            return ref.getResource();
+        } else {
+            return null;
+        }
+    }
+}
diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateRoot.java
new file mode 100644 (file)
index 0000000..135d368
--- /dev/null
@@ -0,0 +1,32 @@
+/* 
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests.minitutorials.v7a2;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.terminal.WrappedRequest;
+import com.vaadin.ui.Root;
+
+/**
+ * Mini tutorial code for
+ * https://vaadin.com/wiki/-/wiki/Main/Using%20Resources%20
+ * in%20the%20shared%20state
+ * 
+ * @author Vaadin Ltd
+ * @version @VERSION@
+ * @since 7.0.0
+ */
+@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet")
+public class ResourceInStateRoot extends Root {
+
+    @Override
+    protected void init(WrappedRequest request) {
+        ResourceInStateComponent component = new ResourceInStateComponent();
+        component.setIcon(new ThemeResource("../runo/icons/32/calendar.png"));
+
+        addComponent(component);
+    }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetContainer.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetContainer.java
new file mode 100644 (file)
index 0000000..3c2f9a6
--- /dev/null
@@ -0,0 +1,46 @@
+package com.vaadin.tests.minitutorials.v7a2;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import com.vaadin.ui.AbstractComponentContainer;
+import com.vaadin.ui.Component;
+
+public class WidgetContainer extends AbstractComponentContainer {
+
+    List<Component> children = new ArrayList<Component>();
+
+    @Override
+    public void addComponent(Component c) {
+        children.add(c);
+        super.addComponent(c);
+        requestRepaint();
+    }
+
+    @Override
+    public void removeComponent(Component c) {
+        children.remove(c);
+        super.removeComponent(c);
+        requestRepaint();
+    }
+
+    public void replaceComponent(Component oldComponent, Component newComponent) {
+        int index = children.indexOf(oldComponent);
+        if (index != -1) {
+            children.remove(index);
+            children.add(index, newComponent);
+            fireComponentDetachEvent(oldComponent);
+            fireComponentAttachEvent(newComponent);
+            requestRepaint();
+        }
+    }
+
+    public int getComponentCount() {
+        return children.size();
+    }
+
+    public Iterator<Component> getComponentIterator() {
+        return children.iterator();
+    }
+}
\ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetcontainerRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetcontainerRoot.java
new file mode 100644 (file)
index 0000000..3b24ec4
--- /dev/null
@@ -0,0 +1,44 @@
+package com.vaadin.tests.minitutorials.v7a2;
+
+import java.util.Random;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.terminal.WrappedRequest;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Root;
+
+@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet")
+public class WidgetcontainerRoot extends Root {
+    @Override
+    public void init(WrappedRequest request) {
+        Label label = new Label("Hello Vaadin user");
+        addComponent(label);
+        final WidgetContainer widgetContainer = new WidgetContainer();
+        addComponent(widgetContainer);
+        widgetContainer.addComponent(new Label(
+                "Click the button to add components to the WidgetContainer."));
+        Button button = new Button("Add more components", new ClickListener() {
+
+            public void buttonClick(ClickEvent event) {
+                Random randomGenerator = new Random();
+                int random = randomGenerator.nextInt(3);
+                Component component;
+                if (random % 3 == 0) {
+                    component = new Label("A new label");
+                } else if (random % 3 == 1) {
+                    component = new Button("A button!");
+                } else {
+                    component = new CheckBox("A textfield");
+                }
+                widgetContainer.addComponent(component);
+            }
+        });
+        addComponent(button);
+    }
+
+}
\ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ComponentInStateState.java b/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ComponentInStateState.java
new file mode 100644 (file)
index 0000000..a5a5f50
--- /dev/null
@@ -0,0 +1,20 @@
+/* 
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests.widgetset.client.minitutorials.v7a2;
+
+import com.vaadin.terminal.gwt.client.ComponentState;
+import com.vaadin.terminal.gwt.client.Connector;
+
+public class ComponentInStateState extends ComponentState {
+    private Connector otherComponent;
+
+    public Connector getOtherComponent() {
+        return otherComponent;
+    }
+
+    public void setOtherComponent(Connector otherComponent) {
+        this.otherComponent = otherComponent;
+    }
+}
diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ComponentInStateStateConnector.java b/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ComponentInStateStateConnector.java
new file mode 100644 (file)
index 0000000..6e855f7
--- /dev/null
@@ -0,0 +1,38 @@
+/* 
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests.widgetset.client.minitutorials.v7a2;
+
+import com.google.gwt.user.client.ui.Label;
+import com.vaadin.terminal.gwt.client.ComponentConnector;
+import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
+import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector;
+import com.vaadin.terminal.gwt.client.ui.Connect;
+import com.vaadin.tests.minitutorials.v7a2.ComponentInStateComponent;
+
+@Connect(ComponentInStateComponent.class)
+public class ComponentInStateStateConnector extends AbstractComponentConnector {
+    @Override
+    public void onStateChanged(StateChangeEvent stateChangeEvent) {
+        super.onStateChanged(stateChangeEvent);
+
+        getWidget().setText(
+                "Client-side type of other component: "
+                        + getOtherComponent().getClass().getName());
+    }
+
+    public ComponentConnector getOtherComponent() {
+        return (ComponentConnector) getState().getOtherComponent();
+    }
+
+    @Override
+    public ComponentInStateState getState() {
+        return (ComponentInStateState) super.getState();
+    }
+
+    @Override
+    public Label getWidget() {
+        return (Label) super.getWidget();
+    }
+}
diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentClientRpc.java b/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentClientRpc.java
new file mode 100644 (file)
index 0000000..68e2df5
--- /dev/null
@@ -0,0 +1,9 @@
+package com.vaadin.tests.widgetset.client.minitutorials.v7a2;
+
+import com.vaadin.terminal.gwt.client.communication.ClientRpc;
+
+public interface MyComponentClientRpc extends ClientRpc {
+
+    public void alert(String message);
+
+}
\ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentConnector.java b/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentConnector.java
new file mode 100644 (file)
index 0000000..2a131c0
--- /dev/null
@@ -0,0 +1,56 @@
+package com.vaadin.tests.widgetset.client.minitutorials.v7a2;
+
+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.vaadin.terminal.gwt.client.MouseEventDetails;
+import com.vaadin.terminal.gwt.client.MouseEventDetailsBuilder;
+import com.vaadin.terminal.gwt.client.communication.RpcProxy;
+import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
+import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector;
+import com.vaadin.terminal.gwt.client.ui.Connect;
+import com.vaadin.tests.minitutorials.v7a2.MyComponent;
+
+@Connect(MyComponent.class)
+public class MyComponentConnector extends AbstractComponentConnector {
+
+    MyComponentServerRpc rpc = RpcProxy
+            .create(MyComponentServerRpc.class, this);
+
+    public MyComponentConnector() {
+        getWidget().addClickHandler(new ClickHandler() {
+            public void onClick(ClickEvent event) {
+
+                final MouseEventDetails mouseDetails = MouseEventDetailsBuilder
+                        .buildMouseEventDetails(event.getNativeEvent(),
+                                getWidget().getElement());
+
+                rpc.clicked(mouseDetails);
+            }
+        });
+        registerRpc(MyComponentClientRpc.class, new MyComponentClientRpc() {
+            public void alert(String message) {
+                Window.alert(message);
+            }
+        });
+    }
+
+    @Override
+    public MyComponentState getState() {
+        return (MyComponentState) super.getState();
+    }
+
+    @Override
+    public void onStateChanged(StateChangeEvent stateChangeEvent) {
+        super.onStateChanged(stateChangeEvent);
+
+        final String text = getState().getText();
+        getWidget().setText(text);
+    }
+
+    @Override
+    public MyComponentWidget getWidget() {
+        return (MyComponentWidget) super.getWidget();
+    }
+
+}
\ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentServerRpc.java b/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentServerRpc.java
new file mode 100644 (file)
index 0000000..7f273c2
--- /dev/null
@@ -0,0 +1,10 @@
+package com.vaadin.tests.widgetset.client.minitutorials.v7a2;
+
+import com.vaadin.terminal.gwt.client.MouseEventDetails;
+import com.vaadin.terminal.gwt.client.communication.ServerRpc;
+
+public interface MyComponentServerRpc extends ServerRpc {
+
+    public void clicked(MouseEventDetails mouseDetails);
+
+}
\ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentState.java b/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentState.java
new file mode 100644 (file)
index 0000000..a80aa7b
--- /dev/null
@@ -0,0 +1,17 @@
+package com.vaadin.tests.widgetset.client.minitutorials.v7a2;
+
+import com.vaadin.terminal.gwt.client.ComponentState;
+
+public class MyComponentState extends ComponentState {
+
+    private String text;
+
+    public String getText() {
+        return text;
+    }
+
+    public void setText(String text) {
+        this.text = text;
+    }
+
+}
\ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentWidget.java b/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentWidget.java
new file mode 100644 (file)
index 0000000..ab03d51
--- /dev/null
@@ -0,0 +1,16 @@
+/* 
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests.widgetset.client.minitutorials.v7a2;
+
+import com.google.gwt.user.client.ui.Label;
+
+public class MyComponentWidget extends Label {
+    public static final String CLASSNAME = "mycomponent";
+
+    public MyComponentWidget() {
+        setText("This is MyComponent");
+        setStyleName(CLASSNAME);
+    }
+}
diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateConnector.java b/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateConnector.java
new file mode 100644 (file)
index 0000000..f05d4a0
--- /dev/null
@@ -0,0 +1,38 @@
+/* 
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests.widgetset.client.minitutorials.v7a2;
+
+import com.google.gwt.user.client.ui.Image;
+import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
+import com.vaadin.terminal.gwt.client.communication.URLReference;
+import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector;
+import com.vaadin.terminal.gwt.client.ui.Connect;
+import com.vaadin.tests.minitutorials.v7a2.ResourceInStateComponent;
+
+@Connect(ResourceInStateComponent.class)
+public class ResourceInStateConnector extends AbstractComponentConnector {
+    @Override
+    public void onStateChanged(StateChangeEvent stateChangeEvent) {
+        super.onStateChanged(stateChangeEvent);
+
+        URLReference icon = getState().getMyIcon();
+        if (icon != null) {
+            getWidget().setUrl(icon.getURL());
+        } else {
+            getWidget().setUrl("");
+        }
+
+    }
+
+    @Override
+    public ResourceInStateState getState() {
+        return (ResourceInStateState) super.getState();
+    }
+
+    @Override
+    public Image getWidget() {
+        return (Image) super.getWidget();
+    }
+}
diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateState.java b/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/ResourceInStateState.java
new file mode 100644 (file)
index 0000000..7c124e7
--- /dev/null
@@ -0,0 +1,17 @@
+package com.vaadin.tests.widgetset.client.minitutorials.v7a2;
+
+import com.vaadin.terminal.gwt.client.ComponentState;
+import com.vaadin.terminal.gwt.client.communication.URLReference;
+
+public class ResourceInStateState extends ComponentState {
+
+    private URLReference myIcon;
+
+    public URLReference getMyIcon() {
+        return myIcon;
+    }
+
+    public void setMyIcon(URLReference icon) {
+        myIcon = icon;
+    }
+}
\ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/VWidgetContainer.java b/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/VWidgetContainer.java
new file mode 100644 (file)
index 0000000..6ec0a6d
--- /dev/null
@@ -0,0 +1,12 @@
+package com.vaadin.tests.widgetset.client.minitutorials.v7a2;
+
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+public class VWidgetContainer extends VerticalPanel {
+
+    public static final String CLASSNAME = "v-widgetcontainer";
+
+    public VWidgetContainer() {
+        setStyleName(CLASSNAME);
+    }
+}
\ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/WidgetContainerConnector.java b/tests/testbench/com/vaadin/tests/widgetset/client/minitutorials/v7a2/WidgetContainerConnector.java
new file mode 100644 (file)
index 0000000..dab0f6e
--- /dev/null
@@ -0,0 +1,35 @@
+package com.vaadin.tests.widgetset.client.minitutorials.v7a2;
+
+import java.util.List;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.terminal.gwt.client.ComponentConnector;
+import com.vaadin.terminal.gwt.client.ConnectorHierarchyChangeEvent;
+import com.vaadin.terminal.gwt.client.ui.AbstractComponentContainerConnector;
+import com.vaadin.terminal.gwt.client.ui.Connect;
+import com.vaadin.tests.minitutorials.v7a2.WidgetContainer;
+
+@Connect(WidgetContainer.class)
+public class WidgetContainerConnector extends
+        AbstractComponentContainerConnector {
+
+    @Override
+    public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) {
+        List<ComponentConnector> children = getChildren();
+        VWidgetContainer widget = (VWidgetContainer) getWidget();
+        widget.clear();
+        for (ComponentConnector connector : children) {
+            widget.add(connector.getWidget());
+        }
+        super.onConnectorHierarchyChange(event);
+    }
+
+    @Override
+    protected Widget createWidget() {
+        return GWT.create(VWidgetContainer.class);
+    }
+
+    public void updateCaption(ComponentConnector connector) {
+    }
+}
\ No newline at end of file