My files section made expand/collapse-able (issue #2346)
authorChristos Stathis <chstath@ebs.gr>
Mon, 30 Apr 2012 16:04:15 +0000 (19:04 +0300)
committerChristos Stathis <chstath@ebs.gr>
Mon, 30 Apr 2012 16:04:15 +0000 (19:04 +0300)
src/gr/grnet/pithos/web/client/Pithos.java
src/gr/grnet/pithos/web/client/foldertree/FolderTreeView.java
src/gr/grnet/pithos/web/public/pithos.css

index efc25d5..00f6431 100644 (file)
@@ -251,12 +251,6 @@ public class Pithos implements EntryPoint, ResizeHandler {
     
     Button upload;
     
-    private HTML usedBytes;
-    
-    private HTML totalBytes;
-    
-    private HTML usedPercent;
-    
     private HTML numOfFiles;
     
     private Toolbar toolbar;
@@ -370,24 +364,6 @@ public class Pithos implements EntryPoint, ResizeHandler {
         
         trees.add(folderTreeView);
         
-        HorizontalPanel separator = new HorizontalPanel();
-        separator.addStyleName("pithos-statisticsSeparator");
-        trees.add(separator);
-        
-        HorizontalPanel statistics = new HorizontalPanel();
-           statistics.addStyleName("pithos-statistics");
-           statistics.add(new HTML("Used:&nbsp;"));
-           usedBytes = new HTML();
-           statistics.add(usedBytes);
-           statistics.add(new HTML("&nbsp;of&nbsp;"));
-           totalBytes = new HTML();
-           statistics.add(totalBytes);
-           statistics.add(new HTML("&nbsp;("));
-           usedPercent = new HTML();
-           statistics.add(usedPercent);
-           statistics.add(new HTML(")"));
-        trees.add(statistics);
-        
         // Add the left and right panels to the split panel.
         splitPanel.setLeftWidget(trees);
         splitPanel.setRightWidget(inner);
@@ -454,7 +430,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
                                    groupTreeView = new GroupTreeView(groupTreeViewModel);
                                    treeViews.add(groupTreeView);
                                    trees.add(groupTreeView);
-                                   showStatistics();
+                                   folderTreeView.showStatistics(account);
                                }
                                        }
                                });
@@ -593,7 +569,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
 
                        @Override
                        public void onSuccess(AccountResource _result) {
-                               showStatistics();
+                               folderTreeView.showStatistics(account);
                        }
 
                        @Override
@@ -615,13 +591,6 @@ public class Pithos implements EntryPoint, ResizeHandler {
                Scheduler.get().scheduleDeferred(headAccount);
        }
 
-       protected void showStatistics() {
-       usedBytes.setHTML(String.valueOf(account.getFileSizeAsString()));
-       totalBytes.setHTML(String.valueOf(account.getQuotaAsString()));
-       NumberFormat nf = NumberFormat.getPercentFormat();
-       usedPercent.setHTML(nf.format(account.getUsedPercentage()));
-       }
-
        protected void createHomeContainer(final AccountResource _account, final Command callback) {
         String path = "/" + Pithos.HOME_CONTAINER;
         PutRequest createPithos = new PutRequest(getApiPath(), getUsername(), path) {
@@ -1137,7 +1106,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
                        @Override
                        public void execute() {
                            mysharedTreeView = new MysharedTreeView(mysharedTreeViewModel);
-                               trees.insert(mysharedTreeView, 3);
+                               trees.insert(mysharedTreeView, 1);
                                treeViews.add(mysharedTreeView);
                                createOtherSharedTree();
                        }
@@ -1171,7 +1140,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
                        @Override
                        public void execute() {
                            otherSharedTreeView = new OtherSharedTreeView(otherSharedTreeViewModel);
-                               trees.insert(otherSharedTreeView, 3);
+                               trees.insert(otherSharedTreeView, 1);
                                treeViews.add(otherSharedTreeView);
                        }
                });
index 0c95e8a..2f86a37 100644 (file)
@@ -38,26 +38,21 @@ package gr.grnet.pithos.web.client.foldertree;
 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.grouptree.GroupTreeView.Templates;
 
 import com.google.gwt.core.client.GWT;
