Automated merge with https://gss.googlecode.com/hg/
[pithos] / src / gr / ebs / gss / client / FileContextMenu.java
index c72bbf0..6fe9334 100644 (file)
@@ -30,6 +30,8 @@ import gr.ebs.gss.client.commands.UploadFileCommand;
 import gr.ebs.gss.client.rest.resource.FileResource;
 import gr.ebs.gss.client.rest.resource.FolderResource;
 import gr.ebs.gss.client.rest.resource.RestResource;
+import gr.ebs.gss.client.rest.resource.RestResourceWrapper;
+import gr.ebs.gss.client.rest.resource.TrashFolderResource;
 
 import java.util.List;
 
@@ -127,6 +129,7 @@ public class FileContextMenu extends PopupPanel implements ClickHandler {
                };
 
                pasteItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + "&nbsp;Paste</span>", true, new PasteCommand(this));
+               pasteItem.getElement().setId("FileContextMenu.paste");
                RestResource sel = GSS.get().getTreeView().getSelection();
                MenuBar contextMenu = new MenuBar(true);
                if (isEmpty) {
@@ -143,10 +146,23 @@ public class FileContextMenu extends PopupPanel implements ClickHandler {
                                        if(sel instanceof FolderResource)
                                                contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this));
                        */
-                       contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + "&nbsp;Refresh</span>", true, new RefreshCommand(this, images));
+                       if(sel instanceof RestResourceWrapper && !(sel instanceof TrashFolderResource)){
+                               MenuItem upload = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this));
+                               upload.getElement().setId("fileContextMenu.upload");
+                               contextMenu.addItem(upload);
+                       }
+                       MenuItem refresh = new MenuItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + "&nbsp;Refresh</span>", true, new RefreshCommand(this, images));
+                       refresh.getElement().setId("fileContextMenu.refresh");
+                       contextMenu.addItem(refresh);
+                       
                } else if (isTrash) {
-                       contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.versions()).getHTML() + "&nbsp;Restore</span>", true, new RestoreTrashCommand(this));
-                       contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(this, images));
+                       MenuItem restore = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.versions()).getHTML() + "&nbsp;Restore</span>", true, new RestoreTrashCommand(this));
+                       restore.getElement().setId("fileContextMenu.restore");
+                       contextMenu.addItem(restore);
+                       
+                       MenuItem delete = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(this, images));
+                       delete.getElement().setId("fileContextMenu.delete");
+                       contextMenu.addItem(delete);
                } else {
                        final Command unselectAllCommand = new Command() {
 
@@ -159,16 +175,26 @@ public class FileContextMenu extends PopupPanel implements ClickHandler {
                                                GSS.get().getSearchResults().clearSelectedRows();
                                }
                        };
-                       cutItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Cut</span>", true, new CutCommand(this));
+                       cutItem = new MenuItem("<span id='fileContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Cut</span>", true, new CutCommand(this));
+                       cutItem.getElement().setId("fileContextMenu.cut");
+                       
                        copyItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + "&nbsp;Copy</span>", true, new CopyCommand(this));
-
+                       copyItem.getElement().setId("fileContextMenu.copy");
+                       
                        updateItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this));
+                       updateItem.getElement().setId("fileContextMenu.upload");
 
                        trashItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + "&nbsp;Move to Trash</span>", true, new ToTrashCommand(this));
+                       trashItem.getElement().setId("fileContextMenu.moveToTrash");
+                       
                        deleteItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(this, images));
+                       deleteItem.getElement().setId("fileContextMenu.delete");
 
                        sharingItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + "&nbsp;Sharing</span>", true, new PropertiesCommand(this, images, 1));
+                       sharingItem.getElement().setId("fileContextMenu.sharing");
+                       
                        propItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(this, images, 0));
+                       propItem.getElement().setId("fileContextMenu.properties");
 
                        
                        if(sel!=null && sel instanceof FolderResource)
@@ -176,18 +202,28 @@ public class FileContextMenu extends PopupPanel implements ClickHandler {
                        String[] link = {"", ""};
                        gss.getTopPanel().getFileMenu().createDownloadLink(link, false);
                        downloadItem = new MenuItem("<span>" + link[0] + AbstractImagePrototype.create(newImages.download()).getHTML() + " Download" + link[1] + "</span>", true, downloadCmd);
+                       downloadItem.getElement().setId("fileContextMenu.download");
                        contextMenu.addItem(downloadItem);
+                       
                        gss.getTopPanel().getFileMenu().createDownloadLink(link, true);
                        saveAsItem = new MenuItem("<span>" + link[0] + AbstractImagePrototype.create(newImages.download()).getHTML() + " Save As" + link[1] + "</span>", true, downloadCmd);
+                       saveAsItem.getElement().setId("fileContextMenu.saveAs");
                        contextMenu.addItem(saveAsItem);
                        contextMenu.addItem(cutItem);
                        contextMenu.addItem(copyItem);
                        if(sel!=null && sel instanceof FolderResource)
                                contextMenu.addItem(pasteItem);
-                       contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.unselectAll()).getHTML() + "&nbsp;Unselect</span>", true, unselectAllCommand);
+                       MenuItem unSelect = new MenuItem("<span>" + AbstractImagePrototype.create(images.unselectAll()).getHTML() + "&nbsp;Unselect</span>", true, unselectAllCommand);
+                       unSelect.getElement().setId("fileContextMenu.unSelect");
+                       contextMenu.addItem(unSelect);
+                       
                        contextMenu.addItem(trashItem);
                        contextMenu.addItem(deleteItem);
-                       contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + "&nbsp;Refresh</span>", true, new RefreshCommand(this, images));
+                       
+                       MenuItem refresh = new MenuItem("<span id='fileContextMenu.refresh'>" + AbstractImagePrototype.create(images.refresh()).getHTML() + "&nbsp;Refresh</span>", true, new RefreshCommand(this, images));
+//                     refresh.getElement().setId("fileContextMenu.refresh");
+                       contextMenu.addItem(refresh);
+                       
                        contextMenu.addItem(sharingItem);
                        contextMenu.addItem(propItem);
                }
@@ -291,6 +327,8 @@ public class FileContextMenu extends PopupPanel implements ClickHandler {
                                        menu = new FileContextMenu(images, false, false);
                                        menu.onMultipleSelection();
                                }*/
+                               menu = new FileContextMenu(images, false, false);
+                               menu.onMultipleSelection();
                                int left = event.getClientX();
                                int top = event.getClientY();
                                menu.setPopupPosition(left, top);
@@ -308,6 +346,7 @@ public class FileContextMenu extends PopupPanel implements ClickHandler {
                        menu = new FileContextMenu(images, false, true);
                else return menu;
                */
+               menu = new FileContextMenu(images, false, true);
                int left = event.getClientX();
                int top = event.getClientY();
                menu.setPopupPosition(left, top);