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