Statistics
| Branch: | Tag: | Revision:

root / src / gr / ebs / gss / client / HelpMenu.java @ 2ba74f46

History | View | Annotate | Download (3.6 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/info.png")
56
                ImageResource about();
57
        }
58

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

    
74
        public void onClick(ClickEvent event) {
75
                HelpMenu menu = new HelpMenu(images);
76
                int left = event.getRelativeElement().getAbsoluteLeft();
77
                int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight();
78
                menu.setPopupPosition(left, top);
79
                menu.show();
80
        }
81

    
82
        public MenuBar createMenu() {
83
                contextMenu.clearItems();
84
                contextMenu.setAutoOpen(false);
85
                Command hideCommand = new Command() {
86
                        public void execute() {
87
                                hide();
88
                        }
89
                };
90
                Command aboutCommand = new Command(){
91
                        public void execute() {
92
                                AboutDialog dlg = new AboutDialog();
93
                                dlg.center();
94
                        }
95
                };
96
                contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.userGuide()).getHTML() + "&nbsp;<a class='hidden-link' " +
97
                                        "href='/userguide/el' target='_blank'>User Guide</a></span>", true, hideCommand);
98
                contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.terms()).getHTML() + "&nbsp;<a class='hidden-link' " +
99
                                        "href='/terms' target='_blank'>Terms &amp; Conditions</a></span>", true, hideCommand);
100
                contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.reportAbuse()).getHTML() + "&nbsp;<a class='hidden-link' " +
101
                                "href='/report-abuse' target='_blank'>Report abuse</a></span>", true, hideCommand);
102
                contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.about()).getHTML() + "&nbsp;About</span>", true, aboutCommand);
103
                return contextMenu;
104
        }
105

    
106
}