2 * Copyright 2009 Electronic Business Systems Ltd.
4 * This file is part of GSS.
6 * GSS is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GSS. If not, see <http://www.gnu.org/licenses/>.
19 package gr.ebs.gss.client.commands;
21 import gr.ebs.gss.client.FileMenu;
23 import com.google.gwt.event.dom.client.ClickEvent;
24 import com.google.gwt.event.dom.client.ClickHandler;
25 import com.google.gwt.event.dom.client.ErrorEvent;
26 import com.google.gwt.event.dom.client.ErrorHandler;
27 import com.google.gwt.event.dom.client.LoadEvent;
28 import com.google.gwt.event.dom.client.LoadHandler;
29 import com.google.gwt.user.client.Command;
30 import com.google.gwt.user.client.ui.DialogBox;
31 import com.google.gwt.user.client.ui.Image;
32 import com.google.gwt.user.client.ui.Label;
33 import com.google.gwt.user.client.ui.PopupPanel;
34 import com.google.gwt.user.client.ui.VerticalPanel;
37 public class ViewImageCommand implements Command {
39 final FileMenu.Images newImages;
41 private PopupPanel containerPanel;
43 private String imageDownloadURL;
45 private Label errorLabel = new Label();
48 * @param _containerPanel
49 * @param _newImages the images of all the possible delete dialogs
51 public ViewImageCommand(PopupPanel _containerPanel, final FileMenu.Images _newImages, String _imageDownloadURL) {
52 containerPanel = _containerPanel;
53 newImages = _newImages;
54 imageDownloadURL = _imageDownloadURL;
58 public void execute() {
59 containerPanel.hide();
61 final Image image = new Image();
62 // Hook up a load handler, so that we can be informed if the image
64 image.addLoadHandler(new LoadHandler() {
67 public void onLoad(LoadEvent event) {
68 errorLabel.setText("");
71 image.addErrorHandler(new ErrorHandler() {
74 public void onError(ErrorEvent event) {
75 errorLabel.setText("An error occurred while loading.");
78 image.setUrl(imageDownloadURL);
79 final DialogBox imagePopup = new DialogBox(true, true);
80 imagePopup.setAnimationEnabled(true);
81 imagePopup.setText("Showing image in actual size");
82 VerticalPanel imageViewPanel = new VerticalPanel();
83 errorLabel.setText("loading image...");
84 imageViewPanel.add(errorLabel);
85 imageViewPanel.add(image);
86 imagePopup.setWidget(imageViewPanel);
87 image.setTitle("Click to close");
88 image.addClickHandler(new ClickHandler() {
91 public void onClick(ClickEvent event) {
95 imagePopup.setPopupPosition(0, 0);