Browse Source

Attach Window in hierarchy change as required (#18502)

Change-Id: Ia9ca393480b80c19e5391bce034534bde31f3a81
tags/7.6.0.alpha4
Artur Signell 8 years ago
parent
commit
50e13188aa

+ 14
- 0
client/src/com/vaadin/client/ui/ui/UIConnector.java View File

@@ -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();
}

}
}


+ 0
- 4
client/src/com/vaadin/client/ui/window/WindowConnector.java View File

@@ -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);

+ 49
- 0
uitest/src/com/vaadin/tests/components/window/GridInWindow.java View File

@@ -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);

}

}

+ 36
- 0
uitest/src/com/vaadin/tests/components/window/GridInWindowTest.java View File

@@ -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();
}
}

+ 10
- 0
uitest/src/com/vaadin/tests/tb3/newelements/WindowElement.java View File

@@ -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();

}
}

Loading…
Cancel
Save