root / src / gr / ebs / gss / client / SettingsMenu.java @ fc0fa492
History | View | Annotate | Download (3.3 kB)
1 | 14ad7326 | pastith | /*
|
---|---|---|---|
2 | 14ad7326 | pastith | * Copyright 2007, 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 | afd3a0ef | Giannis Koutsoubos | import com.google.gwt.event.dom.client.ClickEvent; |
22 | afd3a0ef | Giannis Koutsoubos | import com.google.gwt.event.dom.client.ClickHandler; |
23 | afd3a0ef | Giannis Koutsoubos | import com.google.gwt.resources.client.ClientBundle; |
24 | afd3a0ef | Giannis Koutsoubos | import com.google.gwt.resources.client.ImageResource; |
25 | 14ad7326 | pastith | import com.google.gwt.user.client.Command; |
26 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.AbstractImagePrototype; |
27 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.MenuBar; |
28 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.PopupPanel; |
29 | 14ad7326 | pastith | |
30 | 14ad7326 | pastith | /**
|
31 | 14ad7326 | pastith | * The 'settings' menu implementation.
|
32 | 14ad7326 | pastith | */
|
33 | afd3a0ef | Giannis Koutsoubos | public class SettingsMenu extends PopupPanel implements ClickHandler { |
34 | 14ad7326 | pastith | |
35 | 14ad7326 | pastith | /**
|
36 | 14ad7326 | pastith | * The widget's images.
|
37 | 14ad7326 | pastith | */
|
38 | 14ad7326 | pastith | private Images images;
|
39 | 14ad7326 | pastith | private final MenuBar contextMenu; |
40 | 14ad7326 | pastith | /**
|
41 | 14ad7326 | pastith | * An image bundle for this widgets images.
|
42 | 14ad7326 | pastith | */
|
43 | afd3a0ef | Giannis Koutsoubos | public interface Images extends ClientBundle,MessagePanel.Images { |
44 | 14ad7326 | pastith | |
45 | 14ad7326 | pastith | /**
|
46 | 14ad7326 | pastith | * Will bundle the file 'advancedsettings.png' residing in the package
|
47 | 14ad7326 | pastith | * 'gr.ebs.gss.resources'.
|
48 | 14ad7326 | pastith | *
|
49 | 14ad7326 | pastith | * @return the image prototype
|
50 | 14ad7326 | pastith | */
|
51 | afd3a0ef | Giannis Koutsoubos | @Source("gr/ebs/gss/resources/advancedsettings.png") |
52 | afd3a0ef | Giannis Koutsoubos | ImageResource preferences(); |
53 | 14ad7326 | pastith | |
54 | afd3a0ef | Giannis Koutsoubos | @Source("gr/ebs/gss/resources/lock.png") |
55 | afd3a0ef | Giannis Koutsoubos | ImageResource credentials(); |
56 | 14ad7326 | pastith | |
57 | 14ad7326 | pastith | } |
58 | 14ad7326 | pastith | |
59 | 14ad7326 | pastith | /**
|
60 | 14ad7326 | pastith | * The widget's constructor.
|
61 | 14ad7326 | pastith | *
|
62 | 14ad7326 | pastith | * @param newImages the image bundle passed on by the parent object
|
63 | 14ad7326 | pastith | */
|
64 | 14ad7326 | pastith | public SettingsMenu(final Images newImages) { |
65 | 14ad7326 | pastith | // The popup's constructor's argument is a boolean specifying that it
|
66 | 14ad7326 | pastith | // auto-close itself when the user clicks outside of it.
|
67 | 14ad7326 | pastith | super(true); |
68 | 14ad7326 | pastith | setAnimationEnabled(true);
|
69 | 14ad7326 | pastith | images = newImages; |
70 | 14ad7326 | pastith | |
71 | 14ad7326 | pastith | Command userCredentialsCommand = new Command(){
|
72 | 023f6f1e | Panagiotis Astithas | @Override
|
73 | 14ad7326 | pastith | public void execute() { |
74 | 3ef7b691 | Dimitris Routsis | CredentialsDialog dlg = new CredentialsDialog(newImages);
|
75 | 14ad7326 | pastith | dlg.center(); |
76 | 14ad7326 | pastith | } |
77 | 14ad7326 | pastith | }; |
78 | 14ad7326 | pastith | contextMenu = new MenuBar(true); |
79 | 14ad7326 | pastith | // contextMenu.addItem("<span>" + newImages.preferences().getHTML() + " Preferences</span>", true, cmd);
|
80 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.credentials()).getHTML() + " Show Credentials</span>", true, userCredentialsCommand); |
81 | 14ad7326 | pastith | |
82 | 14ad7326 | pastith | add(contextMenu); |
83 | 14ad7326 | pastith | // setStyleName("toolbarPopup");
|
84 | 14ad7326 | pastith | } |
85 | 14ad7326 | pastith | |
86 | afd3a0ef | Giannis Koutsoubos | @Override
|
87 | afd3a0ef | Giannis Koutsoubos | public void onClick(final ClickEvent event) { |
88 | 14ad7326 | pastith | final SettingsMenu menu = new SettingsMenu(images); |
89 | afd3a0ef | Giannis Koutsoubos | final int left = event.getRelativeElement().getAbsoluteLeft(); |
90 | afd3a0ef | Giannis Koutsoubos | final int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight(); |
91 | 14ad7326 | pastith | menu.setPopupPosition(left, top); |
92 | 14ad7326 | pastith | |
93 | 14ad7326 | pastith | menu.show(); |
94 | 14ad7326 | pastith | } |
95 | 14ad7326 | pastith | |
96 | 14ad7326 | pastith | |
97 | 14ad7326 | pastith | /**
|
98 | 14ad7326 | pastith | * Retrieve the contextMenu.
|
99 | 14ad7326 | pastith | *
|
100 | 14ad7326 | pastith | * @return the contextMenu
|
101 | 14ad7326 | pastith | */
|
102 | 14ad7326 | pastith | public MenuBar getContextMenu() { |
103 | 14ad7326 | pastith | contextMenu.setAutoOpen(false);
|
104 | 14ad7326 | pastith | return contextMenu;
|
105 | 14ad7326 | pastith | } |
106 | 14ad7326 | pastith | |
107 | 14ad7326 | pastith | |
108 | 14ad7326 | pastith | } |