Finished new left pane
[pithos-web-client] / src / gr / grnet / pithos / web / client / grouptree / GroupTreeView.java
index aafacfc..c013e6b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 GRNET S.A. All rights reserved.
+ * Copyright 2011-2012 GRNET S.A. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or
  * without modification, are permitted provided that the following
 package gr.grnet.pithos.web.client.grouptree;
 
 import gr.grnet.pithos.web.client.FolderContextMenu;
+import gr.grnet.pithos.web.client.PithosDisclosurePanel;
+import gr.grnet.pithos.web.client.TreeView;
+import gr.grnet.pithos.web.client.PithosDisclosurePanel.Style;
+import gr.grnet.pithos.web.client.foldertree.Folder;
 
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.resources.client.ImageResource;
+import com.google.gwt.resources.client.ClientBundle.Source;
 import com.google.gwt.resources.client.ImageResource.ImageOptions;
+import com.google.gwt.resources.client.ImageResource.RepeatStyle;
 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.ui.Composite;
+import com.google.gwt.user.client.ui.DisclosurePanel;
+import com.google.gwt.user.client.ui.HTML;
 import com.google.gwt.user.client.ui.Tree;
 
-public class GroupTreeView extends Composite {
+public class GroupTreeView extends Composite implements TreeView {
 
     public void updateChildren(Group group) {
-        TreeNode root = ((CellTree) getWidget()).getRootTreeNode();
+        TreeNode root = tree.getRootTreeNode();
         if (group != null)
                updateChildren(root, group);
         else {
@@ -79,7 +87,7 @@ public class GroupTreeView extends Composite {
 
         @Override
                @ImageOptions(flipRtl = true)
-        @Source("gr/grnet/pithos/web/client/cellTreeClosedItem.gif")
+        @Source("gr/grnet/pithos/web/client/cellTreeClosedItem.png")
         ImageResource cellTreeClosedItem();
 
         @Override
@@ -89,20 +97,24 @@ public class GroupTreeView extends Composite {
 
         @Override
                @ImageOptions(flipRtl = true)
-        @Source("gr/grnet/pithos/web/client/cellTreeOpenItem.gif")
+        @Source("gr/grnet/pithos/web/client/cellTreeOpenItem.png")
         ImageResource cellTreeOpenItem();
 
         @Override
-               @Source({"gr/grnet/pithos/web/client/GssCellTreeBasic.css"})
+               @Source({"gr/grnet/pithos/web/client/PithosCellTreeBasic.css"})
         CellTree.Style cellTreeStyle();
+        
+        @Source("gr/grnet/pithos/web/client/cellTreeLoadingBasic.gif")
+        @ImageOptions(repeatStyle=RepeatStyle.None)
+        ImageResource cellTreeLoadingBasic();
     }
 
     public static interface Images extends Tree.Resources, FolderContextMenu.Images {
 
-        @Source("gr/grnet/pithos/resources/groupevent.png")
+        @Source("gr/grnet/pithos/resources/groups22.png")
         ImageResource groups();
 
-        @Source("gr/grnet/pithos/resources/group.png")
+        @Source("gr/grnet/pithos/resources/groups22.png")
         public ImageResource group();
 
         @Source("gr/grnet/pithos/resources/edit_user.png")
@@ -110,32 +122,63 @@ public class GroupTreeView extends Composite {
     }
 
     static Images images = GWT.create(Images.class);
+    
+    interface Style extends gr.grnet.pithos.web.client.PithosDisclosurePanel.Style {
+       @Override
+               String header();
+    }
+    interface Resources extends gr.grnet.pithos.web.client.PithosDisclosurePanel.Resources {
+               @Override
+               @Source("PithosGroupDisclosurePanel.css")
+               Style pithosDisclosurePanelCss();
+
+               @Override
+               @Source("gr/grnet/pithos/resources/groups22.png")
+       ImageResource icon();
+    }
 
-    static interface Templates extends SafeHtmlTemplates {
+    public static interface Templates extends SafeHtmlTemplates {
         public Templates INSTANCE = GWT.create(Templates.class);
 
-        @Template("<span>{0}</span>")
+        @Template("<span style='margin-left:5px;'>{0}</span>")
         public SafeHtml nameSpan(String name);
       }
 
     private GroupTreeViewModel model;
+    
+    private CellTree tree;
 
     public GroupTreeView(GroupTreeViewModel viewModel) {
         this.model = viewModel;
+
+        PithosDisclosurePanel panel = new PithosDisclosurePanel((Resources) GWT.create(Resources.class), "Groups", false);
         /*
          * Create the tree using the model. We use <code>null</code> as the default
          * value of the root node. The default value will be passed to
          * CustomTreeModel#getNodeInfo();
          */
         CellTree.Resources res = GWT.create(BasicResources.class);
-        CellTree tree = new CellTree(model, null, res);
+        tree = new CellTree(model, null, res);
         tree.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
 
-        initWidget(tree);
+        panel.add(tree);
+        
+        initWidget(panel);
     }
 
     public void updateGroupNode(Group group) {
        model.updateGroupNode(group);
        updateChildren(group);
     }
+
+       @Override
+       public Folder getSelection() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public Object getSelected() {
+               return model.getSelectedObject();
+       }
 }