Statistics
| Branch: | Tag: | Revision:

root / src / gr / ebs / gss / client / commands / ViewImageCommand.java @ b3acdac9

History | View | Annotate | Download (2.9 kB)

1
/*
2
 * Copyright 2009 Electronic Business Systems Ltd.
3
 *
4
 * This file is part of GSS.
5
 *
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.
10
 *
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.
15
 *
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/>.
18
 */
19
package gr.ebs.gss.client.commands;
20

    
21
import gr.ebs.gss.client.FileMenu;
22

    
23
import com.google.gwt.user.client.Command;
24
import com.google.gwt.user.client.ui.ClickListener;
25
import com.google.gwt.user.client.ui.DialogBox;
26
import com.google.gwt.user.client.ui.Image;
27
import com.google.gwt.user.client.ui.Label;
28
import com.google.gwt.user.client.ui.LoadListener;
29
import com.google.gwt.user.client.ui.PopupPanel;
30
import com.google.gwt.user.client.ui.VerticalPanel;
31
import com.google.gwt.user.client.ui.Widget;
32

    
33

    
34
public class ViewImageCommand implements Command {
35

    
36
        final FileMenu.Images newImages;
37

    
38
        private PopupPanel containerPanel;
39

    
40
        private String imageDownloadURL;
41

    
42
        private Label errorLabel = new Label();
43

    
44
        /**
45
         * @param _containerPanel
46
         * @param _newImages the images of all the possible delete dialogs
47
         */
48
        public ViewImageCommand(PopupPanel _containerPanel, final FileMenu.Images _newImages, String _imageDownloadURL) {
49
                containerPanel = _containerPanel;
50
                newImages = _newImages;
51
                imageDownloadURL = _imageDownloadURL;
52
        }
53

    
54
        public void execute() {
55
                containerPanel.hide();
56

    
57
                final Image image = new Image();
58
                // Hook up a load listener, so that we can be informed if the image fails
59
            // to load.
60
            image.addLoadListener(new LoadListener() {
61
                    public void onError(Widget sender) {
62
                            errorLabel.setText("An error occurred while loading.");
63
                    }
64

    
65
                    public void onLoad(Widget sender) {
66
                            errorLabel.setText("");
67
                    }
68
            });
69
            image.setUrl(imageDownloadURL);
70
            //final PopupPanel imagePopup = new PopupPanel(true);
71
            final DialogBox imagePopup = new DialogBox(true, true);
72
            imagePopup.setAnimationEnabled(true);
73
            imagePopup.setText("Showing image in actual size");
74
            VerticalPanel imageViewPanel = new VerticalPanel();
75
            errorLabel.setText("loading image...");
76
            imageViewPanel.add(errorLabel);
77
            imageViewPanel.add(image);
78
            imagePopup.setWidget(imageViewPanel);
79
            image.setTitle("Click to close");
80
            image.addClickListener(new ClickListener() {
81
                    public void onClick(Widget sender) {
82
                            imagePopup.hide();
83
                    }
84
            });
85
            imagePopup.setPopupPosition(0, 0);
86
            imagePopup.show();
87
        }
88
}