2 * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
4 * This file is part of GSS.
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.
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.
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/>.
19 package gr.ebs.gss.client;
21 import gr.ebs.gss.client.commands.NewGroupCommand;
23 import com.google.gwt.event.dom.client.ClickEvent;
24 import com.google.gwt.event.dom.client.ClickHandler;
25 import com.google.gwt.resources.client.ClientBundle;
26 import com.google.gwt.resources.client.ImageResource;
27 import com.google.gwt.user.client.ui.AbstractImagePrototype;
28 import com.google.gwt.user.client.ui.MenuBar;
29 import com.google.gwt.user.client.ui.PopupPanel;
32 * The 'Group' menu implementation.
34 public class GroupMenu extends PopupPanel implements ClickHandler {
36 * The widget's images.
38 private Images images;
39 private final MenuBar contextMenu;
42 * An image bundle for this widgets images.
44 public interface Images extends ClientBundle {
45 @Source("gr/ebs/gss/resources/groupevent.png")
46 ImageResource groupNew();
48 @Source("gr/ebs/gss/resources/view_text.png")
49 ImageResource viewText();
54 * The widget's constructor.
56 * @param newImages the image bundle passed on by the parent object
58 public GroupMenu(final Images newImages) {
59 // The popup's constructor's argument is a boolean specifying that it
60 // auto-close itself when the user clicks outside of it.
62 setAnimationEnabled(true);
65 contextMenu = new MenuBar(true);
66 contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.groupNew()).getHTML() + " New Group</span>", true, new NewGroupCommand(this));
72 public void onClick(ClickEvent event) {
73 GroupMenu menu = new GroupMenu(images);
74 int left = event.getRelativeElement().getAbsoluteLeft();
75 int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight();
76 menu.setPopupPosition(left, top);
82 * Retrieve the contextMenu.
84 * @return the contextMenu
86 public MenuBar getContextMenu() {
87 contextMenu.setAutoOpen(false);