Empty trash feature (still buggy
[pithos-web-client] / src / gr / grnet / pithos / web / client / foldertree / FolderTreeView.java
index a70a4a1..733779c 100644 (file)
 package gr.grnet.pithos.web.client.foldertree;
 
 import com.google.gwt.core.client.GWT;
-import com.google.gwt.resources.client.ClientBundle;
 import com.google.gwt.resources.client.ImageResource;
 import com.google.gwt.resources.client.ImageResource.ImageOptions;
 import com.google.gwt.safehtml.client.SafeHtmlTemplates;
 import com.google.gwt.safehtml.shared.SafeHtml;
 import com.google.gwt.user.cellview.client.CellTree;
 import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy;
+import com.google.gwt.user.cellview.client.TreeNode;
+import com.google.gwt.user.client.Command;
 import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.Tree;
 import gr.grnet.pithos.web.client.FolderContextMenu;
 
 public class FolderTreeView extends Composite {
 
+    public void updateChildren(Folder folder) {
+        TreeNode root = ((CellTree) getWidget()).getRootTreeNode();
+        updateChildren(root, folder);
+    }
+
+    private void updateChildren(TreeNode node, Folder folder) {
+        for (int i=0; i<node.getChildCount(); i++) {
+            if (folder.equals(node.getChildValue(i))) {
+                node.setChildOpen(i, false, true);
+                node.setChildOpen(i, true, true);
+            }
+            else {
+                if (node.isChildOpen(i)) {
+                    TreeNode n = node.setChildOpen(i, true);
+                    updateChildren(n, folder);
+                }
+            }
+       }
+    }
+
     static interface BasicResources extends CellTree.Resources {
 
-        @ImageOptions(flipRtl = true)
-        @Source("cellTreeClosedItem.gif")
+        @Override
+               @ImageOptions(flipRtl = true)
+        @Source("gr/grnet/pithos/web/client/cellTreeClosedItem.gif")
         ImageResource cellTreeClosedItem();
 
-        @ImageOptions(flipRtl = true)
-        @Source("cellTreeLoadingBasic.gif")
+        @Override
+               @ImageOptions(flipRtl = true)
+        @Source("gr/grnet/pithos/web/client/cellTreeLoadingBasic.gif")
         ImageResource cellTreeLoading();
 
-        @ImageOptions(flipRtl = true)
-        @Source("cellTreeOpenItem.gif")
+        @Override
+               @ImageOptions(flipRtl = true)
+        @Source("gr/grnet/pithos/web/client/cellTreeOpenItem.gif")
         ImageResource cellTreeOpenItem();
 
-        @Source({"GssCellTreeBasic.css"})
+        @Override
+               @Source({"gr/grnet/pithos/web/client/GssCellTreeBasic.css"})
         CellTree.Style cellTreeStyle();
     }
 
-    static interface Images extends ClientBundle,Tree.Resources, FolderContextMenu.Images {
+    public static interface Images extends Tree.Resources, FolderContextMenu.Images {
 
         @Source("gr/grnet/pithos/resources/folder_home.png")
         ImageResource home();
 
-        @Source("gr/grnet/pithos/resources/folder_yellow.png")
+        @Source("gr/grnet/pithos/resources/2folder22.png")
         public ImageResource folderYellow();
+
+        @Source("gr/grnet/pithos/resources/mimetypes/document.png")
+        ImageResource document();
+
+        @Source("gr/grnet/pithos/resources/othersshared.png")
+        ImageResource othersShared();
+
+        @Source("gr/grnet/pithos/resources/myshared22.png")
+        ImageResource myShared();
+
+        @Source("gr/grnet/pithos/resources/folder_user.png")
+        ImageResource sharedFolder();
+
+        @Source("gr/grnet/pithos/resources/trash.png")
+        ImageResource trash();
     }
 
     static Images images = GWT.create(Images.class);
@@ -96,7 +136,6 @@ public class FolderTreeView extends Composite {
          */
         CellTree.Resources res = GWT.create(BasicResources.class);
         CellTree tree = new CellTree(model, null, res);
-
         tree.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
 
         initWidget(tree);
@@ -106,4 +145,8 @@ public class FolderTreeView extends Composite {
     public Folder getSelection() {
        return model.getSelection();
     }
+
+    public void updateFolder(Folder folder, boolean showfiles, Command callback) {
+        model.updateFolder(folder, showfiles, callback);
+    }
 }