diff options
author | Automerge <automerge@vaadin.com> | 2012-05-04 13:19:50 +0000 |
---|---|---|
committer | Automerge <automerge@vaadin.com> | 2012-05-04 13:19:50 +0000 |
commit | 295e0f391131d5a9fa9d2f2b08dcc6418e42d484 (patch) | |
tree | 9b5e4f725bc4541d7efaebb70d1df60f78f916b7 | |
parent | 63dc030e321b05faf02248ca266a90dec2aff067 (diff) | |
download | vaadin-framework-295e0f391131d5a9fa9d2f2b08dcc6418e42d484.tar.gz vaadin-framework-295e0f391131d5a9fa9d2f2b08dcc6418e42d484.zip |
[merge from 6.7] Fix #7136: Opening a modal subwindow when there are visible notifications prevented the notifications from fading
svn changeset:23678/svn branch:6.8
4 files changed, 104 insertions, 0 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VNotification.java b/src/com/vaadin/terminal/gwt/client/ui/VNotification.java index 2ee66d01ca..4166148a25 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VNotification.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VNotification.java @@ -41,6 +41,8 @@ public class VNotification extends VOverlay { public static final String STYLE_SYSTEM = "system"; private static final int FADE_ANIMATION_INTERVAL = 50; // == 20 fps + private static final ArrayList<VNotification> notifications = new ArrayList<VNotification>(); + private int startOpacity = 90; private int fadeMsec = 400; private int delayMsec = 1000; @@ -150,6 +152,7 @@ public class VNotification extends VOverlay { addStyleDependentName(style); } super.show(); + notifications.add(this); setPosition(position); /** * Android 4 fails to render notifications correctly without a little @@ -171,6 +174,7 @@ public class VNotification extends VOverlay { temporaryStyle = null; } super.hide(); + notifications.remove(this); fireEvent(new HideEvent(this)); } @@ -421,4 +425,19 @@ public class VNotification extends VOverlay { public interface EventListener extends java.util.EventListener { public void notificationHidden(HideEvent event); } + + /** + * Moves currently visible notifications to the top of the event preview + * stack. Can be called when opening other overlays such as subwindows to + * ensure the notifications receive the events they need and don't linger + * indefinitely. See #7136. + * + * TODO Should this be a generic Overlay feature instead? + */ + public static void bringNotificationsToFront() { + for (VNotification notification : notifications) { + DOM.removeEventPreview(notification); + DOM.addEventPreview(notification); + } + } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java index 103979927a..2355a9c65a 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java @@ -520,6 +520,7 @@ public class VWindow extends VOverlay implements Container, Scheduler.get().scheduleFinally(new Command() { public void execute() { doServerSideOrdering(); + VNotification.bringNotificationsToFront(); } }); } diff --git a/tests/testbench/com/vaadin/tests/components/notification/NotificationsAndModalWindow.html b/tests/testbench/com/vaadin/tests/components/notification/NotificationsAndModalWindow.html new file mode 100644 index 0000000000..35d22da46e --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/notification/NotificationsAndModalWindow.html @@ -0,0 +1,42 @@ +<?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="" /> +<title>NotificationsAndModalWindow</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">NotificationsAndModalWindow</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.notification.NotificationsAndModalWindow?restartApplication</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsAndModalWindow::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>closeNotification</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsAndModalWindow::Root/VNotification[1]</td> + <td>0,0</td> +</tr> +<tr> + <td>closeNotification</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsAndModalWindow::Root/VNotification[0]</td> + <td>0,0</td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsAndModalWindow::Root/VNotification[0]</td> + <td></td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/testbench/com/vaadin/tests/components/notification/NotificationsAndModalWindow.java b/tests/testbench/com/vaadin/tests/components/notification/NotificationsAndModalWindow.java new file mode 100644 index 0000000000..562e8095f2 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/notification/NotificationsAndModalWindow.java @@ -0,0 +1,42 @@ +package com.vaadin.tests.components.notification; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Window; +import com.vaadin.ui.Window.Notification; + +public class NotificationsAndModalWindow extends TestBase { + + @Override + protected void setup() { + getMainWindow().showNotification("Notification 1", + Notification.TYPE_WARNING_MESSAGE); + getMainWindow().showNotification("Notification 2", + Notification.TYPE_WARNING_MESSAGE); + + Button b = new Button("Button"); + b.addListener(new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + + Window w = new Window("This is a window"); + w.setModal(true); + getMainWindow().addWindow(w); + } + + }); + addComponent(b); + } + + @Override + protected String getDescription() { + return "Press the button when both two notifications are visible to add a modal window to the app. When the modal window is visible, the notifications should disappear normally."; + } + + @Override + protected Integer getTicketNumber() { + return 7136; + } + +} |