2 * Copyright 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 com.google.gwt.event.dom.client.ClickEvent;
\r
22 import com.google.gwt.event.dom.client.ClickHandler;
\r
23 import com.google.gwt.resources.client.ClientBundle;
\r
24 import com.google.gwt.resources.client.ImageResource;
\r
25 import com.google.gwt.user.client.Command;
\r
26 import com.google.gwt.user.client.ui.AbstractImagePrototype;
\r
27 import com.google.gwt.user.client.ui.MenuBar;
\r
28 import com.google.gwt.user.client.ui.PopupPanel;
\r
31 * The 'Help' menu implementation.
\r
33 public class HelpMenu extends PopupPanel implements ClickHandler {
\r
36 * The widget's images.
\r
38 private final Images images;
\r
40 private MenuBar contextMenu = new MenuBar(true);
\r
43 * An image bundle for this widget's images.
\r
45 public interface Images extends ClientBundle{
\r
46 @Source("gr/ebs/gss/resources/khelpcenter.png")
\r
47 ImageResource userGuide();
\r
49 @Source("gr/ebs/gss/resources/linewidth.png")
\r
50 ImageResource terms();
\r
52 @Source("gr/ebs/gss/resources/bell.png")
\r
53 ImageResource reportAbuse();
\r
55 @Source("gr/ebs/gss/resources/info.png")
\r
56 ImageResource about();
\r
60 * The widget's constructor.
\r
62 * @param newImages the image bundle passed on by the parent object
\r
64 public HelpMenu(final Images newImages) {
\r
65 // The popup's constructor's argument is a boolean specifying that it
\r
66 // auto-close itself when the user clicks outside of it.
\r
68 setAnimationEnabled(true);
\r
74 public void onClick(ClickEvent event) {
\r
75 HelpMenu menu = new HelpMenu(images);
\r
76 int left = event.getRelativeElement().getAbsoluteLeft();
\r
77 int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight();
\r
78 menu.setPopupPosition(left, top);
\r
82 public MenuBar createMenu() {
\r
83 contextMenu.clearItems();
\r
84 contextMenu.setAutoOpen(false);
\r
85 Command hideCommand = new Command() {
\r
86 public void execute() {
\r
90 Command aboutCommand = new Command(){
\r
91 public void execute() {
\r
92 AboutDialog dlg = new AboutDialog();
\r
96 contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.userGuide()).getHTML() + " <a class='hidden-link' " +
\r
97 "href='/userguide/el' target='_blank'>User Guide</a></span>", true, hideCommand);
\r
98 contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.terms()).getHTML() + " <a class='hidden-link' " +
\r
99 "href='/terms' target='_blank'>Terms & Conditions</a></span>", true, hideCommand);
\r
100 contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.reportAbuse()).getHTML() + " <a class='hidden-link' " +
\r
101 "href='/report-abuse' target='_blank'>Report abuse</a></span>", true, hideCommand);
\r
102 contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.about()).getHTML() + " About</span>", true, aboutCommand);
\r
103 return contextMenu;
\r