summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2011-08-11 07:09:04 +0000
committerLeif Åstrand <leif@vaadin.com>2011-08-11 07:09:04 +0000
commita0875ceaed3454116cd3fd19038d03d5a4724106 (patch)
tree772ef20e0c844879a1b26009b1459c58b673fd5e /src
parent48af8750fd08cd4a5545eabe1015f81e89bc7d7f (diff)
downloadvaadin-framework-a0875ceaed3454116cd3fd19038d03d5a4724106.tar.gz
vaadin-framework-a0875ceaed3454116cd3fd19038d03d5a4724106.zip
#7020 VNotification should be created with GWT.create()
svn changeset:20288/svn branch:6.7
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/vaadin/terminal/gwt/client/ApplicationConnection.java5
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VNotification.java47
2 files changed, 49 insertions, 3 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
index 8baad19786..8c7907bbff 100755
--- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
+++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
@@ -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);
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VNotification.java b/src/com/vaadin/terminal/gwt/client/ui/VNotification.java
index c3d239310c..a7fe91df53 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VNotification.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VNotification.java
@@ -9,6 +9,7 @@ import java.util.Date;
import java.util.EventObject;
import java.util.Iterator;
+import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
@@ -55,12 +56,23 @@ public class VNotification extends VOverlay {
private ArrayList<EventListener> listeners;
private static final int TOUCH_DEVICE_IDLE_DELAY = 1000;
+ /**
+ * @deprecated Use GWT.create instead
+ */
+ @Deprecated
public VNotification() {
setStyleName(STYLENAME);
sinkEvents(Event.ONCLICK);
DOM.setStyleAttribute(getElement(), "zIndex", "" + Z_INDEX_BASE);
}
+ /**
+ * @deprecated Use static {@link #createNotification(int)} instead to enable
+ * GWT deferred binding.
+ *
+ * @param delayMsec
+ */
+ @Deprecated
public VNotification(int delayMsec) {
this();
this.delayMsec = delayMsec;
@@ -76,6 +88,15 @@ public class VNotification extends VOverlay {
}
}
+ /**
+ * @deprecated Use static {@link #createNotification(int, int, int)} instead
+ * to enable GWT deferred binding.
+ *
+ * @param delayMsec
+ * @param fadeMsec
+ * @param startOpacity
+ */
+ @Deprecated
public VNotification(int delayMsec, int fadeMsec, int startOpacity) {
this(delayMsec);
this.fadeMsec = fadeMsec;
@@ -365,7 +386,31 @@ public class VNotification extends VOverlay {
.getStringAttribute("style") : null;
final int position = notification.getIntAttribute("position");
final int delay = notification.getIntAttribute("delay");
- new VNotification(delay).show(html, position, style);
+ createNotification(delay).show(html, position, style);
+ }
+
+ public static VNotification createNotification(int delayMsec) {
+ final VNotification notification = GWT.create(VNotification.class);
+ notification.delayMsec = delayMsec;
+ if (BrowserInfo.get().isTouchDevice()) {
+ new Timer() {
+ @Override
+ public void run() {
+ if (notification.isAttached()) {
+ notification.fade();
+ }
+ }
+ }.schedule(notification.delayMsec + TOUCH_DEVICE_IDLE_DELAY);
+ }
+ return notification;
+ }
+
+ public static VNotification createNotification(int delayMsec, int fadeMsec,
+ int startOpacity) {
+ VNotification notification = createNotification(delayMsec);
+ notification.fadeMsec = fadeMsec;
+ notification.startOpacity = startOpacity;
+ return notification;
}
public class HideEvent extends EventObject {