When multiple files are selected the download option downloads all of them in multipl...
authorChristos Stathis <chstath@ebs.gr>
Tue, 4 Oct 2011 14:15:08 +0000 (17:15 +0300)
committerChristos Stathis <chstath@ebs.gr>
Tue, 4 Oct 2011 14:15:08 +0000 (17:15 +0300)
web_client/src/gr/grnet/pithos/web/client/FileContextMenu.java
web_client/src/gr/grnet/pithos/web/client/ToolsMenu.java

index 92fb0d6..2ad422d 100644 (file)
@@ -50,6 +50,7 @@ import java.util.List;
 import com.google.gwt.resources.client.ClientBundle;
 import com.google.gwt.resources.client.ImageResource;
 import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.ui.AbstractImagePrototype;
 import com.google.gwt.user.client.ui.MenuBar;
 import com.google.gwt.user.client.ui.MenuItem;
@@ -179,7 +180,7 @@ public class FileContextMenu extends PopupPanel {
         *
         * @param newImages the image bundle passed on by the parent object
         */
-       public FileContextMenu(final Pithos app, Images newImages, TreeView selectedTree, Folder selectedFolder, List<File> selectedFiles) {
+       public FileContextMenu(final Pithos app, Images newImages, TreeView selectedTree, Folder selectedFolder, final List<File> selectedFiles) {
                // The popup's constructor's argument is a boolean specifying that it
                // auto-close itself when the user clicks outside of it.
                super(true);
@@ -240,8 +241,14 @@ public class FileContextMenu extends PopupPanel {
                        contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(app, this, selectedFiles, images, 0)));
 
         }
-        if (selectedFiles.size() == 1)
-                   contextMenu.addItem(new MenuItem("<span><a class='hidden-link' href='" + app.getApiPath() + selectedFiles.get(0).getOwner() + selectedFiles.get(0).getUri() + "?X-Auth-Token=" + app.getToken() + "' target='_blank'>" + AbstractImagePrototype.create(newImages.download()).getHTML() + " Download</a></span>", true, (Command) null));
+           contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.download()).getHTML() + "&nbsp;Download</span>", true, new Command() {
+                       
+                       @Override
+                       public void execute() {
+                               for (File f : selectedFiles)
+                                       Window.open(app.getApiPath() + f.getOwner() + f.getUri() + "?X-Auth-Token=" + app.getToken(), "_blank", "");
+                       }
+               }));
 
                add(contextMenu);
        }
index 590ee30..c7a1b2f 100644 (file)
@@ -57,6 +57,7 @@ import gr.grnet.pithos.web.client.grouptree.User;
 import java.util.List;
 
 import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.ui.AbstractImagePrototype;
 import com.google.gwt.user.client.ui.MenuBar;
 import com.google.gwt.user.client.ui.MenuItem;
@@ -88,7 +89,7 @@ public class ToolsMenu extends PopupPanel {
         *
         * @param newImages the image bundle passed on by the parent object
         */
-       public ToolsMenu(Pithos app, Images newImages, TreeView selectedTree, Folder folder, List<File> files) {
+       public ToolsMenu(final Pithos app, Images newImages, TreeView selectedTree, Folder folder, final List<File> files) {
                // The popup's constructor's argument is a boolean specifying that it
                // auto-close itself when the user clicks outside of it.
                super(true);
@@ -180,8 +181,16 @@ public class ToolsMenu extends PopupPanel {
                                        if (properties != null)
                                                contextMenu.addItem(properties);
                                    }
-                               if (files != null && files.size() == 1)
-                                           contextMenu.addItem(new MenuItem("<span><a class='hidden-link' href='" + app.getApiPath() + files.get(0).getOwner() + files.get(0).getUri() + "?X-Auth-Token=" + app.getToken() + "' target='_blank'>" + AbstractImagePrototype.create(newImages.download()).getHTML() + " Download</a></span>", true, (Command) null));
+                               if (files != null) {
+                                           contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.download()).getHTML() + "&nbsp;Download</span>", true, new Command() {
+                                                       
+                                                       @Override
+                                                       public void execute() {
+                                                       for (File f: files)
+                                                               Window.open(app.getApiPath() + files.get(0).getOwner() + files.get(0).getUri() + "?X-Auth-Token=" + app.getToken(), "_blank", "");
+                                                       }
+                                               }));
+                               }
                        }
                }
                else {