X-Git-Url: https://code.grnet.gr/git/pithos-web-client/blobdiff_plain/9d8521d78d3779cd3a37812281b30355c890f96c..d02b08f2e55608496533f32b098406ed1fb289e0:/src/gr/grnet/pithos/web/client/FileContextMenu.java diff --git a/src/gr/grnet/pithos/web/client/FileContextMenu.java b/src/gr/grnet/pithos/web/client/FileContextMenu.java index b1abb8b..b19bde5 100644 --- a/src/gr/grnet/pithos/web/client/FileContextMenu.java +++ b/src/gr/grnet/pithos/web/client/FileContextMenu.java @@ -1,5 +1,5 @@ /* - * Copyright 2011 GRNET S.A. All rights reserved. + * Copyright 2011-2012 GRNET S.A. All rights reserved. * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following @@ -47,9 +47,11 @@ import gr.grnet.pithos.web.client.foldertree.Folder; import java.util.List; +import com.google.gwt.http.client.URL; 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 +181,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 selectedFiles) { + public FileContextMenu(final Pithos app, Images newImages, TreeView selectedTree, Folder selectedFolder, final List 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); @@ -202,11 +204,8 @@ public class FileContextMenu extends PopupPanel { if (selectedFolder != null) { if (!selectedFolder.isInTrash()) { if (canWrite && app.getClipboard().hasFiles()) { - List files = (List) app.getClipboard().getItem(); - if (files.get(0).getOwner().equals(selectedFolder.getOwner())) { - pasteItem = new MenuItem("" + AbstractImagePrototype.create(images.paste()).getHTML() + " Paste", true, new PasteCommand(app, this, selectedFolder)); - contextMenu.addItem(pasteItem); - } + pasteItem = new MenuItem("" + AbstractImagePrototype.create(images.paste()).getHTML() + " Paste", true, new PasteCommand(app, this, selectedFolder)); + contextMenu.addItem(pasteItem); } if (canWrite) { @@ -237,25 +236,22 @@ public class FileContextMenu extends PopupPanel { contextMenu.addItem(deleteItem); } -// MenuItem refresh = new MenuItem("" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh", true, new RefreshCommand(this, images)); -// contextMenu.addItem(refresh); -// sharingItem = new MenuItem("" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing", true, new PropertiesCommand(this, images, 1)); -// contextMenu.addItem(sharingItem); if (selectedFolder != null && !selectedFolder.isInTrash()) { - if (isFolderTreeSelected && selectedFiles.size() == 1) - contextMenu.addItem(new MenuItem("" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties", true, new PropertiesCommand(app, this, selectedFiles, images, 0))); + if (isFolderTreeSelected && selectedFiles.size() == 1) { + contextMenu.addItem(new MenuItem("" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties", true, new PropertiesCommand(app, this, selectedFiles, PropertiesCommand.PROPERTIES))); + contextMenu.addItem(new MenuItem("" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing", true, new PropertiesCommand(app, this, selectedFiles, PropertiesCommand.PERMISSIONS))); + contextMenu.addItem(new MenuItem("" + AbstractImagePrototype.create(newImages.versions()).getHTML() + " Versions", true, new PropertiesCommand(app, this, selectedFiles, PropertiesCommand.VERSIONS))); + } } - if (selectedFiles.size() == 1) - contextMenu.addItem(new MenuItem("" + AbstractImagePrototype.create(newImages.download()).getHTML() + " Download", true, (Command) null)); - MenuItem unSelect = new MenuItem("" + AbstractImagePrototype.create(images.unselectAll()).getHTML() + " Unselect", true, new Command() { - @Override - public void execute() { - hide(); - app.getFileList().clearSelectedRows(); - } - }); - contextMenu.addItem(unSelect); + contextMenu.addItem(new MenuItem("" + AbstractImagePrototype.create(newImages.download()).getHTML() + " Download", true, new Command() { + + @Override + public void execute() { + for (File f : selectedFiles) + Window.open(app.getApiPath() + f.getOwner() + f.getUri() + "?X-Auth-Token=" + URL.encodeQueryString(app.getToken()), "_blank", ""); + } + })); add(contextMenu); }