fixed tree update when moving a node to trash with no children but trashed ones,...
[pithos] / 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.MenuItem;
29 import com.google.gwt.user.client.ui.PopupPanel;
30
31 /**
32  * The 'Help' menu implementation.
33  */
34 public class HelpMenu extends PopupPanel implements ClickHandler {
35
36         /**
37          * The widget's images.
38          */
39         private final Images images;
40
41         private MenuBar contextMenu  = new MenuBar(true);
42
43         /**
44          * An image bundle for this widget's images.
45          */
46         public interface Images extends ClientBundle{
47                 @Source("gr/ebs/gss/resources/khelpcenter.png")
48                 ImageResource userGuide();
49
50                 @Source("gr/ebs/gss/resources/linewidth.png")
51                 ImageResource terms();
52
53                 @Source("gr/ebs/gss/resources/bell.png")
54                 ImageResource reportAbuse();
55
56                 @Source("gr/ebs/gss/resources/bug.png")
57                 ImageResource reportBug();
58
59                 @Source("gr/ebs/gss/resources/info.png")
60                 ImageResource about();
61
62                 @Source("gr/ebs/gss/resources/edit_add.png")
63                 ImageResource upgradeQuota();
64         }
65
66         /**
67          * The widget's constructor.
68          *
69          * @param newImages the image bundle passed on by the parent object
70          */
71         public HelpMenu(final Images newImages) {
72                 // The popup's constructor's argument is a boolean specifying that it
73                 // auto-close itself when the user clicks outside of it.
74                 super(true);
75                 setAnimationEnabled(true);
76                 images = newImages;
77                 createMenu();
78                 add(contextMenu);
79         }
80
81         @Override
82         public void onClick(ClickEvent event) {
83                 HelpMenu menu = new HelpMenu(images);
84                 int left = event.getRelativeElement().getAbsoluteLeft();
85                 int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight();
86                 menu.setPopupPosition(left, top);
87                 menu.show();
88         }
89
90         public MenuBar createMenu() {
91                 contextMenu.clearItems();
92                 contextMenu.setAutoOpen(false);
93                 Command hideCommand = new Command() {
94                         @Override
95                         public void execute() {
96                                 hide();
97                         }
98                 };
99                 Command aboutCommand = new Command(){
100                         @Override
101                         public void execute() {
102                                 AboutDialog dlg = new AboutDialog();
103                                 dlg.center();
104                         }
105                 };
106                 MenuItem userGuideItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.userGuide()).getHTML() + "&nbsp;<a class='hidden-link' " +
107                                         "href='/userguide/el' target='_blank'>User Guide</a></span>", true, hideCommand);
108                 contextMenu.addItem(userGuideItem);
109                 userGuideItem.getElement().setId("topMenu.help.userGuide");
110                 
111                 MenuItem termsItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.terms()).getHTML() + "&nbsp;<a class='hidden-link' " +
112                                         "href='/terms' target='_blank'>Terms &amp; Conditions</a></span>", true, hideCommand);
113                 termsItem.getElement().setId("topMenu.help.terms");
114                 contextMenu.addItem(termsItem);
115                 
116                 MenuItem reportAbuseItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.reportAbuse()).getHTML() + "&nbsp;<a class='hidden-link' " +
117                                         "href='/report-abuse' target='_blank'>Report abuse</a></span>", true, hideCommand);
118                 reportAbuseItem.getElement().setId("topMenu.help.reportAbuse");
119                 contextMenu.addItem(reportAbuseItem);
120                 
121                 MenuItem upgradeQuotaItem= new MenuItem("<span>" + AbstractImagePrototype.create(images.upgradeQuota()).getHTML() + "&nbsp;<a class='hidden-link' " +
122                                         "href='/pithos/coupon' target='_blank'>Upgrade quota</a></span>", true, hideCommand);
123                 upgradeQuotaItem.getElement().setId("topMenu.help.upgradeQuota");
124                 contextMenu.addItem(upgradeQuotaItem);
125                 
126                 MenuItem reportBugItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.reportBug()).getHTML() + "&nbsp;<a class='hidden-link' " +
127                                         "href='http://code.google.com/p/gss/issues/list' target='_blank'>Report bug</a></span>", true, hideCommand);
128                 reportBugItem.getElement().setId("topMenu.help.reportBug");
129                 contextMenu.addItem(reportBugItem);
130                                 
131                 MenuItem aboutItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.about()).getHTML() + "&nbsp;About</span>", true, aboutCommand);
132                 aboutItem.getElement().setId("topMenu.help.about");
133                 contextMenu.addItem(aboutItem);
134                 return contextMenu;
135         }
136
137 }