Separated public from other permissions (issue #2317)
authorChristos Stathis <chstath@ebs.gr>
Thu, 12 Apr 2012 12:54:11 +0000 (15:54 +0300)
committerChristos Stathis <chstath@ebs.gr>
Thu, 12 Apr 2012 12:54:11 +0000 (15:54 +0300)
src/gr/grnet/pithos/web/client/FileContextMenu.java
src/gr/grnet/pithos/web/client/FilePermissionsDialog.java
src/gr/grnet/pithos/web/client/FilePropertiesDialog.java
src/gr/grnet/pithos/web/client/FilePublishDialog.java [new file with mode: 0644]
src/gr/grnet/pithos/web/client/FileVersionsDialog.java
src/gr/grnet/pithos/web/client/ToolsMenu.java
src/gr/grnet/pithos/web/client/commands/PropertiesCommand.java
src/gr/grnet/pithos/web/client/foldertree/File.java
src/gr/grnet/pithos/web/client/mysharedtree/MysharedTreeViewModel.java
src/gr/grnet/pithos/web/client/othersharedtree/OtherSharedTreeViewModel.java

index 19fbaa1..15528c2 100644 (file)
@@ -170,6 +170,9 @@ public class FileContextMenu extends PopupPanel {
          */
         @Source("gr/grnet/pithos/resources/translate.png")
         ImageResource selectAll();
+        
+        @Source("gr/grnet/pithos/resources/internet.png")
+        ImageResource internet();
     }
 
        public static native String getDate()/*-{
@@ -240,6 +243,7 @@ public class FileContextMenu extends PopupPanel {
                if (isFolderTreeSelected && selectedFiles.size() == 1) {
                        contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(app, this, selectedFiles, PropertiesCommand.PROPERTIES)));
                        contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + "&nbsp;Sharing</span>", true, new PropertiesCommand(app, this, selectedFiles, PropertiesCommand.PERMISSIONS)));
+                       contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.internet()).getHTML() + "&nbsp;Publish</span>", true, new PropertiesCommand(app, this, selectedFiles, PropertiesCommand.PUBLISH)));
                        contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.versions()).getHTML() + "&nbsp;Versions</span>", true, new PropertiesCommand(app, this, selectedFiles, PropertiesCommand.VERSIONS)));
                }
 
index e632ef2..5209536 100644 (file)
@@ -73,14 +73,10 @@ public class FilePermissionsDialog extends AbstractPropertiesDialog {
 \r
        protected PermissionsList permList;\r
 \r
-       protected CheckBox readForAll;\r
-       \r
        private HorizontalPanel pathPanel;\r
        \r
        private TextBox path;\r
        \r
-       private Dictionary otherProperties = Dictionary.getDictionary("otherProperties");\r
-       \r
        /**\r
         * An image bundle for this widgets images.\r
         */\r
@@ -195,26 +191,6 @@ public class FilePermissionsDialog extends AbstractPropertiesDialog {
                     "distribute this file and that it does not violate the Terms of Use.", true);\r
         readForAllNote.setStylePrimaryName("pithos-readForAllNote");\r
 \r
-        readForAll = new CheckBox();\r
-        readForAll.setValue(file.isPublished());\r
-        readForAll.addClickHandler(new ClickHandler() {\r
-            @Override\r
-            public void onClick(ClickEvent event) {\r
-               accept();\r
-            }\r
-        });\r
-\r
-        // Only show the read for all permission if the user is the owner.\r
-        if (file.getOwner().equals(app.getUsername())) {\r
-            final HorizontalPanel permForAll = new HorizontalPanel();\r
-            permForAll.add(new Label("Public"));\r
-            permForAll.add(readForAll);\r
-            permForAll.setSpacing(8);\r
-            permForAll.addStyleName("pithos-TabPanelBottom");\r
-            permForAll.add(readForAllNote);\r
-            permPanel.add(permForAll);\r
-        }\r
-\r
         pathPanel = new HorizontalPanel();\r
         pathPanel.setVisible(false);\r
         pathPanel.setWidth("100%");\r
@@ -244,25 +220,19 @@ public class FilePermissionsDialog extends AbstractPropertiesDialog {
                        \r
                        @Override\r
                        public void execute() {\r
-                               showLinkIfPublished();\r
+                               showLinkIfShared();\r
                        }\r
                });\r
         return permPanel;\r
     }\r
 \r
