root / src / gr / ebs / gss / client / GroupMenu.java @ a60ea262
History | View | Annotate | Download (2.8 kB)
1 | 023f6f1e | Panagiotis Astithas | /*
|
---|---|---|---|
2 | 023f6f1e | Panagiotis Astithas | * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
|
3 | 023f6f1e | Panagiotis Astithas | *
|
4 | 023f6f1e | Panagiotis Astithas | * This file is part of GSS.
|
5 | 023f6f1e | Panagiotis Astithas | *
|
6 | 023f6f1e | Panagiotis Astithas | * GSS is free software: you can redistribute it and/or modify
|
7 | 023f6f1e | Panagiotis Astithas | * it under the terms of the GNU General Public License as published by
|
8 | 023f6f1e | Panagiotis Astithas | * the Free Software Foundation, either version 3 of the License, or
|
9 | 023f6f1e | Panagiotis Astithas | * (at your option) any later version.
|
10 | 023f6f1e | Panagiotis Astithas | *
|
11 | 023f6f1e | Panagiotis Astithas | * GSS is distributed in the hope that it will be useful,
|
12 | 023f6f1e | Panagiotis Astithas | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 023f6f1e | Panagiotis Astithas | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 | 023f6f1e | Panagiotis Astithas | * GNU General Public License for more details.
|
15 | 023f6f1e | Panagiotis Astithas | *
|
16 | 023f6f1e | Panagiotis Astithas | * You should have received a copy of the GNU General Public License
|
17 | 023f6f1e | Panagiotis Astithas | * along with GSS. If not, see <http://www.gnu.org/licenses/>.
|
18 | 023f6f1e | Panagiotis Astithas | */
|
19 | 023f6f1e | Panagiotis Astithas | package gr.ebs.gss.client; |
20 | 023f6f1e | Panagiotis Astithas | |
21 | 023f6f1e | Panagiotis Astithas | import gr.ebs.gss.client.commands.NewGroupCommand; |
22 | 023f6f1e | Panagiotis Astithas | |
23 | 023f6f1e | Panagiotis Astithas | import com.google.gwt.event.dom.client.ClickEvent; |
24 | 023f6f1e | Panagiotis Astithas | import com.google.gwt.event.dom.client.ClickHandler; |
25 | 023f6f1e | Panagiotis Astithas | import com.google.gwt.resources.client.ClientBundle; |
26 | 023f6f1e | Panagiotis Astithas | import com.google.gwt.resources.client.ImageResource; |
27 | 023f6f1e | Panagiotis Astithas | import com.google.gwt.user.client.ui.AbstractImagePrototype; |
28 | 023f6f1e | Panagiotis Astithas | import com.google.gwt.user.client.ui.MenuBar; |
29 | 31eb2af3 | Natasa Kapravelou | import com.google.gwt.user.client.ui.MenuItem; |
30 | 023f6f1e | Panagiotis Astithas | import com.google.gwt.user.client.ui.PopupPanel; |
31 | 023f6f1e | Panagiotis Astithas | |
32 | 023f6f1e | Panagiotis Astithas | /**
|
33 | 023f6f1e | Panagiotis Astithas | * The 'Group' menu implementation.
|
34 | 023f6f1e | Panagiotis Astithas | */
|
35 | 023f6f1e | Panagiotis Astithas | public class GroupMenu extends PopupPanel implements ClickHandler { |
36 | 023f6f1e | Panagiotis Astithas | /**
|
37 | 023f6f1e | Panagiotis Astithas | * The widget's images.
|
38 | 023f6f1e | Panagiotis Astithas | */
|
39 | 023f6f1e | Panagiotis Astithas | private Images images;
|
40 | 023f6f1e | Panagiotis Astithas | private final MenuBar contextMenu; |
41 | 023f6f1e | Panagiotis Astithas | |
42 | 023f6f1e | Panagiotis Astithas | /**
|
43 | 023f6f1e | Panagiotis Astithas | * An image bundle for this widgets images.
|
44 | 023f6f1e | Panagiotis Astithas | */
|
45 | 023f6f1e | Panagiotis Astithas | public interface Images extends ClientBundle { |
46 | 023f6f1e | Panagiotis Astithas | @Source("gr/ebs/gss/resources/groupevent.png") |
47 | 023f6f1e | Panagiotis Astithas | ImageResource groupNew(); |
48 | 023f6f1e | Panagiotis Astithas | |
49 | 023f6f1e | Panagiotis Astithas | @Source("gr/ebs/gss/resources/view_text.png") |
50 | 023f6f1e | Panagiotis Astithas | ImageResource viewText(); |
51 | 023f6f1e | Panagiotis Astithas | |
52 | 023f6f1e | Panagiotis Astithas | } |
53 | 023f6f1e | Panagiotis Astithas | |
54 | 023f6f1e | Panagiotis Astithas | /**
|
55 | 023f6f1e | Panagiotis Astithas | * The widget's constructor.
|
56 | 023f6f1e | Panagiotis Astithas | *
|
57 | 023f6f1e | Panagiotis Astithas | * @param newImages the image bundle passed on by the parent object
|
58 | 023f6f1e | Panagiotis Astithas | */
|
59 | 023f6f1e | Panagiotis Astithas | public GroupMenu(final Images newImages) { |
60 | 023f6f1e | Panagiotis Astithas | // The popup's constructor's argument is a boolean specifying that it
|
61 | 023f6f1e | Panagiotis Astithas | // auto-close itself when the user clicks outside of it.
|
62 | 023f6f1e | Panagiotis Astithas | super(true); |
63 | 023f6f1e | Panagiotis Astithas | setAnimationEnabled(true);
|
64 | 023f6f1e | Panagiotis Astithas | images = newImages; |
65 | 023f6f1e | Panagiotis Astithas | |
66 | 023f6f1e | Panagiotis Astithas | contextMenu = new MenuBar(true); |
67 | 31eb2af3 | Natasa Kapravelou | MenuItem newGroupItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.groupNew()).getHTML() + " New Group</span>", true, new NewGroupCommand(this)); |
68 | 31eb2af3 | Natasa Kapravelou | newGroupItem.getElement().setId("topMenu.groupMenu.newGroup");
|
69 | 31eb2af3 | Natasa Kapravelou | contextMenu.addItem(newGroupItem); |
70 | 023f6f1e | Panagiotis Astithas | |
71 | 023f6f1e | Panagiotis Astithas | add(contextMenu); |
72 | 023f6f1e | Panagiotis Astithas | } |
73 | 023f6f1e | Panagiotis Astithas | |
74 | 023f6f1e | Panagiotis Astithas | @Override
|
75 | 023f6f1e | Panagiotis Astithas | public void onClick(ClickEvent event) { |
76 | 023f6f1e | Panagiotis Astithas | GroupMenu menu = new GroupMenu(images);
|
77 | 023f6f1e | Panagiotis Astithas | int left = event.getRelativeElement().getAbsoluteLeft();
|
78 | 023f6f1e | Panagiotis Astithas | int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight();
|
79 | 023f6f1e | Panagiotis Astithas | menu.setPopupPosition(left, top); |
80 | 023f6f1e | Panagiotis Astithas | |
81 | 023f6f1e | Panagiotis Astithas | menu.show(); |
82 | 023f6f1e | Panagiotis Astithas | } |
83 | 023f6f1e | Panagiotis Astithas | |
84 | 023f6f1e | Panagiotis Astithas | /**
|
85 | 023f6f1e | Panagiotis Astithas | * Retrieve the contextMenu.
|
86 | 023f6f1e | Panagiotis Astithas | *
|
87 | 023f6f1e | Panagiotis Astithas | * @return the contextMenu
|
88 | 023f6f1e | Panagiotis Astithas | */
|
89 | 023f6f1e | Panagiotis Astithas | public MenuBar getContextMenu() { |
90 | 023f6f1e | Panagiotis Astithas | contextMenu.setAutoOpen(false);
|
91 | 023f6f1e | Panagiotis Astithas | return contextMenu;
|
92 | 023f6f1e | Panagiotis Astithas | } |
93 | 023f6f1e | Panagiotis Astithas | |
94 | 023f6f1e | Panagiotis Astithas | } |