X-Git-Url: https://code.grnet.gr/git/pithos/blobdiff_plain/afd3a0ef323903ab769574e0871fc55e87df609f..66f2db74d352093675ef8b55e85451da511c50e5:/src/gr/ebs/gss/client/GroupMenu.java diff --git a/src/gr/ebs/gss/client/GroupMenu.java b/src/gr/ebs/gss/client/GroupMenu.java index 550fa01..71edb34 100644 --- a/src/gr/ebs/gss/client/GroupMenu.java +++ b/src/gr/ebs/gss/client/GroupMenu.java @@ -1,90 +1,91 @@ -/* - * Copyright 2007, 2008, 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 gr.ebs.gss.client.commands.NewGroupCommand; - -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.ui.AbstractImagePrototype; -import com.google.gwt.user.client.ui.MenuBar; -import com.google.gwt.user.client.ui.PopupPanel; - -/** - * The 'Group' menu implementation. - */ -public class GroupMenu extends PopupPanel implements ClickHandler { - /** - * The widget's images. - */ - private Images images; - private final MenuBar contextMenu; - - /** - * An image bundle for this widgets images. - */ - public interface Images extends ClientBundle { - @Source("gr/ebs/gss/resources/groupevent.png") - ImageResource groupNew(); - - @Source("gr/ebs/gss/resources/view_text.png") - ImageResource viewText(); - - } - - /** - * The widget's constructor. - * - * @param newImages the image bundle passed on by the parent object - */ - public GroupMenu(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; - - contextMenu = new MenuBar(true); - contextMenu.addItem("" + AbstractImagePrototype.create(newImages.groupNew()).getHTML() + " New Group", true, new NewGroupCommand(this)); - - add(contextMenu); - } - - public void onClick(ClickEvent event) { - GroupMenu menu = new GroupMenu(images); - int left = event.getRelativeElement().getAbsoluteLeft(); - int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight(); - menu.setPopupPosition(left, top); - - menu.show(); - } - - /** - * Retrieve the contextMenu. - * - * @return the contextMenu - */ - public MenuBar getContextMenu() { - contextMenu.setAutoOpen(false); - return contextMenu; - } - -} +/* + * Copyright 2007, 2008, 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 gr.ebs.gss.client.commands.NewGroupCommand; + +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.ui.AbstractImagePrototype; +import com.google.gwt.user.client.ui.MenuBar; +import com.google.gwt.user.client.ui.PopupPanel; + +/** + * The 'Group' menu implementation. + */ +public class GroupMenu extends PopupPanel implements ClickHandler { + /** + * The widget's images. + */ + private Images images; + private final MenuBar contextMenu; + + /** + * An image bundle for this widgets images. + */ + public interface Images extends ClientBundle { + @Source("gr/ebs/gss/resources/groupevent.png") + ImageResource groupNew(); + + @Source("gr/ebs/gss/resources/view_text.png") + ImageResource viewText(); + + } + + /** + * The widget's constructor. + * + * @param newImages the image bundle passed on by the parent object + */ + public GroupMenu(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; + + contextMenu = new MenuBar(true); + contextMenu.addItem("" + AbstractImagePrototype.create(newImages.groupNew()).getHTML() + " New Group", true, new NewGroupCommand(this)); + + add(contextMenu); + } + + @Override + public void onClick(ClickEvent event) { + GroupMenu menu = new GroupMenu(images); + int left = event.getRelativeElement().getAbsoluteLeft(); + int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight(); + menu.setPopupPosition(left, top); + + menu.show(); + } + + /** + * Retrieve the contextMenu. + * + * @return the contextMenu + */ + public MenuBar getContextMenu() { + contextMenu.setAutoOpen(false); + return contextMenu; + } + +}