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.user.client.Command;
\r
22 import com.google.gwt.user.client.ui.AbstractImagePrototype;
\r
23 import com.google.gwt.user.client.ui.ClickListener;
\r
24 import com.google.gwt.user.client.ui.MenuBar;
\r
25 import com.google.gwt.user.client.ui.PopupPanel;
\r
26 import com.google.gwt.user.client.ui.Widget;
\r
27 import com.google.gwt.user.client.ui.ImageBundle.Resource;
\r
30 * The 'Help' menu implementation.
\r
32 public class HelpMenu extends PopupPanel implements ClickListener {
\r
35 * The widget's images.
\r
37 private final Images images;
\r
39 private MenuBar contextMenu = new MenuBar(true);
\r
42 * An image bundle for this widget's images.
\r
44 public interface Images {
\r
45 @Resource("gr/ebs/gss/resources/khelpcenter.png")
\r
46 AbstractImagePrototype userGuide();
\r
48 @Resource("gr/ebs/gss/resources/linewidth.png")
\r
49 AbstractImagePrototype terms();
\r
51 @Resource("gr/ebs/gss/resources/bell.png")
\r
52 AbstractImagePrototype reportAbuse();
\r
54 @Resource("gr/ebs/gss/resources/info.png")
\r
55 AbstractImagePrototype about();
\r
59 * The widget's constructor.
\r
61 * @param newImages the image bundle passed on by the parent object
\r
63 public HelpMenu(final Images newImages) {
\r
64 // The popup's constructor's argument is a boolean specifying that it
\r
65 // auto-close itself when the user clicks outside of it.
\r
67 setAnimationEnabled(true);
\r
73 public void onClick(Widget sender) {
\r
74 HelpMenu menu = new HelpMenu(images);
\r
75 int left = sender.getAbsoluteLeft();
\r
76 int top = sender.getAbsoluteTop() + sender.getOffsetHeight();
\r
77 menu.setPopupPosition(left, top);
\r
81 public MenuBar createMenu() {
\r
82 contextMenu.clearItems();
\r
83 contextMenu.setAutoOpen(false);
\r
84 Command hideCommand = new Command() {
\r
85 public void execute() {
\r
89 Command aboutCommand = new Command(){
\r
90 public void execute() {
\r
91 AboutDialog dlg = new AboutDialog();
\r
95 contextMenu.addItem("<span>" + images.userGuide().getHTML() + " <a class='hidden-link' " +
\r
96 "href='/userguide/el' target='_blank'>User Guide</a></span>", true, hideCommand);
\r
97 contextMenu.addItem("<span>" + images.terms().getHTML() + " <a class='hidden-link' " +
\r
98 "href='/terms' target='_blank'>Terms & Conditions</a></span>", true, hideCommand);
\r
99 contextMenu.addItem("<span>" + images.reportAbuse().getHTML() + " <a class='hidden-link' " +
\r
100 "href='/report-abuse' target='_blank'>Report abuse</a></span>", true, hideCommand);
\r
101 contextMenu.addItem("<span>" + images.about().getHTML() + " About</span>", true, aboutCommand);
\r
102 return contextMenu;
\r