Statistics
| Branch: | Tag: | Revision:

root / src / gr / ebs / gss / client / HelpMenu.java @ 3ee27ba6

History | View | Annotate | Download (4.2 kB)

1
/*
2
 * Copyright 2009 Electronic Business Systems Ltd.
3
 *
4
 * This file is part of GSS.
5
 *
6
 * GSS is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * GSS is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with GSS.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19
package gr.ebs.gss.client;
20

    
21
import com.google.gwt.event.dom.client.ClickEvent;
22
import com.google.gwt.event.dom.client.ClickHandler;
23
import com.google.gwt.resources.client.ClientBundle;
24
import com.google.gwt.resources.client.ImageResource;
25
import com.google.gwt.user.client.Command;
26
import com.google.gwt.user.client.ui.AbstractImagePrototype;
27
import com.google.gwt.user.client.ui.MenuBar;
28
import com.google.gwt.user.client.ui.PopupPanel;
29

    
30
/**
31
 * The 'Help' menu implementation.
32
 */
33
public class HelpMenu extends PopupPanel implements ClickHandler {
34

    
35
        /**
36
         * The widget's images.
37
         */
38
        private final Images images;
39

    
40
        private MenuBar contextMenu  = new MenuBar(true);
41

    
42
        /**
43
         * An image bundle for this widget's images.
44
         */
45
        public interface Images extends ClientBundle{
46
                @Source("gr/ebs/gss/resources/khelpcenter.png")
47
                ImageResource userGuide();
48

    
49
                @Source("gr/ebs/gss/resources/linewidth.png")
50
                ImageResource terms();
51

    
52
                @Source("gr/ebs/gss/resources/bell.png")
53
                ImageResource reportAbuse();
54

    
55
                @Source("gr/ebs/gss/resources/bug.png")
56
                ImageResource reportBug();
57

    
58
                @Source("gr/ebs/gss/resources/info.png")
59
                ImageResource about();
60

    
61
                @Source("gr/ebs/gss/resources/edit_add.png")
62
                ImageResource upgradeQuota();
63
        }
64

    
65
        /**
66
         * The widget's constructor.
67
         *
68
         * @param newImages the image bundle passed on by the parent object
69
         */
70
        public HelpMenu(final Images newImages) {
71
                // The popup's constructor's argument is a boolean specifying that it
72
                // auto-close itself when the user clicks outside of it.
73
                super(true);
74
                setAnimationEnabled(true);
75
                images = newImages;
76
                createMenu();
77
                add(contextMenu);
78
        }
79

    
80
        @Override
81
        public void onClick(ClickEvent event) {
82
                HelpMenu menu = new HelpMenu(images);
83
                int left = event.getRelativeElement().getAbsoluteLeft();
84
                int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight();
85
                menu.setPopupPosition(left, top);
86
                menu.show();
87
        }
88

    
89
        public MenuBar createMenu() {
90
                contextMenu.clearItems();
91
                contextMenu.setAutoOpen(false);
92
                Command hideCommand = new Command() {
93
                        @Override
94
                        public void execute() {
95
                                hide();
96
                        }
97
                };
98
                Command aboutCommand = new Command(){
99
                        @Override
100
                        public void execute() {
101
                                AboutDialog dlg = new AboutDialog();
102
                                dlg.center();
103
                        }
104
                };
105
                contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.userGuide()).getHTML() + "&nbsp;<a class='hidden-link' " +
106
                                        "href='/userguide/el' target='_blank'>User Guide</a></span>", true, hideCommand);
107
                contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.terms()).getHTML() + "&nbsp;<a class='hidden-link' " +
108
                                        "href='/terms' target='_blank'>Terms &amp; Conditions</a></span>", true, hideCommand);
109
                contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.reportAbuse()).getHTML() + "&nbsp;<a class='hidden-link' " +
110
                                "href='/report-abuse' target='_blank'>Report abuse</a></span>", true, hideCommand);
111
                contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.upgradeQuota()).getHTML() + "&nbsp;<a class='hidden-link' " +
112
                                        "href='/pithos/coupon' target='_blank'>Upgrade quota</a></span>", true, hideCommand);
113
                contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.reportBug()).getHTML() + "&nbsp;<a class='hidden-link' " +
114
                                        "href='http://code.google.com/p/gss/issues/list' target='_blank'>Report bug</a></span>", true, hideCommand);
115
                contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.about()).getHTML() + "&nbsp;About</span>", true, aboutCommand);
116
                return contextMenu;
117
        }
118

    
119
}