]> source.dussan.org Git - vaadin-framework.git/commitdiff
(#10180) Moved positioning from onStateChanged to onConnectorHierarchyChange. Added... 55/255/5
authorMikael Grankvist <mgrankvi@vaadin.com>
Tue, 13 Nov 2012 11:35:27 +0000 (13:35 +0200)
committerMikael Grankvist <mgrankvi@vaadin.com>
Tue, 13 Nov 2012 13:55:58 +0000 (15:55 +0200)
Change-Id: Iccd290a8e2be165207abe1b4805ec992d24bad0d

client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java
uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutCorrectPositioningOfHiddenField.html [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutCorrectPositioningOfHiddenField.java [new file with mode: 0644]

index 106aee7ace395a31fac1e42972c362fe62f7ede2..40830531b6a359b060bf5f229045e916f526abd4 100644 (file)
@@ -156,11 +156,15 @@ public class AbsoluteLayoutConnector extends
         // TODO Margin handling
 
         for (ComponentConnector child : getChildComponents()) {
-            getWidget().setWidgetPosition(
-                    child.getWidget(),
-                    getState().connectorToCssPosition.get(child
-                            .getConnectorId()));
+            setChildWidgetPosition(child);
         }
+    }
+
+    private void setChildWidgetPosition(ComponentConnector child) {
+        getWidget().setWidgetPosition(
+                child.getWidget(),
+                getState().connectorToCssPosition.get(child
+                        .getConnectorId()));
     };
 
     /*
@@ -176,6 +180,7 @@ public class AbsoluteLayoutConnector extends
             if (!getWidget().contains(child.getWidget())) {
                 getWidget().add(child.getWidget());
                 child.addStateChangeHandler(childStateChangeHandler);
+                setChildWidgetPosition(child);
             }
         }
         for (ComponentConnector oldChild : event.getOldChildren()) {
diff --git a/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutCorrectPositioningOfHiddenField.html b/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutCorrectPositioningOfHiddenField.html
new file mode 100644 (file)
index 0000000..f00d6b1
--- /dev/null
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="http://localhost:8888/" />
+<title>AbsoluteLayoutCorrectPositioningOfHiddenField</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">AbsoluteLayoutCorrectPositioningOfHiddenField</td></tr>
+</thead><tbody>
+<tr>
+       <td>open</td>
+       <td>/run/com.vaadin.tests.components.absolutelayout.AbsoluteLayoutCorrectPositioningOfHiddenField?restartApplication</td>
+       <td></td>
+</tr>
+<tr>
+       <td>assertElementNotPresent</td>
+       <td>vaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutCorrectPositioningOfHiddenField::PID_SpositionedLabel</td>
+       <td></td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutCorrectPositioningOfHiddenField::PID_SactionButton</td>
+       <td></td>
+</tr>
+<tr>
+       <td>assertElementPresent</td>
+       <td>vaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutCorrectPositioningOfHiddenField::PID_SpositionedLabel</td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>AbsoluteLayoutLabelPositionNotOrigo</td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutCorrectPositioningOfHiddenField::PID_SactionButton</td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>AbsoluteLayoutLabelMovedDown</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutCorrectPositioningOfHiddenField.java b/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutCorrectPositioningOfHiddenField.java
new file mode 100644 (file)
index 0000000..42ea615
--- /dev/null
@@ -0,0 +1,59 @@
+package com.vaadin.tests.components.absolutelayout;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.AbsoluteLayout;
+import com.vaadin.ui.AbsoluteLayout.ComponentPosition;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Label;
+
+public class AbsoluteLayoutCorrectPositioningOfHiddenField extends TestBase {
+
+    @Override
+    protected void setup() {
+        setTheme("tests-tickets");
+        final AbsoluteLayout abs = new AbsoluteLayout();
+        abs.setStyleName("borders");
+        abs.setWidth("250px");
+        abs.setHeight("100px");
+
+        final Label l = new Label("Top 20, Left 20");
+        l.setSizeUndefined();
+        l.setId("positionedLabel");
+        l.setVisible(false);
+        abs.addComponent(l, "top:20px;left:20px");
+
+        final Button action = new Button("Set visible");
+        action.addClickListener(new ClickListener() {
+
+            @Override
+            public void buttonClick(ClickEvent event) {
+                if (l.isVisible()) {
+                    l.setValue("Top 70, Left 20");
+                    ComponentPosition position = abs.getPosition(l);
+                    position.setCSSString("top:70px;left:20px;");
+                    abs.setPosition(l, position);
+                } else {
+                    l.setVisible(true);
+                    action.setCaption("Move down");
+                }
+            }
+        });
+        action.setId("actionButton");
+        abs.addComponent(action, "top: 70px;left: 150px;");
+
+        addComponent(abs);
+    }
+
+    @Override
+    protected String getDescription() {
+        return "AbsoluteLayout should reposition invisible components when set to visible";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 10180;
+    }
+
+}