display message while image loads on the client viewer
[pithos] / src / gr / ebs / gss / client / HelpMenu.java
1 /*\r
2  * Copyright 2009 Electronic Business Systems Ltd.\r
3  *\r
4  * This file is part of GSS.\r
5  *\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
10  *\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
15  *\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
18  */\r
19 package gr.ebs.gss.client;\r
20 \r
21 import com.google.gwt.user.client.Command;\r
22 import com.google.gwt.user.client.ui.AbstractImagePrototype;\r
23 import com.google.gwt.user.client.ui.ClickListener;\r
24 import com.google.gwt.user.client.ui.MenuBar;\r
25 import com.google.gwt.user.client.ui.PopupPanel;\r
26 import com.google.gwt.user.client.ui.Widget;\r
27 import com.google.gwt.user.client.ui.ImageBundle.Resource;\r
28 \r
29 /**\r
30  * The 'Help' menu implementation.\r
31  */\r
32 public class HelpMenu extends PopupPanel implements ClickListener {\r
33 \r
34         /**\r
35          * The widget's images.\r
36          */\r
37         private final Images images;\r
38 \r
39         private MenuBar contextMenu  = new MenuBar(true);\r
40 \r
41         /**\r
42          * An image bundle for this widget's images.\r
43          */\r
44         public interface Images {\r
45                 @Resource("gr/ebs/gss/resources/khelpcenter.png")\r
46                 AbstractImagePrototype userGuide();\r
47 \r
48                 @Resource("gr/ebs/gss/resources/linewidth.png")\r
49                 AbstractImagePrototype terms();\r
50 \r
51                 @Resource("gr/ebs/gss/resources/bell.png")\r
52                 AbstractImagePrototype reportAbuse();\r
53 \r
54                 @Resource("gr/ebs/gss/resources/info.png")\r
55                 AbstractImagePrototype about();\r
56         }\r
57 \r
58         /**\r
59          * The widget's constructor.\r
60          *\r
61          * @param newImages the image bundle passed on by the parent object\r
62          */\r
63         public HelpMenu(final Images newImages) {\r
64                 // The popup's constructor's argument is a boolean specifying that it\r
65                 // auto-close itself when the user clicks outside of it.\r
66                 super(true);\r
67                 setAnimationEnabled(true);\r
68                 images = newImages;\r
69                 createMenu();\r
70                 add(contextMenu);\r
71         }\r
72 \r
73         public void onClick(Widget sender) {\r
74                 HelpMenu menu = new HelpMenu(images);\r
75                 int left = sender.getAbsoluteLeft();\r
76                 int top = sender.getAbsoluteTop() + sender.getOffsetHeight();\r
77                 menu.setPopupPosition(left, top);\r
78                 menu.show();\r
79         }\r
80 \r
81         public MenuBar createMenu() {\r
82                 contextMenu.clearItems();\r
83                 contextMenu.setAutoOpen(false);\r
84                 Command hideCommand = new Command() {\r
85                         public void execute() {\r
86                                 hide();\r
87                         }\r
88                 };\r
89                 Command aboutCommand = new Command(){\r
90                         public void execute() {\r
91                                 AboutDialog dlg = new AboutDialog();\r
92                                 dlg.center();\r
93                         }\r
94                 };\r
95                 contextMenu.addItem("<span>" + images.userGuide().getHTML() + "&nbsp;<a class='hidden-link' " +\r
96                                         "href='/userguide/el' target='_blank'>User Guide</a></span>", true, hideCommand);\r
97                 contextMenu.addItem("<span>" + images.terms().getHTML() + "&nbsp;<a class='hidden-link' " +\r
98                                         "href='/terms' target='_blank'>Terms &amp; Conditions</a></span>", true, hideCommand);\r
99                 contextMenu.addItem("<span>" + images.reportAbuse().getHTML() + "&nbsp;<a class='hidden-link' " +\r
100                                 "href='/report-abuse' target='_blank'>Report abuse</a></span>", true, hideCommand);\r
101                 contextMenu.addItem("<span>" + images.about().getHTML() + "&nbsp;About</span>", true, aboutCommand);\r
102                 return contextMenu;\r
103         }\r
104 \r
105 }\r