Added a share button on the toolbar
authorChristos Stathis <chstath@ebs.gr>
Thu, 26 Jan 2012 13:29:18 +0000 (15:29 +0200)
committerChristos Stathis <chstath@ebs.gr>
Thu, 26 Jan 2012 13:29:18 +0000 (15:29 +0200)
src/gr/grnet/pithos/web/client/FileContextMenu.java
src/gr/grnet/pithos/web/client/FolderContextMenu.java
src/gr/grnet/pithos/web/client/Pithos.java
src/gr/grnet/pithos/web/client/ToolsMenu.java
src/gr/grnet/pithos/web/client/commands/PropertiesCommand.java
src/gr/grnet/pithos/web/public/images/myshared22.png [new file with mode: 0644]
src/gr/grnet/pithos/web/public/pithos.css

index 2ad422d..ef157b4 100644 (file)
@@ -238,7 +238,7 @@ public class FileContextMenu extends PopupPanel {
 
         if (selectedFolder != null && !selectedFolder.isInTrash()) {
                if (isFolderTreeSelected && selectedFiles.size() == 1)
-                       contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(app, this, selectedFiles, images, 0)));
+                       contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(app, this, selectedFiles, 0)));
 
         }
            contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.download()).getHTML() + "&nbsp;Download</span>", true, new Command() {
index 15e9859..238fca0 100644 (file)
@@ -134,7 +134,7 @@ 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));
+                               MenuItem properties = new MenuItem("<span id = 'folderContextMenu.properties'>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(app, this, folder, 0));
                                contextMenu.addItem(properties);
                            }
                }
index b225d23..c8e8b47 100644 (file)
@@ -35,6 +35,7 @@
 package gr.grnet.pithos.web.client;
 
 import gr.grnet.pithos.web.client.commands.NewFolderCommand;
+import gr.grnet.pithos.web.client.commands.PropertiesCommand;
 import gr.grnet.pithos.web.client.commands.UploadFileCommand;
 import gr.grnet.pithos.web.client.foldertree.AccountResource;
 import gr.grnet.pithos.web.client.foldertree.File;
@@ -347,6 +348,26 @@ public class Pithos implements EntryPoint, ResizeHandler {
                });
         toolbar.add(newFolderButton);
 
+        Anchor shareFolderButton = new Anchor("<span class='ico'></span><span class='title'>Share folder</span>", true);
+        shareFolderButton.getElement().setId("sharefolder-button");
+        shareFolderButton.addStyleName("pithos-toolbarItem");
+        shareFolderButton.addClickHandler(new ClickHandler() {
+                       
+                       @Override
+                       public void onClick(@SuppressWarnings("unused") ClickEvent event) {
+                               Folder folder = getSelectedTree().getSelection();
+                               if (folder != null) {
+                               Boolean[] permissions = folder.getPermissions().get(getUsername());
+                               boolean canWrite = folder.getOwner().equals(getUsername()) || (permissions!= null && permissions[1] != null && permissions[1]);
+                               boolean isFolderTreeSelected = selectedTree.equals(getFolderTreeView());
+                               
+                               if (!folder.isInTrash() && canWrite && isFolderTreeSelected && !folder.isContainer())
+                                       new PropertiesCommand(Pithos.this, null, folder, 1).execute();
+                               }
+                       }
+               });
+        toolbar.add(shareFolderButton);
+
         refreshButton = new Anchor("<span class='ico'></span><span class='title'>Refresh</span>", true);
         refreshButton.getElement().setId("refresh-button");
         refreshButton.addStyleName("pithos-toolbarItem");
index 9b12832..428bd06 100644 (file)
@@ -168,9 +168,9 @@ public class ToolsMenu extends PopupPanel {
                                
                                        MenuItem properties = null;
                                        if (files != null && files.size() == 1)
-                                               properties = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;File properties</span>", true, new PropertiesCommand(app, this, files, images, 0));
+                                               properties = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;File properties</span>", true, new PropertiesCommand(app, this, files, 0));
                                        else if (!folder.isContainer())
-                                               properties = new MenuItem("<span id = 'folderContextMenu.properties'>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;Folder properties</span>", true, new PropertiesCommand(app, this, folder, newImages, 0));
+                                               properties = new MenuItem("<span id = 'folderContextMenu.properties'>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;Folder properties</span>", true, new PropertiesCommand(app, this, folder, 0));
                                        if (properties != null)
                                                contextMenu.addItem(properties);
                                    }
index be49fc9..c42abcc 100644 (file)
@@ -54,8 +54,6 @@ import com.google.gwt.user.client.ui.PopupPanel;
  */
 public class PropertiesCommand implements Command {
 
-       final FileContextMenu.Images newImages;
-
        private PopupPanel containerPanel;
 
        private int tabToShow = 0;
@@ -69,9 +67,8 @@ public class PropertiesCommand implements Command {
         * @param _newImages the images of all the possible delete dialogs
         * @param _tab the tab to switch to
         */
-       public PropertiesCommand(Pithos _app, PopupPanel _containerPanel, Object _resource, final FileContextMenu.Images _newImages, int _tab) {
+       public PropertiesCommand(Pithos _app, PopupPanel _containerPanel, Object _resource, int _tab) {
                containerPanel = _containerPanel;
-               newImages = _newImages;
                tabToShow = _tab;
         resource = _resource;
         app = _app;
diff --git a/src/gr/grnet/pithos/web/public/images/myshared22.png b/src/gr/grnet/pithos/web/public/images/myshared22.png
new file mode 100644 (file)
index 0000000..b867b30
Binary files /dev/null and b/src/gr/grnet/pithos/web/public/images/myshared22.png differ
index 698922b..a7455a7 100644 (file)
@@ -493,6 +493,10 @@ div#toolbar a {
        background-image: url(images/folder_new.png);
 }
 
+#shareFolder-button span.ico {
+       background-image: url(images/myshared22.png);
+}
+
 /*move background from inner to centerinner to wrap action buttons too*/
 .dialogMiddleCenterInner.dialogContent  {
     background: url(images/white50.png);