]> source.dussan.org Git - vaadin-framework.git/commitdiff
CRLF -> LF 70/570/1
authorArtur Signell <artur@vaadin.com>
Fri, 4 Jan 2013 09:03:56 +0000 (11:03 +0200)
committerArtur Signell <artur@vaadin.com>
Fri, 4 Jan 2013 09:03:56 +0000 (11:03 +0200)
Change-Id: I864e3ad465539a5b7fee212390a723773f6930ac

16 files changed:
server/src/com/vaadin/server/SystemMessagesInfo.java
uitest/src/com/vaadin/tests/applicationservlet/SystemMessagesTest.java
uitest/src/com/vaadin/tests/components/tabsheet/TabsheetShouldUpdateHeight.java
uitest/src/com/vaadin/tests/components/ui/EmptyWindow.java
uitest/src/com/vaadin/tests/components/ui/WindowWithLabel.java
uitest/src/com/vaadin/tests/errorhandler/ErrorHandlers.java
uitest/src/com/vaadin/tests/minitutorials/v7b9/CountView.java
uitest/src/com/vaadin/tests/minitutorials/v7b9/LoginView.java
uitest/src/com/vaadin/tests/minitutorials/v7b9/MainView.java
uitest/src/com/vaadin/tests/minitutorials/v7b9/MainViewEarlierExample.java
uitest/src/com/vaadin/tests/minitutorials/v7b9/MainView__LastNavigatorExample.java
uitest/src/com/vaadin/tests/minitutorials/v7b9/MessageView.java
uitest/src/com/vaadin/tests/minitutorials/v7b9/NavigationtestUI.java
uitest/src/com/vaadin/tests/minitutorials/v7b9/SassyUI.java
uitest/src/com/vaadin/tests/minitutorials/v7b9/SecretView.java
uitest/src/com/vaadin/tests/minitutorials/v7b9/SettingsView.java

