2 * Copyright (c) 2011 Greek Research and Technology Network
4 package gr.grnet.pithos.web.client;
6 import com.google.gwt.event.dom.client.ClickEvent;
7 import com.google.gwt.event.dom.client.ClickHandler;
8 import com.google.gwt.resources.client.ClientBundle;
9 import com.google.gwt.resources.client.ImageResource;
10 import com.google.gwt.user.client.Command;
11 import com.google.gwt.user.client.ui.AbstractImagePrototype;
12 import com.google.gwt.user.client.ui.MenuBar;
13 import com.google.gwt.user.client.ui.MenuItem;
14 import com.google.gwt.user.client.ui.PopupPanel;
17 * The 'Help' menu implementation.
19 public class HelpMenu extends PopupPanel implements ClickHandler {
22 * The widget's images.
24 private final Images images;
26 private MenuBar contextMenu = new MenuBar(true);
29 * An image bundle for this widget's images.
31 public interface Images extends ClientBundle{
32 @Source("gr/grnet/pithos/resources/khelpcenter.png")
33 ImageResource userGuide();
35 @Source("gr/grnet/pithos/resources/linewidth.png")
36 ImageResource terms();
38 @Source("gr/grnet/pithos/resources/bell.png")
39 ImageResource reportAbuse();
41 @Source("gr/grnet/pithos/resources/bug.png")
42 ImageResource reportBug();
44 @Source("gr/grnet/pithos/resources/info.png")
45 ImageResource about();
47 @Source("gr/grnet/pithos/resources/edit_add.png")
48 ImageResource upgradeQuota();
52 * The widget's constructor.
54 * @param newImages the image bundle passed on by the parent object
56 public HelpMenu(final Images newImages) {
57 // The popup's constructor's argument is a boolean specifying that it
58 // auto-close itself when the user clicks outside of it.
60 setAnimationEnabled(true);
67 public void onClick(ClickEvent event) {
68 HelpMenu menu = new HelpMenu(images);
69 int left = event.getRelativeElement().getAbsoluteLeft();
70 int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight();
71 menu.setPopupPosition(left, top);
75 public MenuBar createMenu() {
76 contextMenu.clearItems();
77 contextMenu.setAutoOpen(false);
78 Command hideCommand = new Command() {
80 public void execute() {
84 Command aboutCommand = new Command(){
86 public void execute() {
87 AboutDialog dlg = new AboutDialog();
91 MenuItem userGuideItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.userGuide()).getHTML() + " <a class='hidden-link' " +
92 "href='/userguide/el' target='_blank'>User Guide</a></span>", true, hideCommand);
93 contextMenu.addItem(userGuideItem);
94 userGuideItem.getElement().setId("topMenu.help.userGuide");
96 MenuItem termsItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.terms()).getHTML() + " <a class='hidden-link' " +
97 "href='/terms' target='_blank'>Terms & Conditions</a></span>", true, hideCommand);
98 termsItem.getElement().setId("topMenu.help.terms");
99 contextMenu.addItem(termsItem);
101 MenuItem reportAbuseItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.reportAbuse()).getHTML() + " <a class='hidden-link' " +
102 "href='/report-abuse' target='_blank'>Report abuse</a></span>", true, hideCommand);
103 reportAbuseItem.getElement().setId("topMenu.help.reportAbuse");
104 contextMenu.addItem(reportAbuseItem);
106 MenuItem upgradeQuotaItem= new MenuItem("<span>" + AbstractImagePrototype.create(images.upgradeQuota()).getHTML() + " <a class='hidden-link' " +
107 "href='/pithos/coupon' target='_blank'>Upgrade quota</a></span>", true, hideCommand);
108 upgradeQuotaItem.getElement().setId("topMenu.help.upgradeQuota");
109 contextMenu.addItem(upgradeQuotaItem);
111 MenuItem reportBugItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.reportBug()).getHTML() + " <a class='hidden-link' " +
112 "href='http://code.google.com/p/pithos/issues/list' target='_blank'>Report bug</a></span>", true, hideCommand);
113 reportBugItem.getElement().setId("topMenu.help.reportBug");
114 contextMenu.addItem(reportBugItem);
116 MenuItem aboutItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.about()).getHTML() + " About</span>", true, aboutCommand);
117 aboutItem.getElement().setId("topMenu.help.about");
118 contextMenu.addItem(aboutItem);