Statistics
| Branch: | Tag: | Revision:

root / src / gr / ebs / gss / client / HelpMenu.java @ e5a2f3bd

History | View | Annotate | Download (4.9 kB)

1 023f6f1e Panagiotis Astithas
/*
2 023f6f1e Panagiotis Astithas
 * Copyright 2009 Electronic Business Systems Ltd.
3 023f6f1e Panagiotis Astithas
 *
4 023f6f1e Panagiotis Astithas
 * This file is part of GSS.
5 023f6f1e Panagiotis Astithas
 *
6 023f6f1e Panagiotis Astithas
 * GSS is free software: you can redistribute it and/or modify
7 023f6f1e Panagiotis Astithas
 * it under the terms of the GNU General Public License as published by
8 023f6f1e Panagiotis Astithas
 * the Free Software Foundation, either version 3 of the License, or
9 023f6f1e Panagiotis Astithas
 * (at your option) any later version.
10 023f6f1e Panagiotis Astithas
 *
11 023f6f1e Panagiotis Astithas
 * GSS is distributed in the hope that it will be useful,
12 023f6f1e Panagiotis Astithas
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 023f6f1e Panagiotis Astithas
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 023f6f1e Panagiotis Astithas
 * GNU General Public License for more details.
15 023f6f1e Panagiotis Astithas
 *
16 023f6f1e Panagiotis Astithas
 * You should have received a copy of the GNU General Public License
17 023f6f1e Panagiotis Astithas
 * along with GSS.  If not, see <http://www.gnu.org/licenses/>.
18 023f6f1e Panagiotis Astithas
 */
19 023f6f1e Panagiotis Astithas
package gr.ebs.gss.client;
20 023f6f1e Panagiotis Astithas
21 023f6f1e Panagiotis Astithas
import com.google.gwt.event.dom.client.ClickEvent;
22 023f6f1e Panagiotis Astithas
import com.google.gwt.event.dom.client.ClickHandler;
23 023f6f1e Panagiotis Astithas
import com.google.gwt.resources.client.ClientBundle;
24 023f6f1e Panagiotis Astithas
import com.google.gwt.resources.client.ImageResource;
25 023f6f1e Panagiotis Astithas
import com.google.gwt.user.client.Command;
26 023f6f1e Panagiotis Astithas
import com.google.gwt.user.client.ui.AbstractImagePrototype;
27 023f6f1e Panagiotis Astithas
import com.google.gwt.user.client.ui.MenuBar;
28 e5a2f3bd Natasa Kapravelou
import com.google.gwt.user.client.ui.MenuItem;
29 023f6f1e Panagiotis Astithas
import com.google.gwt.user.client.ui.PopupPanel;
30 023f6f1e Panagiotis Astithas
31 023f6f1e Panagiotis Astithas
/**
32 023f6f1e Panagiotis Astithas
 * The 'Help' menu implementation.
33 023f6f1e Panagiotis Astithas
 */
