2 * Copyright 2009 Electronic Business Systems Ltd.
\r
4 * This file is part of GSS.
\r
6 * GSS is free software: you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation, either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * GSS is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with GSS. If not, see <http://www.gnu.org/licenses/>.
\r
19 package gr.ebs.gss.client.commands;
\r
21 import gr.ebs.gss.client.FileMenu;
\r
23 import com.google.gwt.user.client.Command;
\r
24 import com.google.gwt.user.client.ui.ClickListener;
\r
25 import com.google.gwt.user.client.ui.DialogBox;
\r
26 import com.google.gwt.user.client.ui.Image;
\r
27 import com.google.gwt.user.client.ui.Label;
\r
28 import com.google.gwt.user.client.ui.LoadListener;
\r
29 import com.google.gwt.user.client.ui.PopupPanel;
\r
30 import com.google.gwt.user.client.ui.VerticalPanel;
\r
31 import com.google.gwt.user.client.ui.Widget;
\r
34 public class ViewImageCommand implements Command {
\r
36 final FileMenu.Images newImages;
\r
38 private PopupPanel containerPanel;
\r
40 private String imageDownloadURL;
\r
42 private Label errorLabel = new Label();
\r
45 * @param _containerPanel
\r
46 * @param _newImages the images of all the possible delete dialogs
\r
48 public ViewImageCommand(PopupPanel _containerPanel, final FileMenu.Images _newImages, String _imageDownloadURL) {
\r
49 containerPanel = _containerPanel;
\r
50 newImages = _newImages;
\r
51 imageDownloadURL = _imageDownloadURL;
\r
54 public void execute() {
\r
55 containerPanel.hide();
\r
57 final Image image = new Image();
\r
58 // Hook up a load listener, so that we can be informed if the image fails
\r
60 image.addLoadListener(new LoadListener() {
\r
61 public void onError(Widget sender) {
\r
62 errorLabel.setText("An error occurred while loading.");
\r
65 public void onLoad(Widget sender) {
\r
66 errorLabel.setText("");
\r
69 image.setUrl(imageDownloadURL);
\r
70 //final PopupPanel imagePopup = new PopupPanel(true);
\r
71 final DialogBox imagePopup = new DialogBox(true, true);
\r
72 imagePopup.setAnimationEnabled(true);
\r
73 imagePopup.setText("Showing image in actual size");
\r
74 VerticalPanel imageViewPanel = new VerticalPanel();
\r
75 errorLabel.setText("loading image...");
\r
76 imageViewPanel.add(errorLabel);
\r
77 imageViewPanel.add(image);
\r
78 imagePopup.setWidget(imageViewPanel);
\r
79 image.setTitle("Click to close");
\r
80 image.addClickListener(new ClickListener() {
\r
81 public void onClick(Widget sender) {
\r
85 imagePopup.setPopupPosition(0, 0);
\r