Statistics
| Branch: | Tag: | Revision:

root / web_client / src / gr / grnet / pithos / web / client / HelpMenu.java @ f55cf326

History | View | Annotate | Download (5.8 kB)

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