Use Lytebox (a Lightbox clone) for quick viewing images.
[pithos] / src / gr / ebs / gss / client / FileMenu.java
index 5a0a467..63fc1f1 100644 (file)
@@ -122,17 +122,33 @@ public class FileMenu extends PopupPanel implements ClickListener {
         *                              and save location\r
         */\r
        void createDownloadLink(String[] link, boolean forceDownload) {\r
+               String downloadURL = getDownloadURL();\r
+               if (!downloadURL.isEmpty()) {\r
+                       link[0] = "<a class='hidden-link' href='" + downloadURL\r
+                                       + (forceDownload ? "&dl=1" : "") + "' target='_blank'>";\r
+                       link[1] = "</a>";\r
+               }\r
+       }\r
+\r
+       public String getDownloadURL() {\r
                GSS app = GSS.get();\r
                Object selection = app.getCurrentSelection();\r
                if (selection != null && selection instanceof FileResource) {\r
                        FileResource file = (FileResource) selection;\r
+                       return getDownloadURL(file);\r
+               }\r
+               return "";\r
+       }\r
+\r
+       public String getDownloadURL(FileResource file) {\r
+               GSS app = GSS.get();\r
+               if (file != null) {\r
                        String dateString = RestCommand.getDate();\r
                        String resource = file.getUri().substring(app.getApiPath().length()-1,file.getUri().length());\r
                        String sig = app.getCurrentUserResource().getUsername()+" "+RestCommand.calculateSig("GET", dateString, resource, RestCommand.base64decode(app.getToken()));\r
-                       link[0] = "<a class='hidden-link' href='" + file.getUri() + "?Authorization=" + URL.encodeComponent(sig) + "&Date="+URL.encodeComponent(dateString)\r
-                                       + (forceDownload ? "&dl=1" : "") + "' target='_blank'>";\r
-                       link[1] = "</a>";\r
+                       return file.getUri() + "?Authorization=" + URL.encodeComponent(sig) + "&Date="+URL.encodeComponent(dateString);\r
                }\r
+               return "";\r
        }\r
 \r
        public MenuBar createMenu() {\r