Initial version of the new left pane (issue #2318)
authorChristos Stathis <chstath@ebs.gr>
Wed, 18 Apr 2012 15:29:48 +0000 (18:29 +0300)
committerChristos Stathis <chstath@ebs.gr>
Wed, 18 Apr 2012 15:29:48 +0000 (18:29 +0300)
src/gr/grnet/pithos/web/Pithos.gwt.xml
src/gr/grnet/pithos/web/client/Pithos.java
src/gr/grnet/pithos/web/client/PithosDisclosurePanel.css [new file with mode: 0644]
src/gr/grnet/pithos/web/client/PithosDisclosurePanel.java [new file with mode: 0644]
src/gr/grnet/pithos/web/client/foldertree/FolderTreeView.java
src/gr/grnet/pithos/web/client/grouptree/GroupTreeView.java
src/gr/grnet/pithos/web/client/mysharedtree/MysharedTreeView.java
src/gr/grnet/pithos/web/client/othersharedtree/OtherSharedTreeView.java

index bff8fd7..bbe984a 100644 (file)
@@ -38,6 +38,7 @@
     <inherits name="com.google.gwt.user.theme.standard.Standard"/>
        <inherits name="com.google.gwt.http.HTTP"/>
        <inherits name="com.google.gwt.json.JSON"/>
+       <inherits name="com.google.gwt.resources.Resources"/>
 
     <entry-point class='gr.grnet.pithos.web.client.Pithos' />
        <stylesheet src='pithos.css' />
index 522e111..b39939b 100644 (file)
@@ -1179,7 +1179,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
                        @Override
                        public void execute() {
                            otherSharedTreeView = new OtherSharedTreeView(otherSharedTreeViewModel);
-                               trees.insert(otherSharedTreeView, 3);
+                               trees.insert(otherSharedTreeView, 2);
                                treeViews.add(otherSharedTreeView);
                        }
                });
diff --git a/src/gr/grnet/pithos/web/client/PithosDisclosurePanel.css b/src/gr/grnet/pithos/web/client/PithosDisclosurePanel.css
new file mode 100644 (file)
index 0000000..f6778cb
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright 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
+ * conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials
+ *      provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and
+ * documentation are those of the authors and should not be
+ * interpreted as representing official policies, either expressed
+ * or implied, of GRNET S.A.
+ */
+.disclosurePanel {
+       padding-left: 10px;
+}
diff --git a/src/gr/grnet/pithos/web/client/PithosDisclosurePanel.java b/src/gr/grnet/pithos/web/client/PithosDisclosurePanel.java
new file mode 100644 (file)
index 0000000..bdfa793
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * Copyright 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
+ * conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials
+ *      provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and
+ * documentation are those of the authors and should not be
+ * interpreted as representing official policies, either expressed
+ * or implied, of GRNET S.A.
+ */
+
+package gr.grnet.pithos.web.client;
+
+import gr.grnet.pithos.web.client.grouptree.GroupTreeView;
+import gr.grnet.pithos.web.client.grouptree.GroupTreeView.Templates;
+
+import com.google.gwt.dom.client.Style;
+import com.google.gwt.event.logical.shared.CloseEvent;
+import com.google.gwt.event.logical.shared.CloseHandler;
+import com.google.gwt.event.logical.shared.OpenEvent;
+import com.google.gwt.event.logical.shared.OpenHandler;
+import com.google.gwt.resources.client.ClientBundle;
+import com.google.gwt.resources.client.CssResource;
+import com.google.gwt.resources.client.ImageResource;
+import com.google.gwt.resources.client.CssResource.ImportedWithPrefix;
+import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
+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.IsWidget;
+
+public class PithosDisclosurePanel extends Composite {
+
+       public interface Style extends CssResource {
+               String disclosurePanel();
+       }
+       
+       public interface Resources extends ClientBundle {
+               @Source("PithosDisclosurePanel.css")
+               Style pithosDisclosurePanelCss();
+               
+               @Source("upArrow.png")
+               ImageResource icon();
+               
+               @Source("upArrow.png")
+               ImageResource open();
+               
+               @Source("downArrow.png")
+               ImageResource closed();
+       }
+       
+       DisclosurePanel panel;
+       
+       public PithosDisclosurePanel(final Resources resources, final String title, boolean open) {
+               resources.pithosDisclosurePanelCss().ensureInjected();
+               panel = new DisclosurePanel();
+               panel.addStyleName(resources.pithosDisclosurePanelCss().disclosurePanel());
+               panel.setHeader(createHeader(resources, title, open));
+               panel.setOpen(open);
+               panel.setAnimationEnabled(true);
+               panel.addOpenHandler(new OpenHandler<DisclosurePanel>() {
+                       
+                       @Override
+                       public void onOpen(OpenEvent<DisclosurePanel> event) {
+                               panel.setHeader(createHeader(resources, title, true));
+                       }
+               });
+               panel.addCloseHandler(new CloseHandler<DisclosurePanel>() {
+                       
+                       @Override
+                       public void onClose(CloseEvent<DisclosurePanel> event) {
+                               panel.setHeader(createHeader(resources, title, false));
+                       }
+               });
+               initWidget(panel);
+       }
+       
+       HTML createHeader(Resources resources, String title, boolean open) {
+        SafeHtmlBuilder sb = new SafeHtmlBuilder();
+        sb.appendHtmlConstant(AbstractImagePrototype.create(resources.icon()).getHTML()).appendHtmlConstant("&nbsp;");
+        sb.append(Templates.INSTANCE.nameSpan(title));
+        sb.appendHtmlConstant(AbstractImagePrototype.create(open ? resources.open() : resources.closed()).getHTML());
+        return new HTML(sb.toSafeHtml());
+       }
+       
+       public void add(IsWidget widget) {
+               panel.add(widget);
+       }
+}
index 08d9e74..cd08416 100644 (file)
@@ -36,6 +36,7 @@
 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 com.google.gwt.core.client.GWT;