index 30a6e82a90bb509bcd09ed508a5968e223deb07e..9a161f5f7a21d0127c66f5ece523c628bbfb127d 100644 (file)
@@ -1,53 +1,53 @@
-package com.vaadin.server;\r
-\r
-import java.io.Serializable;\r
-import java.util.Locale;\r
-\r
-public class SystemMessagesInfo implements Serializable {\r
-\r
-    private Locale locale;\r
-    private VaadinRequest request;\r
-    private VaadinService service;\r
-\r
-    /**\r
-     * The locale of the UI related to the {@link SystemMessages} request.\r
-     * \r
-     * @return The Locale or null if the locale is not known\r
-     */\r
-    public Locale getLocale() {\r
-        return locale;\r
-    }\r
-\r
-    public void setLocale(Locale locale) {\r
-        this.locale = locale;\r
-    }\r
-\r
-    /**\r
-     * Gets the request currently in progress.\r
-     * \r
-     * @return The request currently in progress or null if no request is in\r
-     *         progress.\r
-     */\r
-    public VaadinRequest getRequest() {\r
-        return request;\r
-    }\r
-\r
-    public void setRequest(VaadinRequest request) {\r
-        this.request = request;\r
-    }\r
-\r
-    /**\r
-     * Returns the service this SystemMessages request comes from.\r
-     * \r
-     * @return The service which triggered this request or null of not triggered\r
-     *         from a service.\r
-     */\r
-    public VaadinService getService() {\r
-        return service;\r
-    }\r
-\r
-    public void setService(VaadinService service) {\r
-        this.service = service;\r
-    }\r
-\r
-}\r
+package com.vaadin.server;
+
+import java.io.Serializable;
+import java.util.Locale;
+
+public class SystemMessagesInfo implements Serializable {
+
+    private Locale locale;
+    private VaadinRequest request;
+    private VaadinService service;
+
+    /**
+     * The locale of the UI related to the {@link SystemMessages} request.
+     * 
+     * @return The Locale or null if the locale is not known
+     */
+    public Locale getLocale() {
+        return locale;
+    }
+
+    public void setLocale(Locale locale) {
+        this.locale = locale;
+    }
+
+    /**
+     * Gets the request currently in progress.
+     * 
+     * @return The request currently in progress or null if no request is in
+     *         progress.
+     */
+    public VaadinRequest getRequest() {
+        return request;
+    }
+
+    public void setRequest(VaadinRequest request) {
+        this.request = request;
+    }
+
+    /**
+     * Returns the service this SystemMessages request comes from.
+     * 
+     * @return The service which triggered this request or null of not triggered
+     *         from a service.
+     */
+    public VaadinService getService() {
+        return service;
+    }
+
+    public void setService(VaadinService service) {
+        this.service = service;
+    }
+
+}
index c1db3cea051c10d9eaafbabc83aee5dd68e746dc..047e4657227e4d94fb02f7bfcc9c3ce64db4159d 100644 (file)
@@ -1,91 +1,91 @@
-package com.vaadin.tests.applicationservlet;\r
-\r
-import java.util.Locale;\r
-\r
-import com.vaadin.data.Property.ValueChangeEvent;\r
-import com.vaadin.data.Property.ValueChangeListener;\r
-import com.vaadin.server.CustomizedSystemMessages;\r
-import com.vaadin.server.SystemMessages;\r
-import com.vaadin.server.SystemMessagesInfo;\r
-import com.vaadin.server.SystemMessagesProvider;\r
-import com.vaadin.server.VaadinRequest;\r
-import com.vaadin.tests.components.AbstractTestUI;\r
-import com.vaadin.ui.Button;\r
-import com.vaadin.ui.Button.ClickEvent;\r
-import com.vaadin.ui.Button.ClickListener;\r
-import com.vaadin.ui.NativeSelect;\r
-\r
-public class SystemMessagesTest extends AbstractTestUI {\r
-\r
-    public class MyButton extends Button {\r
-        private boolean fail = false;\r
-\r
-        @Override\r
-        public void beforeClientResponse(boolean initial) {\r
-            super.beforeClientResponse(initial);\r
-            if (fail) {\r
-                throw new RuntimeException("Failed on purpose");\r
-            }\r
-        }\r
-\r
-    }\r
-\r
-    @Override\r
-    protected void setup(VaadinRequest request) {\r
-        final NativeSelect localeSelect = new NativeSelect("UI locale");\r
-        localeSelect.setImmediate(true);\r
-        localeSelect.addItem(new Locale("en", "US"));\r
-        localeSelect.addItem(new Locale("fi", "FI"));\r
-        localeSelect.addItem(Locale.GERMANY);\r
-        localeSelect.addValueChangeListener(new ValueChangeListener() {\r
-\r
-            @Override\r
-            public void valueChange(ValueChangeEvent event) {\r
-                setLocale((Locale) localeSelect.getValue());\r
-                getSession().getService().setSystemMessagesProvider(\r
-                        new SystemMessagesProvider() {\r
-\r
-                            @Override\r
-                            public SystemMessages getSystemMessages(\r
-                                    SystemMessagesInfo systemMessagesInfo) {\r
-                                CustomizedSystemMessages csm = new CustomizedSystemMessages();\r
-                                // csm.setInternalErrorCaption("Request query string: "\r
-                                // + ((VaadinServletRequest) systemMessagesInfo\r
-                                // .getRequest()).getQueryString());\r
-                                csm.setInternalErrorMessage("MessagesInfo locale: "\r
-                                        + systemMessagesInfo.getLocale());\r
-                                return csm;\r
-\r
-                            }\r
-                        });\r
-            }\r
-        });\r
-        localeSelect.setValue(new Locale("fi", "FI"));\r
-        addComponent(localeSelect);\r
-        final MyButton failButton = new MyButton();\r
-        failButton.setCaption("Generate server side error");\r
-        failButton.addClickListener(new ClickListener() {\r
-\r
-            @Override\r
-            public void buttonClick(ClickEvent event) {\r
-                failButton.fail = true;\r
-                failButton.markAsDirty();\r
-            }\r
-        });\r
-        addComponent(failButton);\r
-\r
-    }\r
-\r
-    @Override\r
-    protected String getTestDescription() {\r
-        // TODO Auto-generated method stub\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-    protected Integer getTicketNumber() {\r
-        // TODO Auto-generated method stub\r
-        return null;\r
-    }\r
-\r
-}\r
+package com.vaadin.tests.applicationservlet;
+
+import java.util.Locale;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.server.CustomizedSystemMessages;
+import com.vaadin.server.SystemMessages;
+import com.vaadin.server.SystemMessagesInfo;
+import com.vaadin.server.SystemMessagesProvider;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.NativeSelect;
+
+public class SystemMessagesTest extends AbstractTestUI {
+
+    public class MyButton extends Button {
+        private boolean fail = false;
+
+        @Override
+        public void beforeClientResponse(boolean initial) {
+            super.beforeClientResponse(initial);
+            if (fail) {
+                throw new RuntimeException("Failed on purpose");
+            }
+        }
+
+    }
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        final NativeSelect localeSelect = new NativeSelect("UI locale");
+        localeSelect.setImmediate(true);
+        localeSelect.addItem(new Locale("en", "US"));
+        localeSelect.addItem(new Locale("fi", "FI"));
+        localeSelect.addItem(Locale.GERMANY);
+        localeSelect.addValueChangeListener(new ValueChangeListener() {
+
+            @Override
+            public void valueChange(ValueChangeEvent event) {
+                setLocale((Locale) localeSelect.getValue());
+                getSession().getService().setSystemMessagesProvider(
+                        new SystemMessagesProvider() {
+
+                            @Override
+                            public SystemMessages getSystemMessages(
+                                    SystemMessagesInfo systemMessagesInfo) {
+                                CustomizedSystemMessages csm = new CustomizedSystemMessages();
+                                // csm.setInternalErrorCaption("Request query string: "
+                                // + ((VaadinServletRequest) systemMessagesInfo
+                                // .getRequest()).getQueryString());
+                                csm.setInternalErrorMessage("MessagesInfo locale: "
+                                        + systemMessagesInfo.getLocale());
+                                return csm;
+
+                            }
+                        });
+            }
+        });
+        localeSelect.setValue(new Locale("fi", "FI"));
+        addComponent(localeSelect);
+        final MyButton failButton = new MyButton();
+        failButton.setCaption("Generate server side error");
+        failButton.addClickListener(new ClickListener() {
+
+            @Override
+            public void buttonClick(ClickEvent event) {
+                failButton.fail = true;
+                failButton.markAsDirty();
+            }
+        });
+        addComponent(failButton);
+
+    }
+
+    @Override
+    protected String getTestDescription() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}
index f1a53eca60e4b4c52ccd9e9c11e83cd65d73f192..5271f467dcb64a3c893774e5e79cbcf670d22677 100644 (file)
@@ -1,60 +1,60 @@
-package com.vaadin.tests.components.tabsheet;\r
-\r
-import com.vaadin.tests.components.TestBase;\r
-import com.vaadin.ui.Button;\r
-import com.vaadin.ui.Button.ClickEvent;\r
-import com.vaadin.ui.Component;\r
-import com.vaadin.ui.TabSheet;\r
-import com.vaadin.ui.TextField;\r
-import com.vaadin.ui.VerticalLayout;\r
-\r
-public class TabsheetShouldUpdateHeight extends TestBase {\r
-\r
-    @Override\r
-    public void setup() {\r
-        final TabSheet tabsOuter = new TabSheet();\r
-        final TabSheet tabsInner = new TabSheet();\r
-\r
-        final Component tab2;\r
-\r
-        tabsInner.addTab(tab2 = getLayoutWithComponents(6, "tab2"), "Tab 2");\r
-        tabsInner.addTab(getLayoutWithComponents(8, "tab3"), "Tab 3");\r
-\r
-        tabsOuter.addTab(tabsInner, "Inner tabs");\r
-        tabsOuter.addTab(getLayoutWithComponents(10, "tab1"), "Tab 1");\r
-\r
-        final Button btnSwitch = new Button("switch to Tab2",\r
-                new Button.ClickListener() {\r
-\r
-                    @Override\r
-                    public void buttonClick(final ClickEvent inEvent) {\r
-                        tabsOuter.setSelectedTab(tabsInner);\r
-                        tabsInner.setSelectedTab(tab2);\r
-                    }\r
-                });\r
-\r
-        addComponent(tabsOuter);\r
-        addComponent(btnSwitch);\r
-    }\r
-\r
-    private VerticalLayout getLayoutWithComponents(final int inAmount, String id) {\r
-        final VerticalLayout v = new VerticalLayout();\r
-        v.setDebugId(id);\r
-        v.setSpacing(true);\r
-        v.setMargin(true);\r
-        for (int i = 0; i < inAmount; i++) {\r
-            v.addComponent(new TextField("Text field:"));\r
-        }\r
-        return v;\r
-    }\r
-\r
-    @Override\r
-    protected String getDescription() {\r
-        return "click with mouse first on tab 3 and then on tab 1. now click on the button 'switch to tab2'. then click on tab 3 again and the scrollbars appear";\r
-    }\r
-\r
-    @Override\r
-    protected Integer getTicketNumber() {\r
-        return 9275;\r
-    }\r
+package com.vaadin.tests.components.tabsheet;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class TabsheetShouldUpdateHeight extends TestBase {
+
+    @Override
+    public void setup() {
+        final TabSheet tabsOuter = new TabSheet();
+        final TabSheet tabsInner = new TabSheet();
+
+        final Component tab2;
+
+        tabsInner.addTab(tab2 = getLayoutWithComponents(6, "tab2"), "Tab 2");
+        tabsInner.addTab(getLayoutWithComponents(8, "tab3"), "Tab 3");
+
+        tabsOuter.addTab(tabsInner, "Inner tabs");
+        tabsOuter.addTab(getLayoutWithComponents(10, "tab1"), "Tab 1");
+
+        final Button btnSwitch = new Button("switch to Tab2",
+                new Button.ClickListener() {
+
+                    @Override
+                    public void buttonClick(final ClickEvent inEvent) {
+                        tabsOuter.setSelectedTab(tabsInner);
+                        tabsInner.setSelectedTab(tab2);
+                    }
+                });
+
+        addComponent(tabsOuter);
+        addComponent(btnSwitch);
+    }
+
+    private VerticalLayout getLayoutWithComponents(final int inAmount, String id) {
+        final VerticalLayout v = new VerticalLayout();
+        v.setDebugId(id);
+        v.setSpacing(true);
+        v.setMargin(true);
+        for (int i = 0; i < inAmount; i++) {
+            v.addComponent(new TextField("Text field:"));
+        }
+        return v;
+    }
+
+    @Override
+    protected String getDescription() {
+        return "click with mouse first on tab 3 and then on tab 1. now click on the button 'switch to tab2'. then click on tab 3 again and the scrollbars appear";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 9275;
+    }
 }
\ No newline at end of file
index c3975921dfb5dfeb2cd3f6ae06a0ae5039094ae1..07ce8c3ff839c2a45e840c82f2959db77d2a9814 100644 (file)
@@ -1,26 +1,26 @@
-package com.vaadin.tests.components.ui;\r
-\r
-import com.vaadin.server.VaadinRequest;\r
-import com.vaadin.tests.components.AbstractTestUI;\r
-import com.vaadin.ui.Label;\r
-import com.vaadin.ui.Window;\r
-\r
-public class EmptyWindow extends AbstractTestUI {\r
-\r
-    @Override\r
-    protected void setup(VaadinRequest request) {\r
-        addWindow(new Window("My empty window"));\r
-        setContent(new Label("UI"));\r
-    }\r
-\r
-    @Override\r
-    protected String getTestDescription() {\r
-        return "There should be an empty window on the screen. Currently it should have the min width defined in VWindow";\r
-    }\r
-\r
-    @Override\r
-    protected Integer getTicketNumber() {\r
-        return 10325;\r
-    }\r
-\r
-}\r
+package com.vaadin.tests.components.ui;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Window;
+
+public class EmptyWindow extends AbstractTestUI {
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        addWindow(new Window("My empty window"));
+        setContent(new Label("UI"));
+    }
+
+    @Override
+    protected String getTestDescription() {
+        return "There should be an empty window on the screen. Currently it should have the min width defined in VWindow";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 10325;
+    }
+
+}
index 994c0692e052bf3bfae537ec220d2afcad44459c..790ff00e60dd880cbfb52e8cbb81d5236a489c4d 100644 (file)
@@ -1,27 +1,27 @@
-package com.vaadin.tests.components.ui;\r
-\r
-import com.vaadin.server.VaadinRequest;\r
-import com.vaadin.tests.components.AbstractTestUI;\r
-import com.vaadin.ui.Label;\r
-import com.vaadin.ui.Window;\r
-\r
-public class WindowWithLabel extends AbstractTestUI {\r
-\r
-    @Override\r
-    protected void setup(VaadinRequest request) {\r
-        setContent(new Label("UI"));\r
-        Window window = new Window("A window");\r
-        addWindow(window);\r
-    }\r
-\r
-    @Override\r
-    protected String getTestDescription() {\r
-        return "Resize the window. It should work.";\r
-    }\r
-\r
-    @Override\r
-    protected Integer getTicketNumber() {\r
-        return 10375;\r
-    }\r
-\r
-}\r
+package com.vaadin.tests.components.ui;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Window;
+
+public class WindowWithLabel extends AbstractTestUI {
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        setContent(new Label("UI"));
+        Window window = new Window("A window");
+        addWindow(window);
+    }
+
+    @Override
+    protected String getTestDescription() {
+        return "Resize the window. It should work.";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 10375;
+    }
+
+}
index 2a15dc02c8cb23c93281c6e2edc20da48581df79..a123af0f7dae5ffb9e8eb5d7b5ad6a008ca57cd7 100644 (file)
-package com.vaadin.tests.errorhandler;\r
-\r
-import java.lang.reflect.InvocationTargetException;\r
-\r
-import com.vaadin.event.ListenerMethod.MethodException;\r
-import com.vaadin.server.DefaultErrorHandler;\r
-import com.vaadin.server.ErrorHandler;\r
-import com.vaadin.server.ServerRpcManager.RpcInvocationException;\r
-import com.vaadin.server.VaadinRequest;\r
-import com.vaadin.tests.components.AbstractTestUI;\r
-import com.vaadin.ui.Button;\r
-import com.vaadin.ui.Button.ClickEvent;\r
-import com.vaadin.ui.Button.ClickListener;\r
-import com.vaadin.ui.Component;\r
-import com.vaadin.ui.Label;\r
-import com.vaadin.ui.Notification;\r
-import com.vaadin.ui.Notification.Type;\r
-import com.vaadin.ui.VerticalLayout;\r
-\r
-public class ErrorHandlers extends AbstractTestUI {\r
-\r
-    public static class NotificationErrorHandler implements ErrorHandler {\r
-\r
-        @Override\r
-        public void error(com.vaadin.server.ErrorEvent event) {\r
-            Notification.show(getErrorMessage(event), Type.ERROR_MESSAGE);\r
-        }\r
-\r
-    }\r
-\r
-    @Override\r
-    protected void setup(VaadinRequest request) {\r
-        addComponent(runtimeExceptionOnClick(new Button("Standard button")));\r
-        addComponent(npeOnClick(new Button("Standard button with NPE")));\r
-        Button customErrorButton = notificationErrorHandler(new Button(\r
-                "Button with notification error handler"));\r
-        addComponent(runtimeExceptionOnClick(customErrorButton));\r
-\r
-        final VerticalLayout layoutWithErrorHandler = new VerticalLayout(\r
-                runtimeExceptionOnClick(new Button("Error handler on parent")));\r
-        ErrorHandler e = new ErrorHandler() {\r
-\r
-            @Override\r
-            public void error(com.vaadin.server.ErrorEvent event) {\r
-                layoutWithErrorHandler.addComponent(new Label("Layout error: "\r
-                        + getErrorMessage(event)));\r
-            }\r
-\r
-        };\r
-        layoutWithErrorHandler.setErrorHandler(e);\r
-        layoutWithErrorHandler\r
-                .addComponent(notificationErrorHandler(npeOnClick(new Button(\r
-                        "Error handler on button and parent"))));\r
-        addComponent(layoutWithErrorHandler);\r
-    }\r
-\r
-    private Button notificationErrorHandler(Button button) {\r
-        button.setErrorHandler(new NotificationErrorHandler());\r
-        return button;\r
-    }\r
-\r
-    protected static String getErrorMessage(com.vaadin.server.ErrorEvent event) {\r
-        Component c = DefaultErrorHandler.findAbstractComponent(event);\r
-        String errorMsg = "Error: '" + getMessage(event) + "' in ";\r
-        errorMsg += c.getClass().getSimpleName() + " with caption '"\r
-                + c.getCaption() + "'";\r
-        return errorMsg;\r
-    }\r
-\r
-    private static String getMessage(com.vaadin.server.ErrorEvent event) {\r
-        Throwable e = getUserCodeException(event);\r
-        if (e.getMessage() != null) {\r
-            return e.getMessage();\r
-        } else {\r
-            return e.getClass().getSimpleName();\r
-        }\r
-    }\r
-\r
-    private static Throwable getUserCodeException(\r
-            com.vaadin.server.ErrorEvent event) {\r
-        Throwable t = event.getThrowable();\r
-        if (t instanceof RpcInvocationException) {\r
-            t = t.getCause();\r
-        }\r
-        if (t instanceof InvocationTargetException) {\r
-            t = t.getCause();\r
-        }\r
-        if (t instanceof MethodException) {\r
-            t = t.getCause();\r
-        }\r
-\r
-        return t;\r
-\r
-    }\r
-\r
-    private Button runtimeExceptionOnClick(Button customErrorButton) {\r
-        customErrorButton.setCaption("RE: " + customErrorButton.getCaption());\r
-\r
-        customErrorButton.addClickListener(new ClickListener() {\r
-\r
-            @Override\r
-            public void buttonClick(ClickEvent event) {\r
-                throw new RuntimeException("Fail in click event");\r
-            }\r
-        });\r
-        return customErrorButton;\r
-    }\r
-\r
-    private Button npeOnClick(Button customErrorButton) {\r
-        customErrorButton.setCaption("NPE: " + customErrorButton.getCaption());\r
-        customErrorButton.addClickListener(new ClickListener() {\r
-\r
-            @Override\r
-            public void buttonClick(ClickEvent event) {\r
-                Integer i = null;\r
-                i += 2;\r
-            }\r
-        });\r
-        return customErrorButton;\r
-    }\r
-\r
-    @Override\r
-    protected String getTestDescription() {\r
-        // TODO Auto-generated method stub\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-    protected Integer getTicketNumber() {\r
-        // TODO Auto-generated method stub\r
-        return null;\r
-    }\r
-\r
-}\r
+package com.vaadin.tests.errorhandler;
+
+import java.lang.reflect.InvocationTargetException;
+
+import com.vaadin.event.ListenerMethod.MethodException;
+import com.vaadin.server.DefaultErrorHandler;
+import com.vaadin.server.ErrorHandler;
+import com.vaadin.server.ServerRpcManager.RpcInvocationException;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Notification;
+import com.vaadin.ui.Notification.Type;
+import com.vaadin.ui.VerticalLayout;
+
+public class ErrorHandlers extends AbstractTestUI {
+
+    public static class NotificationErrorHandler implements ErrorHandler {
+
+        @Override
+        public void error(com.vaadin.server.ErrorEvent event) {
+            Notification.show(getErrorMessage(event), Type.ERROR_MESSAGE);
+        }
+
+    }
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        addComponent(runtimeExceptionOnClick(new Button("Standard button")));
+        addComponent(npeOnClick(new Button("Standard button with NPE")));
+        Button customErrorButton = notificationErrorHandler(new Button(
+                "Button with notification error handler"));
+        addComponent(runtimeExceptionOnClick(customErrorButton));
+
+        final VerticalLayout layoutWithErrorHandler = new VerticalLayout(
+                runtimeExceptionOnClick(new Button("Error handler on parent")));
+        ErrorHandler e = new ErrorHandler() {
+
+            @Override
+            public void error(com.vaadin.server.ErrorEvent event) {
+                layoutWithErrorHandler.addComponent(new Label("Layout error: "
+                        + getErrorMessage(event)));
+            }
+
+        };
+        layoutWithErrorHandler.setErrorHandler(e);
+        layoutWithErrorHandler
+                .addComponent(notificationErrorHandler(npeOnClick(new Button(
+                        "Error handler on button and parent"))));
+        addComponent(layoutWithErrorHandler);
+    }
+
+    private Button notificationErrorHandler(Button button) {
+        button.setErrorHandler(new NotificationErrorHandler());
+        return button;
+    }
+
+    protected static String getErrorMessage(com.vaadin.server.ErrorEvent event) {
+        Component c = DefaultErrorHandler.findAbstractComponent(event);
+        String errorMsg = "Error: '" + getMessage(event) + "' in ";
+        errorMsg += c.getClass().getSimpleName() + " with caption '"
+                + c.getCaption() + "'";
+        return errorMsg;
+    }
+
+    private static String getMessage(com.vaadin.server.ErrorEvent event) {
+        Throwable e = getUserCodeException(event);
+        if (e.getMessage() != null) {
+            return e.getMessage();
+        } else {
+            return e.getClass().getSimpleName();
+        }
+    }
+
+    private static Throwable getUserCodeException(
+            com.vaadin.server.ErrorEvent event) {
+        Throwable t = event.getThrowable();
+        if (t instanceof RpcInvocationException) {
+            t = t.getCause();
+        }
+        if (t instanceof InvocationTargetException) {
+            t = t.getCause();
+        }
+        if (t instanceof MethodException) {
+            t = t.getCause();
+        }
+
+        return t;
+
+    }
+
+    private Button runtimeExceptionOnClick(Button customErrorButton) {
+        customErrorButton.setCaption("RE: " + customErrorButton.getCaption());
+
+        customErrorButton.addClickListener(new ClickListener() {
+
+            @Override
+            public void buttonClick(ClickEvent event) {
+                throw new RuntimeException("Fail in click event");
+            }
+        });
+        return customErrorButton;
+    }
+
+    private Button npeOnClick(Button customErrorButton) {
+        customErrorButton.setCaption("NPE: " + customErrorButton.getCaption());
+        customErrorButton.addClickListener(new ClickListener() {
+
+            @Override
+            public void buttonClick(ClickEvent event) {
+                Integer i = null;
+                i += 2;
+            }
+        });
+        return customErrorButton;
+    }
+
+    @Override
+    protected String getTestDescription() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}
index 6e4b2d790d5a057b41821dc1feb7d34fd7f35b0d..7aaf810355a6a85a1562fce8c5869d271a6730ad 100644 (file)
@@ -1,21 +1,21 @@
-package com.vaadin.tests.minitutorials.v7b9;\r
-\r
-import com.vaadin.navigator.View;\r
-import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;\r
-import com.vaadin.ui.Label;\r
-import com.vaadin.ui.Panel;\r
-\r
-public class CountView extends Panel implements View {\r
-    public static final String NAME = "count";\r
-\r
-    private static int count = 1;\r
-\r
-    public CountView() {\r
-        setContent(new Label("Created: " + count++));\r
-    }\r
-\r
-    public void enter(ViewChangeEvent event) {\r
-\r
-    }\r
-\r
+package com.vaadin.tests.minitutorials.v7b9;
+
+import com.vaadin.navigator.View;
+import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+
+public class CountView extends Panel implements View {
+    public static final String NAME = "count";
+
+    private static int count = 1;
+
+    public CountView() {
+        setContent(new Label("Created: " + count++));
+    }
+
+    public void enter(ViewChangeEvent event) {
+
+    }
+
 }
\ No newline at end of file
index a0cb6bacba4895e36ab5ccc306ed9d2c49b5fce5..3aa3e42a5831684ada3221eabd41cda33de651b1 100644 (file)
@@ -1,52 +1,52 @@
-package com.vaadin.tests.minitutorials.v7b9;\r
-\r
-import com.vaadin.navigator.Navigator;\r
-import com.vaadin.navigator.View;\r
-import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;\r
-import com.vaadin.ui.Button;\r
-import com.vaadin.ui.Button.ClickEvent;\r
-import com.vaadin.ui.Layout;\r
-import com.vaadin.ui.Notification;\r
-import com.vaadin.ui.Panel;\r
-import com.vaadin.ui.PasswordField;\r
-import com.vaadin.ui.TextField;\r
-import com.vaadin.ui.UI;\r
-import com.vaadin.ui.VerticalLayout;\r
-\r
-public class LoginView extends Panel implements View {\r
-\r
-    public static final String NAME = "login";\r
-\r
-    public LoginView(final Navigator navigator,\r
-            final String fragmentAndParameters) {\r
-        Layout layout = new VerticalLayout();\r
-\r
-        final TextField email = new TextField("Email");\r
-        layout.addComponent(email);\r
-\r
-        final PasswordField password = new PasswordField("Password");\r
-        layout.addComponent(password);\r
-\r
-        final Button login = new Button("Login", new Button.ClickListener() {\r
-            public void buttonClick(ClickEvent event) {\r
-                Notification.show("Ok, let's pretend you're " + email);\r
-\r
-                // indicate the user is logged in\r
-                ((NavigationtestUI) UI.getCurrent()).setLoggedInUser(email\r
-                        .getValue());\r
-\r
-                // navigate back to the intended place\r
-                navigator.navigateTo(fragmentAndParameters);\r
-            }\r
-        });\r
-        layout.addComponent(login);\r
-        setContent(layout);\r
-\r
-    }\r
-\r
-    @Override\r
-    public void enter(ViewChangeEvent event) {\r
-        // TODO Auto-generated method stub\r
-\r
-    }\r
-}\r
+package com.vaadin.tests.minitutorials.v7b9;
+
+import com.vaadin.navigator.Navigator;
+import com.vaadin.navigator.View;
+import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Notification;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.PasswordField;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+
+public class LoginView extends Panel implements View {
+
+    public static final String NAME = "login";
+
+    public LoginView(final Navigator navigator,
+            final String fragmentAndParameters) {
+        Layout layout = new VerticalLayout();
+
+        final TextField email = new TextField("Email");
+        layout.addComponent(email);
+
+        final PasswordField password = new PasswordField("Password");
+        layout.addComponent(password);
+
+        final Button login = new Button("Login", new Button.ClickListener() {
+            public void buttonClick(ClickEvent event) {
+                Notification.show("Ok, let's pretend you're " + email);
+
+                // indicate the user is logged in
+                ((NavigationtestUI) UI.getCurrent()).setLoggedInUser(email
+                        .getValue());
+
+                // navigate back to the intended place
+                navigator.navigateTo(fragmentAndParameters);
+            }
+        });
+        layout.addComponent(login);
+        setContent(layout);
+
+    }
+
+    @Override
+    public void enter(ViewChangeEvent event) {
+        // TODO Auto-generated method stub
+
+    }
+}
index c08803e549b2fe78f6670879481c38623e1da9e0..3a1a685bbe699c41a330a45d85026fc7315794fa 100644 (file)
@@ -1,61 +1,61 @@
-package com.vaadin.tests.minitutorials.v7b9;\r
-\r
-import com.vaadin.navigator.Navigator;\r
-import com.vaadin.navigator.View;\r
-import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;\r
-import com.vaadin.server.ExternalResource;\r
-import com.vaadin.ui.Button;\r
-import com.vaadin.ui.Button.ClickEvent;\r
-import com.vaadin.ui.Link;\r
-import com.vaadin.ui.Panel;\r
-import com.vaadin.ui.UI;\r
-import com.vaadin.ui.VerticalLayout;\r
-\r
-public class MainView extends Panel implements View {\r
-\r
-    public static final String NAME = "";\r
-\r
-    private Button logOut;\r
-\r
-    public MainView(final Navigator navigator) {\r
-\r
-        VerticalLayout layout = new VerticalLayout();\r
-\r
-        Link lnk = new Link("Count",\r
-                new ExternalResource("#!" + CountView.NAME));\r
-        layout.addComponent(lnk);\r
-\r
-        lnk = new Link("Message: Hello", new ExternalResource("#!"\r
-                + MessageView.NAME + "/Hello"));\r
-        layout.addComponent(lnk);\r
-\r
-        lnk = new Link("Message: Bye", new ExternalResource("#!"\r
-                + MessageView.NAME + "/Bye/Goodbye"));\r
-        layout.addComponent(lnk);\r
-\r
-        lnk = new Link("Private message: Secret", new ExternalResource("#!"\r
-                + SecretView.NAME + "/Secret"));\r
-        layout.addComponent(lnk);\r
-\r
-        lnk = new Link("Private message: Topsecret", new ExternalResource("#!"\r
-                + SecretView.NAME + "/Topsecret"));\r
-        layout.addComponent(lnk);\r
-\r
-        logOut = new Button("Logout", new Button.ClickListener() {\r
-            public void buttonClick(ClickEvent event) {\r
-\r
-                ((NavigationtestUI) UI.getCurrent()).setLoggedInUser(null);\r
-                logOut.setCaption("Login");\r
-                navigator.navigateTo(LoginView.NAME);\r
-\r
-            }\r
-        });\r
-        layout.addComponent(logOut);\r
-        setContent(layout);\r
-    }\r
-\r
-    @Override\r
-    public void enter(ViewChangeEvent event) {\r
-\r
-    }\r
+package com.vaadin.tests.minitutorials.v7b9;
+
+import com.vaadin.navigator.Navigator;
+import com.vaadin.navigator.View;
+import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
+import com.vaadin.server.ExternalResource;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Link;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+
+public class MainView extends Panel implements View {
+
+    public static final String NAME = "";
+
+    private Button logOut;
+
+    public MainView(final Navigator navigator) {
+
+        VerticalLayout layout = new VerticalLayout();
+
+        Link lnk = new Link("Count",
+                new ExternalResource("#!" + CountView.NAME));
+        layout.addComponent(lnk);
+
+        lnk = new Link("Message: Hello", new ExternalResource("#!"
+                + MessageView.NAME + "/Hello"));
+        layout.addComponent(lnk);
+
+        lnk = new Link("Message: Bye", new ExternalResource("#!"
+                + MessageView.NAME + "/Bye/Goodbye"));
+        layout.addComponent(lnk);
+
+        lnk = new Link("Private message: Secret", new ExternalResource("#!"
+                + SecretView.NAME + "/Secret"));
+        layout.addComponent(lnk);
+
+        lnk = new Link("Private message: Topsecret", new ExternalResource("#!"
+                + SecretView.NAME + "/Topsecret"));
+        layout.addComponent(lnk);
+
+        logOut = new Button("Logout", new Button.ClickListener() {
+            public void buttonClick(ClickEvent event) {
+
+                ((NavigationtestUI) UI.getCurrent()).setLoggedInUser(null);
+                logOut.setCaption("Login");
+                navigator.navigateTo(LoginView.NAME);
+
+            }
+        });
+        layout.addComponent(logOut);
+        setContent(layout);
+    }
+
+    @Override
+    public void enter(ViewChangeEvent event) {
+
+    }
 }
\ No newline at end of file
index 55b936f144ec956a4710e496ebf551f364ccd4cb..0eac6a042ed171f778bc5d9e1300eea5a30a9ce2 100644 (file)
@@ -1,60 +1,60 @@
-package com.vaadin.tests.minitutorials.v7b9;\r
-\r
-import com.vaadin.navigator.View;\r
-import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;\r
-import com.vaadin.server.ExternalResource;\r
-import com.vaadin.ui.Button;\r
-import com.vaadin.ui.Button.ClickEvent;\r
-import com.vaadin.ui.Link;\r
-import com.vaadin.ui.Panel;\r
-import com.vaadin.ui.UI;\r
-import com.vaadin.ui.VerticalLayout;\r
-\r
-public class MainViewEarlierExample extends Panel implements View {\r
-\r
-    public static final String NAME = "";\r
-\r
-    public MainViewEarlierExample() {\r
-\r
-        VerticalLayout layout = new VerticalLayout();\r
-\r
-        Link lnk = new Link("Count",\r
-                new ExternalResource("#!" + CountView.NAME));\r
-        layout.addComponent(lnk);\r
-\r
-        lnk = new Link("Message: Hello", new ExternalResource("#!"\r
-                + MessageView.NAME + "/Hello"));\r
-        layout.addComponent(lnk);\r
-\r
-        lnk = new Link("Message: Bye", new ExternalResource("#!"\r
-                + MessageView.NAME + "/Bye/Goodbye"));\r
-        layout.addComponent(lnk);\r
-\r
-        lnk = new Link("Private message: Secret", new ExternalResource("#!"\r
-                + SecretView.NAME + "/Secret"));\r
-        layout.addComponent(lnk);\r
-\r
-        lnk = new Link("Private message: Topsecret", new ExternalResource("#!"\r
-                + SecretView.NAME + "/Topsecret"));\r
-        layout.addComponent(lnk);\r
-\r
-        // login/logout toggle so we can test this\r
-        Button logInOut = new Button("Toggle login",\r
-                new Button.ClickListener() {\r
-                    public void buttonClick(ClickEvent event) {\r
-                        Object user = ((NavigationtestUI) UI.getCurrent())\r
-                                .getLoggedInUser();\r
-                        ((NavigationtestUI) UI.getCurrent())\r
-                                .setLoggedInUser(user == null ? "Smee" : null);\r
-                    }\r
-                });\r
-        layout.addComponent(logInOut);\r
-        setContent(layout);\r
-    }\r
-\r
-    @Override\r
-    public void enter(ViewChangeEvent event) {\r
-\r
-    }\r
-\r
+package com.vaadin.tests.minitutorials.v7b9;
+
+import com.vaadin.navigator.View;
+import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
+import com.vaadin.server.ExternalResource;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Link;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+
+public class MainViewEarlierExample extends Panel implements View {
+
+    public static final String NAME = "";
+
+    public MainViewEarlierExample() {
+
+        VerticalLayout layout = new VerticalLayout();
+
+        Link lnk = new Link("Count",
+                new ExternalResource("#!" + CountView.NAME));
+        layout.addComponent(lnk);
+
+        lnk = new Link("Message: Hello", new ExternalResource("#!"
+                + MessageView.NAME + "/Hello"));
+        layout.addComponent(lnk);
+
+        lnk = new Link("Message: Bye", new ExternalResource("#!"
+                + MessageView.NAME + "/Bye/Goodbye"));
+        layout.addComponent(lnk);
+
+        lnk = new Link("Private message: Secret", new ExternalResource("#!"
+                + SecretView.NAME + "/Secret"));
+        layout.addComponent(lnk);
+
+        lnk = new Link("Private message: Topsecret", new ExternalResource("#!"
+                + SecretView.NAME + "/Topsecret"));
+        layout.addComponent(lnk);
+
+        // login/logout toggle so we can test this
+        Button logInOut = new Button("Toggle login",
+                new Button.ClickListener() {
+                    public void buttonClick(ClickEvent event) {
+                        Object user = ((NavigationtestUI) UI.getCurrent())
+                                .getLoggedInUser();
+                        ((NavigationtestUI) UI.getCurrent())
+                                .setLoggedInUser(user == null ? "Smee" : null);
+                    }
+                });
+        layout.addComponent(logInOut);
+        setContent(layout);
+    }
+
+    @Override
+    public void enter(ViewChangeEvent event) {
+
+    }
+
 }
\ No newline at end of file
index 91d495cb24f1908b52e71c96655a380587dbf6c6..5344a06a315b021251124296e9089d941936e02f 100644 (file)
@@ -1,29 +1,29 @@
-package com.vaadin.tests.minitutorials.v7b9;\r
-\r
-import com.vaadin.navigator.Navigator;\r
-import com.vaadin.navigator.View;\r
-import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;\r
-import com.vaadin.server.ExternalResource;\r
-import com.vaadin.ui.Link;\r
-import com.vaadin.ui.Panel;\r
-import com.vaadin.ui.VerticalLayout;\r
-\r
-public class MainView__LastNavigatorExample extends Panel implements View {\r
-\r
-    public static final String NAME = "";\r
-\r
-    public MainView__LastNavigatorExample(final Navigator navigator) {\r
-\r
-        Link lnk = new Link("Settings", new ExternalResource("#!"\r
-                + SettingsView.NAME));\r
-        VerticalLayout vl = new VerticalLayout();\r
-        vl.addComponent(lnk);\r
-        setContent(vl);\r
-\r
-    }\r
-\r
-    @Override\r
-    public void enter(ViewChangeEvent event) {\r
-\r
-    }\r
-}\r
+package com.vaadin.tests.minitutorials.v7b9;
+
+import com.vaadin.navigator.Navigator;
+import com.vaadin.navigator.View;
+import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
+import com.vaadin.server.ExternalResource;
+import com.vaadin.ui.Link;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
+
+public class MainView__LastNavigatorExample extends Panel implements View {
+
+    public static final String NAME = "";
+
+    public MainView__LastNavigatorExample(final Navigator navigator) {
+
+        Link lnk = new Link("Settings", new ExternalResource("#!"
+                + SettingsView.NAME));
+        VerticalLayout vl = new VerticalLayout();
+        vl.addComponent(lnk);
+        setContent(vl);
+
+    }
+
+    @Override
+    public void enter(ViewChangeEvent event) {
+
+    }
+}
index fbb28b6f4ab143d95ed7c5858b6f1e6c6b9e09c1..e8612888e9078951e49a9e37016ab24e315ce242 100644 (file)
@@ -1,29 +1,29 @@
-package com.vaadin.tests.minitutorials.v7b9;\r
-\r
-import com.vaadin.navigator.View;\r
-import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;\r
-import com.vaadin.ui.Label;\r
-import com.vaadin.ui.Layout;\r
-import com.vaadin.ui.Panel;\r
-import com.vaadin.ui.VerticalLayout;\r
-\r
-public class MessageView extends Panel implements View {\r
-    public static final String NAME = "message";\r
-    private Layout layout;\r
-\r
-    public MessageView() {\r
-        super(new VerticalLayout());\r
-        setCaption("Messages");\r
-    }\r
-\r
-    @Override\r
-    public void enter(ViewChangeEvent event) {\r
-        if (event.getParameters() != null) {\r
-            // split at "/", add each part as a label\r
-            String[] msgs = event.getParameters().split("/");\r
-            for (String msg : msgs) {\r
-                ((Layout) getContent()).addComponent(new Label(msg));\r
-            }\r
-        }\r
-    }\r
+package com.vaadin.tests.minitutorials.v7b9;
+
+import com.vaadin.navigator.View;
+import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
+
+public class MessageView extends Panel implements View {
+    public static final String NAME = "message";
+    private Layout layout;
+
+    public MessageView() {
+        super(new VerticalLayout());
+        setCaption("Messages");
+    }
+
+    @Override
+    public void enter(ViewChangeEvent event) {
+        if (event.getParameters() != null) {
+            // split at "/", add each part as a label
+            String[] msgs = event.getParameters().split("/");
+            for (String msg : msgs) {
+                ((Layout) getContent()).addComponent(new Label(msg));
+            }
+        }
+    }
 }
\ No newline at end of file
index c31bbef748b16e9ffad1ce037358ced1c03c60e9..62941443b2987bdecea22d382c88aabb6b7d22c1 100644 (file)
@@ -1,77 +1,77 @@
-package com.vaadin.tests.minitutorials.v7b9;\r
-\r
-import com.vaadin.annotations.PreserveOnRefresh;\r
-import com.vaadin.navigator.Navigator;\r
-import com.vaadin.server.VaadinRequest;\r
-import com.vaadin.ui.UI;\r
-\r
-@PreserveOnRefresh\r
-public class NavigationtestUI extends UI {\r
-\r
-    Navigator navigator;\r
-\r
-    String loggedInUser;\r
-\r
-    @Override\r
-    public void init(VaadinRequest request) {\r
-        // Create Navigator, make it control the ViewDisplay\r
-        navigator = new Navigator(this, this);\r
-\r
-        // Add some Views\r
-        // no fragment for main view\r
-        navigator.addView(MainView__LastNavigatorExample.NAME,\r
-                new MainView__LastNavigatorExample(navigator));\r
-\r
-        // #settings\r
-        navigator.addView(SettingsView.NAME, new SettingsView(navigator));\r
-\r
-        // #count will be a new instance each time we navigate to it, counts:\r
-        /*\r
-         * Commented away from other example // no fragment for main view\r
-         * navigator.addView(MainView.NAME, new MainView(navigator));\r
-         * \r
-         * navigator.addView(CountView.NAME, CountView.class);\r
-         * \r
-         * // #message adds a label with whatever it receives as a parameter\r
-         * navigator.addView(MessageView.NAME, new MessageView());\r
-         * \r
-         * // #secret works as #message, but you need to be logged in\r
-         * navigator.addView(SecretView.NAME, new SecretView());\r
-         * \r
-         * // #login will navigate to the main view if invoked via this\r
-         * mechanism navigator.addView(LoginView.NAME, new LoginView(navigator,\r
-         * MainView.NAME));\r
-         * \r
-         * // we'll handle permissions with a listener here, you could also do\r
-         * // that in the View itself. navigator.addViewChangeListener(new\r
-         * ViewChangeListener() {\r
-         * \r
-         * @Override public boolean beforeViewChange(ViewChangeEvent event) { if\r
-         * (((NavigationtestUI)UI.getCurrent()).getLoggedInUser() == null) { //\r
-         * Show to LoginView instead, pass intended view String\r
-         * fragmentAndParameters = event.getViewName(); if\r
-         * (event.getParameters() != null) { fragmentAndParameters += "/";\r
-         * fragmentAndParameters += event.getParameters(); }\r
-         * navigator.getDisplay().showView(new LoginView(navigator,\r
-         * fragmentAndParameters)); return false;\r
-         * \r
-         * } else { return true; } }\r
-         * \r
-         * @Override public void afterViewChange(ViewChangeEvent event) {\r
-         * \r
-         * } });\r
-         */\r
-        // react to initial fragment, received before we created the Navigator\r
-\r
-        // This was removed in beta10\r
-        // navigator.navigate();\r
-    }\r
-\r
-    public String getLoggedInUser() {\r
-        return loggedInUser;\r
-    }\r
-\r
-    public void setLoggedInUser(String user) {\r
-        loggedInUser = user;\r
-    }\r
-}\r
+package com.vaadin.tests.minitutorials.v7b9;
+
+import com.vaadin.annotations.PreserveOnRefresh;
+import com.vaadin.navigator.Navigator;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.ui.UI;
+
+@PreserveOnRefresh
+public class NavigationtestUI extends UI {
+
+    Navigator navigator;
+
+    String loggedInUser;
+
+    @Override
+    public void init(VaadinRequest request) {
+        // Create Navigator, make it control the ViewDisplay
+        navigator = new Navigator(this, this);
+
+        // Add some Views
+        // no fragment for main view
+        navigator.addView(MainView__LastNavigatorExample.NAME,
+                new MainView__LastNavigatorExample(navigator));
+
+        // #settings
+        navigator.addView(SettingsView.NAME, new SettingsView(navigator));
+
+        // #count will be a new instance each time we navigate to it, counts:
+        /*
+         * Commented away from other example // no fragment for main view
+         * navigator.addView(MainView.NAME, new MainView(navigator));
+         * 
+         * navigator.addView(CountView.NAME, CountView.class);
+         * 
+         * // #message adds a label with whatever it receives as a parameter
+         * navigator.addView(MessageView.NAME, new MessageView());
+         * 
+         * // #secret works as #message, but you need to be logged in
+         * navigator.addView(SecretView.NAME, new SecretView());
+         * 
+         * // #login will navigate to the main view if invoked via this
+         * mechanism navigator.addView(LoginView.NAME, new LoginView(navigator,
+         * MainView.NAME));
+         * 
+         * // we'll handle permissions with a listener here, you could also do
+         * // that in the View itself. navigator.addViewChangeListener(new
+         * ViewChangeListener() {
+         * 
+         * @Override public boolean beforeViewChange(ViewChangeEvent event) { if
+         * (((NavigationtestUI)UI.getCurrent()).getLoggedInUser() == null) { //
+         * Show to LoginView instead, pass intended view String
+         * fragmentAndParameters = event.getViewName(); if
+         * (event.getParameters() != null) { fragmentAndParameters += "/";
+         * fragmentAndParameters += event.getParameters(); }
+         * navigator.getDisplay().showView(new LoginView(navigator,
+         * fragmentAndParameters)); return false;
+         * 
+         * } else { return true; } }
+         * 
+         * @Override public void afterViewChange(ViewChangeEvent event) {
+         * 
+         * } });
+         */
+        // react to initial fragment, received before we created the Navigator
+
+        // This was removed in beta10
+        // navigator.navigate();
+    }
+
+    public String getLoggedInUser() {
+        return loggedInUser;
+    }
+
+    public void setLoggedInUser(String user) {
+        loggedInUser = user;
+    }
+}
index a167522eeb61cb73105a906e22b83fa8024647e4..0b7ad16657059c37d967e7613db4436d2a3b15af 100644 (file)
@@ -1,28 +1,28 @@
-package com.vaadin.tests.minitutorials.v7b9;\r
-\r
-import com.vaadin.annotations.Theme;\r
-import com.vaadin.server.VaadinRequest;\r
-import com.vaadin.ui.Button;\r
-import com.vaadin.ui.Layout;\r
-import com.vaadin.ui.UI;\r
-import com.vaadin.ui.VerticalLayout;\r
-\r
-@Theme("sassy")\r
-public class SassyUI extends UI {\r
-    @Override\r
-    public void init(VaadinRequest request) {\r
-        Button b = new Button("Reindeer");\r
-        Layout layout = new VerticalLayout();\r
-        layout.addComponent(b);\r
-\r
-        b = new Button("important");\r
-        b.addStyleName("important");\r
-        layout.addComponent(b);\r
-\r
-        b = new Button("More important");\r
-        b.setPrimaryStyleName("my-button");\r
-        layout.addComponent(b);\r
-\r
-        setContent(layout);\r
-    }\r
+package com.vaadin.tests.minitutorials.v7b9;
+
+import com.vaadin.annotations.Theme;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+
+@Theme("sassy")
+public class SassyUI extends UI {
+    @Override
+    public void init(VaadinRequest request) {
+        Button b = new Button("Reindeer");
+        Layout layout = new VerticalLayout();
+        layout.addComponent(b);
+
+        b = new Button("important");
+        b.addStyleName("important");
+        layout.addComponent(b);
+
+        b = new Button("More important");
+        b.setPrimaryStyleName("my-button");
+        layout.addComponent(b);
+
+        setContent(layout);
+    }
 }
\ No newline at end of file
index 93dbe0b9e3dd8aff980b862b73405e03aae85fe4..68eb91fcc5c0e9b1b3318ba82b7126a7f75ba6a0 100644 (file)
@@ -1,16 +1,16 @@
-package com.vaadin.tests.minitutorials.v7b9;\r
-\r
-import com.vaadin.navigator.View;\r
-import com.vaadin.ui.Label;\r
-import com.vaadin.ui.Layout;\r
-\r
-public class SecretView extends MessageView implements View {\r
-    public static final String NAME = "secret";\r
-\r
-    public SecretView() {\r
-        setCaption("Private messages");\r
-\r
-        ((Layout) getContent()).addComponent(new Label("Some private stuff."));\r
-    }\r
-\r
+package com.vaadin.tests.minitutorials.v7b9;
+
+import com.vaadin.navigator.View;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+
+public class SecretView extends MessageView implements View {
+    public static final String NAME = "secret";
+
+    public SecretView() {
+        setCaption("Private messages");
+
+        ((Layout) getContent()).addComponent(new Label("Some private stuff."));
+    }
+
 }
\ No newline at end of file
index 1e026fe64179a548b4e077b64ad9e4fb1ea77833..61492adc39bd15c546cf06837cecf8822adff09b 100644 (file)
-package com.vaadin.tests.minitutorials.v7b9;\r
-\r
-import java.util.Date;\r
-\r
-import com.vaadin.data.Property.ValueChangeEvent;\r
-import com.vaadin.data.Property.ValueChangeListener;\r
-import com.vaadin.data.util.ObjectProperty;\r
-import com.vaadin.navigator.Navigator;\r
-import com.vaadin.navigator.View;\r
-import com.vaadin.navigator.ViewChangeListener;\r
-import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;\r
-import com.vaadin.ui.Button;\r
-import com.vaadin.ui.Button.ClickEvent;\r
-import com.vaadin.ui.DateField;\r
-import com.vaadin.ui.InlineDateField;\r
-import com.vaadin.ui.Layout;\r
-import com.vaadin.ui.Notification;\r
-import com.vaadin.ui.Notification.Type;\r
-import com.vaadin.ui.Panel;\r
-import com.vaadin.ui.VerticalLayout;\r
-import com.vaadin.ui.themes.Reindeer;\r
-\r
-public class SettingsView extends Panel implements View {\r
-\r
-    public static String NAME = "settings";\r
-\r
-    Navigator navigator;\r
-    DateField date;\r
-    Button apply;\r
-    Button cancel;\r
-\r
-    String pendingViewAndParameters = null;\r
-\r
-    public SettingsView(final Navigator navigator) {\r
-        this.navigator = navigator;\r
-        Layout layout = new VerticalLayout();\r
-\r
-        date = new InlineDateField("Birth date");\r
-        date.setImmediate(true);\r
-        layout.addComponent(date);\r
-        // pretend we have a datasource:\r
-        date.setPropertyDataSource(new ObjectProperty<Date>(new Date()));\r
-        date.setBuffered(true);\r
-        // show buttons when date is changed\r
-        date.addValueChangeListener(new ValueChangeListener() {\r
-            public void valueChange(ValueChangeEvent event) {\r
-                hideOrShowButtons();\r
-                pendingViewAndParameters = null;\r
-            }\r
-        });\r
-\r
-        // commit the TextField changes when "Save" is clicked\r
-        apply = new Button("Apply", new Button.ClickListener() {\r
-            public void buttonClick(ClickEvent event) {\r
-                date.commit();\r
-                hideOrShowButtons();\r
-                processPendingView();\r
-            }\r
-        });\r
-        layout.addComponent(apply);\r
-\r
-        // Discard the TextField changes when "Cancel" is clicked\r
-        cancel = new Button("Cancel", new Button.ClickListener() {\r
-            public void buttonClick(ClickEvent event) {\r
-                date.discard();\r
-                hideOrShowButtons();\r
-                processPendingView();\r
-            }\r
-        });\r
-        cancel.setStyleName(Reindeer.BUTTON_LINK);\r
-        layout.addComponent(cancel);\r
-\r
-        // attach a listener so that we'll get asked isViewChangeAllowed?\r
-        navigator.addViewChangeListener(new ViewChangeListener() {\r
-            public boolean beforeViewChange(ViewChangeEvent event) {\r
-                if (event.getOldView() == SettingsView.this\r
-                        && date.isModified()) {\r
-\r
-                    // save the View where the user intended to go\r
-                    pendingViewAndParameters = event.getViewName();\r
-                    if (event.getParameters() != null) {\r
-                        pendingViewAndParameters += "/";\r
-                        pendingViewAndParameters += event.getParameters();\r
-                    }\r
-\r
-                    // Prompt the user to save or cancel if the name is changed\r
-                    Notification.show("Please apply or cancel your changes",\r
-                            Type.WARNING_MESSAGE);\r
-\r
-                    return false;\r
-                } else {\r
-                    return true;\r
-                }\r
-            }\r
-\r
-            public void afterViewChange(ViewChangeEvent event) {\r
-                pendingViewAndParameters = null;\r
-            }\r
-        });\r
-\r
-        setContent(layout);\r
-\r
-    }\r
-\r
-    // Hide or show buttons depending on whether date is modified or not\r
-    private void hideOrShowButtons() {\r
-        apply.setVisible(date.isModified());\r
-        cancel.setVisible(date.isModified());\r
-    }\r
-\r
-    // if there is a pending view change, do it now\r
-    private void processPendingView() {\r
-        if (pendingViewAndParameters != null) {\r
-            navigator.navigateTo(pendingViewAndParameters);\r
-            pendingViewAndParameters = null;\r
-        }\r
-    }\r
-\r
-    public void navigateTo(String fragmentParameters) {\r
-        hideOrShowButtons();\r
-    }\r
-\r
-    @Override\r
-    public void enter(ViewChangeEvent event) {\r
-        // TODO Auto-generated method stub\r
-\r
-    }\r
-\r
+package com.vaadin.tests.minitutorials.v7b9;
+
+import java.util.Date;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.util.ObjectProperty;
+import com.vaadin.navigator.Navigator;
+import com.vaadin.navigator.View;
+import com.vaadin.navigator.ViewChangeListener;
+import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.InlineDateField;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Notification;
+import com.vaadin.ui.Notification.Type;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.themes.Reindeer;
+
+public class SettingsView extends Panel implements View {
+
+    public static String NAME = "settings";
+
+    Navigator navigator;
+    DateField date;
+    Button apply;
+    Button cancel;
+
+    String pendingViewAndParameters = null;
+
+    public SettingsView(final Navigator navigator) {
+        this.navigator = navigator;
+        Layout layout = new VerticalLayout();
+
+        date = new InlineDateField("Birth date");
+        date.setImmediate(true);
+        layout.addComponent(date);
+        // pretend we have a datasource:
+        date.setPropertyDataSource(new ObjectProperty<Date>(new Date()));
+        date.setBuffered(true);
+        // show buttons when date is changed
+        date.addValueChangeListener(new ValueChangeListener() {
+            public void valueChange(ValueChangeEvent event) {
+                hideOrShowButtons();
+                pendingViewAndParameters = null;
+            }
+        });
+
+        // commit the TextField changes when "Save" is clicked
+        apply = new Button("Apply", new Button.ClickListener() {
+            public void buttonClick(ClickEvent event) {
+                date.commit();
+                hideOrShowButtons();
+                processPendingView();
+            }
+        });
+        layout.addComponent(apply);
+
+        // Discard the TextField changes when "Cancel" is clicked
+        cancel = new Button("Cancel", new Button.ClickListener() {
+            public void buttonClick(ClickEvent event) {
+                date.discard();
+                hideOrShowButtons();
+                processPendingView();
+            }
+        });
+        cancel.setStyleName(Reindeer.BUTTON_LINK);
+        layout.addComponent(cancel);
+
+        // attach a listener so that we'll get asked isViewChangeAllowed?
+        navigator.addViewChangeListener(new ViewChangeListener() {
+            public boolean beforeViewChange(ViewChangeEvent event) {
+                if (event.getOldView() == SettingsView.this
+                        && date.isModified()) {
+
+                    // save the View where the user intended to go
+                    pendingViewAndParameters = event.getViewName();
+                    if (event.getParameters() != null) {
+                        pendingViewAndParameters += "/";
+                        pendingViewAndParameters += event.getParameters();
+                    }
+
+                    // Prompt the user to save or cancel if the name is changed
+                    Notification.show("Please apply or cancel your changes",
+                            Type.WARNING_MESSAGE);
+
+                    return false;
+                } else {
+                    return true;
+                }
+            }
+
+            public void afterViewChange(ViewChangeEvent event) {
+                pendingViewAndParameters = null;
+            }
+        });
+
+        setContent(layout);
+
+    }
+
+    // Hide or show buttons depending on whether date is modified or not
+    private void hideOrShowButtons() {
+        apply.setVisible(date.isModified());
+        cancel.setVisible(date.isModified());
+    }
+
+    // if there is a pending view change, do it now
+    private void processPendingView() {
+        if (pendingViewAndParameters != null) {
+            navigator.navigateTo(pendingViewAndParameters);
+            pendingViewAndParameters = null;
+        }
+    }
+
+    public void navigateTo(String fragmentParameters) {
+        hideOrShowButtons();
+    }
+
+    @Override
+    public void enter(ViewChangeEvent event) {
+        // TODO Auto-generated method stub
+
+    }
+
 }
\ No newline at end of file