diff options
author | Henri Sara <hesara@vaadin.com> | 2012-11-13 18:08:29 +0200 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2012-11-13 18:18:40 +0200 |
commit | 391884746fda1781c55b13bc200dd75373f69141 (patch) | |
tree | 0d5a8dcd9d13c5c39813d81252506e12d72741af /uitest | |
parent | 4628bcc3062ef19ed9d561f79fe3bfb3696d6e04 (diff) | |
download | vaadin-framework-391884746fda1781c55b13bc200dd75373f69141.tar.gz vaadin-framework-391884746fda1781c55b13bc200dd75373f69141.zip |
UI based on AbstractBasicComponentContainer (#2924)
Change-Id: I1614a3464b8e7a0e9ecdd8c3a76335cdb85bdf87
Diffstat (limited to 'uitest')
42 files changed, 179 insertions, 109 deletions
diff --git a/uitest/src/com/vaadin/tests/Components.java b/uitest/src/com/vaadin/tests/Components.java index de408104ae..7f024e774a 100644 --- a/uitest/src/com/vaadin/tests/Components.java +++ b/uitest/src/com/vaadin/tests/Components.java @@ -22,7 +22,6 @@ import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.tests.components.AbstractComponentTest; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.Component; -import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.Embedded; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Label; @@ -256,7 +255,7 @@ public class Components extends LegacyApplication { try { AbstractComponentTest t = cls.newInstance(); t.init(); - ComponentContainer c = t.getMainWindow().getContent(); + Component c = t.getMainWindow().getContent(); t.getMainWindow().setContent(null); return c; } catch (InstantiationException e) { diff --git a/uitest/src/com/vaadin/tests/ScrollbarStressTest.java b/uitest/src/com/vaadin/tests/ScrollbarStressTest.java index c671c5aa71..c72817ac41 100644 --- a/uitest/src/com/vaadin/tests/ScrollbarStressTest.java +++ b/uitest/src/com/vaadin/tests/ScrollbarStressTest.java @@ -126,7 +126,7 @@ public class ScrollbarStressTest extends LegacyApplication { el.addComponent(ol); - main.getContent().addComponent(el); + main.addComponent(el); main.removeWindow(subwindow); } diff --git a/uitest/src/com/vaadin/tests/application/DeploymentConfigurationTest.java b/uitest/src/com/vaadin/tests/application/DeploymentConfigurationTest.java index 9c89254bd7..799622b31d 100644 --- a/uitest/src/com/vaadin/tests/application/DeploymentConfigurationTest.java +++ b/uitest/src/com/vaadin/tests/application/DeploymentConfigurationTest.java @@ -5,15 +5,20 @@ import java.util.Properties; import com.vaadin.server.VaadinRequest; import com.vaadin.ui.Label; import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; public class DeploymentConfigurationTest extends UI { @Override protected void init(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); + Properties params = getSession().getConfiguration().getInitParameters(); for (Object key : params.keySet()) { - addComponent(new Label(key + ": " + layout.addComponent(new Label(key + ": " + params.getProperty((String) key))); } } diff --git a/uitest/src/com/vaadin/tests/components/AbstractComponentContainerTest.java b/uitest/src/com/vaadin/tests/components/AbstractComponentContainerTest.java index be3b7760f2..146e996eaf 100644 --- a/uitest/src/com/vaadin/tests/components/AbstractComponentContainerTest.java +++ b/uitest/src/com/vaadin/tests/components/AbstractComponentContainerTest.java @@ -7,10 +7,10 @@ import java.util.LinkedHashMap; import com.vaadin.ui.AbstractComponentContainer; import com.vaadin.ui.Button; import com.vaadin.ui.Component; -import com.vaadin.ui.ComponentContainer.ComponentAttachEvent; -import com.vaadin.ui.ComponentContainer.ComponentAttachListener; -import com.vaadin.ui.ComponentContainer.ComponentDetachEvent; -import com.vaadin.ui.ComponentContainer.ComponentDetachListener; +import com.vaadin.ui.HasComponents.ComponentAttachEvent; +import com.vaadin.ui.HasComponents.ComponentAttachListener; +import com.vaadin.ui.HasComponents.ComponentDetachEvent; +import com.vaadin.ui.HasComponents.ComponentDetachListener; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.InlineDateField; import com.vaadin.ui.NativeButton; diff --git a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java index 480fd2df57..a044b52f18 100644 --- a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java +++ b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java @@ -17,10 +17,14 @@ public abstract class AbstractTestUI extends UI { Label label = new Label(getTestDescription(), ContentMode.HTML); label.setWidth("100%"); + VerticalLayout rootLayout = new VerticalLayout(); + rootLayout.setMargin(true); + setContent(rootLayout); + layout = new VerticalLayout(); - getContent().addComponent(label); - getContent().addComponent(layout); + rootLayout.addComponent(label); + rootLayout.addComponent(layout); ((VerticalLayout) getContent()).setExpandRatio(layout, 1); setup(request); @@ -34,17 +38,14 @@ public abstract class AbstractTestUI extends UI { protected abstract void setup(VaadinRequest request); - @Override public void addComponent(Component c) { getLayout().addComponent(c); } - @Override public void removeComponent(Component c) { getLayout().removeComponent(c); } - @Override public void replaceComponent(Component oldComponent, Component newComponent) { getLayout().replaceComponent(oldComponent, newComponent); } diff --git a/uitest/src/com/vaadin/tests/components/LayoutAttachListenerInfo.java b/uitest/src/com/vaadin/tests/components/LayoutAttachListenerInfo.java index 6e54c0d9f4..b815705883 100644 --- a/uitest/src/com/vaadin/tests/components/LayoutAttachListenerInfo.java +++ b/uitest/src/com/vaadin/tests/components/LayoutAttachListenerInfo.java @@ -7,9 +7,9 @@ import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.ui.AbsoluteLayout; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.ComponentContainer; -import com.vaadin.ui.ComponentContainer.ComponentAttachEvent; import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HasComponents.ComponentAttachEvent; +import com.vaadin.ui.HasComponents.ComponentAttachListener; import com.vaadin.ui.Label; import com.vaadin.ui.Notification; import com.vaadin.ui.OptionGroup; @@ -26,7 +26,7 @@ public class LayoutAttachListenerInfo extends TestBase { "AbsoluteLayout", "OrderedLayout", "GridLayout")); layouts.select("AbsoluteLayout"); layouts.setImmediate(true); - layouts.addListener(new ValueChangeListener() { + layouts.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (event.getProperty().getValue().equals("AbsoluteLayout")) { @@ -64,7 +64,7 @@ public class LayoutAttachListenerInfo extends TestBase { final AbsoluteLayout a = new AbsoluteLayout(); a.setWidth("300px"); a.setHeight("300px"); - a.addListener(new ComponentContainer.ComponentAttachListener() { + a.addComponentAttachListener(new ComponentAttachListener() { @Override public void componentAttachedToContainer(ComponentAttachEvent event) { AbsoluteLayout layout = (AbsoluteLayout) event.getContainer(); @@ -93,7 +93,7 @@ public class LayoutAttachListenerInfo extends TestBase { final VerticalLayout v = new VerticalLayout(); v.setWidth("300px"); v.setHeight("300px"); - v.addListener(new ComponentContainer.ComponentAttachListener() { + v.addComponentAttachListener(new ComponentAttachListener() { @Override public void componentAttachedToContainer(ComponentAttachEvent event) { VerticalLayout layout = (VerticalLayout) event.getContainer(); @@ -122,7 +122,7 @@ public class LayoutAttachListenerInfo extends TestBase { final GridLayout g = new GridLayout(4, 4); g.setWidth("300px"); g.setHeight("300px"); - g.addListener(new ComponentContainer.ComponentAttachListener() { + g.addComponentAttachListener(new ComponentAttachListener() { @Override public void componentAttachedToContainer(ComponentAttachEvent event) { GridLayout layout = (GridLayout) event.getContainer(); diff --git a/uitest/src/com/vaadin/tests/components/TestBase.java b/uitest/src/com/vaadin/tests/components/TestBase.java index 08e39f7e6f..b500a1144b 100644 --- a/uitest/src/com/vaadin/tests/components/TestBase.java +++ b/uitest/src/com/vaadin/tests/components/TestBase.java @@ -16,10 +16,10 @@ public abstract class TestBase extends AbstractTestCase { Label label = new Label(getDescription(), ContentMode.HTML); label.setWidth("100%"); - window.getContent().addComponent(label); + window.addComponent(label); layout = new VerticalLayout(); - window.getContent().addComponent(layout); + window.addComponent(layout); ((VerticalLayout) window.getContent()).setExpandRatio(layout, 1); setup(); diff --git a/uitest/src/com/vaadin/tests/components/abstractcomponent/AllComponentTooltipTest.java b/uitest/src/com/vaadin/tests/components/abstractcomponent/AllComponentTooltipTest.java index 3473f50ee5..4b2b1f81ce 100644 --- a/uitest/src/com/vaadin/tests/components/abstractcomponent/AllComponentTooltipTest.java +++ b/uitest/src/com/vaadin/tests/components/abstractcomponent/AllComponentTooltipTest.java @@ -27,7 +27,8 @@ public class AllComponentTooltipTest extends AbstractTestUI { @Override protected void setup(VaadinRequest request) { - setContent(new GridLayout(5, 5)); + GridLayout layout = new GridLayout(5, 5); + setContent(layout); for (Class<? extends Component> cls : VaadinClasses.getComponents()) { try { AbstractComponent c = (AbstractComponent) cls.newInstance(); @@ -40,7 +41,7 @@ public class AllComponentTooltipTest extends AbstractTestUI { c.setDescription(cls.getName()); c.setWidth("100px"); c.setHeight("100px"); - getContent().addComponent(c); + layout.addComponent(c); System.out.println("Added " + cls.getName()); } catch (Exception e) { System.err.println("Could not instatiate " + cls.getName()); diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuBarRunsOutOfBrowser.java b/uitest/src/com/vaadin/tests/components/menubar/MenuBarRunsOutOfBrowser.java index 78c6d92ee2..0d9c3d8bba 100644 --- a/uitest/src/com/vaadin/tests/components/menubar/MenuBarRunsOutOfBrowser.java +++ b/uitest/src/com/vaadin/tests/components/menubar/MenuBarRunsOutOfBrowser.java @@ -23,7 +23,7 @@ public class MenuBarRunsOutOfBrowser extends AbstractTestCase { menuBar.addItem("ABC", new ThemeResource("icons/16/document.png"), null); menuBar.addItem("123", new ThemeResource("icons/16/help.png"), null); - main.getContent().addComponent(menuBar); + main.addComponent(menuBar); ((VerticalLayout) main.getContent()).setComponentAlignment(menuBar, Alignment.TOP_RIGHT); diff --git a/uitest/src/com/vaadin/tests/components/table/TableInTabsheet.java b/uitest/src/com/vaadin/tests/components/table/TableInTabsheet.java index a9cecfd6b5..ee9609bb96 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableInTabsheet.java +++ b/uitest/src/com/vaadin/tests/components/table/TableInTabsheet.java @@ -18,7 +18,6 @@ public class TableInTabsheet extends AbstractTestUI { @Override protected void setup(VaadinRequest request) { - getUI().setCaption("test"); VerticalLayout vPrinc = new VerticalLayout(); vPrinc.setStyleName(Reindeer.LAYOUT_BLUE); diff --git a/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java b/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java index 1064f2e766..57fc9f3e62 100644 --- a/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java +++ b/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java @@ -11,6 +11,7 @@ import com.vaadin.tests.components.AbstractTestUIProvider; import com.vaadin.ui.Label; import com.vaadin.ui.Link; import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; public class LazyInitUIs extends AbstractTestUIProvider { @@ -18,7 +19,11 @@ public class LazyInitUIs extends AbstractTestUIProvider { private static class EagerInitUI extends UI { @Override public void init(VaadinRequest request) { - addComponent(getRequestInfo("EagerInitUI", request)); + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); + + layout.addComponent(getRequestInfo("EagerInitUI", request)); } } @@ -39,7 +44,11 @@ public class LazyInitUIs extends AbstractTestUIProvider { UI uI = new UI() { @Override protected void init(VaadinRequest request) { - addComponent(getRequestInfo("LazyCreateUI", request)); + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); + + layout.addComponent(getRequestInfo("LazyCreateUI", request)); } }; return uI; @@ -51,20 +60,24 @@ public class LazyInitUIs extends AbstractTestUIProvider { UI uI = new UI() { @Override protected void init(VaadinRequest request) { - addComponent(getRequestInfo("NormalUI", request)); + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); + + layout.addComponent(getRequestInfo("NormalUI", request)); String location = getPage().getLocation().toString(); Link lazyCreateLink = new Link("Open lazyCreate UI", new ExternalResource(location.replaceFirst( "(\\?|#|$).*", "?lazyCreate#lazyCreate"))); lazyCreateLink.setTargetName("_blank"); - addComponent(lazyCreateLink); + layout.addComponent(lazyCreateLink); Link lazyInitLink = new Link("Open eagerInit UI", new ExternalResource(location.replaceFirst( "(\\?|#|$).*", "?eagerInit#eagerInit"))); lazyInitLink.setTargetName("_blank"); - addComponent(lazyInitLink); + layout.addComponent(lazyInitLink); } }; diff --git a/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java b/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java index 8c4ba3980d..53df69f028 100644 --- a/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java +++ b/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java @@ -9,6 +9,7 @@ import com.vaadin.server.VaadinServiceSession; import com.vaadin.tests.components.AbstractTestUIProvider; import com.vaadin.ui.Label; import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; public class UIsInMultipleTabs extends AbstractTestUIProvider { // No cleanup -> will leak, but shouldn't matter for tests @@ -29,7 +30,11 @@ public class UIsInMultipleTabs extends AbstractTestUIProvider { int currentCount = count.incrementAndGet(); String message = "This is UI number " + currentCount; - addComponent(new Label(message)); + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); + + layout.addComponent(new Label(message)); } } diff --git a/uitest/src/com/vaadin/tests/components/window/SubWindowFocusAndBlurListeners.java b/uitest/src/com/vaadin/tests/components/window/SubWindowFocusAndBlurListeners.java index bb247ee065..bb5a817362 100644 --- a/uitest/src/com/vaadin/tests/components/window/SubWindowFocusAndBlurListeners.java +++ b/uitest/src/com/vaadin/tests/components/window/SubWindowFocusAndBlurListeners.java @@ -10,6 +10,7 @@ import com.vaadin.event.ShortcutAction; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.Notification; import com.vaadin.ui.TextField; import com.vaadin.ui.UI; @@ -68,7 +69,7 @@ public class SubWindowFocusAndBlurListeners extends TestBase { main.addWindow(window); - main.addComponent(new TextField()); + ((ComponentContainer) main.getContent()).addComponent(new TextField()); Button button = new Button("Bring to front (should focus too)", new Button.ClickListener() { @@ -77,7 +78,7 @@ public class SubWindowFocusAndBlurListeners extends TestBase { window.bringToFront(); } }); - main.addComponent(button); + ((ComponentContainer) main.getContent()).addComponent(button); Window window2 = new Window("Another window for testing"); main.addWindow(window2); diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestUI.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestUI.java index 61214ede8c..0e6cb19b30 100755 --- a/uitest/src/com/vaadin/tests/integration/IntegrationTestUI.java +++ b/uitest/src/com/vaadin/tests/integration/IntegrationTestUI.java @@ -9,10 +9,15 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.ui.Label; import com.vaadin.ui.Table; import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; public class IntegrationTestUI extends UI { @Override protected void init(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); + final Table table = new Table(); table.addContainerProperty("icon", Resource.class, null); table.setItemIconPropertyId("icon"); @@ -21,7 +26,7 @@ public class IntegrationTestUI extends UI { table.setImmediate(true); table.setSelectable(true); table.setVisibleColumns(new Object[] { "country" }); - addComponent(table); + layout.addComponent(table); Item item = table.addItem("FI"); item.getItemProperty("icon").setValue(new ClassResource("fi.gif")); @@ -37,6 +42,6 @@ public class IntegrationTestUI extends UI { selectedLabel.setValue(String.valueOf(table.getValue())); } }); - addComponent(selectedLabel); + layout.addComponent(selectedLabel); } } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/AutoGeneratingForm.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/AutoGeneratingForm.java index 4111f6c07a..53d76a251f 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/AutoGeneratingForm.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/AutoGeneratingForm.java @@ -21,6 +21,7 @@ import com.vaadin.data.fieldgroup.FieldGroup; import com.vaadin.data.util.BeanItem; import com.vaadin.server.VaadinRequest; import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; /** * Mini tutorial code for @@ -34,6 +35,10 @@ public class AutoGeneratingForm extends UI { @Override protected void init(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); + FieldGroup fieldGroup = new BeanFieldGroup<Person>(Person.class); // We need an item data source before we create the fields to be able to @@ -44,7 +49,7 @@ public class AutoGeneratingForm extends UI { // Loop through the properties, build fields for them and add the fields // to this root for (Object propertyId : fieldGroup.getUnboundPropertyIds()) { - addComponent(fieldGroup.buildAndBind(propertyId)); + layout.addComponent(fieldGroup.buildAndBind(propertyId)); } } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/CreatingPreserveState.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/CreatingPreserveState.java index ffe1f09216..66de5af27e 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/CreatingPreserveState.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/CreatingPreserveState.java @@ -37,7 +37,7 @@ public class CreatingPreserveState extends UI { public void init(VaadinRequest request) { TextField tf = new TextField("Window #" + (++windowCounter)); tf.setImmediate(true); - getContent().addComponent(tf); + setContent(tf); } } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java index 737de10894..6a713c4f64 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java @@ -59,8 +59,7 @@ public class DifferentFeaturesForDifferentClients extends UIProvider { class DefaultRoot extends UI { @Override protected void init(VaadinRequest request) { - getContent().addComponent( - new Label("This browser does not support touch events")); + setContent(new Label("This browser does not support touch events")); } } @@ -70,8 +69,7 @@ class TouchRoot extends UI { WebBrowser webBrowser = getSession().getBrowser(); String screenSize = "" + webBrowser.getScreenWidth() + "x" + webBrowser.getScreenHeight(); - getContent().addComponent( - new Label("Using a touch enabled device with screen size" - + screenSize)); + setContent(new Label("Using a touch enabled device with screen size" + + screenSize)); } } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java index 61cbd94f3a..a84a2206ef 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java @@ -25,7 +25,7 @@ public class DynamicImageUI extends AbstractTestUI { // Add an image using the resource Image image = new Image("A dynamically generated image", resource); - getContent().addComponent(image); + addComponent(image); } @Override diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/FindCurrentUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/FindCurrentUI.java index ebacb2f672..ba7ef78ec1 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/FindCurrentUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/FindCurrentUI.java @@ -55,7 +55,7 @@ public class FindCurrentUI extends UI { } }); - addComponent(helloButton); + setContent(helloButton); } } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/UsingBeanValidation.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/UsingBeanValidation.java index 51c7cbbe60..fa0a8e8c31 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/UsingBeanValidation.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/UsingBeanValidation.java @@ -77,7 +77,7 @@ public class UsingBeanValidation extends UI { TextField firstName = new TextField("First name", item.getItemProperty("name")); firstName.setImmediate(true); - addComponent(firstName); + setContent(firstName); firstName.addValidator(new BeanValidator(Person.class, "name")); } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/UsingUriFragments.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/UsingUriFragments.java index 15c4fa838e..f3bef99e65 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/UsingUriFragments.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/UsingUriFragments.java @@ -23,6 +23,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; /** * Mini tutorial code for @@ -33,11 +34,17 @@ import com.vaadin.ui.UI; */ public class UsingUriFragments extends UI { + private VerticalLayout layout; + @Override protected void init(VaadinRequest request) { + layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); + Label label = new Label("Hello, your fragment is " + getPage().getUriFragment()); - getContent().addComponent(label); + layout.addComponent(label); // React to fragment changes getPage().addListener(new UriFragmentChangedListener() { @@ -50,7 +57,7 @@ public class UsingUriFragments extends UI { // Handle the fragment received in the initial request handleFragment(getPage().getUriFragment()); - addComponent(new Button("Show and set fragment", + layout.addComponent(new Button("Show and set fragment", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { @@ -61,7 +68,7 @@ public class UsingUriFragments extends UI { } private void handleFragment(String uriFragment) { - addComponent(new Label("Got new fragment: " + uriFragment)); + layout.addComponent(new Label("Got new fragment: " + uriFragment)); } } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/UsingXyzWhenInitializing.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/UsingXyzWhenInitializing.java index 52499ffbe5..c4d496641d 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/UsingXyzWhenInitializing.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/UsingXyzWhenInitializing.java @@ -19,6 +19,7 @@ package com.vaadin.tests.minitutorials.v7a1; import com.vaadin.server.VaadinRequest; import com.vaadin.ui.Label; import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; /** * Mini tutorial code for @@ -32,18 +33,22 @@ public class UsingXyzWhenInitializing extends UI { @Override protected void init(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); + String name = request.getParameter("name"); if (name == null) { name = "Unknown"; } - getContent().addComponent(new Label("Hello " + name)); + layout.addComponent(new Label("Hello " + name)); String pathInfo = request.getRequestPathInfo(); if ("/viewSource".equals(pathInfo)) { - getContent().addComponent(new Label("This is the source")); + layout.addComponent(new Label("This is the source")); } else { - getContent().addComponent(new Label("Welcome to my application")); + layout.addComponent(new Label("Welcome to my application")); } // WebBrowser browser = request.getBrowserDetails().getWebBrowser(); diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a2/ComponentInStateUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a2/ComponentInStateUI.java index da178167ed..986811e0f4 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a2/ComponentInStateUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a2/ComponentInStateUI.java @@ -4,6 +4,7 @@ import com.vaadin.annotations.Widgetset; import com.vaadin.server.VaadinRequest; import com.vaadin.ui.Label; import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; /** * Mini tutorial code for @@ -17,10 +18,14 @@ import com.vaadin.ui.UI; public class ComponentInStateUI extends UI { @Override protected void init(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); + ComponentInStateComponent component = new ComponentInStateComponent(); component.setOtherComponent(this); - addComponent(component); - addComponent(new Label("Server-side type of other component: " + layout.addComponent(component); + layout.addComponent(new Label("Server-side type of other component: " + component.getOtherComponent().getClass().getName())); } } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a2/MyComponentUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a2/MyComponentUI.java index caf38077bf..80aeecfa79 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a2/MyComponentUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a2/MyComponentUI.java @@ -41,7 +41,7 @@ public class MyComponentUI extends UI { component.setText("My component text"); - addComponent(component); + setContent(component); } }
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a2/ResourceInStateUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a2/ResourceInStateUI.java index 155c1d9ded..4ddf86c345 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a2/ResourceInStateUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a2/ResourceInStateUI.java @@ -37,7 +37,7 @@ public class ResourceInStateUI extends UI { ResourceInStateComponent component = new ResourceInStateComponent(); component.setMyIcon(new ThemeResource("../runo/icons/32/calendar.png")); - addComponent(component); + setContent(component); } } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a2/WidgetcontainerUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a2/WidgetcontainerUI.java index f7cf6b4270..d81e6b4c59 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a2/WidgetcontainerUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a2/WidgetcontainerUI.java @@ -11,15 +11,20 @@ import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; @Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") public class WidgetcontainerUI extends UI { @Override public void init(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); + Label label = new Label("Hello Vaadin user"); - addComponent(label); + layout.addComponent(label); final WidgetContainer widgetContainer = new WidgetContainer(); - addComponent(widgetContainer); + layout.addComponent(widgetContainer); widgetContainer.addComponent(new Label( "Click the button to add components to the WidgetContainer.")); Button button = new Button("Add more components", new ClickListener() { @@ -39,7 +44,7 @@ public class WidgetcontainerUI extends UI { widgetContainer.addComponent(component); } }); - addComponent(button); + layout.addComponent(button); } }
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a3/AnalyticsUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a3/AnalyticsUI.java index 980d0b90b2..8bc9619902 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a3/AnalyticsUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a3/AnalyticsUI.java @@ -28,7 +28,7 @@ public class AnalyticsUI extends UI { final Analytics analytics = new Analytics("UA-33036133-12"); analytics.extend(this); - addComponent(new Button("Track pageview", new Button.ClickListener() { + setContent(new Button("Track pageview", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { analytics.trackPageview("/fake/url"); diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a3/ComplexTypesUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a3/ComplexTypesUI.java index 792be69410..fd271db7e6 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a3/ComplexTypesUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a3/ComplexTypesUI.java @@ -25,7 +25,7 @@ public class ComplexTypesUI extends UI { protected void init(VaadinRequest request) { ComplexTypesComponent complexTypesComponent = new ComplexTypesComponent(); complexTypesComponent.sendComplexTypes(); - addComponent(complexTypesComponent); + setContent(complexTypesComponent); } } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a3/FlotJavaScriptUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a3/FlotJavaScriptUI.java index a3ed5fe11e..d1d9879a31 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a3/FlotJavaScriptUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a3/FlotJavaScriptUI.java @@ -20,24 +20,30 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; public class FlotJavaScriptUI extends UI { @Override protected void init(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); + final Flot flot = new Flot(); flot.setHeight("300px"); flot.setWidth("400px"); flot.addSeries(1, 2, 4, 8, 16); - addComponent(flot); - - addComponent(new Button("Highlight point", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - flot.highlight(0, 3); - } - })); + layout.addComponent(flot); + + layout.addComponent(new Button("Highlight point", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + flot.highlight(0, 3); + } + })); } } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a3/JSAPIUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a3/JSAPIUI.java index ad4139d883..f9d79a518e 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a3/JSAPIUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a3/JSAPIUI.java @@ -39,7 +39,7 @@ public class JSAPIUI extends UI { } }); - addComponent(new Link( + setContent(new Link( "Send message", new ExternalResource( "javascript:(function(){com.example.api.notify(prompt('Message'),2);})();"))); diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a3/RedButtonUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a3/RedButtonUI.java index 18b4b1430e..a4d4031d5f 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a3/RedButtonUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a3/RedButtonUI.java @@ -22,6 +22,6 @@ import com.vaadin.ui.UI; public class RedButtonUI extends UI { @Override protected void init(VaadinRequest request) { - addComponent(new RedButton("My red button")); + setContent(new RedButton("My red button")); } }
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b5/SettingReadingSessionAttributesUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7b5/SettingReadingSessionAttributesUI.java index bc96152880..99b5973661 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b5/SettingReadingSessionAttributesUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b5/SettingReadingSessionAttributesUI.java @@ -36,22 +36,28 @@ public class SettingReadingSessionAttributesUI extends UI { @Override protected void init(VaadinRequest request) { - addComponent(statusHolder); - addComponent(textField); - addComponent(new Button("Set new values", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - String value = textField.getValue(); + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); - saveValue(SettingReadingSessionAttributesUI.this, value); - } - })); - addComponent(new Button("Reload page", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getPage().setLocation(getPage().getLocation()); - } - })); + layout.addComponent(statusHolder); + layout.addComponent(textField); + layout.addComponent(new Button("Set new values", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + String value = textField.getValue(); + + saveValue(SettingReadingSessionAttributesUI.this, value); + } + })); + layout.addComponent(new Button("Reload page", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + getPage().setLocation(getPage().getLocation()); + } + })); showValue(this); } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b6/LettingUserDownladFile.java b/uitest/src/com/vaadin/tests/minitutorials/v7b6/LettingUserDownloadFile.java index e6a6e267a9..d5c99c931b 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b6/LettingUserDownladFile.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b6/LettingUserDownloadFile.java @@ -31,7 +31,7 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.ui.Button; import com.vaadin.ui.UI; -public class LettingUserDownladFile extends UI { +public class LettingUserDownloadFile extends UI { @Override protected void init(VaadinRequest request) { @@ -41,7 +41,7 @@ public class LettingUserDownladFile extends UI { FileDownloader fileDownloader = new FileDownloader(myResource); fileDownloader.extend(downloadButton); - addComponent(downloadButton); + setContent(downloadButton); } private StreamResource createResource() { diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b6/MyPopupUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7b6/MyPopupUI.java index 2c50b62d0d..59f5831468 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b6/MyPopupUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b6/MyPopupUI.java @@ -24,7 +24,7 @@ public class MyPopupUI extends UI { @Override protected void init(VaadinRequest request) { - addComponent(new Label("This is MyPopupUI")); + setContent(new Label("This is MyPopupUI")); } } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b6/OpeningUIInPopup.java b/uitest/src/com/vaadin/tests/minitutorials/v7b6/OpeningUIInPopup.java index f1db0fc478..7fd8373bbd 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b6/OpeningUIInPopup.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b6/OpeningUIInPopup.java @@ -31,7 +31,7 @@ public class OpeningUIInPopup extends UI { popupOpener.setFeatures("height=300,width=300"); popupOpener.extend(popupButton); - addComponent(popupButton); + setContent(popupButton); } } diff --git a/uitest/src/com/vaadin/tests/navigator/NavigatorTest.java b/uitest/src/com/vaadin/tests/navigator/NavigatorTest.java index 97c4e9fd4f..08832e5e82 100644 --- a/uitest/src/com/vaadin/tests/navigator/NavigatorTest.java +++ b/uitest/src/com/vaadin/tests/navigator/NavigatorTest.java @@ -113,6 +113,10 @@ public class NavigatorTest extends UI { @Override protected void init(VaadinRequest req) { try { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); + navi = new Navigator(this, naviLayout); navi.addView("", new DefaultView()); @@ -127,13 +131,13 @@ public class NavigatorTest extends UI { navi.navigate(); - addComponent(new NaviButton("list")); - addComponent(new NaviButton("edit")); - addComponent(new NaviButton("forbidden")); + layout.addComponent(new NaviButton("list")); + layout.addComponent(new NaviButton("edit")); + layout.addComponent(new NaviButton("forbidden")); - addComponent(params); - addComponent(log); - addComponent(naviLayout); + layout.addComponent(params); + layout.addComponent(log); + layout.addComponent(naviLayout); } catch (Exception e) { e.printStackTrace(); log.log("Exception: " + e); diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket2021.java b/uitest/src/com/vaadin/tests/tickets/Ticket2021.java index 3f798a3e19..938df7befc 100644 --- a/uitest/src/com/vaadin/tests/tickets/Ticket2021.java +++ b/uitest/src/com/vaadin/tests/tickets/Ticket2021.java @@ -38,7 +38,7 @@ public class Ticket2021 extends LegacyApplication { p.setContent(new VerticalLayout()); p.getContent().setSizeFull(); - w.getContent().addComponent(p); + w.addComponent(p); tf1 = new TextArea(); tf1.setRows(5); @@ -59,7 +59,7 @@ public class Ticket2021 extends LegacyApplication { p2.setContent(new VerticalLayout()); p2.getContent().setSizeFull(); - w.getContent().addComponent(p2); + w.addComponent(p2); tf2 = new TextArea(); tf2.setRows(5); @@ -85,7 +85,7 @@ public class Ticket2021 extends LegacyApplication { gl.setSizeFull(); gl.setMargin(false); p3.getContent().addComponent(gl); - w.getContent().addComponent(p3); + w.addComponent(p3); tf3 = new TextArea(); tf3.setRows(5); diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket2024.java b/uitest/src/com/vaadin/tests/tickets/Ticket2024.java index c38ba7822a..2861c9beca 100644 --- a/uitest/src/com/vaadin/tests/tickets/Ticket2024.java +++ b/uitest/src/com/vaadin/tests/tickets/Ticket2024.java @@ -19,7 +19,7 @@ public class Ticket2024 extends LegacyApplication { layout.setWidth("700"); w.getContent().setSizeFull(); w.getContent().setHeight("2000"); - w.getContent().addComponent(layout); + w.addComponent(layout); layout.addComponent(new Label( "This should NOT get stuck when scrolling down")); @@ -28,7 +28,7 @@ public class Ticket2024 extends LegacyApplication { VerticalLayout ol = new VerticalLayout(); ol.setHeight("1000"); ol.setWidth("200"); - w.getContent().addComponent(ol); + w.addComponent(ol); ol.addComponent(new Label("Just a label to enable the scrollbar")); } diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket2029.java b/uitest/src/com/vaadin/tests/tickets/Ticket2029.java index 8031041e5b..db3334d570 100644 --- a/uitest/src/com/vaadin/tests/tickets/Ticket2029.java +++ b/uitest/src/com/vaadin/tests/tickets/Ticket2029.java @@ -32,9 +32,9 @@ public class Ticket2029 extends LegacyApplication { setMainWindow(w); // setTheme("tests-tickets"); Panel p = createPanel(); - w.getContent().addComponent(p); + w.addComponent(p); // w.getLayout().addComponent(createGLPanel()); - w.getContent().addComponent(createPanelV()); + w.addComponent(createPanelV()); } private Panel createPanel() { diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket2048.java b/uitest/src/com/vaadin/tests/tickets/Ticket2048.java index cb6fba3ab8..b2a6e64cd2 100644 --- a/uitest/src/com/vaadin/tests/tickets/Ticket2048.java +++ b/uitest/src/com/vaadin/tests/tickets/Ticket2048.java @@ -75,8 +75,7 @@ public class Ticket2048 extends LegacyApplication { public void buttonClick(ClickEvent event) { Embedded newEmbedded = new Embedded(null, new ThemeResource("icons/64/folder-add.png")); - getMainWindow().getContent().replaceComponent(embedded, - newEmbedded); + getMainWindow().replaceComponent(embedded, newEmbedded); embedded = newEmbedded; } diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket2101.java b/uitest/src/com/vaadin/tests/tickets/Ticket2101.java index d3e6202542..dd10943108 100644 --- a/uitest/src/com/vaadin/tests/tickets/Ticket2101.java +++ b/uitest/src/com/vaadin/tests/tickets/Ticket2101.java @@ -15,7 +15,7 @@ public class Ticket2101 extends LegacyApplication { "Button with a long text which will not fit on 50 pixels"); b.setWidth("50px"); - w.getContent().addComponent(b); + w.addComponent(b); } } diff --git a/uitest/src/com/vaadin/tests/util/SampleDirectory.java b/uitest/src/com/vaadin/tests/util/SampleDirectory.java index 504a4e5dfd..2f21026118 100644 --- a/uitest/src/com/vaadin/tests/util/SampleDirectory.java +++ b/uitest/src/com/vaadin/tests/util/SampleDirectory.java @@ -23,8 +23,8 @@ import com.vaadin.server.VaadinService; import com.vaadin.server.VaadinServiceSession; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Label; +import com.vaadin.ui.LegacyWindow; import com.vaadin.ui.Panel; -import com.vaadin.ui.UI; /** * Provides sample directory based on application directory. If this fails then @@ -42,7 +42,8 @@ public class SampleDirectory { * @param application * @return file pointing to sample directory */ - public static File getDirectory(VaadinServiceSession application, UI uI) { + public static File getDirectory(VaadinServiceSession application, + LegacyWindow uI) { String errorMessage = "Access to application " + "context base directory failed, " + "possible security constraint with Application " @@ -82,9 +83,9 @@ public class SampleDirectory { "Cannot provide sample directory")); errorPanel.addComponent(new Label(errorMessage, ContentMode.HTML)); // Remove all components from applications main window - uI.getContent().removeAllComponents(); + uI.removeAllComponents(); // Add error panel - uI.getContent().addComponent(errorPanel); + uI.addComponent(errorPanel); return null; } } |