root / src / gr / ebs / gss / client / GroupContextMenu.java @ a60ea262
History | View | Annotate | Download (3.3 kB)
1 | 14ad7326 | pastith | /*
|
---|---|---|---|
2 | 14ad7326 | pastith | * Copyright 2008, 2009 Electronic Business Systems Ltd.
|
3 | 14ad7326 | pastith | *
|
4 | 14ad7326 | pastith | * This file is part of GSS.
|
5 | 14ad7326 | pastith | *
|
6 | 14ad7326 | pastith | * GSS is free software: you can redistribute it and/or modify
|
7 | 14ad7326 | pastith | * it under the terms of the GNU General Public License as published by
|
8 | 14ad7326 | pastith | * the Free Software Foundation, either version 3 of the License, or
|
9 | 14ad7326 | pastith | * (at your option) any later version.
|
10 | 14ad7326 | pastith | *
|
11 | 14ad7326 | pastith | * GSS is distributed in the hope that it will be useful,
|
12 | 14ad7326 | pastith | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 14ad7326 | pastith | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 | 14ad7326 | pastith | * GNU General Public License for more details.
|
15 | 14ad7326 | pastith | *
|
16 | 14ad7326 | pastith | * You should have received a copy of the GNU General Public License
|
17 | 14ad7326 | pastith | * along with GSS. If not, see <http://www.gnu.org/licenses/>.
|
18 | 14ad7326 | pastith | */
|
19 | 14ad7326 | pastith | package gr.ebs.gss.client; |
20 | 14ad7326 | pastith | |
21 | 14ad7326 | pastith | import gr.ebs.gss.client.Groups.Images; |
22 | 14ad7326 | pastith | import gr.ebs.gss.client.commands.CopyCommand; |
23 | 14ad7326 | pastith | import gr.ebs.gss.client.commands.DeleteUserOrGroupCommand; |
24 | 14ad7326 | pastith | import gr.ebs.gss.client.commands.NewGroupCommand; |
25 | 14ad7326 | pastith | import gr.ebs.gss.client.commands.NewUserCommand; |
26 | 14ad7326 | pastith | import gr.ebs.gss.client.commands.PasteCommand; |
27 | 9f712d7c | koutsoub | import gr.ebs.gss.client.rest.resource.GroupResource; |
28 | 9f712d7c | koutsoub | import gr.ebs.gss.client.rest.resource.GroupUserResource; |
29 | 14ad7326 | pastith | |
30 | afd3a0ef | Giannis Koutsoubos | import com.google.gwt.user.client.ui.AbstractImagePrototype; |
31 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.MenuBar; |
32 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.MenuItem; |
33 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.PopupPanel; |
34 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.TreeItem; |
35 | 14ad7326 | pastith | |
36 | 14ad7326 | pastith | |
37 | 14ad7326 | pastith | /**
|
38 | 14ad7326 | pastith | * @author kman
|
39 | 14ad7326 | pastith | *
|
40 | 14ad7326 | pastith | */
|
41 | 14ad7326 | pastith | public class GroupContextMenu extends PopupPanel { |
42 | 14ad7326 | pastith | |
43 | 14ad7326 | pastith | /**
|
44 | 14ad7326 | pastith | * The widget's images.
|
45 | 14ad7326 | pastith | */
|
46 | 14ad7326 | pastith | private final Images images; |
47 | 14ad7326 | pastith | private MenuItem copy; |
48 | 14ad7326 | pastith | private MenuItem paste; |
49 | 14ad7326 | pastith | |
50 | 14ad7326 | pastith | |
51 | 14ad7326 | pastith | public GroupContextMenu(final Images newImages) { |
52 | 14ad7326 | pastith | // The popup's constructor's argument is a boolean specifying that it
|
53 | 14ad7326 | pastith | // auto-close itself when the user clicks outside of it.
|
54 | 14ad7326 | pastith | super(true); |
55 | 14ad7326 | pastith | images=newImages; |
56 | 14ad7326 | pastith | setAnimationEnabled(true);
|
57 | 14ad7326 | pastith | final MenuBar contextMenu = new MenuBar(true); |
58 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.groupNew()).getHTML() + " New Group</span>", true, new NewGroupCommand(this)); |
59 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.groupNew()).getHTML() + " Add User</span>", true, new NewUserCommand(this)); |
60 | afd3a0ef | Giannis Koutsoubos | copy = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy User</span>", true, new CopyCommand(this)); |
61 | 14ad7326 | pastith | contextMenu.addItem(copy); |
62 | afd3a0ef | Giannis Koutsoubos | paste = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + " Paste User</span>", true, new PasteCommand(this)); |
63 | 14ad7326 | pastith | contextMenu.addItem(paste); |
64 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteUserOrGroupCommand(this,images)); |
65 | 14ad7326 | pastith | add(contextMenu); |
66 | 14ad7326 | pastith | |
67 | 14ad7326 | pastith | } |
68 | 14ad7326 | pastith | |
69 | 14ad7326 | pastith | /* (non-Javadoc)
|
70 | 14ad7326 | pastith | * @see com.google.gwt.user.client.ui.PopupPanel#show()
|
71 | 14ad7326 | pastith | */
|
72 | 14ad7326 | pastith | @Override
|
73 | 14ad7326 | pastith | public void show() { |
74 | 14ad7326 | pastith | TreeItem current = GSS.get().getGroups().getCurrent(); |
75 | 9f712d7c | koutsoub | if(current !=null && current.getUserObject() instanceof GroupUserResource && GSS.get().getCurrentSelection() instanceof GroupUserResource) |
76 | 14ad7326 | pastith | copy.setVisible(true);
|
77 | 14ad7326 | pastith | else
|
78 | 14ad7326 | pastith | copy.setVisible(false);
|
79 | 9f712d7c | koutsoub | if(current !=null && current.getUserObject() instanceof GroupResource && GSS.get().getCurrentSelection() instanceof GroupResource && GSS.get().getClipboard().hasUserItem()) |
80 | 14ad7326 | pastith | paste.setVisible(true);
|
81 | 14ad7326 | pastith | else
|
82 | 14ad7326 | pastith | paste.setVisible(false);
|
83 | 14ad7326 | pastith | super.show();
|
84 | 14ad7326 | pastith | } |
85 | 14ad7326 | pastith | |
86 | 14ad7326 | pastith | } |