Use a single configuration entry for the service home URL and avoid hardcoding it...
[pithos] / src / gr / ebs / gss / client / FileContextMenu.java
index faa9696..b795e5a 100644 (file)
@@ -40,6 +40,7 @@ import com.google.gwt.user.client.ui.ClickListener;
 import com.google.gwt.user.client.ui.MenuBar;
 import com.google.gwt.user.client.ui.MenuItem;
 import com.google.gwt.user.client.ui.PopupPanel;
+import com.google.gwt.user.client.ui.TreeItem;
 import com.google.gwt.user.client.ui.Widget;
 
 /**
@@ -70,6 +71,8 @@ public class FileContextMenu extends PopupPanel implements ClickListener {
 
        private MenuItem downloadItem;
 
+       private MenuItem saveAsItem;
+
        /**
         * The image bundle for this widget's images that reuses images defined in
         * other menus.
@@ -102,6 +105,7 @@ public class FileContextMenu extends PopupPanel implements ClickListener {
                // The popup's constructor's argument is a boolean specifying that it
                // auto-close itself when the user clicks outside of it.
                super(true);
+               GSS gss = GSS.get();
                setAnimationEnabled(true);
                images = newImages;
 
@@ -121,14 +125,14 @@ public class FileContextMenu extends PopupPanel implements ClickListener {
                        contextMenu.addItem(pasteItem);
                        if (GSS.get().getFolders().getCurrent() != null)
                                if (GSS.get().getFolders().isFileItem(GSS.get().getFolders().getCurrent()))
-                                       contextMenu.addItem("<span>" + newImages.fileUpdate().getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this, images));
+                                       contextMenu.addItem("<span>" + newImages.fileUpdate().getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this));
                                else if (GSS.get().getFolders().isMySharedItem(GSS.get().getFolders().getCurrent()) || GSS      .get()
                                                                                                                                                                                                                        .getFolders()
                                                                                                                                                                                                                        .isOthersSharedItem(GSS .get()
                                                                                                                                                                                                                                                                        .getFolders()
                                                                                                                                                                                                                                                                        .getCurrent()))
                                        if(GSS.get().getFolders().getCurrent().getUserObject() instanceof FolderResource)
-                                               contextMenu.addItem("<span>" + newImages.fileUpdate().getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this, images));
+                                               contextMenu.addItem("<span>" + newImages.fileUpdate().getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this));
                        contextMenu.addItem("<span>" + images.refresh().getHTML() + "&nbsp;Refresh</span>", true, new RefreshCommand(this, images));
                } else if (isTrash) {
                        contextMenu.addItem("<span>" + newImages.versions().getHTML() + "&nbsp;Restore</span>", true, new RestoreTrashCommand(this));
@@ -147,7 +151,7 @@ public class FileContextMenu extends PopupPanel implements ClickListener {
                        cutItem = new MenuItem("<span>" + newImages.cut().getHTML() + "&nbsp;Cut</span>", true, new CutCommand(this));
                        copyItem = new MenuItem("<span>" + newImages.copy().getHTML() + "&nbsp;Copy</span>", true, new CopyCommand(this));
 
-                       updateItem = new MenuItem("<span>" + newImages.fileUpdate().getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this, images));
+                       updateItem = new MenuItem("<span>" + newImages.fileUpdate().getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this));
 
                        trashItem = new MenuItem("<span>" + newImages.emptyTrash().getHTML() + "&nbsp;Move to Trash</span>", true, new ToTrashCommand(this));
                        deleteItem = new MenuItem("<span>" + newImages.delete().getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(this, images));
@@ -155,14 +159,20 @@ public class FileContextMenu extends PopupPanel implements ClickListener {
                        sharingItem = new MenuItem("<span>" + newImages.sharing().getHTML() + "&nbsp;Sharing</span>", true, new PropertiesCommand(this, images, 1));
                        propItem = new MenuItem("<span>" + newImages.viewText().getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(this, images, 0));
 
-                       contextMenu.addItem(updateItem);
+                       TreeItem currentFolder = gss.getFolders().getCurrent();
+                       if(currentFolder!=null && currentFolder.getUserObject() instanceof FolderResource)
+                               contextMenu.addItem(updateItem);
                        String[] link = {"", ""};
-                       GSS.get().getTopPanel().getFileMenu().createDownloadLink(link);
+                       gss.getTopPanel().getFileMenu().createDownloadLink(link, false);
                        downloadItem = new MenuItem("<span>" + link[0] + newImages.download().getHTML() + " Download" + link[1] + "</span>", true, downloadCmd);
                        contextMenu.addItem(downloadItem);
+                       gss.getTopPanel().getFileMenu().createDownloadLink(link, true);
+                       saveAsItem = new MenuItem("<span>" + link[0] + newImages.download().getHTML() + " Save As" + link[1] + "</span>", true, downloadCmd);
+                       contextMenu.addItem(saveAsItem);
                        contextMenu.addItem(cutItem);
                        contextMenu.addItem(copyItem);
-                       contextMenu.addItem(pasteItem);
+                       if(currentFolder!=null && currentFolder.getUserObject() instanceof FolderResource)
+                               contextMenu.addItem(pasteItem);
                        contextMenu.addItem("<span>" + images.unselectAll().getHTML() + "&nbsp;Unselect</span>", true, unselectAllCommand);
                        contextMenu.addItem(trashItem);
                        contextMenu.addItem(deleteItem);
@@ -171,7 +181,7 @@ public class FileContextMenu extends PopupPanel implements ClickListener {
                        contextMenu.addItem(propItem);
                }
                add(contextMenu);
-               if (GSS.get().getClipboard().hasFileItem())
+               if (gss.getClipboard().hasFileItem())
                        pasteItem.setVisible(true);
                else
                        pasteItem.setVisible(false);