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