2 * Copyright 2009 Electronic Business Systems Ltd.
4 * This file is part of GSS.
6 * GSS is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GSS. If not, see <http://www.gnu.org/licenses/>.
19 package gr.ebs.gss.client;
21 import com.google.gwt.event.dom.client.ClickEvent;
22 import com.google.gwt.event.dom.client.ClickHandler;
23 import com.google.gwt.resources.client.ClientBundle;
24 import com.google.gwt.resources.client.ImageResource;
25 import com.google.gwt.user.client.Command;
26 import com.google.gwt.user.client.ui.AbstractImagePrototype;
27 import com.google.gwt.user.client.ui.MenuBar;
28 import com.google.gwt.user.client.ui.PopupPanel;
31 * The 'Help' menu implementation.
33 public class HelpMenu extends PopupPanel implements ClickHandler {
36 * The widget's images.
38 private final Images images;
40 private MenuBar contextMenu = new MenuBar(true);
43 * An image bundle for this widget's images.
45 public interface Images extends ClientBundle{
46 @Source("gr/ebs/gss/resources/khelpcenter.png")
47 ImageResource userGuide();
49 @Source("gr/ebs/gss/resources/linewidth.png")
50 ImageResource terms();
52 @Source("gr/ebs/gss/resources/bell.png")
53 ImageResource reportAbuse();
55 @Source("gr/ebs/gss/resources/bug.png")
56 ImageResource reportBug();
58 @Source("gr/ebs/gss/resources/info.png")
59 ImageResource about();
61 @Source("gr/ebs/gss/resources/edit_add.png")
62 ImageResource upgradeQuota();
66 * The widget's constructor.
68 * @param newImages the image bundle passed on by the parent object
70 public HelpMenu(final Images newImages) {
71 // The popup's constructor's argument is a boolean specifying that it
72 // auto-close itself when the user clicks outside of it.
74 setAnimationEnabled(true);
81 public void onClick(ClickEvent event) {
82 HelpMenu menu = new HelpMenu(images);
83 int left = event.getRelativeElement().getAbsoluteLeft();
84 int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight();
85 menu.setPopupPosition(left, top);
89 public MenuBar createMenu() {
90 contextMenu.clearItems();
91 contextMenu.setAutoOpen(false);
92 Command hideCommand = new Command() {
94 public void execute() {
98 Command aboutCommand = new Command(){
100 public void execute() {
101 AboutDialog dlg = new AboutDialog();
105 contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.userGuide()).getHTML() + " <a class='hidden-link' " +
106 "href='/userguide/el' target='_blank'>User Guide</a></span>", true, hideCommand);
107 contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.terms()).getHTML() + " <a class='hidden-link' " +
108 "href='/terms' target='_blank'>Terms & Conditions</a></span>", true, hideCommand);
109 contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.reportAbuse()).getHTML() + " <a class='hidden-link' " +
110 "href='/report-abuse' target='_blank'>Report abuse</a></span>", true, hideCommand);
111 contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.upgradeQuota()).getHTML() + " <a class='hidden-link' " +
112 "href='/pithos/coupon' target='_blank'>Upgrade quota</a></span>", true, hideCommand);
113 contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.reportBug()).getHTML() + " <a class='hidden-link' " +
114 "href='http://code.google.com/p/gss/issues/list' target='_blank'>Report bug</a></span>", true, hideCommand);
115 contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.about()).getHTML() + " About</span>", true, aboutCommand);