Completed 'Shared by me' file context menu with whatever command is relevant (issue...
[pithos-web-client] / src / gr / grnet / pithos / web / client / ToolsMenu.java
index f1d1dfb..04356bd 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
@@ -54,6 +54,7 @@ import gr.grnet.pithos.web.client.grouptree.User;
 
 import java.util.List;
 
+import com.google.gwt.http.client.URL;
 import com.google.gwt.user.client.Command;
 import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.ui.AbstractImagePrototype;
@@ -99,11 +100,12 @@ public class ToolsMenu 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 isMysharedTreeSelected = app.isMySharedSelected();
                
                if (!folder.isInTrash()) {
                        if (canWrite) {
 
-                               if (isFolderTreeSelected) {
+                               if (isFolderTreeSelected || isMysharedTreeSelected) {
                                        MenuItem cut = null;
                                        if (files != null && !files.isEmpty()) {
                                                        cut = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Cut files</span>", true, new CutCommand(app, this, files));
@@ -129,7 +131,7 @@ public class ToolsMenu extends PopupPanel {
                        }
                
                        if (canWrite) {
-                               if (!app.getClipboard().isEmpty()) {
+                               if (!isMysharedTreeSelected && !app.getClipboard().isEmpty()) {
                                        Object item = app.getClipboard().getItem();
                                        boolean showPaste = false;
                                        if (item instanceof List) {
@@ -150,7 +152,7 @@ public class ToolsMenu extends PopupPanel {
                                        }
                                }
        
-                                   if (isFolderTreeSelected) {
+                                   if (isFolderTreeSelected || isMysharedTreeSelected) {
                                        MenuItem moveToTrash = null;
                                        if (files != null && !files.isEmpty()) {
                                                moveToTrash = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + "&nbsp;Move files to Trash</span>", true, new ToTrashCommand(app, this, files));
@@ -173,11 +175,13 @@ public class ToolsMenu extends PopupPanel {
                                                contextMenu.addItem(delete);
                                                empty = false;
                                        }
-                               
+                                   }
+                                   if (isFolderTreeSelected || isMysharedTreeSelected) {
                                        if (files != null && files.size() == 1) {
                                                contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;File properties</span>", true, new PropertiesCommand(app, this, files, PropertiesCommand.PROPERTIES)));
                                                contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.group()).getHTML() + "&nbsp;Sharing</span>", true, new PropertiesCommand(app, this, files, PropertiesCommand.PERMISSIONS)));
-                                               contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.versions()).getHTML() + "&nbsp;Versions</span>", true, new PropertiesCommand(app, this, files, PropertiesCommand.VERSIONS)));
+                                               contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.internet()).getHTML() + "&nbsp;Publish</span>", true, new PropertiesCommand(app, this, files, PropertiesCommand.PUBLISH)));
+                                               contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.versions()).getHTML() + "&nbsp;Versions</span>", true, new PropertiesCommand(app, this, files, PropertiesCommand.VERSIONS)));
                                                empty = false;
                                        }
                                        else if (!folder.isContainer()) {
@@ -192,7 +196,7 @@ public class ToolsMenu extends PopupPanel {
                                                        @Override
                                                        public void execute() {
                                                        for (File f: files)
-                                                               Window.open(app.getApiPath() + f.getOwner() + f.getUri() + "?X-Auth-Token=" + app.getToken(), "_blank", "");
+                                                               Window.open(app.getApiPath() + f.getOwner() + f.getUri(), "_blank", "");
                                                        }
                                                }));
                                        empty = false;
@@ -235,13 +239,11 @@ public class ToolsMenu extends PopupPanel {
                        contextMenu.addItem(deleteGroup);
                                empty = false;
                        }
-                       else {
-                       MenuItem createGroup = new MenuItem("<span>" + AbstractImagePrototype.create(images.group()).getHTML() + "&nbsp;Create Group</span>", true, new CreateGroupCommand(app, this));
-                       contextMenu.addItem(createGroup);
-                               empty = false;
-                       }
                }
         }
+        MenuItem createGroup = new MenuItem("<span>" + AbstractImagePrototype.create(images.group()).getHTML() + "&nbsp;Create Group</span>", true, new CreateGroupCommand(app, this));
+        contextMenu.addItem(createGroup);
+       empty = false;
                add(contextMenu);
        }