]> source.dussan.org Git - vaadin-framework.git/commitdiff
fixes #4654, added virtual client side synchronization for UI check that happens...
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Fri, 7 May 2010 14:55:24 +0000 (14:55 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Fri, 7 May 2010 14:55:24 +0000 (14:55 +0000)
svn changeset:13085/svn branch:6.3

src/com/vaadin/terminal/gwt/client/ui/VUpload.java
src/com/vaadin/ui/Upload.java

index d164de79db6813b5b7e78c22fe7220a6abdad729..ce3012b3b0944d6ab45802a32474f03d6586e161 100644 (file)
@@ -99,6 +99,8 @@ public class VUpload extends SimplePanel implements Paintable {
 
     private com.google.gwt.dom.client.Element synthesizedFrame;
 
+    private int nextUploadId;
+
     public VUpload() {
         super(com.google.gwt.dom.client.Document.get().createFormElement());
 
@@ -136,9 +138,14 @@ public class VUpload extends SimplePanel implements Paintable {
         if (client.updateComponent(this, uidl, true)) {
             return;
         }
+        if (uidl.hasAttribute("notStarted")) {
+            t.schedule(400);
+            return;
+        }
         setImmediate(uidl.getBooleanAttribute("immediate"));
         this.client = client;
         paintableId = uidl.getId();
+        nextUploadId = uidl.getIntAttribute("nextid");
         element.setAction(client.getAppUri());
         submitButton.setText(uidl.getStringAttribute("buttoncaption"));
         fu.setName(paintableId + "_file");
@@ -265,7 +272,8 @@ public class VUpload extends SimplePanel implements Paintable {
                         .getConsole()
                         .log(
                                 "Visiting server to see if upload started event changed UI.");
-                client.sendPendingVariableChanges();
+                client.updateVariable(paintableId, "pollForStart",
+                        nextUploadId, true);
             }
         };
         t.schedule(800);
index 49cf159e0ae2f37eb936aa6a45bb8f84c39e4227..0e2f022561e0e01a4e71ccf745105e3cebf2ef24 100644 (file)
@@ -100,6 +100,10 @@ public class Upload extends AbstractComponent implements Component.Focusable {
 
     private boolean interrupted = false;
 
+    private boolean notStarted;
+
+    private int nextid;
+
     /* TODO: Add a default constructor, receive to temp file. */
 
     /**
@@ -219,8 +223,14 @@ public class Upload extends AbstractComponent implements Component.Focusable {
      */
     @Override
     public void changeVariables(Object source, Map variables) {
-        // NOP
-
+        if (variables.containsKey("pollForStart")) {
+            int id = (Integer) variables.get("pollForStart");
+            if (!isUploading && id == nextid) {
+                notStarted = true;
+                requestRepaint();
+            } else {
+            }
+        }
     }
 
     /**
@@ -233,6 +243,11 @@ public class Upload extends AbstractComponent implements Component.Focusable {
      */
     @Override
     public void paintContent(PaintTarget target) throws PaintException {
+        if (notStarted) {
+            target.addAttribute("notStarted", true);
+            notStarted = false;
+            return;
+        }
         // The field should be focused
         if (focus) {
             target.addAttribute("focus", true);
@@ -247,7 +262,8 @@ public class Upload extends AbstractComponent implements Component.Focusable {
 
         target.addAttribute("buttoncaption", buttonCaption);
 
-        target.addUploadStreamVariable(this, "stream");
+        target.addAttribute("nextid", nextid);
+
     }
 
     /**
@@ -906,6 +922,7 @@ public class Upload extends AbstractComponent implements Component.Focusable {
             throw new IllegalStateException("uploading already started");
         }
         isUploading = true;
+        nextid++;
     }
 
     /**