+import com.google.gwt.i18n.client.NumberFormat;
 import com.google.gwt.resources.client.ImageResource;
 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.safehtml.shared.SafeHtmlBuilder;
 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.AbstractImagePrototype;
 import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HasVerticalAlignment;
 import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Image;
 import com.google.gwt.user.client.ui.Tree;
 import com.google.gwt.user.client.ui.VerticalPanel;
 
@@ -169,32 +164,20 @@ public class FolderTreeView extends Composite implements TreeView {
     private FolderTreeViewModel model;
     
     private CellTree tree;
+    
+    private HTML usedBytes;
+    
+    private HTML totalBytes;
+    
+    private HTML usedPercent;
 
     public FolderTreeView(FolderTreeViewModel viewModel) {
         this.model = viewModel;
 
-        VerticalPanel panel = new VerticalPanel();
-        panel.addStyleName("pithos-folderTreeSection");
-        Resources resources = GWT.create(Resources.class);
-        
-        HorizontalPanel header = new HorizontalPanel();
-        
-//        SafeHtmlBuilder sb = new SafeHtmlBuilder();
-        Image img = new Image(resources.icon());
-        header.add(img);
-        header.setCellVerticalAlignment(img, HasVerticalAlignment.ALIGN_MIDDLE);
-        header.setCellWidth(img, "32px");
-        HTML title = new HTML("My Files");
-        header.add(title);
-        header.setCellVerticalAlignment(title, HasVerticalAlignment.ALIGN_MIDDLE);
-        
-//        sb.appendHtmlConstant(AbstractImagePrototype.create(resources.icon()).getHTML());
- //       sb.append(Templates.INSTANCE.nameSpan("My Files"));
-//        HTML header = new HTML(sb.toSafeHtml());
-        header.addStyleName("pithos-folderTreeSectionHeader");
-        panel.add(header);
-
+        PithosDisclosurePanel panel = new PithosDisclosurePanel((Resources) GWT.create(Resources.class), "My Files", true);
 
+        VerticalPanel content = new VerticalPanel();
+        
         /*
          * 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
@@ -203,9 +186,27 @@ public class FolderTreeView extends Composite implements TreeView {
         CellTree.Resources res = GWT.create(BasicResources.class);
         tree = new CellTree(model, null, res);
         tree.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
-        tree.addStyleName("pithos-folderTreeSectionContent");
-        panel.add(tree);
-        
+        content.add(tree);
+
+        HorizontalPanel separator = new HorizontalPanel();
+        separator.addStyleName("pithos-statisticsSeparator");
+        content.add(separator);
+
+        HorizontalPanel statistics = new HorizontalPanel();
+           statistics.addStyleName("pithos-statistics");
+           statistics.add(new HTML("Used:&nbsp;"));
+           usedBytes = new HTML();
+           statistics.add(usedBytes);
+           statistics.add(new HTML("&nbsp;of&nbsp;"));
+           totalBytes = new HTML();
+           statistics.add(totalBytes);
+           statistics.add(new HTML("&nbsp;("));
+           usedPercent = new HTML();
+           statistics.add(usedPercent);
+           statistics.add(new HTML(")"));
+           content.add(statistics);
+
+        panel.setContent(content);
         initWidget(panel);
     }
 
@@ -218,4 +219,11 @@ public class FolderTreeView extends Composite implements TreeView {
     public void updateFolder(Folder folder, boolean showfiles, Command callback, final boolean openParent) {
         model.updateFolder(folder, showfiles, callback, openParent);
     }
+    
+       public void showStatistics(AccountResource account) {
+       usedBytes.setHTML(String.valueOf(account.getFileSizeAsString()));
+       totalBytes.setHTML(String.valueOf(account.getQuotaAsString()));
+       NumberFormat nf = NumberFormat.getPercentFormat();
+       usedPercent.setHTML(nf.format(account.getUsedPercentage()));
+       }
 }
index afc6077..c36d903 100644 (file)
@@ -741,19 +741,3 @@ a.pithos-tag {
 .pithos-versionList {
        padding-right: 5px;
 }
-
-.pithos-folderTreeSection {
-       padding-left: 10px;
-       width:100%;
-}
-
-.pithos-folderTreeSectionHeader {
-       background-color: #74aec9;
-       height: 25px;
-    width: 100%;
-}
-
-.pithos-folderTreeSectionContent {
-       padding: 4px 0px 4px 8px;
-       margin-left: 6px;
-}
\ No newline at end of file