34 023f6f1e Panagiotis Astithas
public class HelpMenu extends PopupPanel implements ClickHandler {
35 023f6f1e Panagiotis Astithas
36 023f6f1e Panagiotis Astithas
        /**
37 023f6f1e Panagiotis Astithas
         * The widget's images.
38 023f6f1e Panagiotis Astithas
         */
39 023f6f1e Panagiotis Astithas
        private final Images images;
40 023f6f1e Panagiotis Astithas
41 023f6f1e Panagiotis Astithas
        private MenuBar contextMenu  = new MenuBar(true);
42 023f6f1e Panagiotis Astithas
43 023f6f1e Panagiotis Astithas
        /**
44 023f6f1e Panagiotis Astithas
         * An image bundle for this widget's images.
45 023f6f1e Panagiotis Astithas
         */
46 023f6f1e Panagiotis Astithas
        public interface Images extends ClientBundle{
47 023f6f1e Panagiotis Astithas
                @Source("gr/ebs/gss/resources/khelpcenter.png")
48 023f6f1e Panagiotis Astithas
                ImageResource userGuide();
49 023f6f1e Panagiotis Astithas
50 023f6f1e Panagiotis Astithas
                @Source("gr/ebs/gss/resources/linewidth.png")
51 023f6f1e Panagiotis Astithas
                ImageResource terms();
52 023f6f1e Panagiotis Astithas
53 023f6f1e Panagiotis Astithas
                @Source("gr/ebs/gss/resources/bell.png")
54 023f6f1e Panagiotis Astithas
                ImageResource reportAbuse();
55 023f6f1e Panagiotis Astithas
56 72a90bbf Panagiotis Astithas
                @Source("gr/ebs/gss/resources/bug.png")
57 72a90bbf Panagiotis Astithas
                ImageResource reportBug();
58 72a90bbf Panagiotis Astithas
59 023f6f1e Panagiotis Astithas
                @Source("gr/ebs/gss/resources/info.png")
60 023f6f1e Panagiotis Astithas
                ImageResource about();
61 023f6f1e Panagiotis Astithas
62 023f6f1e Panagiotis Astithas
                @Source("gr/ebs/gss/resources/edit_add.png")
63 023f6f1e Panagiotis Astithas
                ImageResource upgradeQuota();
64 023f6f1e Panagiotis Astithas
        }
65 023f6f1e Panagiotis Astithas
66 023f6f1e Panagiotis Astithas
        /**
67 023f6f1e Panagiotis Astithas
         * The widget's constructor.
68 023f6f1e Panagiotis Astithas
         *
69 023f6f1e Panagiotis Astithas
         * @param newImages the image bundle passed on by the parent object
70 023f6f1e Panagiotis Astithas
         */
71 023f6f1e Panagiotis Astithas
        public HelpMenu(final Images newImages) {
72 023f6f1e Panagiotis Astithas
                // The popup's constructor's argument is a boolean specifying that it
73 023f6f1e Panagiotis Astithas
                // auto-close itself when the user clicks outside of it.
74 023f6f1e Panagiotis Astithas
                super(true);
75 023f6f1e Panagiotis Astithas
                setAnimationEnabled(true);
76 023f6f1e Panagiotis Astithas
                images = newImages;
77 023f6f1e Panagiotis Astithas
                createMenu();
78 023f6f1e Panagiotis Astithas
                add(contextMenu);
79 023f6f1e Panagiotis Astithas
        }
80 023f6f1e Panagiotis Astithas
81 023f6f1e Panagiotis Astithas
        @Override
82 023f6f1e Panagiotis Astithas
        public void onClick(ClickEvent event) {
83 023f6f1e Panagiotis Astithas
                HelpMenu menu = new HelpMenu(images);
84 023f6f1e Panagiotis Astithas
                int left = event.getRelativeElement().getAbsoluteLeft();
85 023f6f1e Panagiotis Astithas
                int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight();
86 023f6f1e Panagiotis Astithas
                menu.setPopupPosition(left, top);
87 023f6f1e Panagiotis Astithas
                menu.show();
88 023f6f1e Panagiotis Astithas
        }
89 023f6f1e Panagiotis Astithas
90 023f6f1e Panagiotis Astithas
        public MenuBar createMenu() {
91 023f6f1e Panagiotis Astithas
                contextMenu.clearItems();
92 023f6f1e Panagiotis Astithas
                contextMenu.setAutoOpen(false);
93 023f6f1e Panagiotis Astithas
                Command hideCommand = new Command() {
94 023f6f1e Panagiotis Astithas
                        @Override
95 023f6f1e Panagiotis Astithas
                        public void execute() {
96 023f6f1e Panagiotis Astithas
                                hide();
97 023f6f1e Panagiotis Astithas
                        }
98 023f6f1e Panagiotis Astithas
                };
99 023f6f1e Panagiotis Astithas
                Command aboutCommand = new Command(){
100 023f6f1e Panagiotis Astithas
                        @Override
101 023f6f1e Panagiotis Astithas
                        public void execute() {
102 023f6f1e Panagiotis Astithas
                                AboutDialog dlg = new AboutDialog();
103 023f6f1e Panagiotis Astithas
                                dlg.center();
104 023f6f1e Panagiotis Astithas
                        }
105 023f6f1e Panagiotis Astithas
                };
106 e5a2f3bd Natasa Kapravelou
                MenuItem userGuideItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.userGuide()).getHTML() + "&nbsp;<a class='hidden-link' " +
107 023f6f1e Panagiotis Astithas
                                        "href='/userguide/el' target='_blank'>User Guide</a></span>", true, hideCommand);
