root / src / gr / grnet / pithos / web / client / HelpMenu.java @ 749068ba
History | View | Annotate | Download (5.8 kB)
1 |
/*
|
---|---|
2 |
* Copyright 2011 GRNET S.A. All rights reserved.
|
3 |
*
|
4 |
* Redistribution and use in source and binary forms, with or
|
5 |
* without modification, are permitted provided that the following
|
6 |
* conditions are met:
|
7 |
*
|
8 |
* 1. Redistributions of source code must retain the above
|
9 |
* copyright notice, this list of conditions and the following
|
10 |
* disclaimer.
|
11 |
*
|
12 |
* 2. Redistributions in binary form must reproduce the above
|
13 |
* copyright notice, this list of conditions and the following
|
14 |
* disclaimer in the documentation and/or other materials
|
15 |
* provided with the distribution.
|
16 |
*
|
17 |
* THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
18 |
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19 |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
20 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
21 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
22 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
23 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
24 |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
25 |
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
26 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
27 |
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28 |
* POSSIBILITY OF SUCH DAMAGE.
|
29 |
*
|
30 |
* The views and conclusions contained in the software and
|
31 |
* documentation are those of the authors and should not be
|
32 |
* interpreted as representing official policies, either expressed
|
33 |
* or implied, of GRNET S.A.
|
34 |
*/
|
35 |
package gr.grnet.pithos.web.client; |
36 |
|
37 |
import com.google.gwt.event.dom.client.ClickEvent; |
38 |
import com.google.gwt.event.dom.client.ClickHandler; |
39 |
import com.google.gwt.resources.client.ClientBundle; |
40 |
import com.google.gwt.resources.client.ImageResource; |
41 |
import com.google.gwt.user.client.Command; |
42 |
import com.google.gwt.user.client.ui.AbstractImagePrototype; |
43 |
import com.google.gwt.user.client.ui.MenuBar; |
44 |
import com.google.gwt.user.client.ui.MenuItem; |
45 |
import com.google.gwt.user.client.ui.PopupPanel; |
46 |
|
47 |
/**
|
48 |
* The 'Help' menu implementation.
|
49 |
*/
|
50 |
public class HelpMenu extends PopupPanel implements ClickHandler { |
51 |
|
52 |
/**
|
53 |
* The widget's images.
|
54 |
*/
|
55 |
private final Images images; |
56 |
|
57 |
private MenuBar contextMenu = new MenuBar(true); |
58 |
|
59 |
/**
|
60 |
* An image bundle for this widget's images.
|
61 |
*/
|
62 |
public interface Images extends ClientBundle{ |
63 |
@Source("gr/grnet/pithos/resources/khelpcenter.png") |
64 |
ImageResource userGuide(); |
65 |
|
66 |
@Source("gr/grnet/pithos/resources/linewidth.png") |
67 |
ImageResource terms(); |
68 |
|
69 |
@Source("gr/grnet/pithos/resources/bell.png") |
70 |
ImageResource reportAbuse(); |
71 |
|
72 |
@Source("gr/grnet/pithos/resources/bug.png") |
73 |
ImageResource reportBug(); |
74 |
|
75 |
@Source("gr/grnet/pithos/resources/info.png") |
76 |
ImageResource about(); |
77 |
|
78 |
@Source("gr/grnet/pithos/resources/edit_add.png") |
79 |
ImageResource upgradeQuota(); |
80 |
} |
81 |
|
82 |
/**
|
83 |
* The widget's constructor.
|
84 |
*
|
85 |
* @param newImages the image bundle passed on by the parent object
|
86 |
*/
|
87 |
public HelpMenu(final Images newImages) { |
88 |
// The popup's constructor's argument is a boolean specifying that it
|
89 |
// auto-close itself when the user clicks outside of it.
|
90 |
super(true); |
91 |
setAnimationEnabled(true);
|
92 |
images = newImages; |
93 |
createMenu(); |
94 |
add(contextMenu); |
95 |
} |
96 |
|
97 |
@Override
|
98 |
public void onClick(ClickEvent event) { |
99 |
HelpMenu menu = new HelpMenu(images);
|
100 |
int left = event.getRelativeElement().getAbsoluteLeft();
|
101 |
int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight();
|
102 |
menu.setPopupPosition(left, top); |
103 |
menu.show(); |
104 |
} |
105 |
|
106 |
public MenuBar createMenu() { |
107 |
contextMenu.clearItems(); |
108 |
contextMenu.setAutoOpen(false);
|
109 |
Command hideCommand = new Command() {
|
110 |
@Override
|
111 |
public void execute() { |
112 |
hide(); |
113 |
} |
114 |
}; |
115 |
Command aboutCommand = new Command(){
|
116 |
@Override
|
117 |
public void execute() { |
118 |
AboutDialog dlg = new AboutDialog();
|
119 |
dlg.center(); |
120 |
} |
121 |
}; |
122 |
MenuItem userGuideItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.userGuide()).getHTML() + " <a class='hidden-link' " + |
123 |
"href='/userguide/el' target='_blank'>User Guide</a></span>", true, hideCommand); |
124 |
contextMenu.addItem(userGuideItem); |
125 |
userGuideItem.getElement().setId("topMenu.help.userGuide");
|
126 |
|
127 |
MenuItem termsItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.terms()).getHTML() + " <a class='hidden-link' " + |
128 |
"href='/terms' target='_blank'>Terms & Conditions</a></span>", true, hideCommand); |
129 |
termsItem.getElement().setId("topMenu.help.terms");
|
130 |
contextMenu.addItem(termsItem); |
131 |
|
132 |
MenuItem reportAbuseItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.reportAbuse()).getHTML() + " <a class='hidden-link' " + |
133 |
"href='/report-abuse' target='_blank'>Report abuse</a></span>", true, hideCommand); |
134 |
reportAbuseItem.getElement().setId("topMenu.help.reportAbuse");
|
135 |
contextMenu.addItem(reportAbuseItem); |
136 |
|
137 |
MenuItem upgradeQuotaItem= new MenuItem("<span>" + AbstractImagePrototype.create(images.upgradeQuota()).getHTML() + " <a class='hidden-link' " + |
138 |
"href='/pithos/coupon' target='_blank'>Upgrade quota</a></span>", true, hideCommand); |
139 |
upgradeQuotaItem.getElement().setId("topMenu.help.upgradeQuota");
|
140 |
contextMenu.addItem(upgradeQuotaItem); |
141 |
|
142 |
MenuItem reportBugItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.reportBug()).getHTML() + " <a class='hidden-link' " + |
143 |
"href='http://code.google.com/p/pithos/issues/list' target='_blank'>Report bug</a></span>", true, hideCommand); |
144 |
reportBugItem.getElement().setId("topMenu.help.reportBug");
|
145 |
contextMenu.addItem(reportBugItem); |
146 |
|
147 |
MenuItem aboutItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.about()).getHTML() + " About</span>", true, aboutCommand); |
148 |
aboutItem.getElement().setId("topMenu.help.about");
|
149 |
contextMenu.addItem(aboutItem); |
150 |
return contextMenu;
|
151 |
} |
152 |
|
153 |
} |