@@ -72,7 +73,7 @@ public class FolderTreeView extends Composite implements TreeView {
        }
        
     public void openFolder(Folder folder) {
-        TreeNode root = ((CellTree) getWidget()).getRootTreeNode();
+        TreeNode root = tree.getRootTreeNode();
         openFolder(root, folder);
     }
 
@@ -153,20 +154,32 @@ public class FolderTreeView extends Composite implements TreeView {
         public SafeHtml imageSpan(String name);
     }
 
+    interface Resources extends gr.grnet.pithos.web.client.PithosDisclosurePanel.Resources {
+       @Override
+               @Source("gr/grnet/pithos/resources/home22.png")
+       ImageResource icon();
+    }
+
     private FolderTreeViewModel model;
+    
+    private CellTree tree;
 
     public FolderTreeView(FolderTreeViewModel viewModel) {
         this.model = viewModel;
+
+        PithosDisclosurePanel panel = new PithosDisclosurePanel((Resources) GWT.create(Resources.class), "My Files", true);
+
         /*
          * 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);
     }
 
 
index e0cb5cf..f2b58fd 100644 (file)
@@ -36,6 +36,7 @@
 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.foldertree.Folder;
 
@@ -50,6 +51,8 @@ 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 implements TreeView {
@@ -118,8 +121,14 @@ public class GroupTreeView extends Composite implements TreeView {
     }
 
     static Images images = GWT.create(Images.class);
+    
+    interface Resources extends gr.grnet.pithos.web.client.PithosDisclosurePanel.Resources {
+       @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>")
@@ -130,6 +139,8 @@ public class GroupTreeView extends Composite implements TreeView {
 
     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
@@ -139,7 +150,9 @@ public class GroupTreeView extends Composite implements TreeView {
         CellTree tree = new CellTree(model, null, res);
         tree.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
 
-        initWidget(tree);
+        panel.add(tree);
+        
+        initWidget(panel);
     }
 
     public void updateGroupNode(Group group) {
index b0c9476..e2fdeed 100644 (file)
 package gr.grnet.pithos.web.client.mysharedtree;
 
 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.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;
@@ -130,10 +130,18 @@ public class MysharedTreeView extends Composite implements TreeView {
         public SafeHtml nameSpan(String name);
       }
 
+    interface Resources extends gr.grnet.pithos.web.client.PithosDisclosurePanel.Resources {
+       @Override
+               @Source("gr/grnet/pithos/resources/myshared22.png")
+       ImageResource icon();
+    }
+
     private MysharedTreeViewModel model;
 
     public MysharedTreeView(MysharedTreeViewModel viewModel) {
         this.model = viewModel;
+        
+        PithosDisclosurePanel panel = new PithosDisclosurePanel((Resources) GWT.create(Resources.class), "Shared by me", 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
@@ -143,7 +151,8 @@ public class MysharedTreeView extends Composite implements TreeView {
         CellTree tree = new CellTree(model, null, res);
         tree.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
 
-        initWidget(tree);
+        panel.add(tree);
+        initWidget(panel);
     }
 
 
index 739ce18..02174ed 100644 (file)
@@ -36,6 +36,7 @@
 package gr.grnet.pithos.web.client.othersharedtree;
 
 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.foldertree.Folder;
 
@@ -133,10 +134,18 @@ public class OtherSharedTreeView extends Composite implements TreeView {
         public SafeHtml nameSpan(String name);
       }
 
+    interface Resources extends gr.grnet.pithos.web.client.PithosDisclosurePanel.Resources {
+       @Override
+               @Source("gr/grnet/pithos/resources/othersshared.png")
+       ImageResource icon();
+    }
+
     private OtherSharedTreeViewModel model;
 
     public OtherSharedTreeView(OtherSharedTreeViewModel viewModel) {
         this.model = viewModel;
+        
+        PithosDisclosurePanel panel = new PithosDisclosurePanel((Resources) GWT.create(Resources.class), "Shared to me", 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
@@ -146,7 +155,8 @@ public class OtherSharedTreeView extends Composite implements TreeView {
         CellTree tree = new CellTree(model, null, res);
         tree.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
 
-        initWidget(tree);
+        panel.add(tree);
+        initWidget(panel);
     }