Disable paste option if the target folder is a child of the folder to-be-copied
authorChristos Stathis <chstath@ebs.gr>
Mon, 26 Sep 2011 09:46:01 +0000 (12:46 +0300)
committerChristos Stathis <chstath@ebs.gr>
Mon, 26 Sep 2011 09:46:01 +0000 (12:46 +0300)
src/gr/grnet/pithos/web/client/FolderContextMenu.java
src/gr/grnet/pithos/web/client/foldertree/Folder.java

index a717dec..c030730 100644 (file)
@@ -121,7 +121,7 @@ public class FolderContextMenu extends PopupPanel {
                                }
                                else {
                                        Folder f = (Folder) item;
-                                       if (f.getOwner().equals(folder.getOwner()))
+                                       if (f.getOwner().equals(folder.getOwner()) && !f.contains(folder))
                                                showPaste = true;
                                }
                                if (showPaste) {
index 7709033..3888d1e 100644 (file)
@@ -327,4 +327,11 @@ public class Folder extends Resource {
        public boolean isHome() {
                return isContainer() && name.equals(Pithos.HOME_CONTAINER);
        }
+
+       public boolean contains(Folder folder) {
+               for (Folder f : subfolders)
+                       if (f.equals(folder) || f.contains(folder))
+                               return true;
+               return false;
+       }
 }