+/*\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