diff options
16 files changed, 885 insertions, 885 deletions
diff --git a/server/src/com/vaadin/server/SystemMessagesInfo.java b/server/src/com/vaadin/server/SystemMessagesInfo.java index 30a6e82a90..9a161f5f7a 100644 --- a/server/src/com/vaadin/server/SystemMessagesInfo.java +++ b/server/src/com/vaadin/server/SystemMessagesInfo.java @@ -1,53 +1,53 @@ -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;
- }
-
-}
+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; + } + +} diff --git a/uitest/src/com/vaadin/tests/applicationservlet/SystemMessagesTest.java b/uitest/src/com/vaadin/tests/applicationservlet/SystemMessagesTest.java index c1db3cea05..047e465722 100644 --- a/uitest/src/com/vaadin/tests/applicationservlet/SystemMessagesTest.java +++ b/uitest/src/com/vaadin/tests/applicationservlet/SystemMessagesTest.java @@ -1,91 +1,91 @@ -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;
- }
-
-}
+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; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabsheetShouldUpdateHeight.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabsheetShouldUpdateHeight.java index f1a53eca60..5271f467dc 100644 --- a/uitest/src/com/vaadin/tests/components/tabsheet/TabsheetShouldUpdateHeight.java +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabsheetShouldUpdateHeight.java @@ -1,60 +1,60 @@ -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;
- }
+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 diff --git a/uitest/src/com/vaadin/tests/components/ui/EmptyWindow.java b/uitest/src/com/vaadin/tests/components/ui/EmptyWindow.java index c3975921df..07ce8c3ff8 100644 --- a/uitest/src/com/vaadin/tests/components/ui/EmptyWindow.java +++ b/uitest/src/com/vaadin/tests/components/ui/EmptyWindow.java @@ -1,26 +1,26 @@ -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;
- }
-
-}
+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; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/ui/WindowWithLabel.java b/uitest/src/com/vaadin/tests/components/ui/WindowWithLabel.java index 994c0692e0..790ff00e60 100644 --- a/uitest/src/com/vaadin/tests/components/ui/WindowWithLabel.java +++ b/uitest/src/com/vaadin/tests/components/ui/WindowWithLabel.java @@ -1,27 +1,27 @@ -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;
- }
-
-}
+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; + } + +} diff --git a/uitest/src/com/vaadin/tests/errorhandler/ErrorHandlers.java b/uitest/src/com/vaadin/tests/errorhandler/ErrorHandlers.java index 2a15dc02c8..a123af0f7d 100644 --- a/uitest/src/com/vaadin/tests/errorhandler/ErrorHandlers.java +++ b/uitest/src/com/vaadin/tests/errorhandler/ErrorHandlers.java @@ -1,134 +1,134 @@ -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;
- }
-
-}
+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; + } + +} diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b9/CountView.java b/uitest/src/com/vaadin/tests/minitutorials/v7b9/CountView.java index 6e4b2d790d..7aaf810355 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b9/CountView.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b9/CountView.java @@ -1,21 +1,21 @@ -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) {
-
- }
-
+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 diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b9/LoginView.java b/uitest/src/com/vaadin/tests/minitutorials/v7b9/LoginView.java index a0cb6bacba..3aa3e42a58 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b9/LoginView.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b9/LoginView.java @@ -1,52 +1,52 @@ -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
-
- }
-}
+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 + + } +} diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainView.java b/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainView.java index c08803e549..3a1a685bbe 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainView.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainView.java @@ -1,61 +1,61 @@ -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) {
-
- }
+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 diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainViewEarlierExample.java b/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainViewEarlierExample.java index 55b936f144..0eac6a042e 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainViewEarlierExample.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainViewEarlierExample.java @@ -1,60 +1,60 @@ -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) {
-
- }
-
+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 diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainView__LastNavigatorExample.java b/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainView__LastNavigatorExample.java index 91d495cb24..5344a06a31 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainView__LastNavigatorExample.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainView__LastNavigatorExample.java @@ -1,29 +1,29 @@ -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) {
-
- }
-}
+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) { + + } +} diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b9/MessageView.java b/uitest/src/com/vaadin/tests/minitutorials/v7b9/MessageView.java index fbb28b6f4a..e8612888e9 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b9/MessageView.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b9/MessageView.java @@ -1,29 +1,29 @@ -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));
- }
- }
- }
+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 diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b9/NavigationtestUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7b9/NavigationtestUI.java index c31bbef748..62941443b2 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b9/NavigationtestUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b9/NavigationtestUI.java @@ -1,77 +1,77 @@ -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;
- }
-}
+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; + } +} diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b9/SassyUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7b9/SassyUI.java index a167522eeb..0b7ad16657 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b9/SassyUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b9/SassyUI.java @@ -1,28 +1,28 @@ -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);
- }
+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 diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b9/SecretView.java b/uitest/src/com/vaadin/tests/minitutorials/v7b9/SecretView.java index 93dbe0b9e3..68eb91fcc5 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b9/SecretView.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b9/SecretView.java @@ -1,16 +1,16 @@ -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."));
- }
-
+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 diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b9/SettingsView.java b/uitest/src/com/vaadin/tests/minitutorials/v7b9/SettingsView.java index 1e026fe641..61492adc39 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b9/SettingsView.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b9/SettingsView.java @@ -1,129 +1,129 @@ -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
-
- }
-
+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 |