File copy/cut/paste implemented
authorChristos Stathis <chstath@ebs.gr>
Fri, 8 Jul 2011 12:39:24 +0000 (15:39 +0300)
committerChristos Stathis <chstath@ebs.gr>
Fri, 8 Jul 2011 12:39:24 +0000 (15:39 +0300)
src/gr/grnet/pithos/web/client/Clipboard.java [moved from src/gr/grnet/pithos/web/client/clipboard/Clipboard.java with 67% similarity]
src/gr/grnet/pithos/web/client/EditMenu.java
src/gr/grnet/pithos/web/client/FileContextMenu.java
src/gr/grnet/pithos/web/client/FolderContextMenu.java
src/gr/grnet/pithos/web/client/GSS.java
src/gr/grnet/pithos/web/client/clipboard/ClipboardItem.java [deleted file]
src/gr/grnet/pithos/web/client/commands/CopyCommand.java
src/gr/grnet/pithos/web/client/commands/CutCommand.java
src/gr/grnet/pithos/web/client/commands/PasteCommand.java

  * interpreted as representing official policies, either expressed
  * or implied, of GRNET S.A.
  */
-package gr.grnet.pithos.web.client.clipboard;
+package gr.grnet.pithos.web.client;
 
+import gr.grnet.pithos.web.client.foldertree.File;
+import gr.grnet.pithos.web.client.foldertree.Folder;
+import java.util.List;
 
 public class Clipboard {
        public final static int CUT=1;
        public final static int COPY=2;
-       private ClipboardItem item;
+
+    private int operation;
+
+    private List<File> files;
+
+    private Folder folder;
 
        /**
         * Retrieve the item.
         *
         * @return the item
         */
-       public ClipboardItem getItem() {
-               return item;
+       public Object getItem() {
+        if (folder != null)
+            return folder;
+        if (files != null)
+            return files;
+        return null;
        }
 
-       /**
-        * Modify the item.
-        *
-        * @param anItem the item to set
-        */
-       public void setItem(ClipboardItem anItem) {
-               item = anItem;
+       public void setItem(int _operation, Folder _folder) {
+        operation = _operation;
+               folder = _folder;
+        files = null;
        }
 
-       public boolean hasFolderOrFileItem(){
-               if( item !=null )
-                       return item.isFileOrFolder();
-               return false;
-       }
+    public void setItem(int _operation, List<File> _files) {
+        operation = _operation;
+        files = _files;
+        folder = null;
+    }
 
-       public boolean isEmpty(){
-               return item == null;
-       }
+    public int getOperation() {
+        return operation;
+    }
 
-       public void clear(){
-               item = null;
-       }
+    public void clear() {
+        folder = null;
+        files = null;
+    }
 }
index 9e4e2d4..b688099 100644 (file)
@@ -39,6 +39,7 @@ import gr.grnet.pithos.web.client.commands.CutCommand;
 import gr.grnet.pithos.web.client.commands.DeleteCommand;
 import gr.grnet.pithos.web.client.commands.PasteCommand;
 import gr.grnet.pithos.web.client.commands.ToTrashCommand;
+import gr.grnet.pithos.web.client.foldertree.Folder;
 import gr.grnet.pithos.web.client.rest.resource.FileResource;
 
 import gr.grnet.pithos.web.client.rest.resource.GroupUserResource;
@@ -195,32 +196,26 @@ public class EditMenu extends PopupPanel implements ClickHandler {
                                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().getRestResourceWrapper() != null)
+                       if(GSS.get().getClipboard().getItem() instanceof List) {
+                if (((List) GSS.get().getClipboard().getItem()).size() > 1)
+                                   pasteLabel = "Paste Files";
+                else
+                    pasteLabel = "Paste File";
+            }
+                       else if(GSS.get().getClipboard().getItem() instanceof Folder)
                                pasteLabel = "Paste Folder";
-               MenuItem cutItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.cut()).getHTML() + "&nbsp;"+cutLabel+"</span>", true, new CutCommand(this));
+               MenuItem cutItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.cut()).getHTML() + "&nbsp;"+cutLabel+"</span>", true, new CutCommand(GSS.get(), this, null));
                cutItem.getElement().setId("topMenu.edit.cut");
                contextMenu.addItem(cutItem).setVisible(cutcopyVisible);
                
