2 * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
\r
4 * This file is part of GSS.
\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
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
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
19 package gr.ebs.gss.client;
\r
21 import gr.ebs.gss.client.commands.NewGroupCommand;
\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
31 * The 'Group' menu implementation.
\r
33 public class GroupMenu extends PopupPanel implements ClickListener {
\r
35 * The widget's images.
\r
37 private Images images;
\r
38 private final MenuBar contextMenu;
\r
41 * An image bundle for this widgets images.
\r
43 public interface Images extends ImageBundle {
\r
44 @Resource("gr/ebs/gss/resources/groupevent.png")
\r
45 AbstractImagePrototype groupNew();
\r
47 @Resource("gr/ebs/gss/resources/view_text.png")
\r
48 AbstractImagePrototype viewText();
\r
53 * The widget's constructor.
\r
55 * @param newImages the image bundle passed on by the parent object
\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
61 setAnimationEnabled(true);
\r
64 contextMenu = new MenuBar(true);
\r
65 contextMenu.addItem("<span>" + newImages.groupNew().getHTML() + " New Group</span>", true, new NewGroupCommand(this));
\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
80 * Retrieve the contextMenu.
\r
82 * @return the contextMenu
\r
84 public MenuBar getContextMenu() {
\r
85 contextMenu.setAutoOpen(false);
\r