root / src / gr / ebs / gss / client / HelpMenu.java @ 2ba74f46
History | View | Annotate | Download (3.6 kB)
1 | 166ce11d | pastith | /*
|
---|---|---|---|
2 | 166ce11d | pastith | * Copyright 2009 Electronic Business Systems Ltd.
|
3 | 166ce11d | pastith | *
|
4 | 166ce11d | pastith | * This file is part of GSS.
|
5 | 166ce11d | pastith | *
|
6 | 166ce11d | pastith | * GSS is free software: you can redistribute it and/or modify
|
7 | 166ce11d | pastith | * it under the terms of the GNU General Public License as published by
|
8 | 166ce11d | pastith | * the Free Software Foundation, either version 3 of the License, or
|
9 | 166ce11d | pastith | * (at your option) any later version.
|
10 | 166ce11d | pastith | *
|
11 | 166ce11d | pastith | * GSS is distributed in the hope that it will be useful,
|
12 | 166ce11d | pastith | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 166ce11d | pastith | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 | 166ce11d | pastith | * GNU General Public License for more details.
|
15 | 166ce11d | pastith | *
|
16 | 166ce11d | pastith | * You should have received a copy of the GNU General Public License
|
17 | 166ce11d | pastith | * along with GSS. If not, see <http://www.gnu.org/licenses/>.
|
18 | 166ce11d | pastith | */
|
19 | 166ce11d | pastith | package gr.ebs.gss.client; |
20 | 166ce11d | 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 | 166ce11d | pastith | import com.google.gwt.user.client.Command; |
26 | 166ce11d | pastith | import com.google.gwt.user.client.ui.AbstractImagePrototype; |
27 | 166ce11d | pastith | import com.google.gwt.user.client.ui.MenuBar; |
28 | 166ce11d | pastith | import com.google.gwt.user.client.ui.PopupPanel; |
29 | 166ce11d | pastith | |
30 | 166ce11d | pastith | /**
|
31 | 166ce11d | pastith | * The 'Help' menu implementation.
|
32 | 166ce11d | pastith | */
|
33 | afd3a0ef | Giannis Koutsoubos | public class HelpMenu extends PopupPanel implements ClickHandler { |
34 | 166ce11d | pastith | |
35 | 166ce11d | pastith | /**
|
36 | 166ce11d | pastith | * The widget's images.
|
37 | 166ce11d | pastith | */
|
38 | 166ce11d | pastith | private final Images images; |
39 | 166ce11d | pastith | |
40 | 166ce11d | pastith | private MenuBar contextMenu = new MenuBar(true); |
41 | 166ce11d | pastith | |
42 | 166ce11d | pastith | /**
|
43 | 166ce11d | pastith | * An image bundle for this widget's images.
|
44 | 166ce11d | pastith | */
|
45 | afd3a0ef | Giannis Koutsoubos | public interface Images extends ClientBundle{ |
46 | afd3a0ef | Giannis Koutsoubos | @Source("gr/ebs/gss/resources/khelpcenter.png") |
47 | afd3a0ef | Giannis Koutsoubos | ImageResource userGuide(); |
48 | 434220a2 | pastith | |
49 | afd3a0ef | Giannis Koutsoubos | @Source("gr/ebs/gss/resources/linewidth.png") |
50 | afd3a0ef | Giannis Koutsoubos | ImageResource terms(); |
51 | 166ce11d | pastith | |
52 | afd3a0ef | Giannis Koutsoubos | @Source("gr/ebs/gss/resources/bell.png") |
53 | afd3a0ef | Giannis Koutsoubos | ImageResource reportAbuse(); |
54 | 434220a2 | pastith | |
55 | afd3a0ef | Giannis Koutsoubos | @Source("gr/ebs/gss/resources/info.png") |
56 | afd3a0ef | Giannis Koutsoubos | ImageResource about(); |
57 | 166ce11d | pastith | } |
58 | 166ce11d | pastith | |
59 | 166ce11d | pastith | /**
|
60 | 166ce11d | pastith | * The widget's constructor.
|
61 | 166ce11d | pastith | *
|
62 | 166ce11d | pastith | * @param newImages the image bundle passed on by the parent object
|
63 | 166ce11d | pastith | */
|
64 | 166ce11d | pastith | public HelpMenu(final Images newImages) { |
65 | 166ce11d | pastith | // The popup's constructor's argument is a boolean specifying that it
|
66 | 166ce11d | pastith | // auto-close itself when the user clicks outside of it.
|
67 | 166ce11d | pastith | super(true); |
68 | 166ce11d | pastith | setAnimationEnabled(true);
|
69 | 166ce11d | pastith | images = newImages; |
70 | 166ce11d | pastith | createMenu(); |
71 | 166ce11d | pastith | add(contextMenu); |
72 | 166ce11d | pastith | } |
73 | 166ce11d | pastith | |
74 | afd3a0ef | Giannis Koutsoubos | public void onClick(ClickEvent event) { |
75 | 166ce11d | pastith | HelpMenu menu = new HelpMenu(images);
|
76 | afd3a0ef | Giannis Koutsoubos | int left = event.getRelativeElement().getAbsoluteLeft();
|
77 | afd3a0ef | Giannis Koutsoubos | int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight();
|
78 | 166ce11d | pastith | menu.setPopupPosition(left, top); |
79 | 166ce11d | pastith | menu.show(); |
80 | 166ce11d | pastith | } |
81 | 166ce11d | pastith | |
82 | 166ce11d | pastith | public MenuBar createMenu() { |
83 | 166ce11d | pastith | contextMenu.clearItems(); |
84 | 166ce11d | pastith | contextMenu.setAutoOpen(false);
|
85 | 434220a2 | pastith | Command hideCommand = new Command() {
|
86 | 166ce11d | pastith | public void execute() { |
87 | 166ce11d | pastith | hide(); |
88 | 166ce11d | pastith | } |
89 | 166ce11d | pastith | }; |
90 | 166ce11d | pastith | Command aboutCommand = new Command(){
|
91 | 166ce11d | pastith | public void execute() { |
92 | 166ce11d | pastith | AboutDialog dlg = new AboutDialog();
|
93 | 166ce11d | pastith | dlg.center(); |
94 | 166ce11d | pastith | } |
95 | 166ce11d | pastith | }; |
96 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.userGuide()).getHTML() + " <a class='hidden-link' " + |
97 | 434220a2 | pastith | "href='/userguide/el' target='_blank'>User Guide</a></span>", true, hideCommand); |
98 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.terms()).getHTML() + " <a class='hidden-link' " + |
99 | 434220a2 | pastith | "href='/terms' target='_blank'>Terms & Conditions</a></span>", true, hideCommand); |
100 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.reportAbuse()).getHTML() + " <a class='hidden-link' " + |
101 | 434220a2 | pastith | "href='/report-abuse' target='_blank'>Report abuse</a></span>", true, hideCommand); |
102 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.about()).getHTML() + " About</span>", true, aboutCommand); |
103 | 166ce11d | pastith | return contextMenu;
|
104 | 166ce11d | pastith | } |
105 | 166ce11d | pastith | |
106 | 166ce11d | pastith | } |