-               MenuItem copyItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.copy()).getHTML() + "&nbsp;"+copyLabel+"</span>", true, new CopyCommand(this));
+               MenuItem copyItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.copy()).getHTML() + "&nbsp;"+copyLabel+"</span>", true, new CopyCommand(GSS.get(), this, null));
                copyItem.getElement().setId("topMenu.edit.copy");
                contextMenu.addItem(copyItem).setVisible(cutcopyVisible);
 
-               MenuItem pasteItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.paste()).getHTML() + "&nbsp;"+pasteLabel+"</span>", true, new PasteCommand(this));
+               MenuItem pasteItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.paste()).getHTML() + "&nbsp;"+pasteLabel+"</span>", true, new PasteCommand(GSS.get(), this, null));
                pasteItem.getElement().setId("topMenu.edit.paste");
                if (GSS.get().getClipboard().getItem() != null)
-                       if(GSS.get().isUserListVisible() && GSS.get().getClipboard().getItem().getUser() == null){
-                               contextMenu.addItem(pasteItem);
-                       }
-                       else if(!GSS.get().isUserListVisible() && GSS.get().getClipboard().getItem().getUser() != null){
-                               //do not show paste
-                       }
-                       else if (GSS.get().getTreeView().getSelection() instanceof RestResourceWrapper){
-                               contextMenu.addItem(pasteItem);
-                       }
+               contextMenu.addItem(pasteItem);
                MenuItem moveToTrashItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + "&nbsp;Move to Trash</span>", true, new ToTrashCommand(this));
                moveToTrashItem.getElement().setId("topMenu.edit.moveToTrash");
                contextMenu     .addItem(moveToTrashItem)
index 7c562f8..d54f5bf 100644 (file)
@@ -137,7 +137,7 @@ public class FileContextMenu extends PopupPanel {
                images = newImages;
         MenuBar contextMenu = new MenuBar(true);
 
-               pasteItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.paste()).getHTML() + "&nbsp;Paste</span>", true, new PasteCommand(this));
+               pasteItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.paste()).getHTML() + "&nbsp;Paste</span>", true, new PasteCommand(GSS.get(), this, selectedFolder));
         contextMenu.addItem(pasteItem);
 
         MenuItem upload = new MenuItem("<span>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this, selectedFolder));
@@ -153,10 +153,10 @@ public class FileContextMenu extends PopupPanel {
                        MenuItem delete = new MenuItem("<span>" + AbstractImagePrototype.create(images.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(this, null, images));
                        contextMenu.addItem(delete);
                } else {
-                       cutItem = new MenuItem("<span id='fileContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Cut</span>", true, new CutCommand(this));
+                       cutItem = new MenuItem("<span id='fileContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Cut</span>", true, new CutCommand(GSS.get(), this, selectedFiles));
             contextMenu.addItem(cutItem);
 
-                       copyItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + "&nbsp;Copy</span>", true, new CopyCommand(this));
+                       copyItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + "&nbsp;Copy</span>", true, new CopyCommand(GSS.get(), this, selectedFiles));
             contextMenu.addItem(copyItem);
 
                        trashItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + "&nbsp;Move to Trash</span>", true, new ToTrashCommand(this));