-    void showLinkIfPublished() {\r
+    void showLinkIfShared() {\r
                if (file.isShared()) {\r
                        UrlBuilder b = Window.Location.createUrlBuilder();\r
-                       if (file.isPublished()) {\r
-                               b.setPath(file.getPublicUri());\r
-                               path.setText(b.buildString());\r
-                       }\r
-                       else {\r
-                               b.setPath(app.getApiPath() + file.getOwner() + file.getUri());\r
-                               String href = Window.Location.getHref();\r
-                               boolean hasParameters = href.contains("?");\r
-                               path.setText(href + (hasParameters ? "&" : "?") + "goto=" + b.buildString());\r
-                       }\r
+                       b.setPath(app.getApiPath() + file.getOwner() + file.getUri());\r
+                       String href = Window.Location.getHref();\r
+                       boolean hasParameters = href.contains("?");\r
+                       path.setText(href + (hasParameters ? "&" : "?") + "goto=" + b.buildString());\r
                pathPanel.setVisible(true);\r
                }\r
                else {\r
@@ -275,15 +245,11 @@ public class FilePermissionsDialog extends AbstractPropertiesDialog {
         */\r
        @Override\r
        protected void accept() {\r
-        Boolean published = null;\r
-               if (readForAll.getValue() != file.isPublished())\r
-                       if (file.getOwner().equals(app.getUsername()))\r
-                published = readForAll.getValue();\r
-        updateMetaData(app.getApiPath(), app.getUsername(), file.getUri() + "?update=", published, permList.getPermissions());\r
+        updateMetaData(app.getApiPath(), app.getUsername(), file.getUri() + "?update=", permList.getPermissions());\r
        }\r
 \r
-       protected void updateMetaData(String api, String owner, final String path, final Boolean published, final Map<String, Boolean[]> newPermissions) {\r
-        if (published != null || newPermissions != null) {\r
+       protected void updateMetaData(String api, String owner, final String path, final Map<String, Boolean[]> newPermissions) {\r
+        if (newPermissions != null) {\r
             PostRequest updateFile = new PostRequest(api, owner, path) {\r
                 @Override\r
                 public void onSuccess(Resource result) {\r
@@ -291,7 +257,7 @@ public class FilePermissionsDialog extends AbstractPropertiesDialog {
 \r
                                                @Override\r
                                                public void onSuccess(File _result) {\r
-                                                       showLinkIfPublished();\r
+                                                       showLinkIfShared();\r
                                    app.updateFolder(file.getParent(), true, new Command() {\r
                                                                \r
                                                                @Override\r
@@ -331,33 +297,29 @@ public class FilePermissionsDialog extends AbstractPropertiesDialog {
             };\r
             updateFile.setHeader("X-Auth-Token", app.getToken());\r
             \r
-            if (published != null)\r
-                updateFile.setHeader("X-Object-Public", published.toString());\r
-            if (newPermissions != null) {\r
-                String readPermHeader = "read=";\r
-                String writePermHeader = "write=";\r
-                for (String u : newPermissions.keySet()) {\r
-                    Boolean[] p = newPermissions.get(u);\r
-                    if (p[0] != null && p[0])\r
-                        readPermHeader += u + ",";\r
-                    if (p[1] != null && p[1])\r
-                        writePermHeader += u + ",";\r
-                }\r
-                if (readPermHeader.endsWith("="))\r
-                    readPermHeader = "";\r
-                else if (readPermHeader.endsWith(","))\r
-                    readPermHeader = readPermHeader.substring(0, readPermHeader.length() - 1);\r
-                if (writePermHeader.endsWith("="))\r
-                    writePermHeader = "";\r
-                else if (writePermHeader.endsWith(","))\r
-                    writePermHeader = writePermHeader.substring(0, writePermHeader.length() - 1);\r
-                String permHeader = readPermHeader +  ((readPermHeader.length()  > 0 && writePermHeader.length() > 0) ?  ";" : "") + writePermHeader;\r
-                if (permHeader.length() == 0)\r
-                    permHeader="~";\r
-                else\r
-                       permHeader = URL.encodePathSegment(permHeader);\r
-                updateFile.setHeader("X-Object-Sharing", permHeader);\r
+            String readPermHeader = "read=";\r
+            String writePermHeader = "write=";\r
+            for (String u : newPermissions.keySet()) {\r
+                Boolean[] p = newPermissions.get(u);\r
+                if (p[0] != null && p[0])\r
+                    readPermHeader += u + ",";\r
+                if (p[1] != null && p[1])\r
+                    writePermHeader += u + ",";\r
             }\r
+            if (readPermHeader.endsWith("="))\r
+                readPermHeader = "";\r
+            else if (readPermHeader.endsWith(","))\r
+                readPermHeader = readPermHeader.substring(0, readPermHeader.length() - 1);\r
+            if (writePermHeader.endsWith("="))\r
+                writePermHeader = "";\r
+            else if (writePermHeader.endsWith(","))\r
+                writePermHeader = writePermHeader.substring(0, writePermHeader.length() - 1);\r
+            String permHeader = readPermHeader +  ((readPermHeader.length()  > 0 && writePermHeader.length() > 0) ?  ";" : "") + writePermHeader;\r
+            if (permHeader.length() == 0)\r
+                permHeader="~";\r
+            else\r
+               permHeader = URL.encodePathSegment(permHeader);\r
+            updateFile.setHeader("X-Object-Sharing", permHeader);\r
             Scheduler.get().scheduleDeferred(updateFile);\r
         }\r
         else\r
@@ -365,7 +327,7 @@ public class FilePermissionsDialog extends AbstractPropertiesDialog {
                                \r
                                @Override\r
                                public void execute() {\r
-                                       if (file.isShared())\r
+                                       if (file.isSharedOrPublished())\r
                                                app.updateMySharedRoot();\r
                                }\r
                        }, true);\r
index 12c577a..336a5ee 100644 (file)
@@ -340,7 +340,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                                \r
                                @Override\r
                                public void execute() {\r
-                                       if (file.isShared())\r
+                                       if (file.isSharedOrPublished())\r
                                                app.updateMySharedRoot();\r
                                }\r
                        }, true);\r
diff --git a/src/gr/grnet/pithos/web/client/FilePublishDialog.java b/src/gr/grnet/pithos/web/client/FilePublishDialog.java
new file mode 100644 (file)
index 0000000..ee96121
--- /dev/null
@@ -0,0 +1,305 @@
+/*\r
+ * Copyright 2011-2012 GRNET S.A. All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or\r
+ * without modification, are permitted provided that the following\r
+ * conditions are met:\r
+ *\r
+ *   1. Redistributions of source code must retain the above\r
+ *      copyright notice, this list of conditions and the following\r
+ *      disclaimer.\r
+ *\r
+ *   2. Redistributions in binary form must reproduce the above\r
+ *      copyright notice, this list of conditions and the following\r
+ *      disclaimer in the documentation and/or other materials\r
+ *      provided with the distribution.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS\r
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR\r
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED\r
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ * The views and conclusions contained in the software and\r
+ * documentation are those of the authors and should not be\r
+ * interpreted as representing official policies, either expressed\r
+ * or implied, of GRNET S.A.\r
+ */\r
+package gr.grnet.pithos.web.client;\r
+\r
+import gr.grnet.pithos.web.client.foldertree.File;\r
+import gr.grnet.pithos.web.client.foldertree.Resource;\r
+import gr.grnet.pithos.web.client.rest.HeadRequest;\r
+import gr.grnet.pithos.web.client.rest.PostRequest;\r
+\r
+import java.util.Map;\r
+\r
+import com.google.gwt.core.client.GWT;\r
+import com.google.gwt.core.client.Scheduler;\r
+import com.google.gwt.dom.client.NativeEvent;\r
+import com.google.gwt.event.dom.client.ClickEvent;\r
+import com.google.gwt.event.dom.client.ClickHandler;\r
+import com.google.gwt.event.dom.client.KeyCodes;\r
+import com.google.gwt.http.client.Response;\r
+import com.google.gwt.http.client.URL;\r
+import com.google.gwt.http.client.UrlBuilder;\r
+import com.google.gwt.i18n.client.Dictionary;\r
+import com.google.gwt.resources.client.ImageResource;\r
+import com.google.gwt.user.client.Command;\r
+import com.google.gwt.user.client.Window;\r
+import com.google.gwt.user.client.Event.NativePreviewEvent;\r
+import com.google.gwt.user.client.ui.Anchor;\r
+import com.google.gwt.user.client.ui.Button;\r
+import com.google.gwt.user.client.ui.CheckBox;\r
+import com.google.gwt.user.client.ui.FocusPanel;\r
+import com.google.gwt.user.client.ui.HasHorizontalAlignment;\r
+import com.google.gwt.user.client.ui.HorizontalPanel;\r
+import com.google.gwt.user.client.ui.Label;\r
+import com.google.gwt.user.client.ui.TextBox;\r
+import com.google.gwt.user.client.ui.VerticalPanel;\r
+\r
+/**\r
+ * The 'File properties' dialog box implementation.\r
+ *\r
+ */\r
+public class FilePublishDialog extends AbstractPropertiesDialog {\r
+\r
+       protected CheckBox readForAll;\r
+       \r
+       private HorizontalPanel pathPanel;\r
+       \r
+       private TextBox path;\r
+       \r
+       /**\r
+        * An image bundle for this widgets images.\r
+        */\r
+       public interface Images extends MessagePanel.Images {\r
+\r
+               @Source("gr/grnet/pithos/resources/edit_user.png")\r
+               ImageResource permUser();\r
+\r
+               @Source("gr/grnet/pithos/resources/groups22.png")\r
+               ImageResource permGroup();\r
+\r
+               @Source("gr/grnet/pithos/resources/editdelete.png")\r
+               ImageResource delete();\r
+       }\r
+\r
+       final File file;\r
+\r
+    Images images = GWT.create(Images.class);\r
+\r
+       /**\r
+        * The widget's constructor.\r
+        */\r
+       public FilePublishDialog(Pithos _app, File _file) {\r
+        super(_app);\r
+        file = _file;\r
+\r
+               Anchor close = new Anchor();\r
+               close.addStyleName("close");\r
+               close.addClickHandler(new ClickHandler() {\r
+                       \r
+                       @Override\r
+                       public void onClick(ClickEvent event) {\r
+                               hide();\r
+                       }\r
+               });\r
+               // Set the dialog's caption.\r
+               setText("Publish/Un-publish");\r
+               setAnimationEnabled(true);\r
+               setGlassEnabled(true);\r
+               setStyleName("pithos-DialogBox");\r
+\r
+               // Outer contains inner and buttons.\r
+               final VerticalPanel outer = new VerticalPanel();\r
+               outer.add(close);\r
+               final FocusPanel focusPanel = new FocusPanel(outer);\r
+               // Inner contains generalPanel and permPanel.\r
+               inner = new VerticalPanel();\r
+               inner.addStyleName("inner");\r
+\r
+        inner.add(createSharingPanel());\r
+\r
+        outer.add(inner);\r
+\r
+               final Button ok = new Button("Close", new ClickHandler() {\r
+                       @Override\r
+                       public void onClick(ClickEvent event) {\r
+                               closeDialog();\r
+                       }\r
+               });\r
+               ok.addStyleName("button");\r
+\r
+        outer.add(ok);\r
+        outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);\r
+\r
+        focusPanel.setFocus(true);\r
+        setWidget(outer);\r
+       }\r
+\r
+    private VerticalPanel createSharingPanel() {\r
+        VerticalPanel permPanel = new VerticalPanel();\r
+\r
+        final Label readForAllNote = new Label("When this option is enabled, the file will be readable" +\r
+                    " by everyone. By checking this option, you are certifying that you have the right to " +\r
+                    "distribute this file and that it does not violate the Terms of Use.", true);\r
+        readForAllNote.setStylePrimaryName("pithos-readForAllNote");\r
+\r
+        readForAll = new CheckBox();\r
+        readForAll.setValue(file.isPublished());\r
+        readForAll.addClickHandler(new ClickHandler() {\r
+            @Override\r
+            public void onClick(ClickEvent event) {\r
+               accept();\r
+            }\r
+        });\r
+\r
+        // Only show the read for all permission if the user is the owner.\r
+        if (file.getOwner().equals(app.getUsername())) {\r
+            final HorizontalPanel permForAll = new HorizontalPanel();\r
+            permForAll.add(new Label("Public"));\r
+            permForAll.add(readForAll);\r
+            permForAll.setSpacing(8);\r
+            permForAll.addStyleName("pithos-TabPanelBottom");\r
+            permForAll.add(readForAllNote);\r
+            permPanel.add(permForAll);\r
+        }\r
+\r
+        pathPanel = new HorizontalPanel();\r
+        pathPanel.setVisible(false);\r
+        pathPanel.setWidth("100%");\r
+        pathPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);\r
+        pathPanel.add(new Label("Link"));\r
+        pathPanel.setSpacing(8);\r
+        pathPanel.addStyleName("pithos-TabPanelBottom");\r
+\r
+        path = new TextBox();\r
+        path.setWidth("100%");\r
+        path.addClickHandler(new ClickHandler() {\r
+            @Override\r
+            public void onClick(ClickEvent event) {\r
+                Pithos.enableIESelection();\r
+                ((TextBox) event.getSource()).selectAll();\r
+                Pithos.preventIESelection();\r
+            }\r
+        });\r
+        path.setText(Window.Location.getHost() + file.getPublicUri());\r
+        path.setTitle("Use this link for sharing the file via e-mail, IM, etc. (crtl-C/cmd-C to copy to system clipboard)");\r
+        path.setWidth("100%");\r
+        path.setReadOnly(true);\r
+        pathPanel.add(path);\r
+        permPanel.add(pathPanel);\r
+\r
+        Scheduler.get().scheduleDeferred(new Command() {\r
+                       \r
+                       @Override\r
+                       public void execute() {\r
+                               showLinkIfPublished();\r
+                       }\r
+               });\r
+        return permPanel;\r
+    }\r
+\r
+    void showLinkIfPublished() {\r
+               if (file.isPublished()) {\r
+                       UrlBuilder b = Window.Location.createUrlBuilder();\r
+                       b.setPath(file.getPublicUri());\r
+                       path.setText(b.buildString());\r
+               pathPanel.setVisible(true);\r
+               }\r
+               else {\r
+                       pathPanel.setVisible(false);\r
+               }\r
+    }\r
+       /**\r
+        * Accepts any change and updates the file\r
+        *\r
+        */\r
+       @Override\r
+       protected void accept() {\r
+        Boolean published = null;\r
+               if (readForAll.getValue() != file.isPublished())\r
+                       if (file.getOwner().equals(app.getUsername()))\r
+                published = readForAll.getValue();\r
+        updateMetaData(app.getApiPath(), app.getUsername(), file.getUri() + "?update=", published);\r
+       }\r
+\r
+       protected void updateMetaData(String api, String owner, final String path, final Boolean published) {\r
+        if (published != null) {\r
+            PostRequest updateFile = new PostRequest(api, owner, path) {\r
+                @Override\r
+                public void onSuccess(Resource result) {\r
+                       HeadRequest<File> headFile = new HeadRequest<File>(File.class, app.getApiPath(), file.getOwner(), path, file) {\r
+\r
+                                               @Override\r
+                                               public void onSuccess(File _result) {\r
+                                                       showLinkIfPublished();\r
+                                   app.updateFolder(file.getParent(), true, new Command() {\r
+                                                               \r
+                                                               @Override\r
+                                                               public void execute() {\r
+                                                                       app.updateMySharedRoot();\r
+                                                               }\r
+                                                       }, true);\r
+                                               }\r
+\r
+                                               @Override\r
+                                               public void onError(Throwable t) {\r
+                                   GWT.log("", t);\r
+                                                       app.setError(t);\r
+                                   app.displayError("System error modifying file:" + t.getMessage());\r
+                                               }\r
+\r
+                                               @Override\r
+                                               protected void onUnauthorized(Response response) {\r
+                                                       app.sessionExpired();\r
+                                               }\r
+                                       };\r
+                                       headFile.setHeader("X-Auth-Token", app.getToken());\r
+                                       Scheduler.get().scheduleDeferred(headFile);\r
+                }\r
+\r
+                @Override\r
+                public void onError(Throwable t) {\r
+                    GWT.log("", t);\r
+                                       app.setError(t);\r
+                    app.displayError("System error modifying file:" + t.getMessage());\r
+                }\r
+\r
+                               @Override\r
+                               protected void onUnauthorized(Response response) {\r
+                                       app.sessionExpired();\r
+                               }\r
+            };\r
+            updateFile.setHeader("X-Auth-Token", app.getToken());\r
+            updateFile.setHeader("X-Object-Public", published.toString());\r
+            Scheduler.get().scheduleDeferred(updateFile);\r
+        }\r
+        else\r
+            app.updateFolder(file.getParent(), true, new Command() {\r
+                               \r
+                               @Override\r
+                               public void execute() {\r
+                                       if (file.isSharedOrPublished())\r
+                                               app.updateMySharedRoot();\r
+                               }\r
+                       }, true);\r
+    }\r
+\r
+       @Override\r
+       protected void onPreviewNativeEvent(NativePreviewEvent preview) {\r
+           super.onPreviewNativeEvent(preview);\r
+\r
+           NativeEvent evt = preview.getNativeEvent();\r
+           if (evt.getType().equals("keydown") && evt.getKeyCode() == KeyCodes.KEY_ENTER)\r
+                               closeDialog();\r
+       }\r
+}\r
index b58a9be..e79007c 100644 (file)
@@ -193,7 +193,7 @@ public class FileVersionsDialog extends AbstractPropertiesDialog {
                        \r
                        @Override\r
                        public void execute() {\r
-                               if (file.isShared())\r
+                               if (file.isSharedOrPublished())\r
                                        app.updateMySharedRoot();\r
                        }\r
                }, true);\r
index febfd67..e51776e 100644 (file)
@@ -178,6 +178,7 @@ public class ToolsMenu extends PopupPanel {
                                        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.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;
                                        }
index c4bdf83..7e40560 100644 (file)
@@ -36,6 +36,7 @@ package gr.grnet.pithos.web.client.commands;
 
 import gr.grnet.pithos.web.client.FilePermissionsDialog;
 import gr.grnet.pithos.web.client.FilePropertiesDialog;
+import gr.grnet.pithos.web.client.FilePublishDialog;
 import gr.grnet.pithos.web.client.FileVersionsDialog;
 import gr.grnet.pithos.web.client.FilesPropertiesDialog;
 import gr.grnet.pithos.web.client.FolderPermissionsDialog;
@@ -59,6 +60,7 @@ public class PropertiesCommand implements Command {
        public static final int PROPERTIES = 0;
        public static final int PERMISSIONS = 1;
        public static final int VERSIONS = 2;
+       public static final int PUBLISH = 3;
 
        private PopupPanel containerPanel;
 
@@ -139,6 +141,16 @@ public class PropertiesCommand implements Command {
                                FileVersionsDialog dlg2 = new FileVersionsDialog(app, files.get(0));
                                dlg2.center();
                                                break;
+                                       case PUBLISH:
+                               app.scheduleFileHeadCommand(f, new Command() {
+                                                       
+                                                       @Override
+                                                       public void execute() {
+                                                               FilePublishDialog dlg = new FilePublishDialog(app, f);
+                                                               dlg.center();
+                                                       }
+                                               });
+                                               break;
                                        default:
                                                break;
                                }
index e1cee32..01a3215 100644 (file)
@@ -139,9 +139,13 @@ public class File extends Resource {
         return nf.format(Double.valueOf(bytes)/(1024 * 1024 * 1024)) + " GB";
     }
 
-    public boolean isShared() {
+    public boolean isSharedOrPublished() {
         return !permissions.isEmpty() || published;
     }
+    
+    public boolean isShared() {
+       return !permissions.isEmpty();
+    }
 
     public void populate(Folder _parent, JSONObject o, String _owner, String _container) {
         this.parent = _parent;
index 5cddcf6..6dbcc00 100644 (file)
@@ -233,7 +233,7 @@ public class MysharedTreeViewModel implements TreeViewModel {
                 public void onSuccess(Folder _result) {
                        if (!_result.isShared()) {
                                for (File file : _result.getFiles()) {
-                                       if (file.isShared())
+                                       if (file.isSharedOrPublished())
                                                sharedFiles.add(file);
                                }
                                Iterator<Folder> iter2 = new ArrayList<Folder>(result.getSubfolders()).listIterator();
index 8caf848..9cca940 100644 (file)
@@ -380,7 +380,7 @@ public class OtherSharedTreeViewModel implements TreeViewModel {
                 public void onSuccess(Folder _result) {
                        if (!_result.isShared() && !_result.isContainer()) {
                                for (File file : _result.getFiles()) {
-                                       if (file.isShared())
+                                       if (file.isSharedOrPublished())
                                                sharedFiles.get(username).add(file);
                                }
                                Iterator<Folder> iter2 = _result.getSubfolders().iterator();