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.MenuItem;
30 import com.google.gwt.user.client.ui.PopupPanel;
33 * The 'Group' menu implementation.
35 public class GroupMenu extends PopupPanel implements ClickHandler {
37 * The widget's images.
39 private Images images;
40 private final MenuBar contextMenu;
43 * An image bundle for this widgets images.
45 public interface Images extends ClientBundle {
46 @Source("gr/ebs/gss/resources/groupevent.png")
47 ImageResource groupNew();
49 @Source("gr/ebs/gss/resources/view_text.png")
50 ImageResource viewText();
55 * The widget's constructor.
57 * @param newImages the image bundle passed on by the parent object
59 public GroupMenu(final Images newImages) {
60 // The popup's constructor's argument is a boolean specifying that it
61 // auto-close itself when the user clicks outside of it.
63 setAnimationEnabled(true);
66 contextMenu = new MenuBar(true);
67 MenuItem newGroupItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.groupNew()).getHTML() + " New Group</span>", true, new NewGroupCommand(this));
68 newGroupItem.getElement().setId("topMenu.groupMenu.newGroup");
69 contextMenu.addItem(newGroupItem);
75 public void onClick(ClickEvent event) {
76 GroupMenu menu = new GroupMenu(images);
77 int left = event.getRelativeElement().getAbsoluteLeft();
78 int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight();
79 menu.setPopupPosition(left, top);
85 * Retrieve the contextMenu.
87 * @return the contextMenu
89 public MenuBar getContextMenu() {
90 contextMenu.setAutoOpen(false);