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