summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2015-08-03 23:02:47 +0300
committerVaadin Code Review <review@vaadin.com>2015-08-04 13:15:47 +0000
commit50e13188aa372b0ad50c7279bcb3f18706897c23 (patch)
treeb05bb4307d5768e37629b1c2ce0ac307930d8087
parent3951ba9c2d751e3719699c546f530859d2b593ee (diff)
downloadvaadin-framework-50e13188aa372b0ad50c7279bcb3f18706897c23.tar.gz
vaadin-framework-50e13188aa372b0ad50c7279bcb3f18706897c23.zip
Attach Window in hierarchy change as required (#18502)
Change-Id: Ia9ca393480b80c19e5391bce034534bde31f3a81
-rw-r--r--client/src/com/vaadin/client/ui/ui/UIConnector.java14
-rw-r--r--client/src/com/vaadin/client/ui/window/WindowConnector.java4
-rw-r--r--uitest/src/com/vaadin/tests/components/window/GridInWindow.java49
-rw-r--r--uitest/src/com/vaadin/tests/components/window/GridInWindowTest.java36
-rw-r--r--uitest/src/com/vaadin/tests/tb3/newelements/WindowElement.java10
5 files changed, 109 insertions, 4 deletions
diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java
index cfb444ada6..6d98e2108a 100644
--- a/client/src/com/vaadin/client/ui/ui/UIConnector.java
+++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java
@@ -71,6 +71,7 @@ import com.vaadin.client.ui.ShortcutActionHandler;
import com.vaadin.client.ui.VNotification;
import com.vaadin.client.ui.VOverlay;
import com.vaadin.client.ui.VUI;
+import com.vaadin.client.ui.VWindow;
import com.vaadin.client.ui.layout.MayScrollChildren;
import com.vaadin.client.ui.window.WindowConnector;
import com.vaadin.server.Page.Styles;
@@ -669,6 +670,19 @@ public class UIConnector extends AbstractSingleComponentContainerConnector
if (c instanceof WindowConnector) {
WindowConnector wc = (WindowConnector) c;
wc.setWindowOrderAndPosition();
+ VWindow window = wc.getWidget();
+ if (!window.isAttached()) {
+
+ // Attach so that all widgets inside the Window are attached
+ // when their onStateChange is run
+
+ // Made invisible here for legacy reasons and made visible
+ // at the end of stateChange. This dance could probably be
+ // removed
+ window.setVisible(false);
+ window.show();
+ }
+
}
}
diff --git a/client/src/com/vaadin/client/ui/window/WindowConnector.java b/client/src/com/vaadin/client/ui/window/WindowConnector.java
index 8c23f712ad..9ea3c8bb68 100644
--- a/client/src/com/vaadin/client/ui/window/WindowConnector.java
+++ b/client/src/com/vaadin/client/ui/window/WindowConnector.java
@@ -356,10 +356,6 @@ public class WindowConnector extends AbstractSingleComponentContainerConnector
if (state.modal != window.vaadinModality) {
window.setVaadinModality(!window.vaadinModality);
}
- if (!window.isAttached()) {
- window.setVisible(false); // hide until possible centering
- window.show();
- }
boolean resizeable = state.resizable
&& state.windowMode == WindowMode.NORMAL;
window.setResizable(resizeable);
diff --git a/uitest/src/com/vaadin/tests/components/window/GridInWindow.java b/uitest/src/com/vaadin/tests/components/window/GridInWindow.java
new file mode 100644
index 0000000000..918a991cc1
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/window/GridInWindow.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.window;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Window;
+
+public class GridInWindow extends AbstractTestUIWithLog {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final Grid grid = new Grid();
+
+ grid.addColumn("Hidable column").setHidable(true);
+ grid.addRow("Close and reopen and it vanishes");
+
+ Button popupButton = new Button("Open PopUp",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(Button.ClickEvent event) {
+ Window subWindow = new Window("Sub-window");
+ subWindow.setContent(grid);
+ subWindow.setWidth(600, Unit.PIXELS);
+ subWindow.setWidth(400, Unit.PIXELS);
+ getUI().addWindow(subWindow);
+ }
+ });
+
+ addComponent(popupButton);
+
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/window/GridInWindowTest.java b/uitest/src/com/vaadin/tests/components/window/GridInWindowTest.java
new file mode 100644
index 0000000000..301a7c60e4
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/window/GridInWindowTest.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.window;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+import com.vaadin.tests.tb3.newelements.WindowElement;
+
+public class GridInWindowTest extends SingleBrowserTest {
+
+ @Test
+ public void ensureAttachInHierachyChange() {
+ openTestURL("debug");
+ $(ButtonElement.class).first().click();
+ assertNoErrorNotifications();
+ $(WindowElement.class).first().close();
+ assertNoErrorNotifications();
+ $(ButtonElement.class).first().click();
+ assertNoErrorNotifications();
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/tb3/newelements/WindowElement.java b/uitest/src/com/vaadin/tests/tb3/newelements/WindowElement.java
index 34344324d0..784d203ab0 100644
--- a/uitest/src/com/vaadin/tests/tb3/newelements/WindowElement.java
+++ b/uitest/src/com/vaadin/tests/tb3/newelements/WindowElement.java
@@ -14,6 +14,7 @@ public class WindowElement extends com.vaadin.testbench.elements.WindowElement {
private final String restoreBoxClass = "v-window-restorebox";
private final String maximizeBoxClass = "v-window-maximizebox";
+ private final String closeBoxClass = "v-window-closebox";
public void restore() {
if (isMaximized()) {
@@ -63,4 +64,13 @@ public class WindowElement extends com.vaadin.testbench.elements.WindowElement {
public String getCaption() {
return findElement(By.className("v-window-header")).getText();
}
+
+ private WebElement getCloseButton() {
+ return findElement(By.className(closeBoxClass));
+ }
+
+ public void close() {
+ getCloseButton().click();
+
+ }
}