-/*\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.CopyCommand;\r
-import gr.ebs.gss.client.commands.CutCommand;\r
-import gr.ebs.gss.client.commands.DeleteCommand;\r
-import gr.ebs.gss.client.commands.PasteCommand;\r
-import gr.ebs.gss.client.commands.ToTrashCommand;\r
-import gr.ebs.gss.client.rest.resource.FileResource;\r
-import gr.ebs.gss.client.rest.resource.FolderResource;\r
-import gr.ebs.gss.client.rest.resource.GroupUserResource;\r
-\r
-import java.util.List;\r
-\r
-import com.google.gwt.user.client.Command;\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.MenuBar;\r
-import com.google.gwt.user.client.ui.PopupPanel;\r
-import com.google.gwt.user.client.ui.Widget;\r
-\r
-/**\r
- * The 'Edit' menu implementation.\r
- */\r
-public class EditMenu extends PopupPanel implements ClickListener {\r
-\r
- /**\r
- * The widget's images.\r
- */\r
- private final Images images;\r
-\r
- private final MenuBar contextMenu = new MenuBar(true);\r
-\r
- /**\r
- * An image bundle for this widget's images.\r
- */\r
- public interface Images extends FileMenu.Images, MessagePanel.Images {\r
-\r
- /**\r
- * Will bundle the file 'editcut.png' residing in the package\r
- * 'gr.ebs.gss.resources'.\r
- *\r
- * @return the image prototype\r
- */\r
- @Resource("gr/ebs/gss/resources/editcut.png")\r
- AbstractImagePrototype cut();\r
-\r
- /**\r
- * Will bundle the file 'editcopy.png' residing in the package\r
- * 'gr.ebs.gss.resources'.\r
- *\r
- * @return the image prototype\r
- */\r
- @Resource("gr/ebs/gss/resources/editcopy.png")\r
- AbstractImagePrototype copy();\r
-\r
- /**\r
- * Will bundle the file 'editpaste.png' residing in the package\r
- * 'gr.ebs.gss.resources'.\r
- *\r
- * @return the image prototype\r
- */\r
- @Resource("gr/ebs/gss/resources/editpaste.png")\r
- AbstractImagePrototype paste();\r
-\r
- /**\r
- * Will bundle the file 'editdelete.png' residing in the package\r
- * 'gr.ebs.gss.resources'.\r
- *\r
- * @return the image prototype\r
- */\r
- @Resource("gr/ebs/gss/resources/editdelete.png")\r
- AbstractImagePrototype delete();\r
-\r
- /**\r
- * Will bundle the file 'translate.png' residing in the package\r
- * 'gr.ebs.gss.resources'.\r
- *\r
- * @return the image prototype\r
- */\r
- @Resource("gr/ebs/gss/resources/translate.png")\r
- AbstractImagePrototype selectAll();\r
-\r
- /**\r
- * Will bundle the file 'border_remove.png' residing in the package\r
- * 'gr.ebs.gss.resources'.\r
- *\r
- * @return the image prototype\r
- */\r
- @Resource("gr/ebs/gss/resources/border_remove.png")\r
- AbstractImagePrototype unselectAll();\r
- }\r
-\r
- /**\r
- * The widget's constructor.\r
- *\r
- * @param newImages the image bundle passed on by the parent object\r
- */\r
- public EditMenu(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
- createMenu();\r
- add(contextMenu);\r
- }\r
-\r
- /*\r
- * (non-Javadoc)\r
- *\r
- * @see com.google.gwt.user.client.ui.ClickListener#onClick(com.google.gwt.user.client.ui.Widget)\r
- */\r
- public void onClick(final Widget sender) {\r
- final EditMenu menu = new EditMenu(images);\r
- final int left = sender.getAbsoluteLeft();\r
- final int top = sender.getAbsoluteTop() + sender.getOffsetHeight();\r
- menu.setPopupPosition(left, top);\r
-\r
- menu.show();\r
- }\r
-\r
- public MenuBar createMenu() {\r
- contextMenu.clearItems();\r
- contextMenu.setAutoOpen(false);\r
-\r
- final Command selectAllCommand = new Command() {\r
-\r
- public void execute() {\r
- hide();\r
- if(GSS.get().isFileListShowing())\r
- GSS.get().getFileList().selectAllRows();\r
- else if(GSS.get().isSearchResultsShowing())\r
- GSS.get().getSearchResults().selectAllRows();\r
- }\r
- };\r
- final Command unselectAllCommand = new Command() {\r
-\r
- public void execute() {\r
- hide();\r
- if(GSS.get().isFileListShowing())\r
- GSS.get().getFileList().clearSelectedRows();\r
- else if(GSS.get().isSearchResultsShowing())\r
- GSS.get().getSearchResults().clearSelectedRows();\r
- }\r
- };\r
-\r
- boolean cutcopyVisible = GSS.get().getCurrentSelection() != null && (GSS.get().getCurrentSelection() instanceof FolderResource\r
- || GSS.get().getCurrentSelection() instanceof FileResource || GSS .get().getCurrentSelection() instanceof GroupUserResource || GSS .get().getCurrentSelection() instanceof List);\r
- String cutLabel = "Cut";\r
- String copyLabel ="Copy";\r
- String pasteLabel = "Paste";\r
- if(GSS.get().getCurrentSelection() != null)\r
- if(GSS.get().getCurrentSelection() instanceof FolderResource){\r
- cutLabel = "Cut Folder";\r
- copyLabel = "Copy Folder";\r
- }\r
- else if(GSS.get().getCurrentSelection() instanceof FileResource){\r
- cutLabel = "Cut File";\r
- copyLabel = "Copy File";\r
- }\r
- else if(GSS.get().getCurrentSelection() instanceof List){\r
- cutLabel = "Cut Files";\r
- copyLabel = "Copy Files";\r
- }\r
- if(GSS.get().getClipboard().getItem() != null)\r
- if(GSS.get().getClipboard().getItem().getFile() != null)\r
- pasteLabel = "Paste File";\r
- else if(GSS.get().getClipboard().getItem().getFiles() != null)\r
- pasteLabel = "Paste Files";\r
- else if(GSS.get().getClipboard().getItem().getFolderResource() != null)\r
- pasteLabel = "Paste Folder";\r
- contextMenu.addItem("<span>" + images.cut().getHTML() + " "+cutLabel+"</span>", true, new CutCommand(this)).setVisible(cutcopyVisible);\r
- contextMenu.addItem("<span>" + images.copy().getHTML() + " "+copyLabel+"</span>", true, new CopyCommand(this)).setVisible(cutcopyVisible);\r
- if (GSS.get().getClipboard().getItem() != null)\r
- if(GSS.get().isUserListVisible() && GSS.get().getClipboard().getItem().getUser() == null)\r
- contextMenu.addItem("<span>" + images.paste().getHTML() + " "+pasteLabel+"</span>", true, new PasteCommand(this));\r
- else if(!GSS.get().isUserListVisible() && GSS.get().getClipboard().getItem().getUser() != null){\r
- //do not show paste\r
- }\r
- else\r
- contextMenu.addItem("<span>" + images.paste().getHTML() + " "+pasteLabel+"</span>", true, new PasteCommand(this));\r
- contextMenu .addItem("<span>" + images.emptyTrash().getHTML() + " Move to Trash</span>", true, new ToTrashCommand(this))\r
- .setVisible(cutcopyVisible);\r
- contextMenu .addItem("<span>" + images.delete().getHTML() + " Delete</span>", true, new DeleteCommand(this, images))\r
- .setVisible(cutcopyVisible);\r
- contextMenu.addItem("<span>" + images.selectAll().getHTML() + " Select All</span>", true, selectAllCommand);\r
- contextMenu.addItem("<span>" + images.unselectAll().getHTML() + " Unselect All</span>", true, unselectAllCommand);\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.CopyCommand;
+import gr.ebs.gss.client.commands.CutCommand;
+import gr.ebs.gss.client.commands.DeleteCommand;
+import gr.ebs.gss.client.commands.PasteCommand;
+import gr.ebs.gss.client.commands.ToTrashCommand;
+import gr.ebs.gss.client.rest.resource.FileResource;
+import gr.ebs.gss.client.rest.resource.FolderResource;
+import gr.ebs.gss.client.rest.resource.GroupUserResource;
+
+import java.util.List;
+
+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.PopupPanel;
+
+/**
+ * The 'Edit' menu implementation.
+ */
+public class EditMenu extends PopupPanel implements ClickHandler {
+
+ /**
+ * The widget's images.
+ */
+ private final Images images;
+
+ private final MenuBar contextMenu = new MenuBar(true);
+
+ /**
+ * An image bundle for this widget's images.
+ */
+ public interface Images extends ClientBundle, FileMenu.Images, MessagePanel.Images {
+
+ /**
+ * Will bundle the file 'editcut.png' residing in the package
+ * 'gr.ebs.gss.resources'.
+ *
+ * @return the image prototype
+ */
+ @Source("gr/ebs/gss/resources/editcut.png")
+ ImageResource cut();
+
+ /**
+ * Will bundle the file 'editcopy.png' residing in the package
+ * 'gr.ebs.gss.resources'.
+ *
+ * @return the image prototype
+ */
+ @Source("gr/ebs/gss/resources/editcopy.png")
+ ImageResource copy();
+
+ /**
+ * Will bundle the file 'editpaste.png' residing in the package
+ * 'gr.ebs.gss.resources'.
+ *
+ * @return the image prototype
+ */
+ @Source("gr/ebs/gss/resources/editpaste.png")
+ ImageResource paste();
+
+ /**
+ * Will bundle the file 'editdelete.png' residing in the package
+ * 'gr.ebs.gss.resources'.
+ *
+ * @return the image prototype
+ */
+ @Override
+ @Source("gr/ebs/gss/resources/editdelete.png")
+ ImageResource delete();
+
+ /**
+ * Will bundle the file 'translate.png' residing in the package
+ * 'gr.ebs.gss.resources'.
+ *
+ * @return the image prototype
+ */
+ @Source("gr/ebs/gss/resources/translate.png")
+ ImageResource selectAll();
+
+ /**
+ * Will bundle the file 'border_remove.png' residing in the package
+ * 'gr.ebs.gss.resources'.
+ *
+ * @return the image prototype
+ */
+ @Source("gr/ebs/gss/resources/border_remove.png")
+ ImageResource unselectAll();
+ }
+
+ /**
+ * The widget's constructor.
+ *
+ * @param newImages the image bundle passed on by the parent object
+ */
+ public EditMenu(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) {
+ final EditMenu menu = new EditMenu(images);
+ final int left = event.getRelativeElement().getAbsoluteLeft();
+ final int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight();
+ menu.setPopupPosition(left, top);
+ menu.show();
+ }
+
+ public MenuBar createMenu() {
+ contextMenu.clearItems();
+ contextMenu.setAutoOpen(false);
+
+ final Command selectAllCommand = new Command() {
+
+ @Override
+ public void execute() {
+ hide();
+ if(GSS.get().isFileListShowing())
+ GSS.get().getFileList().selectAllRows();
+ else if(GSS.get().isSearchResultsShowing())
+ GSS.get().getSearchResults().selectAllRows();
+ }
+ };
+ final Command unselectAllCommand = new Command() {
+
+ @Override
+ public void execute() {
+ hide();
+ if(GSS.get().isFileListShowing())
+ GSS.get().getFileList().clearSelectedRows();
+ else if(GSS.get().isSearchResultsShowing())
+ GSS.get().getSearchResults().clearSelectedRows();
+ }
+ };
+
+ boolean cutcopyVisible = GSS.get().getCurrentSelection() != null && (GSS.get().getCurrentSelection() instanceof FolderResource
+ || GSS.get().getCurrentSelection() instanceof FileResource || GSS .get().getCurrentSelection() instanceof GroupUserResource || GSS .get().getCurrentSelection() instanceof List);
+ String cutLabel = "Cut";
+ String copyLabel ="Copy";
+ String pasteLabel = "Paste";
+ if(GSS.get().getCurrentSelection() != null)
+ if(GSS.get().getCurrentSelection() instanceof FolderResource){
+ cutLabel = "Cut Folder";
+ copyLabel = "Copy Folder";
+ }
+ else if(GSS.get().getCurrentSelection() instanceof FileResource){
+ cutLabel = "Cut File";
+ copyLabel = "Copy File";
+ }
+ else if(GSS.get().getCurrentSelection() instanceof List){
+ cutLabel = "Cut Files";
+ copyLabel = "Copy Files";
+ }
+ if(GSS.get().getClipboard().getItem() != null)
+ if(GSS.get().getClipboard().getItem().getFile() != null)
+ pasteLabel = "Paste File";
+ else if(GSS.get().getClipboard().getItem().getFiles() != null)
+ pasteLabel = "Paste Files";
+ else if(GSS.get().getClipboard().getItem().getFolderResource() != null)
+ pasteLabel = "Paste Folder";
+ contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.cut()).getHTML() + " "+cutLabel+"</span>", true, new CutCommand(this)).setVisible(cutcopyVisible);
+ contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.copy()).getHTML() + " "+copyLabel+"</span>", true, new CopyCommand(this)).setVisible(cutcopyVisible);
+ if (GSS.get().getClipboard().getItem() != null)
+ if(GSS.get().isUserListVisible() && GSS.get().getClipboard().getItem().getUser() == null)
+ contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.paste()).getHTML() + " "+pasteLabel+"</span>", true, new PasteCommand(this));
+ else if(!GSS.get().isUserListVisible() && GSS.get().getClipboard().getItem().getUser() != null){
+ //do not show paste
+ }
+ else if (GSS.get().getFolders().getCurrent().getUserObject() instanceof FolderResource)
+ contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.paste()).getHTML() + " "+pasteLabel+"</span>", true, new PasteCommand(this));
+ contextMenu .addItem("<span>" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(this))
+ .setVisible(cutcopyVisible);
+ contextMenu .addItem("<span>" + AbstractImagePrototype.create(images.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, images))
+ .setVisible(cutcopyVisible);
+ contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.selectAll()).getHTML() + " Select All</span>", true, selectAllCommand);
+ contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.unselectAll()).getHTML() + " Unselect All</span>", true, unselectAllCommand);
+ return contextMenu;
+ }
+
+
+
+}