Cloudbar variables and loginUrl are configurable through runtime.properties and build.xml
[pithos-web-client] / src / gr / grnet / pithos / web / client / FolderContextMenu.java
index 1ff04d9..e0dd76b 100644 (file)
@@ -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
@@ -41,6 +41,7 @@ import gr.grnet.pithos.web.client.commands.EmptyTrashCommand;
 import gr.grnet.pithos.web.client.commands.NewFolderCommand;
 import gr.grnet.pithos.web.client.commands.PasteCommand;
 import gr.grnet.pithos.web.client.commands.PropertiesCommand;
+import gr.grnet.pithos.web.client.commands.RefreshCommand;
 import gr.grnet.pithos.web.client.commands.RestoreTrashCommand;
 import gr.grnet.pithos.web.client.commands.ToTrashCommand;
 import gr.grnet.pithos.web.client.foldertree.Folder;
@@ -85,10 +86,16 @@ public class FolderContextMenu extends PopupPanel {
         Boolean[] permissions = folder.getPermissions().get(app.getUsername());
        boolean canWrite = folder.getOwner().equals(app.getUsername()) || (permissions!= null && permissions[1] != null && permissions[1]);
        boolean isFolderTreeSelected = selectedTree.equals(app.getFolderTreeView());
+       boolean otherSharedTreeSelected = selectedTree.equals(app.getOtherSharedTreeView());
        
+       if (isFolderTreeSelected || otherSharedTreeSelected) {
+               MenuItem refresh = new MenuItem("<span id = 'folderContextMenu.refresh'>" + AbstractImagePrototype.create(images.refresh()).getHTML() + "&nbsp;Refresh</span>", true, new RefreshCommand(app, this, folder));
+               contextMenu.addItem(refresh);
+       }
+
         if (!folder.isInTrash()) {
                if (canWrite) {
-                       MenuItem newFolder = new MenuItem("<span id = 'folderContextMenu.newFolder'>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + "&nbsp;New Folder</span>", true, new NewFolderCommand(app, this, folder, images));
+                       MenuItem newFolder = new MenuItem("<span id = 'folderContextMenu.newFolder'>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + "&nbsp;New Folder</span>", true, new NewFolderCommand(app, this, folder));
                        contextMenu.addItem(newFolder);
 
                        if (isFolderTreeSelected && !folder.isContainer()) {
@@ -97,13 +104,24 @@ public class FolderContextMenu extends PopupPanel {
                        }
                }
 
-               MenuItem copy = new MenuItem("<span id = 'folderContextMenu.copy'>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + "&nbsp;Copy</span>", true, new CopyCommand(app, this, folder));
-               contextMenu.addItem(copy);
+               if (!folder.isContainer()) {
+                       MenuItem copy = new MenuItem("<span id = 'folderContextMenu.copy'>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + "&nbsp;Copy</span>", true, new CopyCommand(app, this, folder));
+                       contextMenu.addItem(copy);
+               }
        
                if (canWrite) {
                        if (!app.getClipboard().isEmpty()) {
-                           pasteItem = new MenuItem("<span id = 'folderContextMenu.paste'>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + "&nbsp;Paste</span>", true, new PasteCommand(app, this, folder));
-                           contextMenu.addItem(pasteItem);
+                               Object item = app.getClipboard().getItem();
+                               boolean showPaste = true;
+                               if (item instanceof Folder) {
+                                       Folder f = (Folder) item;
+                                       if (f.contains(folder))
+                                               showPaste = false;
+                               }
+                               if (showPaste) {
+                                   pasteItem = new MenuItem("<span id = 'folderContextMenu.paste'>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + "&nbsp;Paste</span>", true, new PasteCommand(app, this, folder));
+                                   contextMenu.addItem(pasteItem);
+                               }
                        }
 
                            if (isFolderTreeSelected && !folder.isContainer()) {
@@ -113,8 +131,8 @@ public class FolderContextMenu extends PopupPanel {
                                MenuItem delete = new MenuItem("<span id = 'folderContextMenu.delete'>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(app, this, folder, MessagePanel.images));
                                contextMenu.addItem(delete);
                        
-                               MenuItem properties = new MenuItem("<span id = 'folderContextMenu.properties'>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(app, this, folder, newImages, 0));
-                               contextMenu.addItem(properties);
+                               contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(app, this, folder, PropertiesCommand.PROPERTIES)));
+                               contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + "&nbsp;Sharing</span>", true, new PropertiesCommand(app, this, folder, PropertiesCommand.PERMISSIONS)));
                            }
                }
         }
@@ -131,14 +149,6 @@ public class FolderContextMenu extends PopupPanel {
                        contextMenu.addItem(emptyTrash);
                }
         }
-
-//        MenuItem refresh = new MenuItem("<span id = 'folderContextMenu.refresh'>" + AbstractImagePrototype.create(images.refresh()).getHTML() + "&nbsp;Refresh</span>", true, new RefreshCommand(this, images));
-//        contextMenu.addItem(refresh);
-
-//        MenuItem sharing = new MenuItem("<span id = 'folderContextMenu.sharing'>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + "&nbsp;Sharing</span>", true, new PropertiesCommand(this, newImages, 1));
-//        contextMenu.addItem(sharing);
-
-
                add(contextMenu);
        }
 }