When a file is dropped while another is uploading the alert is updated to show the...
authorChristos Stathis <chstath@ebs.gr>
Fri, 25 May 2012 12:42:17 +0000 (15:42 +0300)
committerChristos Stathis <chstath@ebs.gr>
Fri, 25 May 2012 12:42:17 +0000 (15:42 +0300)
src/gr/grnet/pithos/web/client/FileUploadDialog.java
src/gr/grnet/pithos/web/client/Pithos.java
src/gr/grnet/pithos/web/client/UploadAlert.java

index 7b5d021..0e3ccfe 100644 (file)
@@ -208,10 +208,11 @@ public class FileUploadDialog extends DialogBox {
                                                for (var j=0; j<files.length; j++)
                                                        files[j].url = path + "/" + files[j].name;
                                                dlg.@gr.grnet.pithos.web.client.FileUploadDialog::setInProgress(Z)(true);
-                                               up.start();
+                                               if (up.state == $wnd.plupload.STOPPED)
+                                                       up.start();
                                                app.@gr.grnet.pithos.web.client.Pithos::showUploadIndicator()();
                                                if (!dlg.@gr.grnet.pithos.web.client.FileUploadDialog::isVisible()())
-                                                       app.@gr.grnet.pithos.web.client.Pithos::showUploadAlert(I)(files.length);
+                                                       app.@gr.grnet.pithos.web.client.Pithos::showUploadAlert(I)(up.files.length);
                                        },
                                        
                                        FilesRemoved: function(up, files) {
index 8deaac3..a2d0dcc 100644 (file)
@@ -1386,15 +1386,19 @@ public class Pithos implements EntryPoint, ResizeHandler {
                }
        }-*/;
        
-       public void showUploadAlert(int numOfFiles) {
-               uploadAlert = new UploadAlert(this, numOfFiles);
-               uploadAlert.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
-                       
-                       @Override
-                       public void setPosition(int offsetWidth, int offsetHeight) {
-                               uploadAlert.setPopupPosition((Window.getClientWidth() - offsetWidth)/2, Window.getClientHeight() - offsetHeight);
-                       }
-               });
+       public void showUploadAlert(int nOfFiles) {
+               if (uploadAlert == null)
+                       uploadAlert = new UploadAlert(this, nOfFiles);
+               if (!uploadAlert.isShowing())
+                       uploadAlert.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
+                               
+                               @Override
+                               public void setPosition(int offsetWidth, int offsetHeight) {
+                                       uploadAlert.setPopupPosition((Window.getClientWidth() - offsetWidth)/2, Window.getClientHeight() - offsetHeight);
+                               }
+                       });
+               else
+                       uploadAlert.setNumOfFiles(nOfFiles);
        }
        
        public void hideUploadAlert() {
index bd4b9b6..5616a77 100644 (file)
@@ -47,18 +47,20 @@ import com.google.gwt.user.client.ui.PopupPanel;
  */
 public class UploadAlert extends PopupPanel {
        
+       private HTML label = new HTML();
+       
        /**
         * The widget's constructor.
         */
-       public UploadAlert(final Pithos app, int numOfFiles) {
+       public UploadAlert(final Pithos app, int _numOfFiles) {
                // The popup's constructor's argument is a boolean specifying that it
                // auto-close itself when the user clicks outside of it.
                super(false);
                setAnimationEnabled(true);
                addStyleName(Pithos.resources.pithosCss().uploadAlert());
                FlowPanel content = new FlowPanel();
-               String label = String.valueOf(numOfFiles) + " " + (numOfFiles > 1 ? "files are" : "file is") + " being uploaded";
-               content.add(new HTML(label));
+               setNumOfFiles(_numOfFiles);
+               content.add(label);
                Anchor a = new Anchor("Click for details");
                a.addStyleName(Pithos.resources.pithosCss().uploadAlertLink());
                a.addClickHandler(new ClickHandler() {
@@ -99,4 +101,8 @@ public class UploadAlert extends PopupPanel {
                
                add(content);
        }
+       
+       public void setNumOfFiles(int n) {
+               label.setText(String.valueOf(n) + " " + (n > 1 ? "files are" : "file is") + " being uploaded");
+       }
 }