Started implementation of file list widget
authorChristos Stathis <chstath@ebs.gr>
Tue, 28 Jun 2011 15:25:04 +0000 (18:25 +0300)
committerChristos Stathis <chstath@ebs.gr>
Tue, 28 Jun 2011 15:25:04 +0000 (18:25 +0300)
src/gr/grnet/pithos/web/client/CellTreeViewModel.java
src/gr/grnet/pithos/web/client/DnDFolderPopupMenu.java
src/gr/grnet/pithos/web/client/FileList.java
src/gr/grnet/pithos/web/client/FileMenu.java
src/gr/grnet/pithos/web/client/GSS.java
src/gr/grnet/pithos/web/client/StatusPanel.java
src/gr/grnet/pithos/web/client/foldertree/File.java
src/gr/grnet/pithos/web/client/foldertree/Folder.java
src/gr/grnet/pithos/web/client/foldertree/FolderTreeView.java
src/gr/grnet/pithos/web/client/foldertree/FolderTreeViewModel.java
src/gr/grnet/pithos/web/client/foldertree/GssCellTable.css [new file with mode: 0644]

index 8720687..ce5642b 100644 (file)
@@ -322,24 +322,24 @@ public class CellTreeViewModel implements TreeViewModel{
                  
                  DnDFolderPopupMenu popup ;
                  if(context.getDraggableData() instanceof FileResource){
-                         if(context.getDroppableData() instanceof RestResourceWrapper)
-                                 popup = new DnDFolderPopupMenu(images, ((RestResourceWrapper) context.getDroppableData()).getResource(), Arrays.asList(context.getDraggableData()));
-                         else
-                                 popup = new DnDFolderPopupMenu(images, null, Arrays.asList(context.getDraggableData()));
+//                       if(context.getDroppableData() instanceof RestResourceWrapper)
+//                               popup = new DnDFolderPopupMenu(images, ((RestResourceWrapper) context.getDroppableData()).getResource(), Arrays.asList(context.getDraggableData()));
+ //                      else
+ //                              popup = new DnDFolderPopupMenu(images, null, Arrays.asList(context.getDraggableData()));
                  }
                  
                  else{
-                         if(context.getDroppableData() instanceof RestResourceWrapper)
-                                 popup = new DnDFolderPopupMenu(images, ((RestResourceWrapper) context.getDroppableData()).getResource(), context.getDraggableData());
-                         else
-                                 popup = new DnDFolderPopupMenu(images, null, context.getDraggableData());
+//                       if(context.getDroppableData() instanceof RestResourceWrapper)
+//                               popup = new DnDFolderPopupMenu(images, ((RestResourceWrapper) context.getDroppableData()).getResource(), context.getDraggableData());
+//                       else
+//                               popup = new DnDFolderPopupMenu(images, null, context.getDraggableData());
                  }
                  
                  int left = context.getDroppable().getAbsoluteLeft() + 40;
               int top = context.getDroppable().getAbsoluteTop() + 20;
-              popup.setPopupPosition(left, top);
+//              popup.setPopupPosition(left, top);
                 
-                 popup.show();
+ //              popup.show();
           }
         });
        }
index a1cfd93..9b22f37 100644 (file)
@@ -3,6 +3,8 @@
  */
 package gr.grnet.pithos.web.client;
 
+import gr.grnet.pithos.web.client.foldertree.File;
+import gr.grnet.pithos.web.client.foldertree.Folder;
 import gr.grnet.pithos.web.client.rest.MultiplePostCommand;
 import gr.grnet.pithos.web.client.rest.PostCommand;
 import gr.grnet.pithos.web.client.rest.RestException;
