diff options
3 files changed, 121 insertions, 4 deletions
diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java index 6a908aaa29..396fc76eb0 100644 --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@ -991,14 +991,14 @@ public class VWindow extends VWindowOverlay implements } bubble = false; } + if (type == Event.ONCLICK) { + activateOnClick(); + } } else if (dragging || !contents.isOrHasChild(target)) { onDragEvent(event); bubble = false; } else if (type == Event.ONCLICK) { - // clicked inside window, ensure to be on top - if (!isActive()) { - bringToFront(); - } + activateOnClick(); } /* @@ -1020,6 +1020,13 @@ public class VWindow extends VWindowOverlay implements } } + private void activateOnClick() { + // clicked inside window or inside header, ensure to be on top + if (!isActive()) { + bringToFront(); + } + } + private void onCloseClick() { client.updateVariable(id, "close", true, true); } diff --git a/uitest/src/com/vaadin/tests/components/window/MoveToTop.java b/uitest/src/com/vaadin/tests/components/window/MoveToTop.java new file mode 100644 index 0000000000..4fd748183a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/MoveToTop.java @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2013 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.AbstractTestUI; +import com.vaadin.ui.Window; + +/** + * + * @author Vaadin Ltd + */ +public class MoveToTop extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Window window = new Window("one"); + window.addStyleName("first-window"); + window.setWidth(200, Unit.PIXELS); + window.setHeight(100, Unit.PIXELS); + window.setPositionX(100); + window.setPositionY(100); + addWindow(window); + + window = new Window("two"); + window.setWidth(200, Unit.PIXELS); + window.setHeight(100, Unit.PIXELS); + window.setPositionX(150); + window.setPositionY(150); + window.addStyleName("second-window"); + addWindow(window); + } + + @Override + protected String getTestDescription() { + return "Bring to front window on click it's header"; + } + + @Override + protected Integer getTicketNumber() { + return 13445; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/window/MoveToTopTest.java b/uitest/src/com/vaadin/tests/components/window/MoveToTopTest.java new file mode 100644 index 0000000000..26d7a06531 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/MoveToTopTest.java @@ -0,0 +1,53 @@ +/* + * Copyright 2000-2013 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 java.io.IOException; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @author Vaadin Ltd + */ +public class MoveToTopTest extends MultiBrowserTest { + + @Test + public void testBringToFrontViaHeader() throws IOException { + openTestURL(); + + WebElement firstWindow = driver.findElement(By + .className("first-window")); + + WebElement secondWindow = driver.findElement(By + .className("second-window")); + + secondWindow.click(); + + compareScreen("second-window-over-first"); + + WebElement headerFirst = firstWindow.findElement(By + .className("v-window-outerheader")); + headerFirst.click(); + + compareScreen("first-window-over-second"); + } + +} |