import gr.ebs.gss.client.commands.RestoreTrashCommand;
import gr.ebs.gss.client.commands.ToTrashCommand;
import gr.ebs.gss.client.commands.UploadFileCommand;
+import gr.ebs.gss.client.commands.ViewImageCommand;
import gr.ebs.gss.client.dnd.DnDTreeItem;
import gr.ebs.gss.client.rest.resource.FileResource;
import gr.ebs.gss.client.rest.resource.FolderResource;
private MenuItem saveAsItem;
+ private MenuItem viewImageItem;
+
/**
* The image bundle for this widget's images that reuses images defined in
* other menus.
@Resource("gr/ebs/gss/resources/border_remove.png")
AbstractImagePrototype unselectAll();
- }
+
+ @Resource("gr/ebs/gss/resources/demo.png")
+ AbstractImagePrototype viewImage();
+}
public static native String getDate()/*-{
return (new Date()).toUTCString();
gss.getTopPanel().getFileMenu().createDownloadLink(link, true);
saveAsItem = new MenuItem("<span>" + link[0] + newImages.download().getHTML() + " Save As" + link[1] + "</span>", true, downloadCmd);
contextMenu.addItem(saveAsItem);
+ boolean isImage = false;
+ if (GSS.get().getCurrentSelection() != null)
+ isImage = ((FileResource) GSS.get().getCurrentSelection()).getContentType().startsWith("image/");
+ if (isImage) {
+ viewImageItem = new MenuItem("<span>" + newImages.viewImage().getHTML() + " View Image</span>", true,
+ new ViewImageCommand(this, images, gss.getTopPanel().getFileMenu().getDownloadURL()));
+ contextMenu.addItem(viewImageItem);
+ }
contextMenu.addItem(cutItem);
contextMenu.addItem(copyItem);
if(currentFolder!=null && currentFolder.getUserObject() instanceof FolderResource)
* 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
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
--- /dev/null
+/*\r
+ * Copyright 2009 Electronic Business Systems Ltd.\r
+ *\r
+ * This file is part of GSS.\r
+ *\r
+ * GSS is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * GSS is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with GSS. If not, see <http://www.gnu.org/licenses/>.\r
+ */\r
+package gr.ebs.gss.client.commands;\r
+\r
+import gr.ebs.gss.client.FileMenu;\r
+\r
+import com.google.gwt.user.client.Command;\r
+import com.google.gwt.user.client.ui.ClickListener;\r
+import com.google.gwt.user.client.ui.DialogBox;\r
+import com.google.gwt.user.client.ui.Image;\r
+import com.google.gwt.user.client.ui.Label;\r
+import com.google.gwt.user.client.ui.LoadListener;\r
+import com.google.gwt.user.client.ui.PopupPanel;\r
+import com.google.gwt.user.client.ui.VerticalPanel;\r
+import com.google.gwt.user.client.ui.Widget;\r
+\r
+\r
+public class ViewImageCommand implements Command {\r
+\r
+ final FileMenu.Images newImages;\r
+\r
+ private PopupPanel containerPanel;\r
+\r
+ private String imageDownloadURL;\r
+\r
+ private Label errorLabel = new Label();\r
+\r
+ /**\r
+ * @param _containerPanel\r
+ * @param _newImages the images of all the possible delete dialogs\r
+ */\r
+ public ViewImageCommand(PopupPanel _containerPanel, final FileMenu.Images _newImages, String _imageDownloadURL) {\r
+ containerPanel = _containerPanel;\r
+ newImages = _newImages;\r
+ imageDownloadURL = _imageDownloadURL;\r
+ }\r
+\r
+ public void execute() {\r
+ containerPanel.hide();\r
+\r
+ final Image image = new Image();\r
+ // Hook up a load listener, so that we can be informed if the image fails\r
+ // to load.\r
+ image.addLoadListener(new LoadListener() {\r
+ public void onError(Widget sender) {\r
+ errorLabel.setText("An error occurred while loading.");\r
+ }\r
+\r
+ public void onLoad(Widget sender) {\r
+ }\r
+ });\r
+ image.setUrl(imageDownloadURL);\r
+ //final PopupPanel imagePopup = new PopupPanel(true);\r
+ final DialogBox imagePopup = new DialogBox(true, true);\r
+ imagePopup.setAnimationEnabled(true);\r
+ imagePopup.setText("Showing image in actual size");\r
+ VerticalPanel imageViewPanel = new VerticalPanel();\r
+ imageViewPanel.add(errorLabel);\r
+ imageViewPanel.add(image);\r
+ imagePopup.setWidget(imageViewPanel);\r
+ image.setTitle("Click to close");\r
+ image.addClickListener(new ClickListener() {\r
+ public void onClick(Widget sender) {\r
+ imagePopup.hide();\r
+ }\r
+ });\r
+ imagePopup.setPopupPosition(0, 0);\r
+ imagePopup.show();\r
+ }\r
+}\r