index aaee292..93b5184 100644 (file)
@@ -99,13 +99,13 @@ public class FolderContextMenu extends PopupPanel {
         contextMenu.addItem(newFolder);
 
         // do not show the copy & cut option for the user's root folder
-        MenuItem cut = new MenuItem("<span id = 'folderContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Cut</span>", true, new CutCommand(this));
+        MenuItem cut = new MenuItem("<span id = 'folderContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Cut</span>", true, new CutCommand(GSS.get(), this, folder));
         contextMenu.addItem(cut);
 
-        MenuItem copy = new MenuItem("<span id = 'folderContextMenu.copy'>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + "&nbsp;Copy</span>", true, new CopyCommand(this));
+        MenuItem copy = new MenuItem("<span id = 'folderContextMenu.copy'>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + "&nbsp;Copy</span>", true, new CopyCommand(GSS.get(), this, folder));
         contextMenu.addItem(copy);
 
-        pasteItem = new MenuItem("<span id = 'folderContextMenu.paste'>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + "&nbsp;Paste</span>", true, new PasteCommand(this));
+        pasteItem = new MenuItem("<span id = 'folderContextMenu.paste'>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + "&nbsp;Paste</span>", true, new PasteCommand(GSS.get(), this, folder));
         contextMenu.addItem(pasteItem);
 
         // do not show delete options for the user's root folder
index b85317c..0154ed1 100644 (file)
@@ -36,13 +36,8 @@ package gr.grnet.pithos.web.client;
 
 import com.google.gwt.core.client.Scheduler;
 import com.google.gwt.core.client.Scheduler.ScheduledCommand;
-import com.google.gwt.event.dom.client.ContextMenuEvent;
-import com.google.gwt.event.dom.client.ContextMenuHandler;
-import com.google.gwt.event.shared.GwtEvent;
-import com.google.gwt.event.shared.GwtEvent.Type;
 import com.google.gwt.view.client.SelectionChangeEvent;
 import com.google.gwt.view.client.SingleSelectionModel;
-import gr.grnet.pithos.web.client.clipboard.Clipboard;
 import gr.grnet.pithos.web.client.commands.GetUserCommand;
 import gr.grnet.pithos.web.client.foldertree.AccountResource;
 import gr.grnet.pithos.web.client.foldertree.File;
@@ -77,7 +72,6 @@ import com.google.gwt.i18n.client.DateTimeFormat;
 import com.google.gwt.resources.client.ClientBundle;
 import com.google.gwt.resources.client.ImageResource;
 import com.google.gwt.user.client.Cookies;
-import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.Event;
 import com.google.gwt.user.client.History;
 import com.google.gwt.user.client.Window;
diff --git a/src/gr/grnet/pithos/web/client/clipboard/ClipboardItem.java b/src/gr/grnet/pithos/web/client/clipboard/ClipboardItem.java
deleted file mode 100644 (file)
index aa9e156..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- *   1. Redistributions of source code must retain the above
- *      copyright notice, this list of conditions and the following
- *      disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above
- *      copyright notice, this list of conditions and the following
- *      disclaimer in the documentation and/or other materials
- *      provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.clipboard;
-
-import gr.grnet.pithos.web.client.rest.resource.FileResource;
-import gr.grnet.pithos.web.client.rest.resource.RestResourceWrapper;
-import gr.grnet.pithos.web.client.rest.resource.GroupUserResource;
-
-import java.io.Serializable;
-import java.util.List;
-
-
-public class ClipboardItem implements Serializable{
-       private int operation;
-       private FileResource file;
-       private List<FileResource> files;
-       private RestResourceWrapper folderResource;
-       private GroupUserResource user;
-
-       public ClipboardItem(int anOperation, List<FileResource> theFiles){
-               operation = anOperation;
-               files = theFiles;
-       }
-
-       public ClipboardItem(int anOperation, FileResource aFile){
-               operation = anOperation;
-               file = aFile;
-       }
-
-       public ClipboardItem(int anOperation, RestResourceWrapper folder){
-               operation = anOperation;
-               folderResource = folder;
-       }
-       public ClipboardItem(int anOperation, GroupUserResource aUser){
-               operation = anOperation;
-               user = aUser;
-       }
-
-       public ClipboardItem(GroupUserResource aUser){
-               operation = Clipboard.COPY;
-               user = aUser;
-       }
-
-       public ClipboardItem(List<FileResource> theFiles){
-               operation = Clipboard.COPY;
-               files = theFiles;
-       }
-
-       public ClipboardItem(FileResource aFile){
-               operation = Clipboard.COPY;
-               file = aFile;
-       }
-
-       public ClipboardItem(RestResourceWrapper folder){
-               operation = Clipboard.COPY;
-               folderResource = folder;
-       }
-
-       /**
-        * Retrieve the user.
-        *
-        * @return the user
-        */
-       public GroupUserResource getUser() {
-               return user;
-       }
-
-       /**
-        * Retrieve the operation.
-        *
-        * @return the operation
-        */
-       public int getOperation() {
-               return operation;
-       }
-
-       /**
-        * Retrieve the file.
-        *
-        * @return the file
-        */
-       public FileResource getFile() {
-               return file;
-       }
-
-       /**
-        * Retrieve the files.
-        *
-        * @return the files
-        */
-       public List<FileResource> getFiles() {
-               return files;
-       }
-
-       /**
-        * checks whether the clipboard item is a file or folder
-        */
-       public boolean isFileOrFolder(){
-               if(file !=null || files != null || folderResource != null)
-                       return true;
-               return false;
-       }
-
-       /**
-        * checks whether the clipboard item is a file (or files)
-        */
-       public boolean isFile() {
-               if(file !=null || files != null)
-                       return true;
-               return false;
-       }
-
-       public boolean isUser(){
-               if( user!=null  )
-                       return true;
-               return false;
-       }
-
-       /**
-        * Retrieve the folderResource.
-        *
-        * @return the folderResource
-        */
-       public RestResourceWrapper getRestResourceWrapper() {
-               return folderResource;
-       }
-}
index ce5597e..780865b 100644 (file)
  */
 package gr.grnet.pithos.web.client.commands;
 
+import gr.grnet.pithos.web.client.Clipboard;
 import gr.grnet.pithos.web.client.GSS;
-import gr.grnet.pithos.web.client.clipboard.ClipboardItem;
-import gr.grnet.pithos.web.client.rest.resource.FileResource;
-import gr.grnet.pithos.web.client.rest.resource.GroupUserResource;
-import gr.grnet.pithos.web.client.rest.resource.RestResourceWrapper;
+import gr.grnet.pithos.web.client.foldertree.File;
+import gr.grnet.pithos.web.client.foldertree.Folder;
 
 import java.util.List;
 
@@ -50,34 +49,24 @@ import com.google.gwt.user.client.ui.PopupPanel;
  *
  */
 public class CopyCommand implements Command{
+    private GSS app;
        private PopupPanel containerPanel;
+    private Object resource;
 
-       public CopyCommand(PopupPanel _containerPanel){
+       public CopyCommand(GSS _app, PopupPanel _containerPanel, Object _resource){
+        app = _app;
                containerPanel = _containerPanel;
+        resource = _resource;
        }
 
        @Override
        public void execute() {
                containerPanel.hide();
-               Object selection = GSS.get().getCurrentSelection();
-               if (selection == null)
-                       return;
 
-               if (selection instanceof RestResourceWrapper) {
-                       ClipboardItem clipboardItem = new ClipboardItem((RestResourceWrapper) selection);
-                       GSS.get().getClipboard().setItem(clipboardItem);
-               } else if (selection instanceof FileResource) {
-                       ClipboardItem clipboardItem = new ClipboardItem((FileResource) selection);
-                       GSS.get().getClipboard().setItem(clipboardItem);
-               } else if (selection instanceof GroupUserResource) {
-                       ClipboardItem clipboardItem = new ClipboardItem((GroupUserResource) selection);
-                       GSS.get().getClipboard().setItem(clipboardItem);
+               if (resource instanceof Folder) {
+                       app.getClipboard().setItem(Clipboard.COPY, (Folder) resource);
+               } else if (resource instanceof List) {
+                       app.getClipboard().setItem(Clipboard.COPY, (List<File>) resource);
                }
-                else if (selection instanceof List){
-                        ClipboardItem clipboardItem = new ClipboardItem((List<FileResource>) selection);
-                        GSS.get().getClipboard().setItem(clipboardItem);
-                }
-
        }
-
 }
index 14f2b41..de7fd9b 100644 (file)
  */
 package gr.grnet.pithos.web.client.commands;
 
+import gr.grnet.pithos.web.client.Clipboard;
 import gr.grnet.pithos.web.client.GSS;
-import gr.grnet.pithos.web.client.clipboard.Clipboard;
-import gr.grnet.pithos.web.client.clipboard.ClipboardItem;
-import gr.grnet.pithos.web.client.rest.resource.FileResource;
-import gr.grnet.pithos.web.client.rest.resource.GroupUserResource;
-import gr.grnet.pithos.web.client.rest.resource.RestResourceWrapper;
+import gr.grnet.pithos.web.client.foldertree.File;
 
+import gr.grnet.pithos.web.client.foldertree.Folder;
 import java.util.List;
 
-import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.Command;
 import com.google.gwt.user.client.ui.PopupPanel;
 
-
 /**
  * Command for cutting a file, folder or user to GSS Clipboard
  *
  */
-public class CutCommand implements Command{
+public class CutCommand implements Command {
+    private GSS app;
+
        private PopupPanel containerPanel;
 
-       public CutCommand( PopupPanel _containerPanel ){
+    private Object resource;
+
+       public CutCommand(GSS _app, PopupPanel _containerPanel, Object _resource){
+        app = _app;
                containerPanel = _containerPanel;
+        resource = _resource;
        }
 
        @Override
        public void execute() {
                containerPanel.hide();
-               Object selection = GSS.get().getCurrentSelection();
-               if (selection == null)
-                       return;
-               GWT.log("selection: " + selection.toString(), null);
-               if (selection instanceof RestResourceWrapper) {
-                       ClipboardItem clipboardItem = new ClipboardItem(Clipboard.CUT, (RestResourceWrapper) selection);
-                       GSS.get().getClipboard().setItem(clipboardItem);
-               } else if (selection instanceof FileResource) {
-                       ClipboardItem clipboardItem = new ClipboardItem(Clipboard.CUT, (FileResource) selection);
-                       GSS.get().getClipboard().setItem(clipboardItem);
-               } else if (selection instanceof GroupUserResource) {
-                       ClipboardItem clipboardItem = new ClipboardItem(Clipboard.CUT, (GroupUserResource) selection);
-                       GSS.get().getClipboard().setItem(clipboardItem);
-               }
-               else if (selection instanceof List){
-                        ClipboardItem clipboardItem = new ClipboardItem(Clipboard.CUT, (List<FileResource>) selection);
-                        GSS.get().getClipboard().setItem(clipboardItem);
-                }
-       }
 
+        if (resource instanceof Folder) {
+            app.getClipboard().setItem(Clipboard.CUT, (Folder) resource);
+        } else if (resource instanceof List) {
+            app.getClipboard().setItem(Clipboard.CUT, (List<File>) resource);
+        }
+       }
 }
index 6b478d2..58eacf4 100644 (file)
  */
 package gr.grnet.pithos.web.client.commands;
 
+import com.google.gwt.core.client.Scheduler;
+import gr.grnet.pithos.web.client.Clipboard;
 import gr.grnet.pithos.web.client.GSS;
-import gr.grnet.pithos.web.client.clipboard.Clipboard;
-import gr.grnet.pithos.web.client.clipboard.ClipboardItem;
-import gr.grnet.pithos.web.client.rest.PostCommand;
+import gr.grnet.pithos.web.client.foldertree.File;
+import gr.grnet.pithos.web.client.foldertree.Folder;
+import gr.grnet.pithos.web.client.foldertree.Resource;
+import gr.grnet.pithos.web.client.rest.PutRequest;
 import gr.grnet.pithos.web.client.rest.RestException;
-import gr.grnet.pithos.web.client.rest.resource.FileResource;
-import gr.grnet.pithos.web.client.rest.resource.FolderResource;
-import gr.grnet.pithos.web.client.rest.resource.GroupResource;
-import gr.grnet.pithos.web.client.rest.resource.RestResourceWrapper;
 
-import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
 import com.google.gwt.core.client.GWT;
-import com.google.gwt.http.client.URL;
 import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.DeferredCommand;
 import com.google.gwt.user.client.ui.PopupPanel;
 
 public class PasteCommand implements Command {
 
+    private GSS app;
        private PopupPanel containerPanel;
+    private Folder folder;
 
-       public PasteCommand(PopupPanel _containerPanel) {
+       public PasteCommand(GSS _app, PopupPanel _containerPanel, Folder _folder) {
+        app = _app;
                containerPanel = _containerPanel;
+        folder = _folder;
        }
 
        @Override
        public void execute() {
                containerPanel.hide();
-               Object selection = GSS.get().getCurrentSelection();
-               FolderResource selectedFolder = null;
-               if(selection != null && selection instanceof RestResourceWrapper)
-                       selectedFolder = ((RestResourceWrapper)selection).getResource();
-               //TODO:CELLTREE
-               /*
-               else if(GSS.get().getFolders().getCurrent() != null && ((DnDTreeItem)GSS.get().getFolders().getCurrent()).getFolderResource() != null)
-                       selectedFolder = ((DnDTreeItem)GSS.get().getFolders().getCurrent()).getFolderResource();
-               */
-               if (selectedFolder != null) {
-                       final ClipboardItem citem = GSS.get().getClipboard().getItem();
-                       if (citem != null && citem.getRestResourceWrapper() != null) {
-                               String target = selectedFolder.getUri();
-                               target = target.endsWith("/") ? target : target + '/';
-                               target = target + URL.encodeComponent(citem.getRestResourceWrapper().getResource().getName());
-                               if (citem.getOperation() == Clipboard.COPY) {
-                                       PostCommand cf = new PostCommand(citem.getRestResourceWrapper().getUri() + "?copy=" + target, "", 200) {
-
-                                               @Override
-                                               public void onComplete() {
-                                                       //TODO:CELLTREE
-                                                       //GSS.get().getFolders().updateFolder((DnDTreeItem) GSS.get().getFolders().getCurrent());
-                                                       GSS.get().getTreeView().updateNodeChildren(GSS.get().getTreeView().getSelection());
-                                                       GSS.get().getStatusPanel().updateStats();
-                                                       GSS.get().getClipboard().setItem(null);
-                                               }
-
-                                               @Override
-                                               public void onError(Throwable t) {
-                                                       GWT.log("", t);
-                                                       if(t instanceof RestException){
-                                                               int statusCode = ((RestException)t).getHttpStatusCode();
-                                                               if(statusCode == 405)
-                                                                       GSS.get().displayError("You don't have the necessary permissions");
-
-                                                               else if(statusCode == 409)
-                                                                       GSS.get().displayError("A folder with the same name already exists");
-                                                               else if(statusCode == 413)
-                                                                       GSS.get().displayError("Your quota has been exceeded");
-                                                               else
-                                                                       GSS.get().displayError("Unable to copy folder:"+((RestException)t).getHttpStatusText());
-                                                       }
-                                                       else
-                                                               GSS.get().displayError("System error copying folder:"+t.getMessage());
-                                               }
-                                       };
-                                       DeferredCommand.addCommand(cf);
-                               } else if (citem.getOperation() == Clipboard.CUT) {
-                                       PostCommand cf = new PostCommand(citem.getRestResourceWrapper().getUri() + "?move=" + target, "", 200) {
-
-                                               @Override
-                                               public void onComplete() {
-                                                       //TODO:CELLTREE
-                                                       /*
-                                                       List<TreeItem> items = GSS.get().getFolders().getItemsOfTreeForPath(citem.getFolderResource().getUri());
-                                                       for (TreeItem item : items)
-                                                               if (item.getParentItem() != null && !item.equals(GSS.get().getFolders().getCurrent()))
-                                                                       GSS.get().getFolders().updateFolder((DnDTreeItem) item.getParentItem());
-                                                       GSS.get().getFolders().updateFolder((DnDTreeItem) GSS.get().getFolders().getCurrent());
-                                                       */
-                                                       GSS.get().getTreeView().updateNodeChildren(GSS.get().getTreeView().getSelection());
-                                                       GSS.get().getTreeView().updateNodeChildrenForRemove(citem.getRestResourceWrapper().getResource().getParentURI());
-                                                       GSS.get().getStatusPanel().updateStats();               
-                                                       GSS.get().getClipboard().setItem(null);
-                                               }
-
-                                               @Override
-                                               public void onError(Throwable t) {
-                                                       GWT.log("", t);
-                                                       if(t instanceof RestException){
-                                                               int statusCode = ((RestException)t).getHttpStatusCode();
-                                                               if(statusCode == 405)
-                                                                       GSS.get().displayError("You don't have the necessary permissions");
-                                                               else if(statusCode == 409)
-                                                                       GSS.get().displayError("A folder with the same name already exists");
-                                                               else if(statusCode == 413)
-                                                                       GSS.get().displayError("Your quota has been exceeded");
-                                                               else
-                                                                       GSS.get().displayError("Unable to move folder:"+((RestException)t).getHttpStatusText());
-                                                       }
-                                                       else
-                                                               GSS.get().displayError("System error moving folder:"+t.getMessage());
-                                               }
-                                       };
-                                       DeferredCommand.addCommand(cf);
-                               }
-                               return;
-                       } else if (citem != null && citem.getFile() != null) {
-                               String target = selectedFolder.getUri();
-                               target = target.endsWith("/") ? target : target + '/';
-                               target = target + URL.encodeComponent(citem.getFile().getName());
-                               if (citem.getOperation() == Clipboard.COPY) {
-                                       PostCommand cf = new PostCommand(citem.getFile().getUri() + "?copy=" + target, "", 200) {
-
-                                               @Override
-                                               public void onComplete() {
-                                                       GSS.get().showFileList(true);
-                                                       GSS.get().getStatusPanel().updateStats();
-                                                       GSS.get().getClipboard().setItem(null);
-                                               }
-
-                                               @Override
-                                               public void onError(Throwable t) {
-                                                       GWT.log("", t);
-                                                       if(t instanceof RestException){
-                                                               int statusCode = ((RestException)t).getHttpStatusCode();
-                                                               if(statusCode == 405)
-                                                                       GSS.get().displayError("You don't have the necessary permissions");
-                                                               else if(statusCode == 404)
-                                                                       GSS.get().displayError("File not found");
-                                                               else if(statusCode == 409)
-                                                                       GSS.get().displayError("A file with the same name already exists");
-                                                               else if(statusCode == 413)
-                                                                       GSS.get().displayError("Your quota has been exceeded");
-                                                               else
-                                                                       GSS.get().displayError("Unable to copy file:"+((RestException)t).getHttpStatusText());
-                                                       }
-                                                       else
-                                                               GSS.get().displayError("System error copying file:"+t.getMessage());
-                                               }
-                                       };
-                                       DeferredCommand.addCommand(cf);
-                               } else if (citem.getOperation() == Clipboard.CUT) {
-                                       PostCommand cf = new PostCommand(citem.getFile().getUri() + "?move=" + target, "", 200) {
-
-                                               @Override
-                                               public void onComplete() {
-                                                       GSS.get().showFileList(true);
-                                                       GSS.get().getStatusPanel().updateStats();
-                                                       GSS.get().getClipboard().setItem(null);
-                                               }
-
-                                               @Override
-                                               public void onError(Throwable t) {
-                                                       GWT.log("", t);
-                                                       if(t instanceof RestException){
-                                                               int statusCode = ((RestException)t).getHttpStatusCode();
-                                                               if(statusCode == 405)
-                                                                       GSS.get().displayError("You don't have the necessary permissions");
-                                                               else if(statusCode == 404)
-                                                                       GSS.get().displayError("File not found");
-                                                               else if(statusCode == 409)
-                                                                       GSS.get().displayError("A file with the same name already exists");
-                                                               else if(statusCode == 413)
-                                                                       GSS.get().displayError("Your quota has been exceeded");
-                                                               else
-                                                                       GSS.get().displayError("Unable to copy file:"+((RestException)t).getHttpStatusText());
-                                                       }
-                                                       else
-                                                               GSS.get().displayError("System error copying file:"+t.getMessage());
-                                               }
-                                       };
-                                       DeferredCommand.addCommand(cf);
-                               }
-                               return;
-                       } else if (citem != null && citem.getFiles() != null) {
-                               List<FileResource> res = citem.getFiles();
-                               List<String> fileIds = new ArrayList<String>();
-                               String target = selectedFolder.getUri();
-                               target = target.endsWith("/") ? target : target + '/';
-
-                               if (citem.getOperation() == Clipboard.COPY) {
-                                       for (FileResource fileResource : res) {
-                                               String fileTarget = target + fileResource.getName();
-                                               fileIds.add(fileResource.getUri() + "?copy=" + fileTarget);
-                                       }
-                                       int index = 0;
-                                       executeCopyOrMove(index, fileIds);
-
-                               } else if (citem.getOperation() == Clipboard.CUT) {
-                                       for (FileResource fileResource : res) {
-                                               String fileTarget = target + fileResource.getName();
-                                               fileIds.add(fileResource.getUri() + "?move=" + fileTarget);
-                                       }
-                                       int index = 0;
-                                       executeCopyOrMove(index, fileIds);
-                               }
-                               return;
-                       }
-               }
+        Object clipboardItem = app.getClipboard().getItem();
+        if (clipboardItem == null)
+            return;
+        int operation = app.getClipboard().getOperation();
+        if (clipboardItem instanceof Folder) {
+            if (operation == Clipboard.COPY) {
+
+            }
+            else {
+
+            }
+        }
+        else {
+            List<File> tobeCopied = (List<File>) clipboardItem;
+            Iterator<File> iter = tobeCopied.iterator();
+            if (operation == Clipboard.COPY) {
+                copyFiles(iter);
+            }
+            else {
+                moveFiles(iter);
+            }
+        }
        }
 
-       private void executeCopyOrMove(final int index, final List<String> paths){
-               if(index >= paths.size()){
-                       GSS.get().showFileList(true);
-                       GSS.get().getStatusPanel().updateStats();
-                       GSS.get().getClipboard().setItem(null);
-                       return;
-               }
-               PostCommand cf = new PostCommand(paths.get(index), "", 200) {
-
-                       @Override
-                       public void onComplete() {
-                               executeCopyOrMove(index+1, paths);
-                       }
-
-                       @Override
-                       public void onError(Throwable t) {
-                               GWT.log("", t);
-                               if(t instanceof RestException){
-                                       int statusCode = ((RestException)t).getHttpStatusCode();
-                                       if(statusCode == 405)
-                                               GSS.get().displayError("You don't have the necessary permissions");
-                                       else if(statusCode == 404)
-                                               GSS.get().displayError("File not found");
-                                       else if(statusCode == 409)
-                                               GSS.get().displayError("A file with the same name already exists");
-                                       else if(statusCode == 413)
-                                               GSS.get().displayError("Your quota has been exceeded");
-                                       else
-                                               GSS.get().displayError("Unable to copy file:"+((RestException)t).getHttpStatusText());
-                               }
-                               else
-                                       GSS.get().displayError("System error copying file:"+t.getMessage());
-                       }
-               };
-               DeferredCommand.addCommand(cf);
-       }
+    private void moveFiles(final Iterator<File> iter) {
+        if (iter.hasNext()) {
+            File file = iter.next();
+            String path = app.getApiPath() + app.getUsername() + folder.getUri() + "/" + file.getName();
+            PutRequest copyFile = new PutRequest(path) {
+                @Override
+                public void onSuccess(Resource result) {
+                    moveFiles(iter);
+                }
+
+                @Override
+                public void onError(Throwable t) {
+                    GWT.log("", t);
+                    if (t instanceof RestException) {
+                        GSS.get().displayError("Unable to copy file: " + ((RestException) t).getHttpStatusText());
+                    }
+                    else
+                        GSS.get().displayError("System error unable to copy file: "+t.getMessage());
+                }
+            };
+            copyFile.setHeader("X-Auth-Token", app.getToken());
+            copyFile.setHeader("X-Move-From", file.getUri());
+            Scheduler.get().scheduleDeferred(copyFile);
+        }
+        else {
+            app.getClipboard().clear();
+            app.updateFolder(folder);
+        }
+    }
+
+    private void copyFiles(final Iterator<File> iter) {
+        if (iter.hasNext()) {
+            File file = iter.next();
+            String path = app.getApiPath() + app.getUsername() + folder.getUri() + "/" + file.getName();
+            PutRequest copyFile = new PutRequest(path) {
+                @Override
+                public void onSuccess(Resource result) {
+                    copyFiles(iter);
+                }
+
+                @Override
+                public void onError(Throwable t) {
+                    GWT.log("", t);
+                    if (t instanceof RestException) {
+                        GSS.get().displayError("Unable to copy file: " + ((RestException) t).getHttpStatusText());
+                    }
+                    else
+                        GSS.get().displayError("System error unable to copy file: "+t.getMessage());
+                }
+            };
+            copyFile.setHeader("X-Auth-Token", app.getToken());
+            copyFile.setHeader("X-Copy-From", file.getUri());
+            Scheduler.get().scheduleDeferred(copyFile);
+        }
+        else {
+            app.getClipboard().clear();
+            app.updateFolder(folder);
+        }
+    }
 }