X-Git-Url: https://code.grnet.gr/git/pithos/blobdiff_plain/16baf609bb746ccbc6cd8da7213ee74cf474f2a9..c6f2b274dffad9def6274114fb041ab4ae8021b9:/src/gr/ebs/gss/client/FileMenu.java diff --git a/src/gr/ebs/gss/client/FileMenu.java b/src/gr/ebs/gss/client/FileMenu.java index 23aa254..5a0a467 100644 --- a/src/gr/ebs/gss/client/FileMenu.java +++ b/src/gr/ebs/gss/client/FileMenu.java @@ -25,6 +25,7 @@ import gr.ebs.gss.client.commands.RefreshCommand; import gr.ebs.gss.client.commands.UploadFileCommand; import gr.ebs.gss.client.rest.RestCommand; import gr.ebs.gss.client.rest.resource.FileResource; +import gr.ebs.gss.client.rest.resource.FolderResource; import gr.ebs.gss.client.rest.resource.GroupUserResource; import com.google.gwt.http.client.URL; @@ -117,8 +118,10 @@ public class FileMenu extends PopupPanel implements ClickListener { * @param link a String array with two elements that is modified so that the * first position contains the opening tag and the second one the * closing tag + * @param forceDownload If true, link will be such that browser should ask for filename + * and save location */ - void createDownloadLink(String[] link) { + void createDownloadLink(String[] link, boolean forceDownload) { GSS app = GSS.get(); Object selection = app.getCurrentSelection(); if (selection != null && selection instanceof FileResource) { @@ -126,7 +129,8 @@ public class FileMenu extends PopupPanel implements ClickListener { String dateString = RestCommand.getDate(); String resource = file.getUri().substring(app.getApiPath().length()-1,file.getUri().length()); String sig = app.getCurrentUserResource().getUsername()+" "+RestCommand.calculateSig("GET", dateString, resource, RestCommand.base64decode(app.getToken())); - link[0] = ""; + link[0] = ""; link[1] = ""; } } @@ -144,13 +148,16 @@ public class FileMenu extends PopupPanel implements ClickListener { Folders folders = GSS.get().getFolders(); TreeItem selectedItem = folders.getCurrent(); boolean downloadVisible = GSS.get().getCurrentSelection() != null && GSS.get().getCurrentSelection() instanceof FileResource; + boolean uploadVisible = GSS.get().getFolders().getCurrent().getUserObject() instanceof FolderResource; boolean propertiesNotVisible = selectedItem != null && (folders.isTrash(selectedItem) || folders.isMyShares(selectedItem) || folders.isOthersShared(selectedItem) || selectedItem.getUserObject() instanceof GroupUserResource); contextMenu.addItem("" + images.folderNew().getHTML() + " New Folder", true, new NewFolderCommand(this, images)); - contextMenu.addItem("" + images.fileUpdate().getHTML() + " Upload", true, new UploadFileCommand(this, images)); + contextMenu.addItem("" + images.fileUpdate().getHTML() + " Upload", true, new UploadFileCommand(this)); if (downloadVisible) { String[] link = {"", ""}; - createDownloadLink(link); + createDownloadLink(link, false); contextMenu.addItem("" + link[0] + images.download().getHTML() + " Download" + link[1] + "", true, downloadCmd); + createDownloadLink(link, true); + contextMenu.addItem("" + link[0] + images.download().getHTML() + " Save As" + link[1] + "", true, downloadCmd); } contextMenu.addItem("" + images.emptyTrash().getHTML() + " Empty Trash", true, new EmptyTrashCommand(this)); contextMenu.addItem("" + images.refresh().getHTML() + " Refresh", true, new RefreshCommand(this, images));