@@ -23,270 +25,264 @@ import com.google.gwt.user.client.ui.PopupPanel;
 
 public class DnDFolderPopupMenu extends PopupPanel {
 
-        public DnDFolderPopupMenu(final CellTreeView.Images newImages, final FolderResource target, final Object toCopy) {
-                // 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);
-                // A dummy command that we will execute from unimplemented leaves.
-                final Command cancelCmd = new Command() {
-
-                        @Override
-                        public void execute() {
-                                hide();
-                        }
-                };
-
-                final MenuBar contextMenu = new MenuBar(true);
-                final CellTreeView folders = GSS.get().getTreeView();
-
-                contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Move</span>", true, new Command() {
-
-                                @Override
-                                public void execute() {
-                                        if (toCopy instanceof RestResourceWrapper){
-                                                moveFolder(target, ((RestResourceWrapper) toCopy).getResource());
-                                        }
-                                        else if(toCopy instanceof List){
-                                               List<FileResource> files = GSS.get().getFileList().getSelectedFiles();
-                                                moveFiles(target, files);
-                                        }
-                                        hide();
-                                }
-
-                        }).setVisible(target != null);
-
-                contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + "&nbsp;Copy</span>", true, new Command() {
-
-                        @Override
-                        public void execute() {
-                                if (toCopy instanceof RestResourceWrapper)
-                                        copyFolder(target, ((RestResourceWrapper) toCopy).getResource());
-                                else if(toCopy instanceof List){
-                                       List<FileResource> files = GSS.get().getFileList().getSelectedFiles();
-                                    copyFiles(target, files);
-                                }
-                                hide();
-                        }
-
-                }).setVisible(target != null);
-
-                contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.trash()).getHTML() + "&nbsp;Delete (Trash)</span>", true, new Command() {
-
-                        @Override
-                        public void execute() {
-                               GWT.log("EXECUTE TRASH:"+toCopy.getClass().getName());
-                                if (toCopy instanceof RestResourceWrapper){
-                                        trashFolder(((RestResourceWrapper) toCopy).getResource());
-                                }
-                                else if(toCopy instanceof List){
-                                       List<FileResource> files = GSS.get().getFileList().getSelectedFiles();
-                                    trashFiles(files);
-                                }
-                                hide();
-                        }
-
-                }).setVisible(target == null);
-                contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Cancel</span>", true, cancelCmd);
-
-                add(contextMenu);
-
-        }
-
-        private void copyFolder(final FolderResource target, FolderResource toCopy) {
-                String atarget = target.getUri();
-                atarget = atarget.endsWith("/") ? atarget : atarget + '/';
-                atarget = atarget + toCopy.getName();
-                PostCommand cf = new PostCommand(toCopy.getUri() + "?copy=" + atarget, "", 200) {
-
-                        @Override
-                        public void onComplete() {
-                                       GSS.get().getTreeView().updateNodeChildren(new RestResourceWrapper(target));
-                                                               GSS.get().getStatusPanel().updateStats();
-                        }
-
-                        @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);
-        }
-
-        private void moveFolder(final FolderResource target, final FolderResource toCopy) {
-                String atarget = target.getUri();
-                atarget = atarget.endsWith("/") ? atarget : atarget + '/';
-                atarget = atarget + toCopy.getName();
-
-                PostCommand cf = new PostCommand(toCopy.getUri() + "?move=" + atarget, "", 200) {
-
-                        @Override
-                        public void onComplete() {
-                               GWT.log("[MOVE]"+target.getUri()+"   "+ toCopy.getParentURI());
-                               GSS.get().getTreeView().updateNodeChildren(new RestResourceWrapper(target));
-                                                       GSS.get().getTreeView().updateNodeChildrenForRemove(toCopy.getParentURI());
-                                                       GSS.get().getStatusPanel().updateStats();
-                        }
-
-                        @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);
-        }
-
-        private void copyFiles(final FolderResource ftarget, List<FileResource> files) {
-                List<String> fileIds = new ArrayList<String>();
-                String target = ftarget.getUri();
-                target = target.endsWith("/") ? target : target + '/';
-                for (FileResource fileResource : files) {
-                        String fileTarget = target + URL.encodeComponent(fileResource.getName());
-                        fileIds.add(fileResource.getUri() + "?copy=" + fileTarget);
+    public DnDFolderPopupMenu(final CellTreeView.Images newImages, final Folder target, final Object toCopy) {
+        // 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);
+        // A dummy command that we will execute from unimplemented leaves.
+        final Command cancelCmd = new Command() {
+
+            @Override
+            public void execute() {
+                hide();
+            }
+        };
+
+        final MenuBar contextMenu = new MenuBar(true);
+        final CellTreeView folders = GSS.get().getTreeView();
+
+        contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Move</span>", true, new Command() {
+
+            @Override
+            public void execute() {
+                if (toCopy instanceof Folder) {
+                    moveFolder(target, (Folder) toCopy);
                 }
-                int index = 0;
-                executeCopyOrMoveFiles(index, fileIds);
-
-        }
-
-        private void moveFiles(final FolderResource ftarget, List<FileResource> files) {
-                List<String> fileIds = new ArrayList<String>();
-                String target = ftarget.getUri();
-                target = target.endsWith("/") ? target : target + '/';
-                for (FileResource fileResource : files) {
-                        String fileTarget = target + URL.encodeComponent(fileResource.getName());
-                        fileIds.add(fileResource.getUri() + "?move=" + fileTarget);
+                else if (toCopy instanceof List) {
+                    List<File> files = GSS.get().getFileList().getSelectedFiles();
+                    moveFiles(target, files);
                 }
-                int index = 0;
-                executeCopyOrMoveFiles(index, fileIds);
-
-        }
-
-        private void trashFolder(final FolderResource folder){
-                PostCommand tot = new PostCommand(folder.getUri()+"?trash=","",200){
-
-                        @Override
-                        public void onComplete() {
-                               GSS.get().getTreeView().updateNodeChildrenForRemove(folder.getParentURI());
-                               GSS.get().getTreeView().updateTrashNode();
-                                /*for(TreeItem item : items)
-                                        GSS.get().getFolders().updateFolder((DnDTreeItem) item);
-                                GSS.get().getFolders().update(GSS.get().getFolders().getTrashItem());
-                               
-                                GSS.get().showFileList(true);
-                                */
-                        }
-
-                        @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("Folder does not exist");
-                                        else
-                                                GSS.get().displayError("Unable to trash folder:"+((RestException)t).getHttpStatusText());
-                                }
-                                else
-                                        GSS.get().displayError("System error trashing folder:"+t.getMessage());
-                        }
-                };
-                DeferredCommand.addCommand(tot);
-        }
-
-        private void trashFiles(List<FileResource> files){
-                final List<String> fileIds = new ArrayList<String>();
-                for(FileResource f : files)
-                        fileIds.add(f.getUri()+"?trash=");
-                MultiplePostCommand tot = new MultiplePostCommand(fileIds.toArray(new String[0]),200){
-
-                        @Override
-                        public void onComplete() {
-                                GSS.get().showFileList(true);
-                        }
-
-                        @Override
-                        public void onError(String p, 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 does not exist");
-                                        else
-                                                GSS.get().displayError("Unable to trash file:"+((RestException)t).getHttpStatusText());
-                                }
-                                else
-                                        GSS.get().displayError("System error trashing file:"+t.getMessage());
-                        }
-                };
-                DeferredCommand.addCommand(tot);
-        }
-
-
-        private void executeCopyOrMoveFiles(final int index, final List<String> paths) {
-                if (index >= paths.size()) {
-                        GSS.get().showFileList(true);
-                        GSS.get().getStatusPanel().updateStats();
-                        return;
+                hide();
+            }
+        }).setVisible(target != null);
+
+        contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + "&nbsp;Copy</span>", true, new Command() {
+
+            @Override
+            public void execute() {
+                if (toCopy instanceof Folder)
+                    copyFolder(target, (Folder) toCopy);
+                else if (toCopy instanceof List) {
+                    List<File> files = GSS.get().getFileList().getSelectedFiles();
+                    copyFiles(target, files);
                 }
-                PostCommand cf = new PostCommand(paths.get(index), "", 200) {
-
-                        @Override
-                        public void onComplete() {
-                                executeCopyOrMoveFiles(index + 1, paths);
-                        }
+                hide();
+            }
+        }).setVisible(target != 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());
+        contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.trash()).getHTML() + "&nbsp;Delete (Trash)</span>", true, new Command() {
 
-                        }
-                };
-                DeferredCommand.addCommand(cf);
+            @Override
+            public void execute() {
+                GWT.log("EXECUTE TRASH:" + toCopy.getClass().getName());
+                if (toCopy instanceof RestResourceWrapper) {
+                    trashFolder(((RestResourceWrapper) toCopy).getResource());
+                }
+                else if (toCopy instanceof List) {
+                    List<File> files = GSS.get().getFileList().getSelectedFiles();
+                    trashFiles(files);
+                }
+                hide();
+            }
+        }).setVisible(target == null);
+        contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Cancel</span>", true, cancelCmd);
+
+        add(contextMenu);
+    }
+
+    private void copyFolder(final Folder target, Folder toCopy) {
+//        String atarget = target.getUri();
+//        atarget = atarget.endsWith("/") ? atarget : atarget + '/';
+//        atarget = atarget + toCopy.getName();
+//        PostCommand cf = new PostCommand(toCopy.getUri() + "?copy=" + atarget, "", 200) {
+//
+//            @Override
+//            public void onComplete() {
+//                GSS.get().getTreeView().updateNodeChildren(new RestResourceWrapper(target));
+//                GSS.get().getStatusPanel().updateStats();
+//            }
+//
+//            @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);
+    }
+
+    private void moveFolder(final Folder target, final Folder toCopy) {
+//        String atarget = target.getUri();
+//        atarget = atarget.endsWith("/") ? atarget : atarget + '/';
+//        atarget = atarget + toCopy.getName();
+//
+//        PostCommand cf = new PostCommand(toCopy.getUri() + "?move=" + atarget, "", 200) {
+//
+//            @Override
+//            public void onComplete() {
+//                GWT.log("[MOVE]" + target.getUri() + "   " + toCopy.getParentURI());
+//                GSS.get().getTreeView().updateNodeChildren(new RestResourceWrapper(target));
+//                GSS.get().getTreeView().updateNodeChildrenForRemove(toCopy.getParentURI());
+//                GSS.get().getStatusPanel().updateStats();
+//            }
+//
+//            @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);
+    }
+
+    private void copyFiles(final Folder ftarget, List<File> files) {
+//        List<String> fileIds = new ArrayList<String>();
+//        String target = ftarget.getUri();
+//        target = target.endsWith("/") ? target : target + '/';
+//        for (File file : files) {
+//            String fileTarget = target + URL.encodeComponent(file.getName());
+//            fileIds.add(file.getUri() + "?copy=" + fileTarget);
+//        }
+//        int index = 0;
+//        executeCopyOrMoveFiles(index, fileIds);
+    }
+
+    private void moveFiles(final Folder ftarget, List<File> files) {
+//        List<String> fileIds = new ArrayList<String>();
+//        String target = ftarget.getUri();
+//        target = target.endsWith("/") ? target : target + '/';
+//        for (File file : files) {
+//            String fileTarget = target + URL.encodeComponent(file.getName());
+//            fileIds.add(file.getUri() + "?move=" + fileTarget);
+//        }
+//        int index = 0;
+//        executeCopyOrMoveFiles(index, fileIds);
+    }
+
+    private void trashFolder(final FolderResource folder) {
+        PostCommand tot = new PostCommand(folder.getUri() + "?trash=", "", 200) {
+
+            @Override
+            public void onComplete() {
+                GSS.get().getTreeView().updateNodeChildrenForRemove(folder.getParentURI());
+                GSS.get().getTreeView().updateTrashNode();
+                /*for(TreeItem item : items)
+                        GSS.get().getFolders().updateFolder((DnDTreeItem) item);
+                GSS.get().getFolders().update(GSS.get().getFolders().getTrashItem());
+
+                GSS.get().showFileList(true);
+                */
+            }
+
+            @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("Folder does not exist");
+                    else
+                        GSS.get().displayError("Unable to trash folder:" + ((RestException) t).getHttpStatusText());
+                }
+                else
+                    GSS.get().displayError("System error trashing folder:" + t.getMessage());
+            }
+        };
+        DeferredCommand.addCommand(tot);
+    }
+
+    private void trashFiles(List<File> files) {
+        final List<String> fileIds = new ArrayList<String>();
+        for (File f : files)
+            fileIds.add(f.getUri() + "?trash=");
+        MultiplePostCommand tot = new MultiplePostCommand(fileIds.toArray(new String[0]), 200) {
+
+            @Override
+            public void onComplete() {
+                GSS.get().showFileList(true);
+            }
+
+            @Override
+            public void onError(String p, 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 does not exist");
+                    else
+                        GSS.get().displayError("Unable to trash file:" + ((RestException) t).getHttpStatusText());
+                }
+                else
+                    GSS.get().displayError("System error trashing file:" + t.getMessage());
+            }
+        };
+        DeferredCommand.addCommand(tot);
+    }
+
+    private void executeCopyOrMoveFiles(final int index, final List<String> paths) {
+        if (index >= paths.size()) {
+            GSS.get().showFileList(true);
+            GSS.get().getStatusPanel().updateStats();
+            return;
         }
-
+        PostCommand cf = new PostCommand(paths.get(index), "", 200) {
+
+            @Override
+            public void onComplete() {
+                executeCopyOrMoveFiles(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);
+    }
 }
\ No newline at end of file
index ccf2203..a2e7bae 100644 (file)
@@ -7,6 +7,9 @@ package gr.grnet.pithos.web.client;
 import static com.google.gwt.query.client.GQuery.$;
 
 import gr.grnet.pithos.web.client.commands.UploadFileCommand;
+import gr.grnet.pithos.web.client.foldertree.File;
+import gr.grnet.pithos.web.client.foldertree.Folder;
+import gr.grnet.pithos.web.client.foldertree.FolderTreeView;
 import gr.grnet.pithos.web.client.rest.GetCommand;
 import gr.grnet.pithos.web.client.rest.RestCommand;
 import gr.grnet.pithos.web.client.rest.resource.FileResource;
@@ -19,7 +22,6 @@ import gr.grnet.pithos.web.client.rest.resource.SharedResource;
 import gr.grnet.pithos.web.client.rest.resource.TrashFolderResource;
 import gr.grnet.pithos.web.client.rest.resource.TrashResource;
 import gr.grnet.pithos.web.client.rest.resource.UserResource;
-import gr.grnet.pithos.web.client.rest.resource.UserSearchResource;
 import gwtquery.plugins.draggable.client.DraggableOptions;
 import gwtquery.plugins.draggable.client.StopDragException;
 import gwtquery.plugins.draggable.client.DraggableOptions.DragFunction;
@@ -44,12 +46,9 @@ import com.google.gwt.cell.client.SafeHtmlCell;
 import com.google.gwt.cell.client.TextCell;
 import com.google.gwt.cell.client.ValueUpdater;
 import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.RepeatingCommand;
 import com.google.gwt.dom.client.Style.Cursor;
 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.http.client.URL;
 import com.google.gwt.i18n.client.DateTimeFormat;
 import com.google.gwt.resources.client.ClientBundle;
 import com.google.gwt.resources.client.ImageResource;
@@ -59,7 +58,6 @@ import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
 import com.google.gwt.user.cellview.client.CellTable;
 import com.google.gwt.user.cellview.client.GssSimplePager;
 import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.DeferredCommand;
 import com.google.gwt.user.client.Event;
 import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.ui.AbstractImagePrototype;
@@ -72,16 +70,25 @@ import com.google.gwt.view.client.MultiSelectionModel;
 import com.google.gwt.view.client.ProvidesKey;
 import com.google.gwt.view.client.SelectionChangeEvent;
 import com.google.gwt.view.client.SelectionChangeEvent.Handler;
+import java.util.Set;
 
 /**
  * A composite that displays the list of files in a particular folder.
  */
 public class FileList extends Composite {
-       ListDataProvider<FileResource> provider = new ListDataProvider<FileResource>();
+
+       ListDataProvider<File> provider = new ListDataProvider<File>();
+
+    /**
+       * The styles applied to the table.
+       */
+    interface TableStyle extends CellTable.Style {
+    }
+
        interface TableResources extends DragAndDropCellTable.Resources {
            @Source({CellTable.Style.DEFAULT_CSS, "GssCellTable.css"})
            TableStyle cellTableStyle();
-         }
+       }
        
        static interface Templates extends SafeHtmlTemplates {
            Templates INSTANCE = GWT.create(Templates.class);
@@ -100,16 +107,9 @@ public class FileList extends Composite {
 
         @Template("<span id='{0}' class='{1}'>{2}</span>")
         public SafeHtml spanWithIdAndClass(String id, String cssClass, String content);
-         }
-       
-       
-       /**
-          * The styles applied to the table.
-          */
-         interface TableStyle extends CellTable.Style {
-         }
+       }
 
-       private String showingStats = "";
+    private String showingStats = "";
 
        private int startIndex = 0;
 
@@ -118,8 +118,6 @@ public class FileList extends Composite {
         */
        public static final boolean DONE = false;
 
-       
-       
        private final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");
 
        /**
@@ -202,53 +200,6 @@ public class FileList extends Composite {
 
        }
        
-       DragStopEventHandler dragStop = new DragStopEventHandler() {
-               
-               @Override
-               public void onDragStop(DragStopEvent event) {
-                       GWT.log("DRAG STOPPED");
-                       
-               }
-       };
-       
-       private static class ContactCell extends AbstractCell<gr.grnet.pithos.web.client.rest.resource.FileResource> {
-
-           /**
-            * The html of the image used for contacts.
-            * 
-            */
-           private final String imageHtml;
-
-           public ContactCell(ImageResource image) {
-             this.imageHtml = AbstractImagePrototype.create(image).getHTML();
-           }
-
-           
-
-               
-
-           @Override
-           public void render(Context context, FileResource value, SafeHtmlBuilder sb) {
-             // Value can be null, so do a null check..
-             if (value == null) {
-               return;
-             }
-
-          sb.append(Templates.INSTANCE.rendelContactCell(imageHtml, value.getName(), value.getFileSizeAsString()));
-           }
-
-
-         }
-       /**
-        * Retrieve the celltable.
-        *
-        * @return the celltable
-        */
-       public DragAndDropCellTable<FileResource> getCelltable() {
-               return celltable;
-       }
-       
-       
        /**
         * The number of files in this folder.
         */
@@ -262,7 +213,7 @@ public class FileList extends Composite {
        /**
         * A cache of the files in the list.
         */
-       private List<FileResource> files;
+       private List<File> files;
 
        /**
         * The widget's image bundle.
@@ -270,15 +221,26 @@ public class FileList extends Composite {
        private final Images images;
        
        private FileContextMenu menuShowing;
-       private DragAndDropCellTable<FileResource> celltable;
-       private final MultiSelectionModel<FileResource> selectionModel;
+
+       private DragAndDropCellTable<File> celltable;
+
+       private final MultiSelectionModel<File> selectionModel;
+
        private final List<SortableHeader> allHeaders = new ArrayList<SortableHeader>();
+
        SortableHeader nameHeader;
+
        GssSimplePager pagerBottom;
+
        GssSimplePager pagerTop;
+
        Button uploadButtonBottom;
+
        Button uploadButtonTop;
-       /**
+
+    FolderTreeView treeView;
+
+    /**
         * Construct the file list widget. This entails setting up the widget
         * layout, fetching the number of files in the current folder from the
         * server and filling the local file cache of displayed files with data from
@@ -286,117 +248,133 @@ public class FileList extends Composite {
         *
         * @param _images
         */
-       public FileList(Images _images) {
+       public FileList(Images _images, FolderTreeView treeView) {
                images = _images;
-               DragAndDropCellTable.Resources resources = GWT.create(TableResources.class);
-               ProvidesKey<FileResource> keyProvider = new ProvidesKey<FileResource>(){
+        this.treeView = treeView;
+
+        DragAndDropCellTable.Resources resources = GWT.create(TableResources.class);
+
+        ProvidesKey<File> keyProvider = new ProvidesKey<File>(){
 
                        @Override
-                       public Object getKey(FileResource item) {
+                       public Object getKey(File item) {
                                return item.getUri();
                        }
-                       
                };
-               celltable = new DragAndDropCellTable<FileResource>(GSS.VISIBLE_FILE_COUNT,resources,keyProvider);
-               
-               DragAndDropColumn<FileResource, ImageResource> status = new DragAndDropColumn<FileResource, ImageResource>(new ImageResourceCell(){
-                       @Override
-                 public boolean handlesSelection() {
-                           return false;
-                         }
-               }) {
-                 @Override
-                 public ImageResource getValue(FileResource entity) {
-                   return getFileIcon(entity);
-                 }
-                 
-              };
+
+               celltable = new DragAndDropCellTable<File>(GSS.VISIBLE_FILE_COUNT, resources, keyProvider);
+        celltable.setWidth("100%");
+        celltable.setStyleName("pithos-List");
+
+               DragAndDropColumn<File, ImageResource> status = new DragAndDropColumn<File, ImageResource>(new ImageResourceCell() {
+                   @Override
+               public boolean handlesSelection() {
+                   return false;
+               }
+               })
+        {
+                @Override
+                public ImageResource getValue(File entity) {
+                    return getFileIcon(entity);
+                }
+           };
            celltable.addColumn(status,"");
-           
            initDragOperation(status);
-               final DragAndDropColumn<FileResource,SafeHtml> nameColumn = new DragAndDropColumn<FileResource,SafeHtml>(new SafeHtmlCell()) {
+
+        final DragAndDropColumn<File,SafeHtml> nameColumn = new DragAndDropColumn<File,SafeHtml>(new SafeHtmlCell()) {
 
                        @Override
-                       public SafeHtml getValue(FileResource object) {
+                       public SafeHtml getValue(File object) {
                                SafeHtmlBuilder sb = new SafeHtmlBuilder();
                 sb.append(Templates.INSTANCE.filenameSpan(object.getName()));
-                               if (object.getContentType().endsWith("png") || object.getContentType().endsWith("gif") || object.getContentType().endsWith("jpeg") ){
-                                       sb.appendHtmlConstant("&nbsp;").append(Templates.INSTANCE.viewLink(GSS.get().getTopPanel().getFileMenu().getDownloadURL(object), object.getOwner() + " : " + object.getPath() + object.getName()));
+                               if (object.getContentType().endsWith("png") || object.getContentType().endsWith("gif") || object.getContentType().endsWith("jpeg")) {
+                               sb.appendHtmlConstant("&nbsp;")
+                      .append(Templates.INSTANCE.viewLink(object.getUri(), object.getOwner() + " : " + object.getPath() + object.getName()));
                                }
                                
                                return sb.toSafeHtml();
                        }
                        
                };
-               initDragOperation(nameColumn);
-               celltable.addColumn(nameColumn,nameHeader = new SortableHeader("Name"));
+        initDragOperation(nameColumn);
+        celltable.addColumn(nameColumn, nameHeader = new SortableHeader("Name"));
                allHeaders.add(nameHeader);
-               //nameHeader.setSorted(true);
-               //nameHeader.toggleReverseSort();
                nameHeader.setUpdater(new FileValueUpdater(nameHeader, "name"));
+
                celltable.redrawHeaders();
                
-               
-           
-           
-           SortableHeader aheader;
-           DragAndDropColumn<FileResource,String> aColumn;
-               celltable.addColumn(aColumn=new DragAndDropColumn<FileResource,String>(new TextCell()) {
+           DragAndDropColumn<File,String> aColumn = new DragAndDropColumn<File, String>(new TextCell()) {
                        @Override
-                       public String getValue(FileResource object) {
-                               return GSS.get().findUserFullName(object.getOwner());
-                       }                       
-               },aheader = new SortableHeader("Owner"));
+                       public String getValue(File object) {
+                               return object.getOwner();
+                       }
+               };
+        SortableHeader aheader = new SortableHeader("Owner");
+               celltable.addColumn(aColumn, aheader);
                initDragOperation(aColumn);
                allHeaders.add(aheader);
-               aheader.setUpdater(new FileValueUpdater(aheader, "owner"));
-               celltable.addColumn(aColumn=new DragAndDropColumn<FileResource,String>(new TextCell()) {
+        aheader.setUpdater(new FileValueUpdater(aheader, "owner"));
+
+        aColumn = new DragAndDropColumn<File,String>(new TextCell()) {
                        @Override
-                       public String getValue(FileResource object) {
-                               // TODO Auto-generated method stub
+                       public String getValue(File object) {
                                return object.getPath();
-                       }                       
-               },aheader = new SortableHeader("Path"));
+                       }
+               };
+        aheader = new SortableHeader("Path");
+               celltable.addColumn(aColumn, aheader);
                initDragOperation(aColumn);
                allHeaders.add(aheader);
-               
-               aheader.setUpdater(new FileValueUpdater(aheader, "path"));      
-               celltable.addColumn(aColumn=new DragAndDropColumn<FileResource,String>(new TextCell()) {
+               aheader.setUpdater(new FileValueUpdater(aheader, "path"));
+
+        aColumn = new DragAndDropColumn<File,String>(new TextCell()) {
                        @Override
-                       public String getValue(FileResource object) {
-                               if(object.isVersioned())
-                                       return object.getVersion().toString();
-                               return "-";
-                       }                       
-               },aheader = new SortableHeader("Version"));
+                       public String getValue(File object) {
+                       return String.valueOf(object.getVersion());
+                       }
+               };
+        aheader = new SortableHeader("Version");
+               celltable.addColumn(aColumn, aheader);
                initDragOperation(aColumn);
                allHeaders.add(aheader);
                aheader.setUpdater(new FileValueUpdater(aheader, "version"));
-               celltable.addColumn(aColumn=new DragAndDropColumn<FileResource,String>(new TextCell()) {
+
+        aColumn = new DragAndDropColumn<File,String>(new TextCell()) {
                        @Override
-                       public String getValue(FileResource object) {
+                       public String getValue(File object) {
                                // TODO Auto-generated method stub
-                               return object.getFileSizeAsString();
-                       }                       
-               },aheader = new SortableHeader("Size"));
+                               return object.getSizeAsString();
+                       }
+               };
+        aheader = new SortableHeader("Size");
+        celltable.addColumn(aColumn, aheader);
                initDragOperation(aColumn);
                allHeaders.add(aheader);
-               aheader.setUpdater(new FileValueUpdater(aheader, "size"));      
-               celltable.addColumn(aColumn=new DragAndDropColumn<FileResource,String>(new TextCell()) {
+               aheader.setUpdater(new FileValueUpdater(aheader, "size"));
+
+        aColumn = new DragAndDropColumn<File,String>(new TextCell()) {
                        @Override
-                       public String getValue(FileResource object) {
-                               return formatter.format(object.getModificationDate());
-                       }                       
-               },aheader = new SortableHeader("Last Modified"));
+                       public String getValue(File object) {
+                               return formatter.format(object.getLastModified());
+                       }
+               };
+        aheader = new SortableHeader("Last Modified");
+               celltable.addColumn(aColumn, aheader);
                allHeaders.add(aheader);
                aheader.setUpdater(new FileValueUpdater(aheader, "date"));
               
-               
                provider.addDataDisplay(celltable);
-               celltable.addDragStopHandler(dragStop);
+
+               celltable.addDragStopHandler(new DragStopEventHandler() {
+
+               @Override
+                   public void onDragStop(DragStopEvent event) {
+                           GWT.log("DRAG STOPPED");
+                   }
+           });
                celltable.addDragStartHandler(new DragStartEventHandler() {
 
-                     public void onDragStart(DragStartEvent event) {
+                   public void onDragStart(DragStartEvent event) {
                        FileResource value = event.getDraggableData();
                        
                        com.google.gwt.dom.client.Element helper = event.getHelper();
@@ -409,20 +387,16 @@ public class FileList extends Composite {
                                sb.appendEscaped(getSelectedFiles().size()+" files");
                        sb.appendHtmlConstant("</b>");
                        helper.setInnerHTML(sb.toSafeHtml().asString());
+                   }
+               });
 
-                     }
-                   });
-               
-               
-               
-               
-               
-               
                VerticalPanel vp = new VerticalPanel();
                vp.setWidth("100%");
+
                pagerTop = new GssSimplePager(GssSimplePager.TextLocation.CENTER);
-               pagerTop.setDisplay(celltable); 
-               uploadButtonTop=new Button("<span id='topMenu.file.upload'>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + "&nbsp;Upload</span>");
+        pagerTop.setVisible(false);
+               pagerTop.setDisplay(celltable);
+               uploadButtonTop = new Button("<span id='topMenu.file.upload'>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + "&nbsp;Upload</span>");
                uploadButtonTop.addClickHandler(new ClickHandler() {
                        
                        @Override
@@ -434,12 +408,12 @@ public class FileList extends Composite {
                topPanel.add(pagerTop);
                topPanel.add(uploadButtonTop);
                vp.add(topPanel);
-               celltable.setWidth("100%");
-               vp.add(celltable);
+
+        vp.add(celltable);
+
                pagerBottom = new GssSimplePager(GssSimplePager.TextLocation.CENTER);
+        pagerBottom.setVisible(false);
                pagerBottom.setDisplay(celltable);
-               HorizontalPanel bottomPanel = new HorizontalPanel();
-               bottomPanel.add(pagerBottom);
                uploadButtonBottom=new Button("<span id='topMenu.file.upload'>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + "&nbsp;Upload</span>");
                uploadButtonBottom.addClickHandler(new ClickHandler() {
                        
@@ -448,22 +422,20 @@ public class FileList extends Composite {
                                new UploadFileCommand(null).execute();
                        }
                });
+        HorizontalPanel bottomPanel = new HorizontalPanel();
+        bottomPanel.add(pagerBottom);
                bottomPanel.add(uploadButtonBottom);
+
                vp.add(bottomPanel);
                vp.setCellWidth(celltable, "100%");
-               
                initWidget(vp);
-               pagerBottom.setVisible(false);
-               pagerTop.setVisible(false);
 
-               celltable.setStyleName("pithos-List");
-               selectionModel = new MultiSelectionModel<FileResource>(keyProvider);
-               
+               selectionModel = new MultiSelectionModel<File>(keyProvider);
 
-                Handler selectionHandler = new SelectionChangeEvent.Handler() { 
+                Handler selectionHandler = new SelectionChangeEvent.Handler() {
              @Override 
-             public void onSelectionChange(com.google.gwt.view.client.SelectionChangeEvent event) {
-                if(getSelectedFiles().size()==1)
+             public void onSelectionChange(SelectionChangeEvent event) {
+                if(getSelectedFiles().size() == 1)
                         GSS.get().setCurrentSelection(getSelectedFiles().get(0));
                 else
                         GSS.get().setCurrentSelection(getSelectedFiles());
@@ -471,16 +443,9 @@ public class FileList extends Composite {
          };
          selectionModel.addSelectionChangeHandler(selectionHandler);
          
-               celltable.setSelectionModel(selectionModel,GSSSelectionEventManager.<FileResource>createDefaultManager());
+               celltable.setSelectionModel(selectionModel, GSSSelectionEventManager.<File> createDefaultManager());
                celltable.setPageSize(GSS.VISIBLE_FILE_COUNT);
                
-//             Scheduler.get().scheduleIncremental(new RepeatingCommand() {
-//
-//                     @Override
-//                     public boolean execute() {
-//                             return fetchRootFolder();
-//                     }
-//             });
                sinkEvents(Event.ONCONTEXTMENU);
                sinkEvents(Event.ONMOUSEUP);
                sinkEvents(Event.ONMOUSEDOWN);
@@ -489,50 +454,43 @@ public class FileList extends Composite {
                sinkEvents(Event.ONDBLCLICK);
                GSS.preventIESelection();
        }
-       
 
+       public List<File> getSelectedFiles() {
+        return new ArrayList<File>(selectionModel.getSelectedSet());
+       }
        
-        public List<FileResource> getSelectedFiles() {
-         return new ArrayList<FileResource>(selectionModel.getSelectedSet());
-        }
-       
-        private void initDragOperation(DragAndDropColumn<?, ?> column) {
-
-                   // retrieve draggableOptions on the column
-                   DraggableOptions draggableOptions = column.getDraggableOptions();
-                   // use template to construct the helper. The content of the div will be set
-                   // after
-                   draggableOptions.setHelper($(Templates.INSTANCE.outerHelper().asString()));
-                   //draggableOptions.setZIndex(100);
-                   // opacity of the helper
-                   draggableOptions.setAppendTo("body"); 
-                   //draggableOptions.setOpacity((float) 0.8);
-                   draggableOptions.setContainment("document");
-                   // cursor to use during the drag operation
-                   draggableOptions.setCursor(Cursor.MOVE);
-                   // set the revert option
-                   draggableOptions.setRevert(RevertOption.ON_INVALID_DROP);
-                   // prevents dragging when user click on the category drop-down list
-                   draggableOptions.setCancel("select");
-                   
-                   
-                   draggableOptions.setOnBeforeDragStart(new DragFunction() {
-                               
-                               @Override
-                               public void f(DragContext context) {
-                                        FileResource value = context.getDraggableData();
-                                    if(!selectionModel.isSelected(value)){
-                                       throw new StopDragException();
-                                     }
-                                       
-                               }
-                       });
-                 }
+       private void initDragOperation(DragAndDropColumn<?, ?> column) {
+        // retrieve draggableOptions on the column
+               DraggableOptions draggableOptions = column.getDraggableOptions();
+               // use template to construct the helper. The content of the div will be set
+               // after
+               draggableOptions.setHelper($(Templates.INSTANCE.outerHelper().asString()));
+               //draggableOptions.setZIndex(100);
+               // opacity of the helper
+               draggableOptions.setAppendTo("body");
+               //draggableOptions.setOpacity((float) 0.8);
+               draggableOptions.setContainment("document");
+               // cursor to use during the drag operation
+               draggableOptions.setCursor(Cursor.MOVE);
+               // set the revert option
+               draggableOptions.setRevert(RevertOption.ON_INVALID_DROP);
+               // prevents dragging when user click on the category drop-down list
+               draggableOptions.setCancel("select");
+           draggableOptions.setOnBeforeDragStart(new DragFunction() {
+                       @Override
+                       public void f(DragContext context) {
+                       File value = context.getDraggableData();
+                               if (!selectionModel.isSelected(value)) {
+                       throw new StopDragException();
+                   }
+                       }
+               });
+    }
        
-        public void showContextMenu(Event event){
-                menuShowing = new FileContextMenu(images, false, true);
-                       menuShowing=menuShowing.onEmptyEvent(event);
-        }
+       public void showContextMenu(Event event){
+               menuShowing = new FileContextMenu(images, false, true);
+               menuShowing=menuShowing.onEmptyEvent(event);
+       }
        @Override
        public void onBrowserEvent(Event event) {
                
@@ -559,13 +517,8 @@ public class FileList extends Composite {
                } else if (DOM.eventGetType(event) == Event.ONDBLCLICK)
                        if (getSelectedFiles().size() == 1) {
                                GSS app = GSS.get();
-                               FileResource file = getSelectedFiles().get(0);
-                               String dateString = RestCommand.getDate();
-                               String resource = file.getUri().substring(app.getApiPath().length() - 1, file.getUri().length());
-                               String sig = app.getCurrentUserResource().getUsername() + " " +
-                                               RestCommand.calculateSig("GET", dateString, resource,
-                                               RestCommand.base64decode(app.getToken()));
-                               Window.open(file.getUri() + "?Authorization=" + URL.encodeComponent(sig) + "&Date=" + URL.encodeComponent(dateString), "_blank", "");
+                               File file = getSelectedFiles().get(0);
+                               Window.open(file.getUri(), "_blank", "");
                                event.preventDefault();
                                return;
                        }
@@ -573,21 +526,6 @@ public class FileList extends Composite {
        }
 
        /**
-        * Retrieve the root folder for the current user.
-        *
-        * @return true if the retrieval was successful
-        */
-       protected boolean fetchRootFolder() {
-               UserResource user = GSS.get().getCurrentUserResource();
-               if (user == null)
-                       return !DONE;
-               // Update cache and clear selection.
-               updateFileCache(true);
-               return DONE;
-       }
-
-
-       /**
         * Update the display of the file list.
         */
        void update(boolean sort) {
@@ -597,9 +535,8 @@ public class FileList extends Composite {
                        max = count;
                folderTotalSize = 0;
                
-               copyListAndContinue(files);
-               for(FileResource f : files){
-                       folderTotalSize += f.getContentLength();
+               for(File f : files){
+                       folderTotalSize += f.getBytes();
                }
                if (folderFileCount == 0) {
                        showingStats = "no files";
@@ -623,28 +560,9 @@ public class FileList extends Composite {
         * @param file
         * @return the icon
         */
-       private ImageResource getFileIcon(FileResource file) {
+       private ImageResource getFileIcon(File file) {
                String mimetype = file.getContentType();
-               boolean shared = false;
-               if(GSS.get().getTreeView().getSelection()!=null && (GSS.get().getTreeView().getSelection() instanceof OtherUserResource || GSS.get().getTreeView().getSelection() instanceof OthersFolderResource)){
-                       OtherUserResource otherUser = null;
-                       if(GSS.get().getTreeView().getSelection() instanceof OtherUserResource)
-                               otherUser = (OtherUserResource) GSS.get().getTreeView().getSelection();
-                       else if (GSS.get().getTreeView().getSelection() instanceof OthersFolderResource){
-                               otherUser = GSS.get().getTreeView().getOtherUserResourceOfOtherFolder((OthersFolderResource) GSS.get().getTreeView().getSelection());
-                       }
-                       if(otherUser ==null)
-                               shared=false;
-                       else{
-                               String uname = otherUser.getUsername();
-                               if(uname==null)
-                                       uname = GSS.get().getTreeView().getOthers().getUsernameOfUri(otherUser.getUri());
-                               if(uname != null)
-                                       shared = file.isShared();
-                       }
-               }
-               else
-                       shared = file.isShared();
+               boolean shared = file.isShared();
                if (mimetype == null)
                        return shared ? images.documentShared() : images.document();
                mimetype = mimetype.toLowerCase();
@@ -682,53 +600,18 @@ public class FileList extends Composite {
                GSS.get().getStatusPanel().updateCurrentlyShowing(showingStats);
        }
        
-       public void updateFileCache(boolean clearSelection){
-               if(clearSelection){
-                       clearSelectedRows();
-               }
-               
-               final RestResource folderItem = GSS.get().getTreeView().getSelection();
-               // Validation.
-               if (folderItem == null || folderItem.equals(GSS.get().getTreeView().getOthers())) {
-                       setFiles(new ArrayList<FileResource>());
-                       update(true);
-                       return;
-               }
-               else if (folderItem instanceof RestResourceWrapper) {
-                       setFiles(((RestResourceWrapper) folderItem).getResource().getFiles());
-                       update(true);
-               }
-               else if (folderItem instanceof SharedResource) {
-                       setFiles(((SharedResource) folderItem).getFiles());
-                       update(true);
-               }
-               else if (folderItem instanceof OtherUserResource) {
-                       setFiles(((OtherUserResource) folderItem).getFiles());
-                       update(true);
-               }
-               else if (folderItem instanceof TrashResource) {
-                       setFiles(((TrashResource) folderItem).getFiles());
-                       update(true);
-               }
-       }
-       
-
        /**
         * Fill the file cache with data.
         */
-       public void setFiles(final List<FileResource> _files) {
-               if (_files.size() > 0 && ! (GSS.get().getTreeView().getSelection() instanceof TrashResource)) {
-                       files = new ArrayList<FileResource>();
-                       for (FileResource fres : _files)
-                               if (!fres.isDeleted())
-                                       files.add(fres);
-               }
-               else
-                       files = _files;
-               Collections.sort(files, new Comparator<FileResource>() {
+       public void setFiles(final List<File> _files) {
+               files = new ArrayList<File>();
+       for (File fres : _files)
+               if (!fres.isInTrash())
+                               files.add(fres);
+               Collections.sort(files, new Comparator<File>() {
 
                        @Override
-                       public int compare(FileResource arg0, FileResource arg1) {
+                       public int compare(File arg0, File arg1) {
                                return arg0.getName().compareTo(arg1.getName());
                        }
 
@@ -738,17 +621,27 @@ public class FileList extends Composite {
                nameHeader.setSorted(true);
                nameHeader.toggleReverseSort();
                for (SortableHeader otherHeader : allHeaders) {
-                 if (otherHeader != nameHeader) {
+               if (otherHeader != nameHeader) {
                    otherHeader.setSorted(false);
                    otherHeader.setReverseSort(true);
-                 }
                }
-               //
-       }
+           }
 
-       
+        if(files.size() > GSS.VISIBLE_FILE_COUNT){
+            pagerBottom.setVisible(true);
+            pagerTop.setVisible(true);
+        }
+        else{
+            pagerTop.setVisible(false);
+            pagerBottom.setVisible(false);
+        }
+        Folder selectedItem = treeView.getSelection();
+
+        provider.setList(files);
+        provider.refresh();
+        celltable.redrawHeaders();
+       }
 
-       
        /**
         * Does the list contains the requested filename
         *
@@ -763,7 +656,7 @@ public class FileList extends Composite {
        }
 
        public void clearSelectedRows() {
-               Iterator<FileResource> it = selectionModel.getSelectedSet().iterator();
+               Iterator<File> it = selectionModel.getSelectedSet().iterator();
                while(it.hasNext()){
                        selectionModel.setSelected(it.next(),false);
                }
@@ -774,7 +667,7 @@ public class FileList extends Composite {
         *
         */
        public void selectAllRows() {
-               Iterator<FileResource> it = provider.getList().iterator();
+               Iterator<File> it = provider.getList().iterator();
                while(it.hasNext()){
                        selectionModel.setSelected(it.next(),true);
                }
@@ -784,21 +677,21 @@ public class FileList extends Composite {
 
        
        private void sortFiles(final String sortingProperty, final boolean sortingType){
-               Collections.sort(files, new Comparator<FileResource>() {
+               Collections.sort(files, new Comparator<File>() {
 
             @Override
-            public int compare(FileResource arg0, FileResource arg1) {
+            public int compare(File arg0, File arg1) {
                     AbstractImagePrototype descPrototype = AbstractImagePrototype.create(images.desc());
                     AbstractImagePrototype ascPrototype = AbstractImagePrototype.create(images.asc());
                     if (sortingType){
                             if (sortingProperty.equals("version")) {
-                                    return arg0.getVersion().compareTo(arg1.getVersion());
+                                    return arg0.getVersion() - arg1.getVersion();
                             } else if (sortingProperty.equals("owner")) {
                                     return arg0.getOwner().compareTo(arg1.getOwner());
                             } else if (sortingProperty.equals("date")) {
-                                    return arg0.getModificationDate().compareTo(arg1.getModificationDate());
+                                    return arg0.getLastModified().compareTo(arg1.getLastModified());
                             } else if (sortingProperty.equals("size")) {
-                                    return arg0.getContentLength().compareTo(arg1.getContentLength());
+                                    return (int) (arg0.getBytes() - arg1.getBytes());
                             } else if (sortingProperty.equals("name")) {
                                     return arg0.getName().compareTo(arg1.getName());
                             } else if (sortingProperty.equals("path")) {
@@ -809,16 +702,15 @@ public class FileList extends Composite {
                     }
                     else if (sortingProperty.equals("version")) {
                             
-                            return arg1.getVersion().compareTo(arg0.getVersion());
+                            return arg1.getVersion() - arg0.getVersion();
                     } else if (sortingProperty.equals("owner")) {
                             
                             return arg1.getOwner().compareTo(arg0.getOwner());
                     } else if (sortingProperty.equals("date")) {
                             
-                            return arg1.getModificationDate().compareTo(arg0.getModificationDate());
+                            return arg1.getLastModified().compareTo(arg0.getLastModified());
                     } else if (sortingProperty.equals("size")) {
-                            
-                            return arg1.getContentLength().compareTo(arg0.getContentLength());
+                            return (int) (arg1.getBytes() - arg0.getBytes());
                     } else if (sortingProperty.equals("name")) {
                             
                             return arg1.getName().compareTo(arg0.getName());
@@ -861,96 +753,10 @@ public class FileList extends Composite {
                }
                
        }
-       /**
-        * Creates a new ArrayList<FileResources> from the given files ArrayList 
-        * in order that the input files remain untouched 
-        * and continues to find user's full names of each FileResource element
-        * in the new ArrayList
-        *    
-        * @param filesInput
-        */
-       private void copyListAndContinue(List<FileResource> filesInput){
-               List<FileResource> copiedFiles = new ArrayList<FileResource>();         
-               for(FileResource file : filesInput) {
-                       copiedFiles.add(file);
-               }
-               handleFullNames(copiedFiles);
-       }
-       
-       /**
-        * Examines whether or not the user's full name exists in the 
-        * userFullNameMap in the GSS.java for every element of the input list.
-        * If the user's full name does not exist in the map then a command is being made.  
-        * 
-        * @param filesInput
-        */
-       private void handleFullNames(List<FileResource> filesInput){            
-               if(filesInput.size() == 0){
-                       showCellTable();
-                       return;
-               }               
-
-               if(GSS.get().findUserFullName(filesInput.get(0).getOwner()) == null){
-                       findFullNameAndUpdate(filesInput);              
-                       return;
-               }
-                               
-               if(filesInput.size() >= 1){
-                       filesInput.remove(filesInput.get(0));
-                       if(filesInput.isEmpty()){
-                               showCellTable();                                
-                       }else{
-                               handleFullNames(filesInput);
-                       }
-               }               
-       }
-       
-       /**
-        * Makes a command to search for full name from a given username. 
-        * Only after the completion of the command the celltable is shown
-        * or the search for the next full name continues.
-        *  
-        * @param filesInput
-        */
-       private void findFullNameAndUpdate(final List<FileResource> filesInput){                
-               String aUserName = filesInput.get(0).getOwner();
-               String path = GSS.get().getApiPath() + "users/" + aUserName; 
 
-               GetCommand<UserSearchResource> gg = new GetCommand<UserSearchResource>(UserSearchResource.class, path, false,null) {
-                       @Override
-                       public void onComplete() {
-                               final UserSearchResource result = getResult();
-                               for (UserResource user : result.getUsers()){
-                                       String username = user.getUsername();
-                                       String userFullName = user.getName();
-                                       GSS.get().putUserToMap(username, userFullName);
-                                       if(filesInput.size() >= 1){
-                                               filesInput.remove(filesInput.get(0));
-                                               if(filesInput.isEmpty()){
-                                                       showCellTable();
-                                               }else{
-                                                       handleFullNames(filesInput);
-                                               }                                                                                               
-                                       }                                                                       
-                               }
-                       }
-                       @Override
-                       public void onError(Throwable t) {
-                               GWT.log("", t);
-                               GSS.get().displayError("Unable to fetch user's full name from the given username " + filesInput.get(0).getOwner());
-                               if(filesInput.size() >= 1){
-                                       filesInput.remove(filesInput.get(0));
-                                       handleFullNames(filesInput);                                    
-                               }
-                       }
-               };
-               DeferredCommand.addCommand(gg);
-       
-       }
        /**
         * Shows the files in the cellTable 
-        */
-
+     */
        private void showCellTable(){
                if(files.size()>GSS.VISIBLE_FILE_COUNT){
                        pagerBottom.setVisible(true);
@@ -960,10 +766,6 @@ public class FileList extends Composite {
                        pagerTop.setVisible(false);
                        pagerBottom.setVisible(false);
                }
-               RestResource selectedItem = GSS.get().getTreeView().getSelection();
-               boolean uploadVisible = !(selectedItem != null && (selectedItem instanceof TrashResource || selectedItem instanceof TrashFolderResource || selectedItem instanceof SharedResource || selectedItem instanceof OthersResource || selectedItem instanceof OtherUserResource));
-               uploadButtonBottom.setVisible(uploadVisible&&files.size()>=GSS.VISIBLE_FILE_COUNT);
-               uploadButtonTop.setVisible(uploadVisible&&files.size()>=GSS.VISIBLE_FILE_COUNT);
                provider.setList(files);
                
                provider.refresh();
@@ -971,6 +773,4 @@ public class FileList extends Composite {
                //celltable.redraw();
                celltable.redrawHeaders();              
        }
-
-       
 }
index 071544f..8cbb424 100644 (file)
@@ -139,10 +139,7 @@ public class FileMenu extends PopupPanel implements ClickHandler {
        public String getDownloadURL(FileResource file) {
                GSS app = GSS.get();
                if (file != null) {
-                       String dateString = RestCommand.getDate();
-                       String resource = file.getUri().substring(app.getApiPath().length()-1,file.getUri().length());
-                       String sig = app.getCurrentUserResource().getUsername()+" "+RestCommand.calculateSig("GET", dateString, resource, RestCommand.base64decode(app.getToken()));
-                       return file.getUri() + "?Authorization=" + URL.encodeComponent(sig) + "&Date="+URL.encodeComponent(dateString);
+                       return file.getUri();
                }
                return "";
        }
index 568f6a1..c3e678d 100644 (file)
@@ -8,9 +8,14 @@ import com.google.gwt.core.client.Scheduler.ScheduledCommand;
 import com.google.gwt.user.client.ui.DockPanel;
 import com.google.gwt.user.client.ui.HasVerticalAlignment;
 import com.google.gwt.view.client.ListDataProvider;
+import com.google.gwt.view.client.SelectionChangeEvent;
+import com.google.gwt.view.client.SelectionChangeEvent.Handler;
+import com.google.gwt.view.client.SingleSelectionModel;
+import com.google.gwt.view.client.TreeViewModel.NodeInfo;
 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;
 import gr.grnet.pithos.web.client.foldertree.Folder;
 import gr.grnet.pithos.web.client.foldertree.FolderTreeView;
 import gr.grnet.pithos.web.client.foldertree.FolderTreeViewModel;
@@ -55,6 +60,7 @@ import com.google.gwt.user.client.ui.HorizontalSplitPanel;
 import com.google.gwt.user.client.ui.RootPanel;
 import com.google.gwt.user.client.ui.TabPanel;
 import com.google.gwt.user.client.ui.VerticalPanel;
+import java.util.Set;
 
 /**
  * Entry point classes define <code>onModuleLoad()</code>.
@@ -195,9 +201,9 @@ public class GSS implements EntryPoint, ResizeHandler {
      */
     private String token;
 
-    private FolderTreeViewModel folderTreeViewModel = new FolderTreeViewModel();
-
-    private FolderTreeView folderTreeView = new FolderTreeView(folderTreeViewModel);
+    private SingleSelectionModel<Folder> folderTreeSelectionModel;
+    private FolderTreeViewModel folderTreeViewModel;
+    private FolderTreeView folderTreeView;
 
     private AccountResource account;
 
@@ -217,17 +223,14 @@ public class GSS implements EntryPoint, ResizeHandler {
         messagePanel.setWidth("100%");
         messagePanel.setVisible(false);
 
-        fileList = new FileList(images);
 
         // Inner contains the various lists.
         inner.sinkEvents(Event.ONCONTEXTMENU);
         inner.setAnimationEnabled(true);
         inner.getTabBar().addStyleName("pithos-MainTabBar");
         inner.getDeckPanel().addStyleName("pithos-MainTabPanelBottom");
-        inner.add(fileList, createHeaderHTML(AbstractImagePrototype.create(images.folders()), "Files"), true);
 
         inner.setWidth("100%");
-        inner.selectTab(0);
 
         inner.addSelectionHandler(new SelectionHandler<Integer>() {
 
@@ -242,6 +245,21 @@ public class GSS implements EntryPoint, ResizeHandler {
             }
         });
 
+        folderTreeSelectionModel = new SingleSelectionModel<Folder>();
+        folderTreeSelectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
+            @Override
+            public void onSelectionChange(SelectionChangeEvent event) {
+                Folder f = folderTreeSelectionModel.getSelectedObject();
+                showFiles(f);
+            }
+        });
+
+        folderTreeViewModel = new FolderTreeViewModel(folderTreeSelectionModel);
+        folderTreeView = new FolderTreeView(folderTreeViewModel);
+
+        fileList = new FileList(images, folderTreeView);
+        inner.add(fileList, createHeaderHTML(AbstractImagePrototype.create(images.folders()), "Files"), true);
+
         // Add the left and right panels to the split panel.
         splitPanel.setLeftWidget(folderTreeView);
         splitPanel.setRightWidget(inner);
@@ -290,7 +308,13 @@ public class GSS implements EntryPoint, ResizeHandler {
         });
     }
 
-       /**
+    private void showFiles(Folder f) {
+        Set<File> files = f.getFiles();
+        fileList.setFiles(new ArrayList<File>(files));
+        inner.selectTab(0);
+    }
+
+    /**
         * Parse and store the user credentials to the appropriate fields.
         */
        private boolean parseUserCredentials() {
@@ -322,7 +346,7 @@ public class GSS implements EntryPoint, ResizeHandler {
                Configuration conf = (Configuration) GWT.create(Configuration.class);
 
 //        Window.Location.assign(GWT.getModuleBaseURL() + conf.loginUrl() + "?next=" + Window.Location.getHref());
-        Cookies.setCookie(conf.authCookie(), "demo" + conf.cookieSeparator() + "0000");
+        Cookies.setCookie(conf.authCookie(), "test" + conf.cookieSeparator() + "0000");
         Window.Location.assign(GWT.getModuleBaseURL() + "GSS.html");
        }
 
@@ -335,6 +359,7 @@ public class GSS implements EntryPoint, ResizeHandler {
                 account = result;
                 statusPanel.displayStats(account);
                 folderTreeViewModel.initialize(account);
+                inner.selectTab(0);
             }
 
             @Override
@@ -346,7 +371,7 @@ public class GSS implements EntryPoint, ResizeHandler {
                     GSS.get().displayError("System error fetching user data: " + t.getMessage());
             }
         };
-
+        getAccount.setHeader("X-Auth-Token", token);
         Scheduler.get().scheduleDeferred(getAccount);
     }
 
@@ -410,21 +435,6 @@ public class GSS implements EntryPoint, ResizeHandler {
        }
 
        /**
-        * Make the user list visible.
-        */
-       public void showUserList() {
-               inner.selectTab(1);
-       }
-
-       /**
-        * Make the file list visible.
-        */
-       public void showFileList() {
-               fileList.updateFileCache(true /*clear selection*/);
-               inner.selectTab(0);
-       }
-
-       /**
         * Make the file list visible.
         *
         * @param update
@@ -453,24 +463,8 @@ public class GSS implements EntryPoint, ResizeHandler {
                        if (currentFolder instanceof RestResourceWrapper) {
                                RestResourceWrapper folder = (RestResourceWrapper) currentFolder;
                                files = folder.getResource().getFiles();
-                       } else if (currentFolder instanceof TrashResource) {
-                               TrashResource folder = (TrashResource) currentFolder;
-                               files = folder.getFiles();
-                       }
-                       else if (currentFolder instanceof SharedResource) {
-                               SharedResource folder = (SharedResource) currentFolder;
-                               files = folder.getFiles();
-                       }
-                       else if (currentFolder instanceof OtherUserResource) {
-                               OtherUserResource folder = (OtherUserResource) currentFolder;
-                               files = folder.getFiles();
                        }
-                       if (files != null)
-                               getFileList().setFiles(files);
-                       else
-                               getFileList().setFiles(new ArrayList<FileResource>());
                }
-               fileList.updateFileCache(clearSelection /*clear selection*/);
                inner.selectTab(0);
        }
 
index 79141f1..7cf2756 100644 (file)
@@ -158,7 +158,7 @@ public class StatusPanel extends Composite {
                 GWT.log("ERR", t);
             }
         };
-
+        getAccount.setHeader("X-Auth-Token", app.getToken());
         Scheduler.get().scheduleDeferred(getAccount);
        }
 
index 8894514..cfd8049 100644 (file)
@@ -4,5 +4,125 @@
 
 package gr.grnet.pithos.web.client.foldertree;
 
-public class File {
+import com.google.gwt.i18n.client.NumberFormat;
+import com.google.gwt.json.client.JSONObject;
+import java.util.Date;
+
+public class File extends Resource {
+    private String name;
+
+    private String hash;
+
+    private int version;
+
+    private long bytes;
+
+    private String contentType;
+
+    private Date lastModified;
+
+    private String modifiedBy;
+
+    private Date versionTimestamp;
+
+    private String path;
+
+    private String owner;
+
+    private boolean inTrash;
+
+    public String getContentType() {
+        return contentType;
+    }
+
+    public String getHash() {
+        return hash;
+    }
+
+    public Date getLastModified() {
+        return lastModified;
+    }
+
+    public String getModifiedBy() {
+        return modifiedBy;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public int getVersion() {
+        return version;
+    }
+
+    public Date getVersionTimestamp() {
+        return versionTimestamp;
+    }
+
+    @Override
+    public String getLastModifiedSince() {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public String getUri() {
+        return path + "/" + name;
+    }
+
+    public String getOwner() {
+        return owner;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public long getBytes() {
+        return bytes;
+    }
+
+    public String getSizeAsString() {
+        NumberFormat nf = NumberFormat.getFormat("######.#");
+        if (bytes < 1024)
+            return String.valueOf(bytes) + " B";
+        else if (bytes < 1024 * 1024)
+            return nf.format(Double.valueOf(bytes)/(1024)) + " KB";
+        else if (bytes < 1024 * 1024 * 1024)
+            return nf.format(Double.valueOf(bytes)/(1024 * 1024)) + " MB";
+        return nf.format(Double.valueOf(bytes)/(1024 * 1024 * 1024)) + " GB";
+    }
+
+    public boolean isShared() {
+        return false;
+    }
+
+    public boolean isInTrash() {
+        return inTrash;
+    }
+
+    public void populate(JSONObject o) {
+        String path = unmarshallString(o, "name");
+        if (path.contains("/"))
+            name = path.substring(path.lastIndexOf("/") + 1, path.length()); //strip the prefix
+        else
+            name = path;
+        hash = unmarshallString(o, "hash");
+        bytes = unmarshallLong(o, "bytes");
+        version = unmarshallInt(o, "version");
+        contentType = unmarshallString(o, "content_type");
+        lastModified = unmarshallDate(o, "last_modified");
+        modifiedBy = unmarshallString(o, "modified_by");
+        versionTimestamp = unmarshallDate(o, "version_timestamp");
+    }
+
+    public boolean equals(Object other) {
+        if (other instanceof File) {
+            File o = (File) other;
+            return name.equals(o.getName());
+        }
+        return false;
+    }
+
+    public int hashCode() {
+        return name.hashCode();
+    }
 }
index 73224e2..e58e894 100644 (file)
@@ -11,8 +11,10 @@ import com.google.gwt.json.client.JSONArray;
 import com.google.gwt.json.client.JSONObject;
 import com.google.gwt.json.client.JSONParser;
 import com.google.gwt.json.client.JSONValue;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.LinkedHashSet;
+import java.util.List;
 import java.util.Set;
 
 public class Folder extends Resource {
@@ -38,6 +40,8 @@ public class Folder extends Resource {
      */
     private String prefix = "";
 
+    private Set<File> files = new LinkedHashSet<File>();
+
     public Folder() {};
 
     public Folder(String name) {
@@ -102,7 +106,9 @@ public class Folder extends Resource {
                         subfolders.add(f);
                     }
                     else {
-                        // add file
+                        File file = new File();
+                        file.populate(o);
+                        files.add(file);
                     }
                 }
             }
@@ -166,4 +172,8 @@ public class Folder extends Resource {
     public int hashCode() {
         return prefix.hashCode() + name.hashCode();
     }
+
+    public Set<File> getFiles() {
+        return files;
+    }
 }
index 12fc4f7..cef6baa 100644 (file)
@@ -87,4 +87,8 @@ public class FolderTreeView extends Composite {
         sinkEvents(Event.ONMOUSEUP);
         initWidget(tree);
     }
+
+    public Folder getSelection() {
+       return model.getSelection();
+    }
 }
index fcf9655..d9ea587 100644 (file)
@@ -21,24 +21,12 @@ import java.util.Set;
 
 public class FolderTreeViewModel implements TreeViewModel {
 
-    private SingleSelectionModel<Folder> selectionModel = new SingleSelectionModel<Folder>();
-
     private ListDataProvider<Folder> rootDataProvider = new ListDataProvider<Folder>();
 
-    public FolderTreeViewModel() {
-        Handler selectionHandler = new SelectionChangeEvent.Handler() {
-            @Override
-            public void onSelectionChange(SelectionChangeEvent event) {
-                NodeInfo<Folder> nodeInfo = (NodeInfo<Folder>) getNodeInfo(selectionModel.getSelectedObject());
-                if(nodeInfo == null || nodeInfo.getValueUpdater() == null) {
-//                    GSS.get().showFileList(selectionModel.getSelectedObject());
-                }
-                else
-                    nodeInfo.getValueUpdater().update(selectionModel.getSelectedObject());
-                GSS.get().setCurrentSelection(selectionModel.getSelectedObject());
-            }
-        };
-        selectionModel.addSelectionChangeHandler(selectionHandler);
+    private SingleSelectionModel<Folder> selectionModel;
+
+    public FolderTreeViewModel(SingleSelectionModel<Folder> selectionModel) {
+        this.selectionModel = selectionModel;
     }
 
     @Override
@@ -73,6 +61,7 @@ public class FolderTreeViewModel implements TreeViewModel {
                                 GSS.get().displayError("System error fetching folder: " + t.getMessage());
                         }
                     };
+                    getFolder.setHeader("X-Auth-Token", app.getToken());
                     Scheduler.get().scheduleDeferred(getFolder);
                 }
             });
@@ -110,11 +99,14 @@ public class FolderTreeViewModel implements TreeViewModel {
                         GSS.get().displayError("System error fetching folder: " + t.getMessage());
                 }
             };
+            getFolder.setHeader("X-Auth-Token", app.getToken());
             Scheduler.get().scheduleDeferred(getFolder);
         }
         else {
             dataProvider.getList().clear();
             dataProvider.getList().addAll(folders);
+            if (dataProvider.equals(rootDataProvider))
+                selectionModel.setSelected(dataProvider.getList().get(0), true);
         }
     }
 
@@ -122,4 +114,8 @@ public class FolderTreeViewModel implements TreeViewModel {
         Iterator<Folder> iter = account.getContainers().iterator();
         fetchFolder(iter, rootDataProvider, account.getContainers());
     }
+
+    public Folder getSelection() {
+        return selectionModel.getSelectedObject();
+    }
 }
diff --git a/src/gr/grnet/pithos/web/client/foldertree/GssCellTable.css b/src/gr/grnet/pithos/web/client/foldertree/GssCellTable.css
new file mode 100644 (file)
index 0000000..0496d77
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2010 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+/* Incremental changes from CellTable.css */ 
+.cellTableFooter {
+  padding: 3px 9px;
+}
+
+.cellTableHeader {
+  /*padding: 3px 9px;*/
+  border:none;
+       background-color: #E0EDFE;
+       font-weight: bold;
+       cursor: pointer;
+}
+
+.cellTableCell {
+  padding: 4px 9px;
+  border-width: 0;
+}
+
+.cellTableFirstColumn {
+  padding: 0px;
+}
+
+.cellTableLastColumn {
+  padding: 0px;
+}
+
+.cellTableFirstColumnFooter {
+  border: 0px;
+  padding: 0px;
+}
+
+.cellTableFirstColumnHeader {
+  border: 0px;
+  padding: 0px;
+}
+
+.cellTableLastColumnFooter {
+  border: 0px;
+  padding: 0px;
+}
+
+.cellTableLastColumnHeader {
+  border: 0px;
+  padding: 0px;
+}
+
+.cellTableEvenRow {
+  cursor: hand;
+  cursor: pointer;
+}
+
+.cellTableOddRow {
+  cursor: hand;
+  cursor: pointer;
+}
+
+.cellTableSelectedRow {
+  background: #628cd5;
+  color: white;
+  height: auto;
+  overflow: auto;
+}
+
+ .cellTableHoveredRow {
+  
+  /*background-color: #E0EDFE;
+  color: white;
+  height: auto;
+  overflow: auto;*/
+}
\ No newline at end of file