]> source.dussan.org Git - vaadin-framework.git/commitdiff
[merge from 6.7] Fix #7136: Opening a modal subwindow when there are visible notifica...
authorAutomerge <automerge@vaadin.com>
Fri, 4 May 2012 13:19:50 +0000 (13:19 +0000)
committerAutomerge <automerge@vaadin.com>
Fri, 4 May 2012 13:19:50 +0000 (13:19 +0000)
svn changeset:23678/svn branch:6.8

src/com/vaadin/terminal/gwt/client/ui/VNotification.java
src/com/vaadin/terminal/gwt/client/ui/VWindow.java
tests/testbench/com/vaadin/tests/components/notification/NotificationsAndModalWindow.html [new file with mode: 0644]
tests/testbench/com/vaadin/tests/components/notification/NotificationsAndModalWindow.java [new file with mode: 0644]

index 2ee66d01caeaa2b62872cbca73e618eba20c62b0..4166148a25566facb86e2e295ca0de1a37df4409 100644 (file)
@@ -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);
+        }
+    }
 }
index 103979927a49b7f93ce75a396078dcf7be81de90..2355a9c65a1808d989b7bee52fca717297a97f12 100644 (file)
@@ -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 (file)
index 0000000..35d22da
--- /dev/null
@@ -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 (file)
index 0000000..562e809
--- /dev/null
@@ -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;
+    }
+
+}