Revision 023f6f1e src/gr/ebs/gss/client/HelpMenu.java

b/src/gr/ebs/gss/client/HelpMenu.java
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
		@Source("gr/ebs/gss/resources/edit_add.png")
59
		ImageResource upgradeQuota();
60
	}
61

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

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

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

  
111
}
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
		@Source("gr/ebs/gss/resources/edit_add.png")
59
		ImageResource upgradeQuota();
60
	}
61

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

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

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

  
114
}

Also available in: Unified diff