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;
/**
private MenuItem downloadItem;
+ private MenuItem saveAsItem;
+
/**
* The image bundle for this widget's images that reuses images defined in
* other menus.
// 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;
MenuBar contextMenu = new MenuBar(true);
if (isEmpty) {
contextMenu.addItem(pasteItem);
- if (gss.getFolders().getCurrent() != null)
- if (gss.getFolders().isFileItem(gss.getFolders().getCurrent()))
- contextMenu.addItem("<span>" + newImages.fileUpdate().getHTML() + " Upload</span>", true, new UploadFileCommand(this, images));
- else if (gss.getFolders().isMySharedItem(gss.getFolders().getCurrent()) || GSS .get()
+ if (GSS.get().getFolders().getCurrent() != null)
+ if (GSS.get().getFolders().isFileItem(GSS.get().getFolders().getCurrent()))
+ contextMenu.addItem("<span>" + newImages.fileUpdate().getHTML() + " 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.getFolders().getCurrent().getUserObject() instanceof FolderResource)
- contextMenu.addItem("<span>" + newImages.fileUpdate().getHTML() + " Upload</span>", true, new UploadFileCommand(this, images));
+ if(GSS.get().getFolders().getCurrent().getUserObject() instanceof FolderResource)
+ contextMenu.addItem("<span>" + newImages.fileUpdate().getHTML() + " Upload</span>", true, new UploadFileCommand(this));
contextMenu.addItem("<span>" + images.refresh().getHTML() + " Refresh</span>", true, new RefreshCommand(this, images));
} else if (isTrash) {
contextMenu.addItem("<span>" + newImages.versions().getHTML() + " Restore</span>", true, new RestoreTrashCommand(this));
cutItem = new MenuItem("<span>" + newImages.cut().getHTML() + " Cut</span>", true, new CutCommand(this));
copyItem = new MenuItem("<span>" + newImages.copy().getHTML() + " Copy</span>", true, new CopyCommand(this));
- updateItem = new MenuItem("<span>" + newImages.fileUpdate().getHTML() + " Upload</span>", true, new UploadFileCommand(this, images));
+ updateItem = new MenuItem("<span>" + newImages.fileUpdate().getHTML() + " Upload</span>", true, new UploadFileCommand(this));
trashItem = new MenuItem("<span>" + newImages.emptyTrash().getHTML() + " Move to Trash</span>", true, new ToTrashCommand(this));
deleteItem = new MenuItem("<span>" + newImages.delete().getHTML() + " Delete</span>", true, new DeleteCommand(this, images));
sharingItem = new MenuItem("<span>" + newImages.sharing().getHTML() + " Sharing</span>", true, new PropertiesCommand(this, images, 1));
propItem = new MenuItem("<span>" + newImages.viewText().getHTML() + " 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 file 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() + " Unselect</span>", true, unselectAllCommand);
contextMenu.addItem(trashItem);
contextMenu.addItem(deleteItem);
contextMenu.addItem(propItem);
}
add(contextMenu);
- if (GSS.get().getClipboard().hasFileItem())
+ if (gss.getClipboard().hasFileItem())
pasteItem.setVisible(true);
else
pasteItem.setVisible(false);
import gr.ebs.gss.client.commands.UploadFileCommand;\r
import gr.ebs.gss.client.rest.RestCommand;\r
import gr.ebs.gss.client.rest.resource.FileResource;\r
+import gr.ebs.gss.client.rest.resource.FolderResource;\r
import gr.ebs.gss.client.rest.resource.GroupUserResource;\r
\r
import com.google.gwt.http.client.URL;\r
* @param link a String array with two elements that is modified so that the\r
* first position contains the opening tag and the second one the\r
* closing tag\r
+ * @param forceDownload If true, link will be such that browser should ask for filename\r
+ * and save location\r
*/\r
- void createDownloadLink(String[] link) {\r
+ void createDownloadLink(String[] link, boolean forceDownload) {\r
GSS app = GSS.get();\r
Object selection = app.getCurrentSelection();\r
if (selection != null && selection instanceof FileResource) {\r
String dateString = RestCommand.getDate();\r
String resource = file.getUri().substring(app.getApiPath().length()-1,file.getUri().length());\r
String sig = app.getCurrentUserResource().getUsername()+" "+RestCommand.calculateSig("GET", dateString, resource, RestCommand.base64decode(app.getToken()));\r
- link[0] = "<a class='hidden-link' href='" + file.getUri() + "?Authorization=" + URL.encodeComponent(sig) + "&Date="+URL.encodeComponent(dateString) + "' target='_blank'>";\r
+ link[0] = "<a class='hidden-link' href='" + file.getUri() + "?Authorization=" + URL.encodeComponent(sig) + "&Date="+URL.encodeComponent(dateString)\r
+ + (forceDownload ? "&dl=1" : "") + "' target='_blank'>";\r
link[1] = "</a>";\r
}\r
}\r
Folders folders = GSS.get().getFolders();\r
TreeItem selectedItem = folders.getCurrent();\r
boolean downloadVisible = GSS.get().getCurrentSelection() != null && GSS.get().getCurrentSelection() instanceof FileResource;\r
+ boolean uploadVisible = GSS.get().getFolders().getCurrent().getUserObject() instanceof FolderResource;\r
boolean propertiesNotVisible = selectedItem != null && (folders.isTrash(selectedItem) || folders.isMyShares(selectedItem) || folders.isOthersShared(selectedItem) || selectedItem.getUserObject() instanceof GroupUserResource);\r
contextMenu.addItem("<span>" + images.folderNew().getHTML() + " New Folder</span>", true, new NewFolderCommand(this, images));\r
- if (uploadVisible) contextMenu.addItem("<span>" + images.fileUpdate().getHTML() + " Upload</span>", true, new UploadFileCommand(this, images));\r
+ contextMenu.addItem("<span>" + images.fileUpdate().getHTML() + " Upload</span>", true, new UploadFileCommand(this));\r
if (downloadVisible) {\r
String[] link = {"", ""};\r
- createDownloadLink(link);\r
+ createDownloadLink(link, false);\r
contextMenu.addItem("<span>" + link[0] + images.download().getHTML() + " Download" + link[1] + "</span>", true, downloadCmd);\r
+ createDownloadLink(link, true);\r
+ contextMenu.addItem("<span>" + link[0] + images.download().getHTML() + " Save file as" + link[1] + "</span>", true, downloadCmd);\r
}\r
contextMenu.addItem("<span>" + images.emptyTrash().getHTML() + " Empty Trash</span>", true, new EmptyTrashCommand(this));\r
contextMenu.addItem("<span>" + images.refresh().getHTML() + " Refresh</span>", true, new RefreshCommand(this, images));\r