First rough implementation of the file upload functionality using Google Gears. Multi...
[pithos] / src / gr / ebs / gss / client / GroupMenu.java
1 /*\r
2  * Copyright 2007, 2008, 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 gr.ebs.gss.client.commands.NewGroupCommand;\r
22 \r
23 import com.google.gwt.user.client.ui.AbstractImagePrototype;\r
24 import com.google.gwt.user.client.ui.ClickListener;\r
25 import com.google.gwt.user.client.ui.ImageBundle;\r
26 import com.google.gwt.user.client.ui.MenuBar;\r
27 import com.google.gwt.user.client.ui.PopupPanel;\r
28 import com.google.gwt.user.client.ui.Widget;\r
29 \r
30 /**\r
31  * The 'Group' menu implementation.\r
32  */\r
33 public class GroupMenu extends PopupPanel implements ClickListener {\r
34         /**\r
35          * The widget's images.\r
36          */\r
37         private Images images;\r
38         private final MenuBar contextMenu;\r
39 \r
40         /**\r
41          * An image bundle for this widgets images.\r
42          */\r
43         public interface Images extends ImageBundle {\r
44                 @Resource("gr/ebs/gss/resources/groupevent.png")\r
45                 AbstractImagePrototype groupNew();\r
46 \r
47                 @Resource("gr/ebs/gss/resources/view_text.png")\r
48                 AbstractImagePrototype viewText();\r
49 \r
50         }\r
51 \r
52         /**\r
53          * The widget's constructor.\r
54          *\r
55          * @param newImages the image bundle passed on by the parent object\r
56          */\r
57         public GroupMenu(final Images newImages) {\r
58                 // The popup's constructor's argument is a boolean specifying that it\r
59                 // auto-close itself when the user clicks outside of it.\r
60                 super(true);\r
61                 setAnimationEnabled(true);\r
62                 images = newImages;\r
63 \r
64                 contextMenu = new MenuBar(true);\r
65                 contextMenu.addItem("<span>" + newImages.groupNew().getHTML() + "&nbsp;New Group</span>", true, new NewGroupCommand(this));\r
66 \r
67                 add(contextMenu);\r
68         }\r
69 \r
70         public void onClick(Widget sender) {\r
71                 GroupMenu menu = new GroupMenu(images);\r
72                 int left = sender.getAbsoluteLeft();\r
73                 int top = sender.getAbsoluteTop() + sender.getOffsetHeight();\r
74                 menu.setPopupPosition(left, top);\r
75 \r
76                 menu.show();\r
77         }\r
78 \r
79         /**\r
80          * Retrieve the contextMenu.\r
81          *\r
82          * @return the contextMenu\r
83          */\r
84         public MenuBar getContextMenu() {\r
85                 contextMenu.setAutoOpen(false);\r
86                 return contextMenu;\r
87         }\r
88 \r
89 }\r