X-Git-Url: https://code.grnet.gr/git/pithos/blobdiff_plain/16baf609bb746ccbc6cd8da7213ee74cf474f2a9..4aba5423d07fbf1a1388a27cc996b38db5c4835c:/src/gr/ebs/gss/client/HelpMenu.java diff --git a/src/gr/ebs/gss/client/HelpMenu.java b/src/gr/ebs/gss/client/HelpMenu.java index a75ab1b..c499f08 100644 --- a/src/gr/ebs/gss/client/HelpMenu.java +++ b/src/gr/ebs/gss/client/HelpMenu.java @@ -1,105 +1,137 @@ -/* - * Copyright 2009 Electronic Business Systems Ltd. - * - * This file is part of GSS. - * - * GSS is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GSS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GSS. If not, see . - */ -package gr.ebs.gss.client; - -import com.google.gwt.user.client.Command; -import com.google.gwt.user.client.ui.AbstractImagePrototype; -import com.google.gwt.user.client.ui.ClickListener; -import com.google.gwt.user.client.ui.MenuBar; -import com.google.gwt.user.client.ui.PopupPanel; -import com.google.gwt.user.client.ui.Widget; -import com.google.gwt.user.client.ui.ImageBundle.Resource; - -/** - * The 'Help' menu implementation. - */ -public class HelpMenu extends PopupPanel implements ClickListener { - - /** - * The widget's images. - */ - private final Images images; - - private MenuBar contextMenu = new MenuBar(true); - - /** - * An image bundle for this widget's images. - */ - public interface Images { - @Resource("gr/ebs/gss/resources/khelpcenter.png") - AbstractImagePrototype userGuide(); - - @Resource("gr/ebs/gss/resources/linewidth.png") - AbstractImagePrototype terms(); - - @Resource("gr/ebs/gss/resources/bell.png") - AbstractImagePrototype reportAbuse(); - - @Resource("gr/ebs/gss/resources/info.png") - AbstractImagePrototype about(); - } - - /** - * The widget's constructor. - * - * @param newImages the image bundle passed on by the parent object - */ - public HelpMenu(final Images newImages) { - // The popup's constructor's argument is a boolean specifying that it - // auto-close itself when the user clicks outside of it. - super(true); - setAnimationEnabled(true); - images = newImages; - createMenu(); - add(contextMenu); - } - - public void onClick(Widget sender) { - HelpMenu menu = new HelpMenu(images); - int left = sender.getAbsoluteLeft(); - int top = sender.getAbsoluteTop() + sender.getOffsetHeight(); - menu.setPopupPosition(left, top); - menu.show(); - } - - public MenuBar createMenu() { - contextMenu.clearItems(); - contextMenu.setAutoOpen(false); - Command hideCommand = new Command() { - public void execute() { - hide(); - } - }; - Command aboutCommand = new Command(){ - public void execute() { - AboutDialog dlg = new AboutDialog(); - dlg.center(); - } - }; - contextMenu.addItem("" + images.userGuide().getHTML() + " User Guide", true, hideCommand); - contextMenu.addItem("" + images.terms().getHTML() + " Terms & Conditions", true, hideCommand); - contextMenu.addItem("" + images.reportAbuse().getHTML() + " Report abuse", true, hideCommand); - contextMenu.addItem("" + images.about().getHTML() + " About", true, aboutCommand); - return contextMenu; - } - -} +/* + * Copyright 2009 Electronic Business Systems Ltd. + * + * This file is part of GSS. + * + * GSS is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GSS is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GSS. If not, see . + */ +package gr.ebs.gss.client; + +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.resources.client.ClientBundle; +import com.google.gwt.resources.client.ImageResource; +import com.google.gwt.user.client.Command; +import com.google.gwt.user.client.ui.AbstractImagePrototype; +import com.google.gwt.user.client.ui.MenuBar; +import com.google.gwt.user.client.ui.MenuItem; +import com.google.gwt.user.client.ui.PopupPanel; + +/** + * The 'Help' menu implementation. + */ +public class HelpMenu extends PopupPanel implements ClickHandler { + + /** + * The widget's images. + */ + private final Images images; + + private MenuBar contextMenu = new MenuBar(true); + + /** + * An image bundle for this widget's images. + */ + public interface Images extends ClientBundle{ + @Source("gr/ebs/gss/resources/khelpcenter.png") + ImageResource userGuide(); + + @Source("gr/ebs/gss/resources/linewidth.png") + ImageResource terms(); + + @Source("gr/ebs/gss/resources/bell.png") + ImageResource reportAbuse(); + + @Source("gr/ebs/gss/resources/bug.png") + ImageResource reportBug(); + + @Source("gr/ebs/gss/resources/info.png") + ImageResource about(); + + @Source("gr/ebs/gss/resources/edit_add.png") + ImageResource upgradeQuota(); + } + + /** + * The widget's constructor. + * + * @param newImages the image bundle passed on by the parent object + */ + public HelpMenu(final Images newImages) { + // The popup's constructor's argument is a boolean specifying that it + // auto-close itself when the user clicks outside of it. + super(true); + setAnimationEnabled(true); + images = newImages; + createMenu(); + add(contextMenu); + } + + @Override + public void onClick(ClickEvent event) { + HelpMenu menu = new HelpMenu(images); + int left = event.getRelativeElement().getAbsoluteLeft(); + int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight(); + menu.setPopupPosition(left, top); + menu.show(); + } + + public MenuBar createMenu() { + contextMenu.clearItems(); + contextMenu.setAutoOpen(false); + Command hideCommand = new Command() { + @Override + public void execute() { + hide(); + } + }; + Command aboutCommand = new Command(){ + @Override + public void execute() { + AboutDialog dlg = new AboutDialog(); + dlg.center(); + } + }; + MenuItem userGuideItem = new MenuItem("" + AbstractImagePrototype.create(images.userGuide()).getHTML() + " User Guide", true, hideCommand); + contextMenu.addItem(userGuideItem); + userGuideItem.getElement().setId("topMenu.help.userGuide"); + + MenuItem termsItem = new MenuItem("" + AbstractImagePrototype.create(images.terms()).getHTML() + " Terms & Conditions", true, hideCommand); + termsItem.getElement().setId("topMenu.help.terms"); + contextMenu.addItem(termsItem); + + MenuItem reportAbuseItem = new MenuItem("" + AbstractImagePrototype.create(images.reportAbuse()).getHTML() + " Report abuse", true, hideCommand); + reportAbuseItem.getElement().setId("topMenu.help.reportAbuse"); + contextMenu.addItem(reportAbuseItem); + + MenuItem upgradeQuotaItem= new MenuItem("" + AbstractImagePrototype.create(images.upgradeQuota()).getHTML() + " Upgrade quota", true, hideCommand); + upgradeQuotaItem.getElement().setId("topMenu.help.upgradeQuota"); + contextMenu.addItem(upgradeQuotaItem); + + MenuItem reportBugItem = new MenuItem("" + AbstractImagePrototype.create(images.reportBug()).getHTML() + " Report bug", true, hideCommand); + reportBugItem.getElement().setId("topMenu.help.reportBug"); + contextMenu.addItem(reportBugItem); + + MenuItem aboutItem = new MenuItem("" + AbstractImagePrototype.create(images.about()).getHTML() + " About", true, aboutCommand); + aboutItem.getElement().setId("topMenu.help.about"); + contextMenu.addItem(aboutItem); + return contextMenu; + } + +}