108 e5a2f3bd Natasa Kapravelou
                contextMenu.addItem(userGuideItem);
109 e5a2f3bd Natasa Kapravelou
                userGuideItem.getElement().setId("topMenu.helpMenu.userGuide");
110 e5a2f3bd Natasa Kapravelou
                
111 e5a2f3bd Natasa Kapravelou
                MenuItem termsItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.terms()).getHTML() + "&nbsp;<a class='hidden-link' " +
112 023f6f1e Panagiotis Astithas
                                        "href='/terms' target='_blank'>Terms &amp; Conditions</a></span>", true, hideCommand);
113 e5a2f3bd Natasa Kapravelou
                termsItem.getElement().setId("topMenu.helpMenu.terms");
114 e5a2f3bd Natasa Kapravelou
                contextMenu.addItem(termsItem);
115 e5a2f3bd Natasa Kapravelou
                
116 e5a2f3bd Natasa Kapravelou
                MenuItem reportAbuseItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.reportAbuse()).getHTML() + "&nbsp;<a class='hidden-link' " +
117 e5a2f3bd Natasa Kapravelou
                                        "href='/report-abuse' target='_blank'>Report abuse</a></span>", true, hideCommand);
118 e5a2f3bd Natasa Kapravelou
                reportAbuseItem.getElement().setId("topMenu.helpMenu.reportAbuse");
119 e5a2f3bd Natasa Kapravelou
                contextMenu.addItem(reportAbuseItem);
120 e5a2f3bd Natasa Kapravelou
                
121 e5a2f3bd Natasa Kapravelou
                MenuItem upgradeQuotaItem= new MenuItem("<span>" + AbstractImagePrototype.create(images.upgradeQuota()).getHTML() + "&nbsp;<a class='hidden-link' " +
122 023f6f1e Panagiotis Astithas
                                        "href='/pithos/coupon' target='_blank'>Upgrade quota</a></span>", true, hideCommand);
123 e5a2f3bd Natasa Kapravelou
                upgradeQuotaItem.getElement().setId("topMenu.helpMenu.upgradeQuota");
124 e5a2f3bd Natasa Kapravelou
                contextMenu.addItem(upgradeQuotaItem);
125 e5a2f3bd Natasa Kapravelou
                
126 e5a2f3bd Natasa Kapravelou
                MenuItem reportBugItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.reportBug()).getHTML() + "&nbsp;<a class='hidden-link' " +
127 72a90bbf Panagiotis Astithas
                                        "href='http://code.google.com/p/gss/issues/list' target='_blank'>Report bug</a></span>", true, hideCommand);
128 e5a2f3bd Natasa Kapravelou
                reportBugItem.getElement().setId("topMenu.helpMenu.reportBug");
129 e5a2f3bd Natasa Kapravelou
                contextMenu.addItem(reportBugItem);
130 e5a2f3bd Natasa Kapravelou
                                
131 e5a2f3bd Natasa Kapravelou
                MenuItem aboutItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.about()).getHTML() + "&nbsp;About</span>", true, aboutCommand);
132 e5a2f3bd Natasa Kapravelou
                aboutItem.getElement().setId("topMenu.helpMenu.about");
133 e5a2f3bd Natasa Kapravelou
                contextMenu.addItem(aboutItem);
134 023f6f1e Panagiotis Astithas
                return contextMenu;
135 023f6f1e Panagiotis Astithas
        }
136 023f6f1e Panagiotis Astithas
137 023f6f1e Panagiotis Astithas
}