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.MenuItem;
29 import com.google.gwt.user.client.ui.PopupPanel;
32 * The 'Help' menu implementation.
34 public class HelpMenu extends PopupPanel implements ClickHandler {
37 * The widget's images.
39 private final Images images;
41 private MenuBar contextMenu = new MenuBar(true);
44 * An image bundle for this widget's images.
46 public interface Images extends ClientBundle{
47 @Source("gr/ebs/gss/resources/khelpcenter.png")
48 ImageResource userGuide();
50 @Source("gr/ebs/gss/resources/linewidth.png")
51 ImageResource terms();
53 @Source("gr/ebs/gss/resources/bell.png")
54 ImageResource reportAbuse();
56 @Source("gr/ebs/gss/resources/bug.png")
57 ImageResource reportBug();
59 @Source("gr/ebs/gss/resources/info.png")
60 ImageResource about();
62 @Source("gr/ebs/gss/resources/edit_add.png")
63 ImageResource upgradeQuota();
67 * The widget's constructor.
69 * @param newImages the image bundle passed on by the parent object
71 public HelpMenu(final Images newImages) {
72 // The popup's constructor's argument is a boolean specifying that it
73 // auto-close itself when the user clicks outside of it.
75 setAnimationEnabled(true);
82 public void onClick(ClickEvent event) {
83 HelpMenu menu = new HelpMenu(images);
84 int left = event.getRelativeElement().getAbsoluteLeft();
85 int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight();
86 menu.setPopupPosition(left, top);
90 public MenuBar createMenu() {
91 contextMenu.clearItems();
92 contextMenu.setAutoOpen(false);
93 Command hideCommand = new Command() {
95 public void execute() {
99 Command aboutCommand = new Command(){
101 public void execute() {
102 AboutDialog dlg = new AboutDialog();
106 MenuItem userGuideItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.userGuide()).getHTML() + " <a class='hidden-link' " +
107 "href='/userguide/el' target='_blank'>User Guide</a></span>", true, hideCommand);
108 contextMenu.addItem(userGuideItem);
109 userGuideItem.getElement().setId("topMenu.helpMenu.userGuide");
111 MenuItem termsItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.terms()).getHTML() + " <a class='hidden-link' " +
112 "href='/terms' target='_blank'>Terms & Conditions</a></span>", true, hideCommand);
113 termsItem.getElement().setId("topMenu.helpMenu.terms");
114 contextMenu.addItem(termsItem);
116 MenuItem reportAbuseItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.reportAbuse()).getHTML() + " <a class='hidden-link' " +
117 "href='/report-abuse' target='_blank'>Report abuse</a></span>", true, hideCommand);
118 reportAbuseItem.getElement().setId("topMenu.helpMenu.reportAbuse");
119 contextMenu.addItem(reportAbuseItem);
121 MenuItem upgradeQuotaItem= new MenuItem("<span>" + AbstractImagePrototype.create(images.upgradeQuota()).getHTML() + " <a class='hidden-link' " +
122 "href='/pithos/coupon' target='_blank'>Upgrade quota</a></span>", true, hideCommand);
123 upgradeQuotaItem.getElement().setId("topMenu.helpMenu.upgradeQuota");
124 contextMenu.addItem(upgradeQuotaItem);
126 MenuItem reportBugItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.reportBug()).getHTML() + " <a class='hidden-link' " +
127 "href='http://code.google.com/p/gss/issues/list' target='_blank'>Report bug</a></span>", true, hideCommand);
128 reportBugItem.getElement().setId("topMenu.helpMenu.reportBug");
129 contextMenu.addItem(reportBugItem);
131 MenuItem aboutItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.about()).getHTML() + " About</span>", true, aboutCommand);
132 aboutItem.getElement().setId("topMenu.helpMenu.about");
133 contextMenu.addItem(aboutItem);