select row on right click
[pithos] / src / gr / ebs / gss / client / GroupMenu.java
index 7679cae..71edb34 100644 (file)
@@ -1,89 +1,91 @@
-/*\r
- * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.\r
- *\r
- * This file is part of GSS.\r
- *\r
- * GSS is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * GSS is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with GSS.  If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package gr.ebs.gss.client;\r
-\r
-import gr.ebs.gss.client.commands.NewGroupCommand;\r
-\r
-import com.google.gwt.user.client.ui.AbstractImagePrototype;\r
-import com.google.gwt.user.client.ui.ClickListener;\r
-import com.google.gwt.user.client.ui.ImageBundle;\r
-import com.google.gwt.user.client.ui.MenuBar;\r
-import com.google.gwt.user.client.ui.PopupPanel;\r
-import com.google.gwt.user.client.ui.Widget;\r
-\r
-/**\r
- * The 'Group' menu implementation.\r
- */\r
-public class GroupMenu extends PopupPanel implements ClickListener {\r
-       /**\r
-        * The widget's images.\r
-        */\r
-       private Images images;\r
-       private final MenuBar contextMenu;\r
-\r
-       /**\r
-        * An image bundle for this widgets images.\r
-        */\r
-       public interface Images extends ImageBundle {\r
-               @Resource("gr/ebs/gss/resources/groupevent.png")\r
-               AbstractImagePrototype groupNew();\r
-\r
-               @Resource("gr/ebs/gss/resources/view_text.png")\r
-               AbstractImagePrototype viewText();\r
-\r
-       }\r
-\r
-       /**\r
-        * The widget's constructor.\r
-        *\r
-        * @param newImages the image bundle passed on by the parent object\r
-        */\r
-       public GroupMenu(final Images newImages) {\r
-               // The popup's constructor's argument is a boolean specifying that it\r
-               // auto-close itself when the user clicks outside of it.\r
-               super(true);\r
-               setAnimationEnabled(true);\r
-               images = newImages;\r
-\r
-               contextMenu = new MenuBar(true);\r
-               contextMenu.addItem("<span>" + newImages.groupNew().getHTML() + "&nbsp;New Group</span>", true, new NewGroupCommand(this));\r
-\r
-               add(contextMenu);\r
-       }\r
-\r
-       public void onClick(Widget sender) {\r
-               GroupMenu menu = new GroupMenu(images);\r
-               int left = sender.getAbsoluteLeft();\r
-               int top = sender.getAbsoluteTop() + sender.getOffsetHeight();\r
-               menu.setPopupPosition(left, top);\r
-\r
-               menu.show();\r
-       }\r
-\r
-       /**\r
-        * Retrieve the contextMenu.\r
-        *\r
-        * @return the contextMenu\r
-        */\r
-       public MenuBar getContextMenu() {\r
-               contextMenu.setAutoOpen(false);\r
-               return contextMenu;\r
-       }\r
-\r
-}\r
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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("<span>" + AbstractImagePrototype.create(newImages.groupNew()).getHTML() + "&nbsp;New Group</span>", 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;
+       }
+
+}