]> source.dussan.org Git - vaadin-framework.git/commitdiff
#7020 VNotification should be created with GWT.create()
authorLeif Åstrand <leif@vaadin.com>
Thu, 11 Aug 2011 07:09:04 +0000 (07:09 +0000)
committerLeif Åstrand <leif@vaadin.com>
Thu, 11 Aug 2011 07:09:04 +0000 (07:09 +0000)
svn changeset:20288/svn branch:6.7

src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
src/com/vaadin/terminal/gwt/client/ui/VNotification.java

index 8baad19786679a1ba26ef96de300d36fe7ebb7a2..8c7907bbff7807a108fa2394f2baade88a6f0057 100755 (executable)
@@ -649,7 +649,7 @@ public class ApplicationConnection {
             html.append(details);
             html.append("</I></p>");
 
-            VNotification n = new VNotification(1000 * 60 * 45);
+            VNotification n = VNotification.createNotification(1000 * 60 * 45);
             n.addEventListener(new NotificationRedirect(url));
             n.show(html.toString(), VNotification.CENTERED_TOP,
                     VNotification.STYLE_SYSTEM);
@@ -1008,7 +1008,8 @@ public class ApplicationConnection {
 
                         if (html.length() != 0) {
                             /* 45 min */
-                            VNotification n = new VNotification(1000 * 60 * 45);
+                            VNotification n = VNotification
+                                    .createNotification(1000 * 60 * 45);
                             n.addEventListener(new NotificationRedirect(url));
                             n.show(html, VNotification.CENTERED_TOP,
                                     VNotification.STYLE_SYSTEM);
index c3d239310c3bd746b4dc34cc3b5f074fc022470b..a7fe91df53e86c8a269f09ae0f884e876b0e81eb 100644 (file)
@@ -9,6 +9,7 @@ import java.util.Date;
 import java.util.EventObject;\r
 import java.util.Iterator;\r
 \r
+import com.google.gwt.core.client.GWT;\r
 import com.google.gwt.event.dom.client.KeyCodes;\r
 import com.google.gwt.user.client.DOM;\r
 import com.google.gwt.user.client.Element;\r
@@ -55,12 +56,23 @@ public class VNotification extends VOverlay {
     private ArrayList<EventListener> listeners;\r
     private static final int TOUCH_DEVICE_IDLE_DELAY = 1000;\r
 \r
+    /**\r
+     * @deprecated Use GWT.create instead\r
+     */\r
+    @Deprecated\r
     public VNotification() {\r
         setStyleName(STYLENAME);\r
         sinkEvents(Event.ONCLICK);\r
         DOM.setStyleAttribute(getElement(), "zIndex", "" + Z_INDEX_BASE);\r
     }\r
 \r
+    /**\r
+     * @deprecated Use static {@link #createNotification(int)} instead to enable\r
+     *             GWT deferred binding.\r
+     * \r
+     * @param delayMsec\r
+     */\r
+    @Deprecated\r
     public VNotification(int delayMsec) {\r
         this();\r
         this.delayMsec = delayMsec;\r
@@ -76,6 +88,15 @@ public class VNotification extends VOverlay {
         }\r
     }\r
 \r
+    /**\r
+     * @deprecated Use static {@link #createNotification(int, int, int)} instead\r
+     *             to enable GWT deferred binding.\r
+     * \r
+     * @param delayMsec\r
+     * @param fadeMsec\r
+     * @param startOpacity\r
+     */\r
+    @Deprecated\r
     public VNotification(int delayMsec, int fadeMsec, int startOpacity) {\r
         this(delayMsec);\r
         this.fadeMsec = fadeMsec;\r
@@ -365,7 +386,31 @@ public class VNotification extends VOverlay {
                 .getStringAttribute("style") : null;\r
         final int position = notification.getIntAttribute("position");\r
         final int delay = notification.getIntAttribute("delay");\r
-        new VNotification(delay).show(html, position, style);\r
+        createNotification(delay).show(html, position, style);\r
+    }\r
+\r
+    public static VNotification createNotification(int delayMsec) {\r
+        final VNotification notification = GWT.create(VNotification.class);\r
+        notification.delayMsec = delayMsec;\r
+        if (BrowserInfo.get().isTouchDevice()) {\r
+            new Timer() {\r
+                @Override\r
+                public void run() {\r
+                    if (notification.isAttached()) {\r
+                        notification.fade();\r
+                    }\r
+                }\r
+            }.schedule(notification.delayMsec + TOUCH_DEVICE_IDLE_DELAY);\r
+        }\r
+        return notification;\r
+    }\r
+\r
+    public static VNotification createNotification(int delayMsec, int fadeMsec,\r
+            int startOpacity) {\r
+        VNotification notification = createNotification(delayMsec);\r
+        notification.fadeMsec = fadeMsec;\r
+        notification.startOpacity = startOpacity;\r
+        return notification;\r
     }\r
 \r
     public class HideEvent extends EventObject {\r