First version of client that displays first level containers
authorChristos Stathis <chstath@ebs.gr>
Fri, 17 Jun 2011 16:39:25 +0000 (19:39 +0300)
committerChristos Stathis <chstath@ebs.gr>
Fri, 17 Jun 2011 16:39:25 +0000 (19:39 +0300)
39 files changed:
web_client/build.xml
web_client/src/gr/grnet/pithos/web/client/CellTreeView.java
web_client/src/gr/grnet/pithos/web/client/Configuration.java
web_client/src/gr/grnet/pithos/web/client/Configuration.properties
web_client/src/gr/grnet/pithos/web/client/DeleteGroupDialog.java [deleted file]
web_client/src/gr/grnet/pithos/web/client/DeleteUserDialog.java [deleted file]
web_client/src/gr/grnet/pithos/web/client/EditMenu.java
web_client/src/gr/grnet/pithos/web/client/FileContextMenu.java
web_client/src/gr/grnet/pithos/web/client/GSS.java
web_client/src/gr/grnet/pithos/web/client/GroupContextMenu.java [deleted file]
web_client/src/gr/grnet/pithos/web/client/GroupMenu.java [deleted file]
web_client/src/gr/grnet/pithos/web/client/GroupPropertiesDialog.java [deleted file]
web_client/src/gr/grnet/pithos/web/client/Groups.java [deleted file]
web_client/src/gr/grnet/pithos/web/client/Search.java
web_client/src/gr/grnet/pithos/web/client/SearchResults.java [deleted file]
web_client/src/gr/grnet/pithos/web/client/TopPanel.java
web_client/src/gr/grnet/pithos/web/client/UserAddDialog.java [deleted file]
web_client/src/gr/grnet/pithos/web/client/commands/DeleteCommand.java
web_client/src/gr/grnet/pithos/web/client/commands/DeleteUserOrGroupCommand.java [deleted file]
web_client/src/gr/grnet/pithos/web/client/commands/NewGroupCommand.java [deleted file]
web_client/src/gr/grnet/pithos/web/client/commands/NewUserCommand.java [deleted file]
web_client/src/gr/grnet/pithos/web/client/commands/PasteCommand.java
web_client/src/gr/grnet/pithos/web/client/foldertree/AccountResource.java [new file with mode: 0644]
web_client/src/gr/grnet/pithos/web/client/foldertree/ContainerResource.java [new file with mode: 0644]
web_client/src/gr/grnet/pithos/web/client/foldertree/File.java [new file with mode: 0644]
web_client/src/gr/grnet/pithos/web/client/foldertree/Folder.java [new file with mode: 0644]
web_client/src/gr/grnet/pithos/web/client/foldertree/FolderTreeView.java [new file with mode: 0644]
web_client/src/gr/grnet/pithos/web/client/foldertree/FolderTreeViewModel.java [new file with mode: 0644]
web_client/src/gr/grnet/pithos/web/client/foldertree/GssCellTreeBasic.css [new file with mode: 0644]
web_client/src/gr/grnet/pithos/web/client/foldertree/ObjectResource.java [new file with mode: 0644]
web_client/src/gr/grnet/pithos/web/client/foldertree/Resource.java [new file with mode: 0644]
web_client/src/gr/grnet/pithos/web/client/foldertree/SubDirResource.java [new file with mode: 0644]
web_client/src/gr/grnet/pithos/web/client/foldertree/cellTreeClosedItem.gif [new file with mode: 0644]
web_client/src/gr/grnet/pithos/web/client/foldertree/cellTreeLoadingBasic.gif [new file with mode: 0644]
web_client/src/gr/grnet/pithos/web/client/foldertree/cellTreeOpenItem.gif [new file with mode: 0644]
web_client/src/gr/grnet/pithos/web/client/rest/GetRequest.java [new file with mode: 0644]
web_client/src/gr/grnet/pithos/web/client/rest/RestException.java
web_client/src/gr/grnet/pithos/web/client/rest/RestRequestCallback.java [new file with mode: 0644]
web_client/src/gr/grnet/pithos/web/client/rest/resource/RestResource.java

index fcc2b16..73234a9 100644 (file)
         <!--move file="${gwt.www.dir}/${gwt.module}/${gwt.module.class}.html" tofile="${gwt.www.dir}/${gwt.module}/index.html"/-->
        </target>
 
+    <target name="uploadToVM" depends="gwt-compile">
+        <scp todir="chstath@pithos.dev.grnet.gr:/var/www/pithos_web_client" keyfile="/home/chstath/.ssh/id_rsa" passphrase="r0bax45">
+            <fileset dir="${gwt.www.dir}/${gwt.module}"/>
+        </scp>
+    </target>
+
        <target name="clean" description="Delete all build artifacts">
                <delete dir="${build.dir}"/>
        </target>
             <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=55555"/>
             <arg value="-war"/>
             <arg value="${gwt.www.dir}/${gwt.module}"/>
+            <arg value="-noserver"/>
             <arg value="-startupUrl"/>
-            <arg value="GSS.html"/>
+            <arg value="http://127.0.0.1:8080/client/GSS.html"/>
             <arg value="${gwt.module}"/>
         </java>
     </target>
index 6bf1775..c91abe1 100644 (file)
@@ -375,7 +375,6 @@ public class CellTreeView extends Composite{
                                @Override
                                public void onComplete() {
                                        others = getResult();
-                                       GSS.get().removeGlassPanel();
                                }
 
                                @Override
index 5da52b4..003d80a 100644 (file)
@@ -46,7 +46,7 @@ public interface Configuration extends Constants {
        /**
         * @return the relative path of the API root URL
         */
-       @DefaultStringValue("rest/")
+       @DefaultStringValue("/v1/")
        String apiPath();
 
        /**
index a230d37..437de88 100644 (file)
@@ -7,5 +7,5 @@ loginUrl=pithos/login
 logoutUrl=/Shibboleth.sso/Logout
 authCookie=_pithos_a
 cookieSeparator=|
-apiPath=v1/
+apiPath=/v1/
 version=2.0
\ No newline at end of file
diff --git a/web_client/src/gr/grnet/pithos/web/client/DeleteGroupDialog.java b/web_client/src/gr/grnet/pithos/web/client/DeleteGroupDialog.java
deleted file mode 100644 (file)
index 6238381..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/*\r
- *  Copyright (c) 2011 Greek Research and Technology Network\r
- */\r
-package gr.grnet.pithos.web.client;\r
-\r
-import gr.grnet.pithos.web.client.MessagePanel.Images;\r
-import gr.grnet.pithos.web.client.rest.DeleteCommand;\r
-import gr.grnet.pithos.web.client.rest.RestException;\r
-import gr.grnet.pithos.web.client.rest.resource.GroupResource;\r
-\r
-import com.google.gwt.core.client.GWT;\r
-import com.google.gwt.dom.client.NativeEvent;\r
-import com.google.gwt.event.dom.client.ClickEvent;\r
-import com.google.gwt.event.dom.client.ClickHandler;\r
-import com.google.gwt.event.dom.client.KeyCodes;\r
-import com.google.gwt.user.client.DeferredCommand;\r
-import com.google.gwt.user.client.Event.NativePreviewEvent;\r
-import com.google.gwt.user.client.ui.AbstractImagePrototype;\r
-import com.google.gwt.user.client.ui.Button;\r
-import com.google.gwt.user.client.ui.DialogBox;\r
-import com.google.gwt.user.client.ui.HTML;\r
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;\r
-import com.google.gwt.user.client.ui.HorizontalPanel;\r
-import com.google.gwt.user.client.ui.TreeItem;\r
-import com.google.gwt.user.client.ui.VerticalPanel;\r
-\r
-/**\r
- * The 'delete group' dialog box.\r
- */\r
-public class DeleteGroupDialog extends DialogBox {\r
-\r
-       /**\r
-        * The widget's constructor.\r
-        * @param images the supplied images\r
-        */\r
-       public DeleteGroupDialog(final Images images) {\r
-               // Use this opportunity to set the dialog's caption.\r
-               setText("Delete group");\r
-               setAnimationEnabled(true);\r
-               final GroupResource group = (GroupResource) GSS.get().getCurrentSelection();\r
-               // Create a VerticalPanel to contain the 'about' label and the 'OK'\r
-               // button.\r
-               final VerticalPanel outer = new VerticalPanel();\r
-               final HorizontalPanel buttons = new HorizontalPanel();\r
-\r
-               // Create the 'about' text and set a style name so we can style it with\r
-               // CSS.\r
-               final HTML text = new HTML("<table><tr><td>" + AbstractImagePrototype.create(images.warn()).getHTML() + "</td><td>" + "Are you sure you want to delete group '" + group.getName() + "'?</td></tr></table>");\r
-               text.setStyleName("pithos-warnMessage");\r
-               outer.add(text);\r
-\r
-               // Create the 'Quit' button, along with a listener that hides the dialog\r
-               // when the button is clicked and quits the application.\r
-               final Button ok = new Button("OK", new ClickHandler() {\r
-                       @Override\r
-                       public void onClick(ClickEvent event) {\r
-                               deleteGroup();\r
-                               hide();\r
-                       }\r
-               });\r
-               ok.getElement().setId("deleteGroup.button.ok");\r
-               buttons.add(ok);\r
-               buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER);\r
-               // Create the 'Cancel' button, along with a listener that hides the\r
-               // dialog\r
-               // when the button is clicked.\r
-               final Button cancel = new Button("Cancel", new ClickHandler() {\r
-                       @Override\r
-                       public void onClick(ClickEvent event) {\r
-                               hide();\r
-                       }\r
-               });\r
-               cancel.getElement().setId("deleteGroup.button.cancel");\r
-               buttons.add(cancel);\r
-               buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);\r
-               buttons.setSpacing(8);\r
-               buttons.setStyleName("pithos-warnMessage");\r
-               outer.setStyleName("pithos-warnMessage");\r
-               outer.add(buttons);\r
-               outer.setCellHorizontalAlignment(text, HasHorizontalAlignment.ALIGN_CENTER);\r
-               outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);\r
-               setWidget(outer);\r
-       }\r
-\r
-       /**\r
-        * Generate an RPC request to delete a group.\r
-        *\r
-        * @param userId the ID of the current user\r
-        */\r
-       private void deleteGroup() {\r
-               final TreeItem group = GSS.get().getGroups().getCurrent();\r
-               if (group == null) {\r
-                       GSS.get().displayError("No group was selected!");\r
-                       return;\r
-               }\r
-               DeleteCommand dg = new DeleteCommand(((GroupResource)group.getUserObject()).getUri()){\r
-                       @Override\r
-                       public void onComplete() {\r
-                               GSS.get().getGroups().updateGroups();\r
-                       }\r
-\r
-                       @Override\r
-                       public void onError(Throwable t) {\r
-                               GWT.log("", t);\r
-                               if(t instanceof RestException){\r
-                                       int statusCode = ((RestException)t).getHttpStatusCode();\r
-                                       if(statusCode == 405)\r
-                                               GSS.get().displayError("You don't have the necessary permissions");\r
-                                       else if(statusCode == 404)\r
-                                               GSS.get().displayError("Group not found");\r
-                                       else\r
-                                               GSS.get().displayError("Unable to delete group:"+((RestException)t).getHttpStatusText());\r
-                               }\r
-                               else\r
-                                       GSS.get().displayError("System error unable to delete group:"+t.getMessage());\r
-                       }\r
-               };\r
-               DeferredCommand.addCommand(dg);\r
-       }\r
-\r
-\r
-       @Override\r
-       protected void onPreviewNativeEvent(NativePreviewEvent preview) {\r
-               super.onPreviewNativeEvent(preview);\r
-\r
-               NativeEvent evt = preview.getNativeEvent();\r
-               if (evt.getType().equals("keydown"))\r
-                       // Use the popup's key preview hooks to close the dialog when either\r
-                       // enter or escape is pressed.\r
-                       switch (evt.getKeyCode()) {\r
-                               case KeyCodes.KEY_ENTER:\r
-                                       hide();\r
-                                       deleteGroup();\r
-                                       break;\r
-                               case KeyCodes.KEY_ESCAPE:\r
-                                       hide();\r
-                                       break;\r
-                       }\r
-       }\r
-\r
-}\r
diff --git a/web_client/src/gr/grnet/pithos/web/client/DeleteUserDialog.java b/web_client/src/gr/grnet/pithos/web/client/DeleteUserDialog.java
deleted file mode 100644 (file)
index bca5f4a..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- *  Copyright (c) 2011 Greek Research and Technology Network
- */
-package gr.grnet.pithos.web.client;
-
-import gr.grnet.pithos.web.client.MessagePanel.Images;
-import gr.grnet.pithos.web.client.rest.DeleteCommand;
-import gr.grnet.pithos.web.client.rest.RestException;
-import gr.grnet.pithos.web.client.rest.resource.GroupUserResource;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.dom.client.NativeEvent;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.dom.client.KeyCodes;
-import com.google.gwt.user.client.DeferredCommand;
-import com.google.gwt.user.client.Event.NativePreviewEvent;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.DialogBox;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.TreeItem;
-import com.google.gwt.user.client.ui.VerticalPanel;
-
-
-public class DeleteUserDialog extends DialogBox {
-
-       /**
-        * The widget's constructor.
-        * @param images the supplied images
-        */
-       public DeleteUserDialog(final Images images) {
-               // Use this opportunity to set the dialog's caption.
-               setText("Delete user");
-               setAnimationEnabled(true);
-               final GroupUserResource group = (GroupUserResource) GSS.get().getCurrentSelection();
-               // Create a VerticalPanel to contain the 'about' label and the 'OK'
-               // button.
-               final VerticalPanel outer = new VerticalPanel();
-               final HorizontalPanel buttons = new HorizontalPanel();
-
-               // Create the 'about' text and set a style name so we can style it with
-               // CSS.
-               final HTML text = new HTML("<table><tr><td>" + AbstractImagePrototype.create(images.warn()).getHTML() + "</td><td>" + "Are you sure you want to remove user '" + group.getName() + "'?</td></tr></table>");
-               text.setStyleName("pithos-warnMessage");
-               outer.add(text);
-
-               // Create the 'Quit' button, along with a listener that hides the dialog
-               // when the button is clicked and quits the application.
-               final Button ok = new Button("OK", new ClickHandler() {
-                       @Override
-                       public void onClick(ClickEvent event) {
-                               deleteUser();
-                               hide();
-                       }
-               });
-               ok.getElement().setId("deleteUser.button.ok");
-               buttons.add(ok);
-               buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER);
-               // Create the 'Cancel' button, along with a listener that hides the
-               // dialog
-               // when the button is clicked.
-               final Button cancel = new Button("Cancel", new ClickHandler() {
-                       @Override
-                       public void onClick(ClickEvent event) {
-                               hide();
-                       }
-               });
-               cancel.getElement().setId("confirmation.button.cancel");
-               buttons.add(cancel);
-               buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);
-               buttons.setSpacing(8);
-               buttons.setStyleName("pithos-warnMessage");
-               outer.setStyleName("pithos-warnMessage");
-               outer.add(buttons);
-               outer.setCellHorizontalAlignment(text, HasHorizontalAlignment.ALIGN_CENTER);
-               outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);
-               setWidget(outer);
-       }
-
-       /**
-        * Generate an RPC request to delete a group.
-        *
-        * @param userId the ID of the current user
-        */
-       private void deleteUser() {
-               final TreeItem user = GSS.get().getGroups().getCurrent();
-               final TreeItem group = user.getParentItem();
-               if (group == null) {
-                       GSS.get().displayError("No user was selected!");
-                       return;
-               }
-               final GroupUserResource memberR = (GroupUserResource) user.getUserObject();
-               DeleteCommand du = new DeleteCommand(memberR.getUri()){
-
-                       @Override
-                       public void onComplete() {
-                               GSS.get().getGroups().updateGroups();
-                       }
-
-                       @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("User not found");
-                                       else
-                                               GSS.get().displayError("Unable to delete user:"+((RestException)t).getHttpStatusText());
-                               }
-                               else
-                                       GSS.get().displayError("System error unable to delete user:"+t.getMessage());
-                       }
-               };
-               DeferredCommand.addCommand(du);
-
-       }
-
-       @Override
-       protected void onPreviewNativeEvent(NativePreviewEvent preview) {
-               super.onPreviewNativeEvent(preview);
-
-               NativeEvent evt = preview.getNativeEvent();
-               if (evt.getType().equals("keydown"))
-               // Use the popup's key preview hooks to close the dialog when either
-               // enter or escape is pressed.
-               switch (evt.getKeyCode()) {
-                       case KeyCodes.KEY_ENTER:
-                               hide();
-                               deleteUser();
-                               break;
-                       case KeyCodes.KEY_ESCAPE:
-                               hide();
-                               break;
-               }
-       }
-
-}
-
index 71355a3..d45428f 100644 (file)
@@ -133,8 +133,6 @@ public class EditMenu extends PopupPanel implements ClickHandler {
                                hide();
                                if(GSS.get().isFileListShowing())
                                        GSS.get().getFileList().selectAllRows();
-                               else if(GSS.get().isSearchResultsShowing())
-                                       GSS.get().getSearchResults().selectAllRows();
                        }
                };
                final Command unselectAllCommand = new Command() {
@@ -144,8 +142,6 @@ public class EditMenu extends PopupPanel implements ClickHandler {
                                hide();
                                if(GSS.get().isFileListShowing())
                                        GSS.get().getFileList().clearSelectedRows();
-                               else if(GSS.get().isSearchResultsShowing())
-                                       GSS.get().getSearchResults().clearSelectedRows();
                        }
                };
 
index 5b32aad..db883ed 100644 (file)
@@ -156,8 +156,6 @@ public class FileContextMenu extends PopupPanel implements ClickHandler {
                                        hide();
                                        if(GSS.get().isFileListShowing())
                                                GSS.get().getFileList().clearSelectedRows();
-                                       else if(GSS.get().isSearchResultsShowing())
-                                               GSS.get().getSearchResults().clearSelectedRows();
                                }
                        };
                        cutItem = new MenuItem("<span id='fileContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Cut</span>", true, new CutCommand(this));
index bd1e28a..db35fd4 100644 (file)
@@ -3,9 +3,15 @@
  */
 package gr.grnet.pithos.web.client;
 
+import com.google.gwt.core.client.Scheduler;
+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 gr.grnet.pithos.web.client.clipboard.Clipboard;
 import gr.grnet.pithos.web.client.commands.GetUserCommand;
-import gr.grnet.pithos.web.client.rest.GetCommand;
+import gr.grnet.pithos.web.client.foldertree.AccountResource;
+import gr.grnet.pithos.web.client.foldertree.FolderTreeView;
+import gr.grnet.pithos.web.client.rest.GetRequest;
 import gr.grnet.pithos.web.client.rest.RestException;
 import gr.grnet.pithos.web.client.rest.resource.FileResource;
 import gr.grnet.pithos.web.client.rest.resource.OtherUserResource;
@@ -27,8 +33,6 @@ import com.google.gwt.event.logical.shared.ResizeEvent;
 import com.google.gwt.event.logical.shared.ResizeHandler;
 import com.google.gwt.event.logical.shared.SelectionEvent;
 import com.google.gwt.event.logical.shared.SelectionHandler;
-import com.google.gwt.event.logical.shared.ValueChangeEvent;
-import com.google.gwt.event.logical.shared.ValueChangeHandler;
 import com.google.gwt.http.client.URL;
 import com.google.gwt.i18n.client.DateTimeFormat;
 import com.google.gwt.resources.client.ClientBundle;
@@ -42,13 +46,12 @@ import com.google.gwt.user.client.History;
 import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.ui.AbstractImagePrototype;
 import com.google.gwt.user.client.ui.DecoratedTabPanel;
-import com.google.gwt.user.client.ui.DockPanel;
 import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.HasVerticalAlignment;
 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;
+
 /**
  * Entry point classes define <code>onModuleLoad()</code>.
  */
@@ -67,13 +70,15 @@ public class GSS implements EntryPoint, ResizeHandler {
         */
        private static Images images = (Images) GWT.create(Images.class);
 
-       private GlassPanel glassPanel = new GlassPanel();
+    public String getUsername() {
+        return username;
+    }
 
-       /**
+    /**
         * An aggregate image bundle that pulls together all the images for this
         * application into a single bundle.
         */
-       public interface Images extends ClientBundle, TopPanel.Images, StatusPanel.Images, FileMenu.Images, EditMenu.Images, SettingsMenu.Images, GroupMenu.Images, FilePropertiesDialog.Images, MessagePanel.Images, FileList.Images, SearchResults.Images, Search.Images, Groups.Images, CellTreeView.Images {
+       public interface Images extends ClientBundle, TopPanel.Images, StatusPanel.Images, FileMenu.Images, EditMenu.Images, SettingsMenu.Images, FilePropertiesDialog.Images, MessagePanel.Images, FileList.Images, Search.Images, CellTreeView.Images {
 
                @Source("gr/grnet/pithos/resources/document.png")
                ImageResource folders();
@@ -134,16 +139,6 @@ public class GSS implements EntryPoint, ResizeHandler {
        private FileList fileList;
 
        /**
-        * The group list widget.
-        */
-       private Groups groups = new Groups(images);
-
-       /**
-        * The search result widget.
-        */
-       private SearchResults searchResults;
-
-       /**
         * The tab panel that occupies the right side of the screen.
         */
        private TabPanel inner = new DecoratedTabPanel(){
@@ -153,10 +148,6 @@ public class GSS implements EntryPoint, ResizeHandler {
                                if(isFileListShowing()){
                                        getFileList().showContextMenu(event);
                                }
-                               else if(isUserListVisible()){
-                                       getGroups().setCurrent(null);
-                                       getGroups().showPopup(event.getClientX(),event.getClientY());
-                               }
                        }
                };
        };
@@ -187,33 +178,38 @@ public class GSS implements EntryPoint, ResizeHandler {
         */
        private Object currentSelection;
 
-       /**
-        * The authentication token of the current user.
-        */
-       private String token;
 
        /**
         * The WebDAV password of the current user
         */
        private String webDAVPassword;
 
-       
-
        public HashMap<String, String> userFullNameMap = new HashMap<String, String>();
 
+    private String username = null;
+
+    /**
+     * The authentication token of the current user.
+     */
+    private String token;
+
+    private FolderTreeView folderTreeView = new FolderTreeView();
+
        @Override
        public void onModuleLoad() {
                // Initialize the singleton before calling the constructors of the
                // various widgets that might call GSS.get().
                singleton = this;
-               RootPanel.get().add(glassPanel, 0, 0);
-               parseUserCredentials();
-               
-               topPanel = new TopPanel(GSS.images);
-               topPanel.setWidth("100%");
+               if (parseUserCredentials())
+            initialize();
+       }
 
-               messagePanel.setWidth("100%");
-               messagePanel.setVisible(false);
+    private void initialize() {
+        topPanel = new TopPanel(GSS.images);
+        topPanel.setWidth("100%");
+
+        messagePanel.setWidth("100%");
+        messagePanel.setVisible(false);
 
                search = new Search(images);
                searchStatus.add(search, DockPanel.WEST);
@@ -223,191 +219,106 @@ public class GSS implements EntryPoint, ResizeHandler {
                searchStatus.setCellVerticalAlignment(userDetailsPanel, HasVerticalAlignment.ALIGN_MIDDLE);
                searchStatus.setWidth("100%");
 
-               fileList = new FileList(images);
-
-               searchResults = new SearchResults(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.add(groups, createHeaderHTML(AbstractImagePrototype.create(images.groups()), "Groups"), true);
-               inner.add(searchResults, createHeaderHTML(AbstractImagePrototype.create(images.search()), "Search Results"), true);
-               //inner.add(new CellTreeView(images), createHeaderHTML(AbstractImagePrototype.create(images.search()), "Cell tree sample"), true);
-               inner.setWidth("100%");
-               inner.selectTab(0);
-
-               inner.addSelectionHandler(new SelectionHandler<Integer>() {
-
-                       @Override
-                       public void onSelection(SelectionEvent<Integer> event) {
-                               int tabIndex = event.getSelectedItem();
-//                             TreeItem treeItem = GSS.get().getFolders().getCurrent();
-                               switch (tabIndex) {
-                                       case 0:
-//                                             Files tab selected
-                                               //fileList.clearSelectedRows();
-                                               fileList.updateCurrentlyShowingStats();
-                                               break;
-                                       case 1:
-//                                             Groups tab selected
-                                               groups.updateCurrentlyShowingStats();
-                                       updateHistory("Groups");
-                                               break;
-                                       case 2:
-//                                             Search tab selected
-                                               searchResults.clearSelectedRows();
-                                               searchResults.updateCurrentlyShowingStats();
-                                       updateHistory("Search");
-                                               break;
-                               }
-                       }
-               });
-//             If the application starts with no history token, redirect to a new "Files" state
-               String initToken = History.getToken();
-               if(initToken.length() == 0)
-                       History.newItem("Files");
-//                Add history listener to handle any history events
-               History.addValueChangeHandler(new ValueChangeHandler<String>() {
-                       @Override
-                       public void onValueChange(ValueChangeEvent<String> event) {
-                               String tokenInput = event.getValue();
-                               String historyToken = handleSpecialFolderNames(tokenInput);
-                               try {
-                                       if(historyToken.equals("Search"))
-                                               inner.selectTab(2);
-                                       else if(historyToken.equals("Groups"))
-                                               inner.selectTab(1);
-                                       else if(historyToken.equals("Files")|| historyToken.length()==0)
-                                               inner.selectTab(0);
-                                       else {
-                                               /*TODO: CELLTREE
-                                               PopupTree popupTree = GSS.get().getFolders().getPopupTree();
-                                               TreeItem treeObj = GSS.get().getFolders().getPopupTree().getTreeItem(historyToken);
-                                               SelectionEvent.fire(popupTree, treeObj);
-                                               */
-                                       }
-                               } catch (IndexOutOfBoundsException e) {
-                                       inner.selectTab(0);
-                               }
-                       }
-               });
-
-               // Add the left and right panels to the split panel.
-               splitPanel.setLeftWidget(treeView);
-               splitPanel.setRightWidget(inner);
-               splitPanel.setSplitPosition("25%");
-               splitPanel.setSize("100%", "100%");
-               splitPanel.addStyleName("pithos-splitPanel");
-               
-               // Create a dock panel that will contain the menu bar at the top,
-               // the shortcuts to the left, the status bar at the bottom and the
-               // right panel taking the rest.
-               VerticalPanel outer = new VerticalPanel();
-               outer.add(topPanel);
+        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>() {
+
+            @Override
+            public void onSelection(SelectionEvent<Integer> event) {
+                int tabIndex = event.getSelectedItem();
+                switch (tabIndex) {
+                    case 0:
+                        fileList.updateCurrentlyShowingStats();
+                        break;
+                }
+            }
+        });
+
+        // Add the left and right panels to the split panel.
+        splitPanel.setLeftWidget(folderTreeView);
+        splitPanel.setRightWidget(inner);
+        splitPanel.setSplitPosition("25%");
+        splitPanel.setSize("100%", "100%");
+        splitPanel.addStyleName("pithos-splitPanel");
+
+        // Create a dock panel that will contain the menu bar at the top,
+        // the shortcuts to the left, the status bar at the bottom and the
+        // right panel taking the rest.
+        VerticalPanel outer = new VerticalPanel();
+        outer.add(topPanel);
                outer.add(searchStatus);
-               outer.add(messagePanel);
-               outer.add(splitPanel);
-               outer.add(statusPanel);
-               outer.setWidth("100%");
-               outer.setCellHorizontalAlignment(messagePanel, HasHorizontalAlignment.ALIGN_CENTER);
-
-               outer.setSpacing(4);
-
-               // Hook the window resize event, so that we can adjust the UI.
-               Window.addResizeHandler(this);
-               // Clear out the window's built-in margin, because we want to take
-               // advantage of the entire client area.
-               Window.setMargin("0px");
-               // Finally, add the outer panel to the RootPanel, so that it will be
-               // displayed.
-               RootPanel.get().add(outer);
-               // Call the window resized handler to get the initial sizes setup. Doing
-               // this in a deferred command causes it to occur after all widgets'
-               // sizes have been computed by the browser.
-               DeferredCommand.addCommand(new Command() {
-
-                       @Override
-                       public void execute() {
-                               onWindowResized(Window.getClientHeight());
-                       }
-               });
-       }
-
-       /**
-        * Fetches the User object for the specified username.
-        *
-        * @param username the username of the user
-        */
-       private void fetchUser(final String username) {
-               String path = getApiPath() + username + "/";
-               GetCommand<UserResource> getUserCommand = new GetCommand<UserResource>(UserResource.class, username, path, null) {
-
-                       @Override
-                       public void onComplete() {
-                               
-                               currentUserResource = getResult();
-                       }
-
-                       @Override
-                       public void onError(Throwable t) {
-                               GWT.log("Fetching user error", t);
-                               if (t instanceof RestException)
-                                       GSS.get().displayError("No user found:" + ((RestException) t).getHttpStatusText());
-                               else
-                                       GSS.get().displayError("System error fetching user data:" + t.getMessage());
-                               authenticateUser();
-                       }
-               };
-               DeferredCommand.addCommand(getUserCommand);
-       }
+        outer.add(messagePanel);
+        outer.add(splitPanel);
+        outer.add(statusPanel);
+        outer.setWidth("100%");
+        outer.setCellHorizontalAlignment(messagePanel, HasHorizontalAlignment.ALIGN_CENTER);
+
+        outer.setSpacing(4);
+
+        // Hook the window resize event, so that we can adjust the UI.
+        Window.addResizeHandler(this);
+        // Clear out the window's built-in margin, because we want to take
+        // advantage of the entire client area.
+        Window.setMargin("0px");
+        // Finally, add the outer panel to the RootPanel, so that it will be
+        // displayed.
+        RootPanel.get().add(outer);
+        // Call the window resized handler to get the initial sizes setup. Doing
+        // this in a deferred command causes it to occur after all widgets'
+        // sizes have been computed by the browser.
+        DeferredCommand.addCommand(new Command() {
+
+            @Override
+            public void execute() {
+                onWindowResized(Window.getClientHeight());
+            }
+        });
+    }
 
        /**
         * Parse and store the user credentials to the appropriate fields.
         */
-       private void parseUserCredentials() {
-//             Configuration conf = (Configuration) GWT.create(Configuration.class);
-//             String cookie = conf.authCookie();
-//             String auth = Cookies.getCookie(cookie);
-//             if (auth == null) {
-//                     authenticateUser();
-//                     // Redundant, but silences warnings about possible auth NPE, below.
-//                     return;
-//             }
-//             int sepIndex = auth.indexOf(conf.cookieSeparator());
-//             if (sepIndex == -1)
-//                     authenticateUser();
-//             token = auth.substring(sepIndex + 1);
-//             final String username = auth.substring(0, sepIndex);
-//             if (username == null)
-//                     authenticateUser();
-//
-//             refreshWebDAVPassword();
-
-        final String username = "test";
-               DeferredCommand.addCommand(new Command() {
-
-                       @Override
-                       public void execute() {
-                               fetchUser(username);
-                       }
-               });
+       private boolean parseUserCredentials() {
+               Configuration conf = (Configuration) GWT.create(Configuration.class);
+               String cookie = conf.authCookie();
+               String auth = Cookies.getCookie(cookie);
+               if (auth == null) {
+                       authenticateUser();
+            return false;
+        }
+        else {
+            String[] authSplit = auth.split("\\" + conf.cookieSeparator(), 2);
+            if (authSplit.length != 2) {
+                authenticateUser();
+                return false;
+            }
+            else {
+                username = authSplit[0];
+                token = authSplit[1];
+                return true;
+            }
+        }
        }
 
-       /**
+    /**
         * Redirect the user to the login page for authentication.
         */
        protected void authenticateUser() {
-//             Configuration conf = (Configuration) GWT.create(Configuration.class);
-        //IMPORTANT: Temporary circumvention of the Shiboleth login process for development and testing
-        //Some time in the future the comment line will be restored
-        
+               Configuration conf = (Configuration) GWT.create(Configuration.class);
+
 //        Window.Location.assign(GWT.getModuleBaseURL() + conf.loginUrl() + "?next=" + Window.Location.getHref());
-//        Cookies.setCookie(conf.authCookie(), "chstath@ebs.gr" + conf.cookieSeparator() + "triapoulakiakathontan");
-//        Window.Location.assign(GWT.getModuleBaseURL());
+        Cookies.setCookie(conf.authCookie(), "demo" + conf.cookieSeparator() + "0000");
+        Window.Location.assign(GWT.getModuleBaseURL() + "GSS.html");
        }
 
        /**
@@ -447,9 +358,6 @@ public class GSS implements EntryPoint, ResizeHandler {
                        newHeight = 1;
                splitPanel.setHeight("" + newHeight);
                inner.setHeight("" + newHeight);
-               /*if(isFileListShowing()){
-                       getFileList().setHeight("" + (newHeight-50));
-               }*/
        }
 
        @Override
@@ -500,9 +408,9 @@ public class GSS implements EntryPoint, ResizeHandler {
                        RestResource currentFolder = getTreeView().getSelection();
                        if(currentFolder!=null){
                                showFileList(currentFolder);
-                       }
                }
-               
+               }
+
        }
        
        public void showFileList(RestResource r) {
@@ -538,17 +446,6 @@ public class GSS implements EntryPoint, ResizeHandler {
        }
 
        /**
-        * Make the search results visible.
-        *
-        * @param query the search query string
-        */
-       public void showSearchResults(String query) {
-               searchResults.updateFileCache(query);
-               searchResults.updateCurrentlyShowingStats();
-               inner.selectTab(2);
-       }
-
-       /**
         * Display the 'loading' indicator.
         */
        public void showLoadingIndicator(String message, String path) {
@@ -651,15 +548,6 @@ public class GSS implements EntryPoint, ResizeHandler {
        }
 
        /**
-        * Retrieve the groups.
-        *
-        * @return the groups
-        */
-       public Groups getGroups() {
-               return groups;
-       }
-
-       /**
         * Retrieve the fileList.
         *
         * @return the fileList
@@ -668,10 +556,6 @@ public class GSS implements EntryPoint, ResizeHandler {
                return fileList;
        }
 
-       public SearchResults getSearchResults() {
-               return searchResults;
-       }
-
        /**
         * Retrieve the topPanel.
         *
@@ -713,10 +597,6 @@ public class GSS implements EntryPoint, ResizeHandler {
                return webDAVPassword;
        }
 
-       public void removeGlassPanel() {
-               glassPanel.removeFromParent();
-       }
-
        /**
         * Retrieve the currentUserResource.
         *
@@ -749,7 +629,7 @@ public class GSS implements EntryPoint, ResizeHandler {
         */
        public String getApiPath() {
                Configuration conf = (Configuration) GWT.create(Configuration.class);
-               return GWT.getModuleBaseURL() + conf.apiPath();
+               return conf.apiPath();
        }
 
        /**
@@ -846,6 +726,4 @@ public class GSS implements EntryPoint, ResizeHandler {
                }
                
        }
-       
-       
 }
diff --git a/web_client/src/gr/grnet/pithos/web/client/GroupContextMenu.java b/web_client/src/gr/grnet/pithos/web/client/GroupContextMenu.java
deleted file mode 100644 (file)
index 7a7feb3..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2011 Greek Research and Technology Network
- */
-package gr.grnet.pithos.web.client;
-
-import gr.grnet.pithos.web.client.Groups.Images;
-import gr.grnet.pithos.web.client.commands.CopyCommand;
-import gr.grnet.pithos.web.client.commands.DeleteUserOrGroupCommand;
-import gr.grnet.pithos.web.client.commands.NewGroupCommand;
-import gr.grnet.pithos.web.client.commands.NewUserCommand;
-import gr.grnet.pithos.web.client.commands.PasteCommand;
-import gr.grnet.pithos.web.client.rest.resource.GroupResource;
-import gr.grnet.pithos.web.client.rest.resource.GroupUserResource;
-
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.MenuBar;
-import com.google.gwt.user.client.ui.MenuItem;
-import com.google.gwt.user.client.ui.PopupPanel;
-import com.google.gwt.user.client.ui.TreeItem;
-
-
-public class GroupContextMenu extends PopupPanel {
-
-       /**
-        * The widget's images.
-        */
-       private final Images images;
-       private MenuItem copy;
-       private MenuItem paste;
-       private MenuItem newGroup;
-       private MenuItem addUser;
-       private MenuItem delete;
-       public GroupContextMenu(final Images newImages) {
-               // The popup's constructor's argument is a boolean specifying that it
-               // auto-close itself when the user clicks outside of it.
-               super(true);
-               images=newImages;
-               setAnimationEnabled(true);
-               final MenuBar contextMenu = new MenuBar(true);
-               newGroup = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.groupNew()).getHTML() + "&nbsp;New Group</span>", true, new NewGroupCommand(this));
-               newGroup.getElement().setId("groupContextMenu.newGroup");
-               contextMenu.addItem(newGroup);
-               
-               addUser = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.groupNew()).getHTML() + "&nbsp;Add User</span>", true, new NewUserCommand(this));
-               addUser.getElement().setId("groupContextMenu.addUser");
-               contextMenu.addItem(addUser);
-                               
-               copy = new MenuItem("<span id=groupContextMenu.copyUser>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + "&nbsp;Copy User</span>", true, new CopyCommand(this));
-               copy.getElement().setId("groupContextMenu.copyUser");
-               contextMenu.addItem(copy);
-               
-               paste = new MenuItem("<span id=groupContextMenu.pasteUser>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + "&nbsp;Paste User</span>", true, new PasteCommand(this));
-               paste.getElement().setId("groupContextMenu.pasteUser");
-               contextMenu.addItem(paste);
-               
-               delete = new MenuItem("<span id=groupContextMenu.delete>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteUserOrGroupCommand(this,images));
-               delete.getElement().setId("groupContextMenu.delete");
-               contextMenu.addItem(delete);
-               
-               add(contextMenu);
-
-       }
-
-       /* (non-Javadoc)
-        * @see com.google.gwt.user.client.ui.PopupPanel#show()
-        */
-       @Override
-       public void show() {
-               TreeItem current = GSS.get().getGroups().getCurrent();
-               if(current==null){
-                       copy.setVisible(false);
-                       paste.setVisible(false);
-                       addUser.setVisible(false);
-                       delete.setVisible(false);
-               }
-               else{
-                       newGroup.setVisible(false);
-                       if(current.getUserObject() instanceof GroupUserResource && GSS.get().getCurrentSelection() instanceof GroupUserResource)
-                               copy.setVisible(true);
-                       else
-                               copy.setVisible(false);
-                       if(current.getUserObject() instanceof GroupResource && GSS.get().getCurrentSelection() instanceof GroupResource && GSS.get().getClipboard().hasUserItem())
-                               paste.setVisible(true);
-                       else
-                               paste.setVisible(false);
-               }
-               super.show();
-       }
-
-}
diff --git a/web_client/src/gr/grnet/pithos/web/client/GroupMenu.java b/web_client/src/gr/grnet/pithos/web/client/GroupMenu.java
deleted file mode 100644 (file)
index c8ff109..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2011 Greek Research and Technology Network
- */
-package gr.grnet.pithos.web.client;
-
-import gr.grnet.pithos.web.client.commands.NewGroupCommand;
-
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.resources.client.ClientBundle;
-import com.google.gwt.resources.client.ImageResource;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.MenuBar;
-import com.google.gwt.user.client.ui.MenuItem;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-/**
- * The 'Group' menu implementation.
- */
-public class GroupMenu extends PopupPanel implements ClickHandler {
-       /**
-        * The widget's images.
-        */
-       private Images images;
-       private final MenuBar contextMenu;
-
-       /**
-        * An image bundle for this widgets images.
-        */
-       public interface Images extends ClientBundle {
-               @Source("gr/grnet/pithos/resources/groupevent.png")
-               ImageResource groupNew();
-
-               @Source("gr/grnet/pithos/resources/view_text.png")
-               ImageResource viewText();
-
-       }
-
-       /**
-        * The widget's constructor.
-        *
-        * @param newImages the image bundle passed on by the parent object
-        */
-       public GroupMenu(final Images newImages) {
-               // 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);
-               images = newImages;
-
-               contextMenu = new MenuBar(true);
-               MenuItem newGroupItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.groupNew()).getHTML() + "&nbsp;New Group</span>", true, new NewGroupCommand(this));
-               newGroupItem.getElement().setId("topMenu.group.newGroup");
-               contextMenu.addItem(newGroupItem);
-               
-               add(contextMenu);
-       }
-
-       @Override
-       public void onClick(ClickEvent event) {
-               GroupMenu menu = new GroupMenu(images);
-               int left = event.getRelativeElement().getAbsoluteLeft();
-               int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight();
-               menu.setPopupPosition(left, top);
-
-               menu.show();
-       }
-
-       /**
-        * Retrieve the contextMenu.
-        *
-        * @return the contextMenu
-        */
-       public MenuBar getContextMenu() {
-               contextMenu.setAutoOpen(false);
-               return contextMenu;
-       }
-
-}
diff --git a/web_client/src/gr/grnet/pithos/web/client/GroupPropertiesDialog.java b/web_client/src/gr/grnet/pithos/web/client/GroupPropertiesDialog.java
deleted file mode 100644 (file)
index a74f43e..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (c) 2011 Greek Research and Technology Network
- */
-package gr.grnet.pithos.web.client;
-
-import gr.grnet.pithos.web.client.rest.PostCommand;
-import gr.grnet.pithos.web.client.rest.RestException;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.dom.client.NativeEvent;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.dom.client.KeyCodes;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.user.client.DeferredCommand;
-import com.google.gwt.user.client.Event.NativePreviewEvent;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.DialogBox;
-import com.google.gwt.user.client.ui.Grid;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.TextBox;
-import com.google.gwt.user.client.ui.VerticalPanel;
-
-public class GroupPropertiesDialog extends DialogBox {
-
-       /**
-        * The widget that holds the folderName of the folder.
-        */
-       private TextBox groupName = new TextBox();
-
-       /**
-        * A flag that denotes whether the dialog will be used to create or modify a
-        * folder.
-        */
-       private final boolean create;
-
-       /**
-        * The widget's constructor.
-        *
-        * @param _create true if the dialog is displayed for creating a new
-        *            sub-folder of the selected folder, false if it is displayed
-        *            for modifying the selected folder
-        */
-       public GroupPropertiesDialog(final boolean _create) {
-               setAnimationEnabled(true);
-               create = _create;
-               // Use this opportunity to set the dialog's caption.
-               if (create)
-                       setText("Create Group");
-               else
-                       setText("Group properties");
-               final VerticalPanel panel = new VerticalPanel();
-               setWidget(panel);
-               groupName.getElement().setId("groupDialog.textBox.name");
-               final Grid generalTable = new Grid(1, 2);
-               generalTable.setText(0, 0, "Group Name");
-               generalTable.setWidget(0, 1, groupName);
-               generalTable.getCellFormatter().setStyleName(0, 0, "props-labels");
-               generalTable.getCellFormatter().setStyleName(0, 1, "props-values");
-               generalTable.setCellSpacing(4);
-
-               panel.add(generalTable);
-               final HorizontalPanel buttons = new HorizontalPanel();
-               final Button ok = new Button("OK", new ClickHandler() {
-                       @Override
-                       public void onClick(ClickEvent event) {
-                               createGroup(groupName.getText());
-                               hide();
-                       }
-               });
-               ok.getElement().setId("groupDialog.button.ok");
-               buttons.add(ok);
-               buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER);
-               // Create the 'Cancel' button, along with a listener that hides the
-               // dialog
-               // when the button is clicked.
-               final Button cancel = new Button("Cancel", new ClickHandler() {
-                       @Override
-                       public void onClick(ClickEvent event) {
-                               hide();
-                       }
-               });
-               cancel.getElement().setId("groupDialog.button.cancel");
-               buttons.add(cancel);
-               buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);
-               buttons.setSpacing(8);
-               buttons.addStyleName("pithos-TabPanelBottom");
-               panel.add(buttons);
-               panel.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);
-               //panel.addStyleName("pithos-DialogBox");
-               panel.addStyleName("pithos-TabPanelBottom");
-       }
-       @Override
-       public void center() {
-               super.center();
-               groupName.setFocus(true);
-       }
-
-       @Override
-       protected void onPreviewNativeEvent(NativePreviewEvent preview) {
-               super.onPreviewNativeEvent(preview);
-
-               NativeEvent evt = preview.getNativeEvent();
-               if (evt.getType().equals("keydown"))
-                       // Use the popup's key preview hooks to close the dialog when either
-                       // enter or escape is pressed.
-                       switch (evt.getKeyCode()) {
-                               case KeyCodes.KEY_ENTER:
-                                       hide();
-                                       createGroup( groupName.getText());
-                                       break;
-                               case KeyCodes.KEY_ESCAPE:
-                                       hide();
-                                       break;
-                       }
-       }
-
-
-       /**
-        * Generate an RPC request to create a new group.
-        *
-        * @param userId the ID of the user whose namespace will be searched for
-        *            groups
-        * @param aGroupName the name of the group to create
-        */
-       private void createGroup(String aGroupName) {
-
-               if (aGroupName == null || aGroupName.length() == 0) {
-                       GSS.get().displayError("Empty group name!");
-                       return;
-               }
-               GWT.log("createGroup(" + aGroupName + ")", null);
-               PostCommand cg = new PostCommand(GSS.get().getCurrentUserResource().getGroupsPath()+"?name="+URL.encodeComponent(aGroupName), "", 201){
-
-                       @Override
-                       public void onComplete() {
-                               GSS.get().getGroups().updateGroups();
-                               GSS.get().showUserList();
-                       }
-
-                       @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("Resource does not exist");
-                                       else if(statusCode == 409)
-                                               GSS.get().displayError("A group with the same name already exists");
-                                       else if(statusCode == 413)
-                                               GSS.get().displayError("Your quota has been exceeded");
-                                       else
-                                               GSS.get().displayError("Unable to create group:"+((RestException)t).getHttpStatusText());
-                               }
-                               else
-                                       GSS.get().displayError("System error creating group:"+t.getMessage());
-                       }
-               };
-               DeferredCommand.addCommand(cg);
-
-       }
-}
diff --git a/web_client/src/gr/grnet/pithos/web/client/Groups.java b/web_client/src/gr/grnet/pithos/web/client/Groups.java
deleted file mode 100644 (file)
index 732418e..0000000
+++ /dev/null
@@ -1,345 +0,0 @@
-/*\r
- * Copyright (c) 2011 Greek Research and Technology Network\r
- */\r
-package gr.grnet.pithos.web.client;\r
-\r
-import gr.grnet.pithos.web.client.rest.GetCommand;\r
-import gr.grnet.pithos.web.client.rest.MultipleGetCommand;\r
-import gr.grnet.pithos.web.client.rest.resource.GroupResource;\r
-import gr.grnet.pithos.web.client.rest.resource.GroupUserResource;\r
-import gr.grnet.pithos.web.client.rest.resource.GroupsResource;\r
-\r
-import java.util.List;\r
-\r
-import com.google.gwt.core.client.GWT;\r
-import com.google.gwt.dom.client.NativeEvent;\r
-import com.google.gwt.event.dom.client.ContextMenuEvent;\r
-import com.google.gwt.event.dom.client.ContextMenuHandler;\r
-import com.google.gwt.event.logical.shared.OpenEvent;\r
-import com.google.gwt.event.logical.shared.OpenHandler;\r
-import com.google.gwt.event.logical.shared.SelectionEvent;\r
-import com.google.gwt.event.logical.shared.SelectionHandler;\r
-import com.google.gwt.resources.client.ClientBundle;\r
-import com.google.gwt.resources.client.ImageResource;\r
-import com.google.gwt.user.client.DOM;\r
-import com.google.gwt.user.client.DeferredCommand;\r
-import com.google.gwt.user.client.Event;\r
-import com.google.gwt.user.client.ui.AbstractImagePrototype;\r
-import com.google.gwt.user.client.ui.Composite;\r
-import com.google.gwt.user.client.ui.HTML;\r
-import com.google.gwt.user.client.ui.Tree;\r
-import com.google.gwt.user.client.ui.TreeItem;\r
-\r
-/**\r
- * A component that displays a list of the user's groups.\r
- */\r
-public class Groups extends Composite implements SelectionHandler, OpenHandler {\r
-\r
-       /**\r
-        * An image bundle for this widget.\r
-        */\r
-       public interface Images extends Tree.Resources, ClientBundle, FileMenu.Images, EditMenu.Images, GroupMenu.Images, MessagePanel.Images {\r
-\r
-               /**\r
-                * Will bundle the file 'groupevent.png' residing in the package\r
-                * 'gr.grnet.pithos.web.resources'.\r
-                *\r
-                * @return the image prototype\r
-                */\r
-               @Source("gr/grnet/pithos/resources/groupevent.png")\r
-               ImageResource groupImage();\r
-\r
-               @Override\r
-               @Source("gr/grnet/pithos/resources/editdelete.png")\r
-               ImageResource delete();\r
-\r
-       }\r
-\r
-       /**\r
-        * cached latest group selection (for selecting and expanding on refresh)\r
-        */\r
-       private String selectedGroup = null;\r
-\r
-       /**\r
-        * The tree widget that displays the groups.\r
-        */\r
-       private Tree tree;\r
-\r
-       /**\r
-        * A cached copy of the currently selected group widget.\r
-        */\r
-       private TreeItem current;\r
-\r
-       /**\r
-        * A cached copy of the previously selected group widget.\r
-        */\r
-       private TreeItem previous;\r
-\r
-       /**\r
-        * The widget's image bundle.\r
-        */\r
-       private final Images images;\r
-\r
-       private GroupContextMenu menu;\r
-\r
-       /**\r
-        * Constructs a new groups widget with a bundle of images.\r
-        *\r
-        * @param newImages a bundle that provides the images for this widget\r
-        */\r
-       public Groups(final Images newImages) {\r
-\r
-               images = newImages;\r
-               menu = new GroupContextMenu(images);\r
-               tree = new Tree(newImages);\r
-               this.addHandler(new ContextMenuHandler() {\r
-\r
-                       @Override\r
-                       public void onContextMenu(ContextMenuEvent event) {\r
-                               if(current==null) return;\r
-                               int left = current.getAbsoluteLeft() + 40;\r
-                               int top = current.getAbsoluteTop() + 20;\r
-                               showPopup(left, top);\r
-\r
-                       }\r
-               }, ContextMenuEvent.getType());\r
-               tree.getElement().setId("groupsList.tree");\r
-               tree.addSelectionHandler(this);\r
-               tree.addOpenHandler(this);\r
-               tree.setAnimationEnabled(true);\r
-               initWidget(tree);\r
-               this.getElement().setAttribute("id", "CreativeFilesPanel");\r
-               setStylePrimaryName("pithos-Groups");\r
-               sinkEvents(Event.ONCONTEXTMENU);\r
-               sinkEvents(Event.ONMOUSEUP);\r
-               sinkEvents(Event.ONDBLCLICK);\r
-               sinkEvents(Event.KEYEVENTS);\r
-       }\r
-\r
-\r
-       /**\r
-        * Make an RPC call to retrieve the groups that belong to the specified\r
-        * user.\r
-        */\r
-       public void updateGroups() {\r
-               GetCommand<GroupsResource> gg = new GetCommand<GroupsResource>(GroupsResource.class, GSS.get().getCurrentUserResource().getGroupsPath(),null){\r
-\r
-                       @Override\r
-                       public void onComplete() {\r
-                               GroupsResource res = getResult();\r
-                               MultipleGetCommand<GroupResource> ga = new MultipleGetCommand<GroupResource>(GroupResource.class, res.getGroupPaths().toArray(new String[]{}), null){\r
-\r
-                                       @Override\r
-                                       public void onComplete() {\r
-                                               List<GroupResource> groupList = getResult();\r
-                                               tree.clear();\r
-                                               for (int i = 0; i < groupList.size(); i++) {\r
-                                                       final TreeItem item = new TreeItem();\r
-                                                       item.setWidget(imageItemHTML(images.groupImage(), groupList.get(i).getName(),item));\r
-                                                       item.setUserObject(groupList.get(i));                                                   \r
-                                                       tree.addItem(item);\r
-                                                       updateUsers(item);\r
-                                               }\r
-                                       }\r
-\r
-                                       @Override\r
-                                       public void onError(Throwable t) {\r
-                                               GWT.log("", t);\r
-                                       }\r
-\r
-                                       @Override\r
-                                       public void onError(String p, Throwable throwable) {\r
-                                               GWT.log("Path:"+p, throwable);\r
-                                       }\r
-                               };\r
-                               DeferredCommand.addCommand(ga);\r
-                       }\r
-\r
-                       @Override\r
-                       public void onError(Throwable t) {\r
-\r
-                       }\r
-               };\r
-               DeferredCommand.addCommand(gg);\r
-       }\r
-\r
-       /**\r
-        *  update status panel with currently showing file stats\r
-        */\r
-       public void updateCurrentlyShowingStats() {\r
-               GSS.get().getStatusPanel().updateCurrentlyShowing(null); //clear stats - nothing to show for the groups tab\r
-       }\r
-\r
-       /**\r
-        * A helper method to simplify adding tree items that have attached images.\r
-        *\r
-        * @param parent the tree item to which the new item will be added.\r
-        * @param title the text associated with this item.\r
-        * @param imageProto\r
-        * @return the new tree item\r
-        */\r
-       private TreeItem addImageItem(final TreeItem parent, final String title, final ImageResource imageProto) {\r
-               final TreeItem item = new TreeItem();\r
-               item.setWidget(imageItemHTML(imageProto, title,item));\r
-               parent.addItem(item);\r
-               return item;\r
-       }\r
-\r
-       /**\r
-        * Generates HTML for a tree item with an attached icon.\r
-        *\r
-        * @param imageProto the icon image\r
-        * @param title the title of the item\r
-        * @return the resultant HTML\r
-        */\r
-       private HTML imageItemHTML(final ImageResource imageProto, final String title,final TreeItem item) {\r
-               final HTML link = new HTML("<a class='hidden-link' href='javascript:;'>" + "<span id='groupsList."+title+"'>" + AbstractImagePrototype.create(imageProto).getHTML() + "&nbsp;" + title + "</span>" + "</a>"){\r
-                       @Override\r
-                       public void onBrowserEvent(Event event) {\r
-                               switch (DOM.eventGetType(event)) {\r
-                                       case Event.ONMOUSEDOWN:\r
-                                               if (DOM.eventGetButton(event) == NativeEvent.BUTTON_RIGHT || DOM.eventGetButton(event) == NativeEvent.BUTTON_LEFT)\r
-                                                       onSelection(item);\r
-                                               break;\r
-                                       case Event.ONCONTEXTMENU:\r
-                                               showPopup(event.getClientX(), event.getClientY());\r
-                                               event.preventDefault();\r
-                                               event.stopPropagation();\r
-                                               break;\r
-                               }\r
-                               super.onBrowserEvent(event);\r
-\r
-                       }\r
-               };                      \r
-               link.sinkEvents(Event.ONMOUSEDOWN);\r
-               link.sinkEvents(Event.ONCONTEXTMENU);\r
-               link.sinkEvents(Event.ONCLICK);\r
-               link.sinkEvents(Event.ONKEYDOWN);               \r
-               return link;\r
-       }\r
-\r
-\r
-\r
-       protected void showPopup(final int x, final int y) {\r
-               menu.hide();\r
-               menu = new GroupContextMenu(images);\r
-               menu.setPopupPosition(x, y);\r
-               menu.show();\r
-       }\r
-\r
-\r
-\r
-       /**\r
-        * Generate an RPC request to retrieve the users of the specified group for\r
-        * display.\r
-        *\r
-        * @param groupItem the TreeItem widget that corresponds to the requested\r
-        *            group\r
-        */\r
-       void updateUsers(final TreeItem groupItem) {\r
-               if(groupItem.getUserObject() instanceof GroupResource){\r
-                       GroupResource res = (GroupResource) groupItem.getUserObject();\r
-                       MultipleGetCommand<GroupUserResource> gu = new MultipleGetCommand<GroupUserResource>(GroupUserResource.class, res.getUserPaths().toArray(new String[]{}), null){\r
-                               @Override\r
-                               public void onComplete() {\r
-                                       List<GroupUserResource> users = getResult();\r
-                                       groupItem.removeItems();\r
-                                       for (int i = 0; i < users.size(); i++) {\r
-                                               final TreeItem userItem = addImageItem(groupItem, users.get(i).getName() + " &lt;" + users.get(i).getUsername() + "&gt;", images.permUser());\r
-                                               userItem.setUserObject(users.get(i));\r
-                                       }\r
-                                       if (selectedGroup != null && groupItem.getText().equals(selectedGroup)) {\r
-                                               //SelectionEvent.fire(tree, groupItem);;\r
-                                               onSelection(groupItem);\r
-                                               groupItem.setState(true);\r
-                                       }\r
-                               }\r
-\r
-                               @Override\r
-                               public void onError(Throwable t) {\r
-                                       GWT.log("", t);\r
-                               }\r
-\r
-                               @Override\r
-                               public void onError(String p, Throwable throwable) {\r
-                                       GWT.log("Path:"+p, throwable);\r
-                               }\r
-                       };\r
-                       DeferredCommand.addCommand(gu);\r
-               }\r
-\r
-       }\r
-\r
-       /**\r
-        * Retrieve the current.\r
-        *\r
-        * @return the current\r
-        */\r
-       TreeItem getCurrent() {\r
-               return current;\r
-       }\r
-\r
-       /**\r
-        * Modify the current.\r
-        *\r
-        * @param newCurrent the current to set\r
-        */\r
-       void setCurrent(final TreeItem newCurrent) {\r
-               current = newCurrent;\r
-       }\r
-\r
-       /**\r
-        * Retrieve the previous.\r
-        *\r
-        * @return the previous\r
-        */\r
-       private TreeItem getPrevious() {\r
-               return previous;\r
-       }\r
-\r
-       /**\r
-        * Modify the previous.\r
-        *\r
-        * @param newPrevious the previous to set\r
-        */\r
-       private void setPrevious(final TreeItem newPrevious) {\r
-               previous = newPrevious;\r
-       }\r
-\r
-       @Override\r
-       public void setVisible(final boolean visible) {\r
-               super.setVisible(visible);\r
-               if (visible)\r
-                       updateGroups();\r
-       }\r
-\r
-       @Override\r
-       public void onSelection(SelectionEvent event) {\r
-               final TreeItem item = (TreeItem)event.getSelectedItem();\r
-               onSelection(item);\r
-\r
-       }\r
-\r
-       private void onSelection(TreeItem item){\r
-               final Object selected = item.getUserObject();\r
-               // Preserve the previously selected item, so that the current's\r
-               // onClick() method gets a chance to find it.\r
-               if (getPrevious() != null)\r
-                       getPrevious().getWidget().removeStyleName("pithos-SelectedRow");\r
-               setCurrent(item);\r
-               getCurrent().getWidget().addStyleName("pithos-SelectedRow");\r
-               setPrevious(getCurrent());\r
-               GSS.get().setCurrentSelection(selected);\r
-               //cache the latest top level node (group) for selecting and expanding on refresh\r
-               if (item.getParentItem() == null)\r
-                       selectedGroup = item.getText();\r
-               else\r
-                       selectedGroup = item.getParentItem().getText();\r
-       }\r
-\r
-       @Override\r
-       public void onOpen(OpenEvent event) {\r
-               final TreeItem item = (TreeItem) event.getTarget();\r
-               updateUsers(item);\r
-       }\r
-}\r
index 381851d..0b48efb 100644 (file)
@@ -63,9 +63,7 @@ public class Search extends Composite implements FocusHandler,BlurHandler {
                        @Override\r
                        public void onKeyPress(KeyPressEvent event) {\r
                                char keyCode = event.getCharCode();\r
-                               if (keyCode == '\r')\r
-                                       GSS.get().showSearchResults(tb.getText());\r
-                               else if (keyCode == 27) {\r
+                if (keyCode == 27) {\r
                                        // Simulate the proper behavior for the escape key\r
                                        // (27 == ESC).\r
                                        onLostFocus((Widget)event.getSource());\r
@@ -74,19 +72,10 @@ public class Search extends Composite implements FocusHandler,BlurHandler {
                        }\r
                });\r
 \r
-               Button b = new Button(createHeaderHTML(images.searchButton(), "Search"), new ClickHandler() {\r
-                       @Override\r
-                       public void onClick(ClickEvent event) {\r
-                               GSS.get().showSearchResults(tb.getText());\r
-                       }\r
-               });\r
-               b.getElement().setId("button.search");\r
-               \r
                HorizontalPanel panel = new HorizontalPanel();\r
                panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);\r
                panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);\r
                panel.add(tb);\r
-               panel.add(b);\r
                initWidget(panel);\r
        }\r
 \r
diff --git a/web_client/src/gr/grnet/pithos/web/client/SearchResults.java b/web_client/src/gr/grnet/pithos/web/client/SearchResults.java
deleted file mode 100644 (file)
index d576c2d..0000000
+++ /dev/null
@@ -1,853 +0,0 @@
-/*
- * Copyright (c) 2011 Greek Research and Technology Network
- */
-package gr.grnet.pithos.web.client;
-
-
-import static com.google.gwt.query.client.GQuery.$;
-
-import gr.grnet.pithos.web.client.rest.GetCommand;
-import gr.grnet.pithos.web.client.rest.RestCommand;
-import gr.grnet.pithos.web.client.rest.RestException;
-import gr.grnet.pithos.web.client.rest.resource.FileResource;
-import gr.grnet.pithos.web.client.rest.resource.SearchResource;
-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;
-import gwtquery.plugins.draggable.client.DraggableOptions.RevertOption;
-import gwtquery.plugins.draggable.client.events.DragContext;
-import gwtquery.plugins.draggable.client.events.DragStartEvent;
-import gwtquery.plugins.draggable.client.events.DragStopEvent;
-import gwtquery.plugins.draggable.client.events.DragStartEvent.DragStartEventHandler;
-import gwtquery.plugins.draggable.client.events.DragStopEvent.DragStopEventHandler;
-import gwtquery.plugins.droppable.client.gwt.DragAndDropCellTable;
-import gwtquery.plugins.droppable.client.gwt.DragAndDropColumn;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-
-import com.google.gwt.cell.client.AbstractCell;
-import com.google.gwt.cell.client.ImageResourceCell;
-import com.google.gwt.cell.client.SafeHtmlCell;
-import com.google.gwt.cell.client.TextCell;
-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.http.client.URL;
-import com.google.gwt.i18n.client.DateTimeFormat;
-import com.google.gwt.resources.client.ClientBundle;
-import com.google.gwt.resources.client.ImageResource;
-import com.google.gwt.safehtml.shared.SafeHtml;
-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.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy;
-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;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.view.client.AsyncDataProvider;
-import com.google.gwt.view.client.HasData;
-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;
-
-/**
- * A composite that displays a list of search results for a particular query on
- * files.
- */
-public class SearchResults extends Composite{
-       private HTML searchResults = new HTML("Results for search:");
-       private String lastQuery;
-       SearchDataProvider provider = new SearchDataProvider();
-       /**
-        * Specifies that the images available for this composite will be the ones
-        * available in FileContextMenu.
-        */
-       public interface Images extends ClientBundle,FileContextMenu.Images, CellTreeView.Images, FileList.Images {
-
-               @Source("gr/grnet/pithos/resources/blank.gif")
-               ImageResource blank();
-
-               @Source("gr/grnet/pithos/resources/asc.png")
-               ImageResource asc();
-
-               @Source("gr/grnet/pithos/resources/desc.png")
-               ImageResource desc();
-       }
-
-       
-       interface TableResources extends DragAndDropCellTable.Resources {
-           @Source({CellTable.Style.DEFAULT_CSS, "GssCellTable.css"})
-           TableStyle cellTableStyle();
-         }
-       
-       /**
-          * The styles applied to the table.
-          */
-         interface TableStyle extends CellTable.Style {
-         }
-
-       private String showingStats = "";
-
-       private int startIndex = 0;
-
-       /**
-        * A constant that denotes the completion of an IncrementalCommand.
-        */
-       public static final boolean DONE = false;
-
-       
-       
-       private final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");
-
-       
-       
-       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(FileList.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.
-        */
-       int folderFileCount;
-
-       /**
-        * Total folder size
-        */
-       long folderTotalSize;
-
-       /**
-        * A cache of the files in the list.
-        */
-       private List<FileResource> files;
-
-       /**
-        * The widget's image bundle.
-        */
-       private final Images images;
-       
-       private FileContextMenu menuShowing;
-       private DragAndDropCellTable<FileResource> celltable;
-       private final MultiSelectionModel<FileResource> selectionModel;
-       
-       GssSimplePager pager;
-       GssSimplePager pagerTop;
-       /**
-        * 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
-        * the server, as well.
-        *
-        * @param _images
-        */
-       public SearchResults(Images _images) {
-               images = _images;
-               DragAndDropCellTable.Resources resources = GWT.create(TableResources.class);
-               ProvidesKey<FileResource> keyProvider = new ProvidesKey<FileResource>(){
-
-                       @Override
-                       public Object getKey(FileResource item) {
-                               return item.getUri();
-                       }
-                       
-               };
-               
-               celltable = new DragAndDropCellTable<FileResource>(GSS.VISIBLE_FILE_COUNT,resources,keyProvider){
-                       @Override
-                       protected void onBrowserEvent2(Event event) {
-                               /*if (DOM.eventGetType((Event) event) == Event.ONMOUSEDOWN && DOM.eventGetButton((Event) event) == NativeEvent.BUTTON_RIGHT){
-                                       fireClickEvent((Element) event.getEventTarget().cast());                                        
-                               }*/
-                               super.onBrowserEvent2(event);
-                       }
-               };
-               provider.addDataDisplay(celltable);
-               celltable.addDragStopHandler(dragStop);
-               celltable.addDragStartHandler(new DragStartEventHandler() {
-
-                     public void onDragStart(DragStartEvent event) {
-                       FileResource value = event.getDraggableData();
-                       
-                       com.google.gwt.dom.client.Element helper = event.getHelper();
-                       SafeHtmlBuilder sb = new SafeHtmlBuilder();
-                       sb.appendHtmlConstant("<b>");
-                       DisplayHelper.log(value.getName());
-                       if(getSelectedFiles().size()==1)
-                               sb.appendEscaped(value.getName());
-                       else
-                               sb.appendEscaped(getSelectedFiles().size()+" files");
-                       sb.appendHtmlConstant("</b>");
-                       helper.setInnerHTML(sb.toSafeHtml().asString());
-
-                     }
-                   });
-               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.addColumn(status,"");
-           
-           initDragOperation(status);
-               final DragAndDropColumn<FileResource,SafeHtml> nameColumn = new DragAndDropColumn<FileResource,SafeHtml>(new SafeHtmlCell()) {
-
-
-                       @Override
-                       public SafeHtml getValue(FileResource object) {
-                               SafeHtmlBuilder sb = new SafeHtmlBuilder();
-                sb.append(FileList.Templates.INSTANCE.filenameSpan(object.getName()));
-                               if (object.getContentType().endsWith("png") || object.getContentType().endsWith("gif") || object.getContentType().endsWith("jpeg") ){
-                    sb.appendHtmlConstant("&nbsp;").append(FileList.Templates.INSTANCE.viewLink(GSS.get().getTopPanel().getFileMenu().getDownloadURL(object), object.getOwner() + " : " + object.getPath() + object.getName()));
-                               }
-
-                               return sb.toSafeHtml();
-                       }
-                       
-               };
-               initDragOperation(nameColumn);
-               celltable.addColumn(nameColumn,"Name");
-               
-           DragAndDropColumn<FileResource,String> aColumn;
-               celltable.addColumn(aColumn=new DragAndDropColumn<FileResource,String>(new TextCell()) {
-                       @Override
-                       public String getValue(FileResource object) {
-                               return GSS.get().findUserFullName(object.getOwner());
-                       }                       
-               },"Owner");
-               initDragOperation(aColumn);
-               
-               celltable.addColumn(aColumn=new DragAndDropColumn<FileResource,String>(new TextCell()) {
-                       @Override
-                       public String getValue(FileResource object) {
-                               if(object.isDeleted())
-                                       return object.getPath()+" (In Trash)";
-                               return object.getPath();
-                       }                       
-               },"Path");
-               initDragOperation(aColumn);
-               
-               
-                       
-               celltable.addColumn(aColumn=new DragAndDropColumn<FileResource,String>(new TextCell()) {
-                       @Override
-                       public String getValue(FileResource object) {
-                               return object.getVersion().toString();
-                       }                       
-               },"Version");
-               initDragOperation(aColumn);
-               
-               
-               celltable.addColumn(aColumn=new DragAndDropColumn<FileResource,String>(new TextCell()) {
-                       @Override
-                       public String getValue(FileResource object) {
-                               // TODO Auto-generated method stub
-                               return object.getFileSizeAsString();
-                       }                       
-               },"Size");
-               initDragOperation(aColumn);
-                       
-               celltable.addColumn(aColumn=new DragAndDropColumn<FileResource,String>(new TextCell()) {
-                       @Override
-                       public String getValue(FileResource object) {
-                               return formatter.format(object.getModificationDate());
-                       }                       
-               },"Last Modified");
-               
-               
-              
-
-               VerticalPanel vp = new VerticalPanel();
-               vp.setWidth("100%");
-               celltable.setWidth("100%");
-               vp.add(searchResults);
-               searchResults.addStyleName("pithos-searchLabel");
-               pagerTop = new GssSimplePager(GssSimplePager.TextLocation.CENTER);
-               pagerTop.setDisplay(celltable);
-               vp.add(pagerTop);
-               vp.add(celltable);
-               pager = new GssSimplePager(GssSimplePager.TextLocation.CENTER);
-               pager.setDisplay(celltable);
-               //celltable.setPageSize(2);
-               
-               vp.add(pager);
-               vp.setCellWidth(celltable, "100%");
-               
-               initWidget(vp);
-               
-               //initWidget(celltable);
-               celltable.setStyleName("pithos-List");
-               selectionModel = new MultiSelectionModel<FileResource>();
-               
-
-                Handler selectionHandler = new SelectionChangeEvent.Handler() { 
-             @Override 
-             public void onSelectionChange(com.google.gwt.view.client.SelectionChangeEvent event) {
-                if(getSelectedFiles().size()==1)
-                        GSS.get().setCurrentSelection(getSelectedFiles().get(0));
-                else
-                        GSS.get().setCurrentSelection(getSelectedFiles());
-                               //contextMenu.setFiles(getSelectedFiles());
-             }
-         };
-         selectionModel.addSelectionChangeHandler(selectionHandler);
-         
-               celltable.setSelectionModel(selectionModel,GSSSelectionEventManager.<FileResource>createDefaultManager());
-               celltable.setPageSize(GSS.VISIBLE_FILE_COUNT);
-               celltable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
-               Scheduler.get().scheduleIncremental(new RepeatingCommand() {
-
-                       @Override
-                       public boolean execute() {
-                               return fetchRootFolder();
-                       }
-               });
-               sinkEvents(Event.ONCONTEXTMENU);
-               sinkEvents(Event.ONMOUSEUP);
-               sinkEvents(Event.ONMOUSEDOWN);
-               sinkEvents(Event.ONCLICK);
-               sinkEvents(Event.ONKEYDOWN);
-               sinkEvents(Event.ONDBLCLICK);
-               GSS.preventIESelection();
-       }
-       
-       //public native void fireClickEvent(Element element) /*-{
-         //  var evObj = $doc.createEvent('MouseEvents');
-           //evObj.initEvent('click', true, true);
-           //element.dispatchEvent(evObj);
-       //}-*/;
-
-        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($(FileList.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();
-                                     }
-                                       
-                               }
-                       });
-                 }
-       
-        public void showContextMenu(Event event){
-                menuShowing = new FileContextMenu(images, false, true);
-                       menuShowing=menuShowing.onEmptyEvent(event);
-        }
-       @Override
-       public void onBrowserEvent(Event event) {
-               
-               if (files == null || files.size() == 0) {
-                       if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) {
-                               menuShowing = new FileContextMenu(images, false, true);
-                               menuShowing=menuShowing.onEmptyEvent(event);
-                               event.preventDefault();
-                               event.cancelBubble(true);
-                       }
-                       return;
-               }
-               if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() != 0) {
-                       GWT.log("*****GOING TO SHOW CONTEXT MENU ****", null);
-                       menuShowing =  new FileContextMenu(images, false, false);
-                       menuShowing=menuShowing.onEvent(event);
-                       event.cancelBubble(true);
-                       event.preventDefault();
-               } else if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) {
-                       menuShowing = new FileContextMenu(images, false, true);
-                       menuShowing=menuShowing.onEmptyEvent(event);
-                       event.cancelBubble(true);
-                       event.preventDefault();
-               } 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()));
-                               if(!file.isDeleted()){
-                                       Window.open(file.getUri() + "?Authorization=" + URL.encodeComponent(sig) + "&Date=" + URL.encodeComponent(dateString), "_blank", "");
-                               }
-                               event.preventDefault();
-                               return;
-                       }
-               super.onBrowserEvent(event);
-       }
-
-       /**
-        * 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(null);
-               return DONE;
-       }
-
-
-       /**
-        * Update the display of the file list.
-        */
-       void update(boolean sort) {
-               int count = folderFileCount;
-               int max = startIndex + GSS.VISIBLE_FILE_COUNT;
-               if (max > count)
-                       max = count;
-               folderTotalSize = 0;
-               
-               copyListAndContinue(files);
-               for(FileResource f : files){
-                       folderTotalSize += f.getContentLength();
-               }
-               if (folderFileCount == 0) {
-                       showingStats = "no files";
-               } else if (folderFileCount < GSS.VISIBLE_FILE_COUNT) {
-                       if (folderFileCount == 1)
-                               showingStats = "1 file";
-                       else
-                               showingStats = folderFileCount + " files";
-                       showingStats += " (" + FileResource.getFileSizeAsString(folderTotalSize) + ")";
-               } else {
-                       showingStats = "" + (startIndex + 1) + " - " + max + " of " + count + " files" + " (" + FileResource.getFileSizeAsString(folderTotalSize) + ")";
-               }
-               updateCurrentlyShowingStats();
-
-       }
-
-       /**
-        * Return the proper icon based on the MIME type of the file.
-        *
-        * @param file
-        * @return the icon
-        */
-       private ImageResource getFileIcon(FileResource file) {
-               String mimetype = file.getContentType();
-               boolean shared = file.isShared();
-               if (mimetype == null)
-                       return shared ? images.documentShared() : images.document();
-               mimetype = mimetype.toLowerCase();
-               if (mimetype.startsWith("application/pdf"))
-                       return shared ? images.pdfShared() : images.pdf();
-               else if (mimetype.endsWith("excel"))
-                       return shared ? images.spreadsheetShared() : images.spreadsheet();
-               else if (mimetype.endsWith("msword"))
-                       return shared ? images.wordprocessorShared() : images.wordprocessor();
-               else if (mimetype.endsWith("powerpoint"))
-                       return shared ? images.presentationShared() : images.presentation();
-               else if (mimetype.startsWith("application/zip") ||
-                                       mimetype.startsWith("application/gzip") ||
-                                       mimetype.startsWith("application/x-gzip") ||
-                                       mimetype.startsWith("application/x-tar") ||
-                                       mimetype.startsWith("application/x-gtar"))
-                       return shared ? images.zipShared() : images.zip();
-               else if (mimetype.startsWith("text/html"))
-                       return shared ? images.htmlShared() : images.html();
-               else if (mimetype.startsWith("text/plain"))
-                       return shared ? images.txtShared() : images.txt();
-               else if (mimetype.startsWith("image/"))
-                       return shared ? images.imageShared() : images.image();
-               else if (mimetype.startsWith("video/"))
-                       return shared ? images.videoShared() : images.video();
-               else if (mimetype.startsWith("audio/"))
-                       return shared ? images.audioShared() : images.audio();
-               return shared ? images.documentShared() : images.document();
-       }
-
-       /**
-        * Update status panel with currently showing file stats.
-        */
-       public void updateCurrentlyShowingStats() {
-               GSS.get().getStatusPanel().updateCurrentlyShowing(showingStats);
-       }
-
-       public void updateFileCache(String query) {
-               final GSS app = GSS.get();
-               setLastQuery(query);
-               clearSelectedRows();
-               //clearLabels();
-               startIndex = 0;
-               app.showLoadingIndicator("Getting Search Results",null);
-               if (query == null || query.trim().equals("")) {
-                       searchResults.setHTML("You must specify a query.");
-                       setFiles(new ArrayList());
-                       update(true);
-                       app.hideLoadingIndicator();
-               } else if (!GSS.isValidResourceName(query)) {
-                       searchResults.setHTML("The query was invalid. Try to use words that appear in the file's name, contents or tags.");
-                       setFiles(new ArrayList());
-                       update(true);
-                       app.hideLoadingIndicator();
-               } else{
-                       searchResults.setHTML("Search results for " + query);
-                       showCellTable(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)
-                               files.add(fres);
-               }
-               else
-                       files = _files;
-               Collections.sort(files, new Comparator<FileResource>() {
-
-                       @Override
-                       public int compare(FileResource arg0, FileResource arg1) {
-                               return arg0.getName().compareTo(arg1.getName());
-                       }
-
-               });
-               folderFileCount = files.size();
-       }
-
-       
-
-       
-       /**
-        * Does the list contains the requested filename
-        *
-        * @param fileName
-        * @return true/false
-        */
-       public boolean contains(String fileName) {
-               for (int i = 0; i < files.size(); i++)
-                       if (files.get(i).getName().equals(fileName))
-                               return true;
-               return false;
-       }
-
-       public void clearSelectedRows() {
-               Iterator<FileResource> it = selectionModel.getSelectedSet().iterator();
-               while(it.hasNext()){
-                       selectionModel.setSelected(it.next(),false);
-               }
-       }
-
-       /**
-        *
-        */
-       public void selectAllRows() {
-               Iterator<FileResource> it = selectionModel.getSelectedSet().iterator();
-               while(it.hasNext()){
-                       selectionModel.setSelected(it.next(),true);
-               }
-
-
-       }
-
-       
-       private void sortFiles(final String sortingProperty, final boolean sortingType){
-               Collections.sort(files, new Comparator<FileResource>() {
-
-            @Override
-            public int compare(FileResource arg0, FileResource 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());
-                            } else if (sortingProperty.equals("owner")) {
-                                    return arg0.getOwner().compareTo(arg1.getOwner());
-                            } else if (sortingProperty.equals("date")) {
-                                    return arg0.getModificationDate().compareTo(arg1.getModificationDate());
-                            } else if (sortingProperty.equals("size")) {
-                                    return arg0.getContentLength().compareTo(arg1.getContentLength());
-                            } else if (sortingProperty.equals("name")) {
-                                    return arg0.getName().compareTo(arg1.getName());
-                            } else if (sortingProperty.equals("path")) {
-                                    return arg0.getUri().compareTo(arg1.getUri());
-                            } else {
-                                    return arg0.getName().compareTo(arg1.getName());
-                            }
-                    }
-                    else if (sortingProperty.equals("version")) {
-                            
-                            return arg1.getVersion().compareTo(arg0.getVersion());
-                    } else if (sortingProperty.equals("owner")) {
-                            
-                            return arg1.getOwner().compareTo(arg0.getOwner());
-                    } else if (sortingProperty.equals("date")) {
-                            
-                            return arg1.getModificationDate().compareTo(arg0.getModificationDate());
-                    } else if (sortingProperty.equals("size")) {
-                            
-                            return arg1.getContentLength().compareTo(arg0.getContentLength());
-                    } else if (sortingProperty.equals("name")) {
-                            
-                            return arg1.getName().compareTo(arg0.getName());
-                    } else if (sortingProperty.equals("path")) {
-                            
-                            return arg1.getUri().compareTo(arg0.getUri());
-                    } else {
-                            
-                            return arg1.getName().compareTo(arg0.getName());
-                    }
-            }
-
-               });
-       }
-       
-       
-       /**
-        * 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(false);
-                       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(false);                           
-                       }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(false);
-                                               }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(boolean update){
-               if(celltable.getRowCount()>GSS.VISIBLE_FILE_COUNT){
-                       pager.setVisible(true);
-                       pagerTop.setVisible(true);
-               }
-               else{
-                       pager.setVisible(false);
-                       pagerTop.setVisible(false);
-               }
-               if(update)
-                       provider.onRangeChanged(celltable);
-               celltable.redrawHeaders();              
-       }
-       
-       
-       /**
-        * Retrieve the lastQuery.
-        *
-        * @return the lastQuery
-        */
-       public String getLastQuery() {
-               return lastQuery;
-       }
-       
-       
-       /**
-        * Modify the lastQuery.
-        *
-        * @param lastQuery the lastQuery to set
-        */
-       public void setLastQuery(String lastQuery) {
-               this.lastQuery = lastQuery;
-       }
-       
-       class SearchDataProvider extends AsyncDataProvider<FileResource>{
-
-               @Override
-               protected void onRangeChanged(final HasData<FileResource> display) {
-                       final int start = display.getVisibleRange().getStart();
-                       final GSS app = GSS.get();
-                       if(getLastQuery()==null||getLastQuery().equals("")){
-                               display.setRowCount(0,true);
-                               return;
-                               
-                       }
-                       GetCommand<SearchResource> eg = new GetCommand<SearchResource>(SearchResource.class,
-                                               app.getApiPath() + "search/" +URL.encodeComponent(getLastQuery())+"?start="+start, null) {
-
-                               @Override
-                               public void onComplete() {
-                                       SearchResource s = getResult();
-                                       display.setRowCount(s.getSize(),true);
-                                       display.setRowData(start, s.getFiles());
-                                       setFiles(s.getFiles());
-                                       update(true);
-                                       
-                               }
-
-                               @Override
-                               public void onError(Throwable t) {
-                                       if(t instanceof RestException)
-                                               app.displayError("Unable to perform search:"+((RestException)t).getHttpStatusText());
-                                       else
-                                               app.displayError("System error performing search:"+t.getMessage());
-                                       GWT.log("",t);
-                                       updateFileCache("");
-                               }
-
-                       };
-                       DeferredCommand.addCommand(eg);
-                       
-               }
-               
-       }
-
-}
index fea03dc..b10d5fd 100644 (file)
@@ -31,7 +31,7 @@ public class TopPanel extends Composite {
         * An image bundle for this widgets images.
         */
        public interface Images extends ClientBundle, FileMenu.Images, EditMenu.Images,
-                       SettingsMenu.Images, GroupMenu.Images, FilePropertiesDialog.Images,
+                       SettingsMenu.Images, FilePropertiesDialog.Images,
                        HelpMenu.Images, LoadingIndicator.Images {
 
                @Source("gr/grnet/pithos/resources/exit.png")
@@ -75,11 +75,6 @@ public class TopPanel extends Composite {
        private EditMenu editMenu;
 
        /**
-        * The group menu widget.
-        */
-       private GroupMenu groupMenu;
-
-       /**
         * The settings menu widget.
         */
        private SettingsMenu settingsMenu;
@@ -103,10 +98,10 @@ public class TopPanel extends Composite {
        public TopPanel(Images images) {
                fileMenu = new FileMenu(images);
                editMenu = new EditMenu(images);
-               groupMenu = new GroupMenu(images);
                settingsMenu = new SettingsMenu(images);
                helpMenu = new HelpMenu(images);
                loading = new LoadingIndicator(images);
+        loading.hide();
                HorizontalPanel outer = new HorizontalPanel();
 
                outer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
@@ -146,11 +141,6 @@ public class TopPanel extends Composite {
                };
                editItem.getElement().setId("topMenu.edit");
                
-               MenuItem groupItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
-                                       AbstractImagePrototype.create(images.group()).getHTML() + "</td><td>Group</td></tr></table>", true,
-                                       groupMenu.getContextMenu());
-               groupItem.getElement().setId("topMenu.group");
-               
                MenuItem configureItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
                                        AbstractImagePrototype.create(images.configure()).getHTML() + "</td><td>Settings</td></tr></table>",
                                        true,settingsMenu.getContextMenu());
@@ -168,7 +158,6 @@ public class TopPanel extends Composite {
                menu.addItem(quitItem);
                menu.addItem(fileItem);
                menu.addItem(editItem);
-               menu.addItem(groupItem);
                menu.addItem(configureItem);
                menu.addItem(helpItem);
 
diff --git a/web_client/src/gr/grnet/pithos/web/client/UserAddDialog.java b/web_client/src/gr/grnet/pithos/web/client/UserAddDialog.java
deleted file mode 100644 (file)
index 0cd8b52..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright (c) 2011 Greek Research and Technology Network
- */
-package gr.grnet.pithos.web.client;
-
-import gr.grnet.pithos.web.client.rest.GetCommand;
-import gr.grnet.pithos.web.client.rest.PostCommand;
-import gr.grnet.pithos.web.client.rest.RestException;
-import gr.grnet.pithos.web.client.rest.resource.GroupResource;
-import gr.grnet.pithos.web.client.rest.resource.UserResource;
-import gr.grnet.pithos.web.client.rest.resource.UserSearchResource;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.dom.client.NativeEvent;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.dom.client.FocusEvent;
-import com.google.gwt.event.dom.client.FocusHandler;
-import com.google.gwt.event.dom.client.KeyCodes;
-import com.google.gwt.event.dom.client.KeyUpEvent;
-import com.google.gwt.event.dom.client.KeyUpHandler;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.user.client.DeferredCommand;
-import com.google.gwt.user.client.Event.NativePreviewEvent;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.DialogBox;
-import com.google.gwt.user.client.ui.FlexTable;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
-import com.google.gwt.user.client.ui.SuggestBox;
-import com.google.gwt.user.client.ui.VerticalPanel;
-
-public class UserAddDialog extends DialogBox {
-
-       private MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
-       private SuggestBox suggestBox = new SuggestBox(oracle);
-
-       String selectedUser=null;
-       FlexTable userTable = new FlexTable();
-
-       /**
-        * The widget's constructor.
-        */
-       public UserAddDialog() {
-               setAnimationEnabled(true);
-               setText("Add User");
-               VerticalPanel panel = new VerticalPanel();
-               setWidget(panel);
-               panel.addStyleName("pithos-TabPanelBottom");
-               userTable.addStyleName("pithos-permList");
-               userTable.setWidget(0, 0, new Label("Username:"));
-               userTable.getFlexCellFormatter().setStyleName(0, 0, "props-toplabels");
-               suggestBox.getTextBox().addFocusHandler(new FocusHandler() {
-
-                       @Override
-                       public void onFocus(FocusEvent event) {
-                               if (selectedUser != null && selectedUser.endsWith("@"))
-                                       updateSuggestions();
-                       }
-               });
-
-               suggestBox.addKeyUpHandler(new KeyUpHandler() {
-
-                       @Override
-                       public void onKeyUp(KeyUpEvent event) {
-                               // Ignore the arrow keys.
-                               int keyCode=event.getNativeKeyCode();
-                               if(keyCode == KeyCodes.KEY_UP ||
-                                               keyCode == KeyCodes.KEY_DOWN ||
-                                               keyCode == KeyCodes.KEY_LEFT ||
-                                               keyCode == KeyCodes.KEY_RIGHT)
-                                       return;
-                               if (keyCode==KeyCodes.KEY_ESCAPE) {
-                                       suggestBox.hideSuggestionList();
-                                       return;
-                               }
-                               String text = suggestBox.getText().trim();
-                               // Avoid useless queries for keystrokes that do not modify the
-                               // text.
-                               if (text.equals(selectedUser))
-                                       return;
-                               selectedUser = text;
-                               // Go to the server only if the user typed the @ character.
-                               if (selectedUser.endsWith("@"))
-                                       updateSuggestions();
-                       }
-               });
-               suggestBox.getElement().setId("addUser.textBox");
-        userTable.setWidget(0, 1, suggestBox);
-        panel.add(userTable);
-               HorizontalPanel buttons = new HorizontalPanel();
-               Button ok = new Button("OK", new ClickHandler() {
-                       @Override
-                       public void onClick(ClickEvent event) {
-                               addUser();
-                               hide();
-                       }
-               });
-               ok.getElement().setId("addUser.button.ok");
-               buttons.add(ok);
-               buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER);
-               // Create the 'Cancel' button, along with a listener that hides the
-               // dialog when the button is clicked.
-               Button cancel = new Button("Cancel", new ClickHandler() {
-                       @Override
-                       public void onClick(ClickEvent event) {
-                               hide();
-                       }
-               });
-               cancel.getElement().setId("addUser.button.cancel");
-               buttons.add(cancel);
-               buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);
-               buttons.setSpacing(8);
-               buttons.addStyleName("pithos-TabPanelBottom");
-               panel.add(buttons);
-               panel.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);
-               panel.addStyleName("pithos-DialogBox");
-       }
-
-       @Override
-       public void center() {
-               super.center();
-               suggestBox.setFocus(true);
-       }
-
-       @Override
-       protected void onPreviewNativeEvent(NativePreviewEvent preview) {
-               super.onPreviewNativeEvent(preview);
-
-               NativeEvent evt = preview.getNativeEvent();
-               if (evt.getType().equals("keydown"))
-                       // Use the popup's key preview hooks to close the dialog when either
-                       // enter or escape is pressed.
-                       switch (evt.getKeyCode()) {
-                               case KeyCodes.KEY_ENTER:
-                                       addUser();
-                                       hide();
-                                       break;
-                               case KeyCodes.KEY_ESCAPE:
-                                       hide();
-                                       break;
-                       }
-       }
-
-       /**
-        * Generate a request to add a user to a group.
-        *
-        * @param groupName the name of the group to create
-        */
-       private void addUser() {
-               GroupResource group = (GroupResource) GSS.get().getCurrentSelection();
-               selectedUser = suggestBox.getText();
-               if ( group == null ) {
-                       GSS.get().displayError("Empty group name!");
-                       return;
-               }
-               if ( selectedUser == null ) {
-                       GSS.get().displayError("No User Selected!");
-                       return;
-               }
-               PostCommand cg = new PostCommand(group.getUri()+"?name="+selectedUser, "", 201){
-                       @Override
-                       public void onComplete() {
-                               GSS.get().getGroups().updateGroups();
-                               GSS.get().showUserList();
-                       }
-
-                       @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("User does not exist");
-                                       else if(statusCode == 409)
-                                               GSS.get().displayError("A user with the same name already exists");
-                                       else if(statusCode == 413)
-                                               GSS.get().displayError("Your quota has been exceeded");
-                                       else
-                                               GSS.get().displayError("Unable to add user: "+((RestException)t).getHttpStatusText());
-                               }
-                               else
-                                       GSS.get().displayError("System error adding user: "+t.getMessage());
-                       }
-               };
-               DeferredCommand.addCommand(cg);
-       }
-
-       /**
-        * Update the list of suggestions.
-        */
-       protected void updateSuggestions() {
-               final GSS app = GSS.get();
-               String query = selectedUser.substring(0, selectedUser.length()-1);
-               GWT.log("Searching for " + query, null);
-
-               GetCommand<UserSearchResource> eg = new GetCommand<UserSearchResource>(UserSearchResource.class,
-                                       app.getApiPath() + "users/" + URL.encodeComponent(query), false, null) {
-
-                       @Override
-                       public void onComplete() {
-                               suggestBox.hideSuggestionList();
-                               oracle.clear();
-                               UserSearchResource s = getResult();
-                               for (UserResource user : s.getUsers()) {
-                                       GWT.log("Found " + user.getUsername(), null);
-                                       oracle.add(user.getUsername());
-                               }
-                               suggestBox.showSuggestionList();
-                       }
-
-                       @Override
-                       public void onError(Throwable t) {
-                               if(t instanceof RestException)
-                                       app.displayError("Unable to perform search: "+((RestException)t).getHttpStatusText());
-                               else
-                                       app.displayError("System error while searching for users: "+t.getMessage());
-                               GWT.log("", t);
-                               DisplayHelper.log(t.getMessage());
-                       }
-
-               };
-               DeferredCommand.addCommand(eg);
-       }
-
-}
index 4ab4191..cc73ab8 100644 (file)
@@ -5,11 +5,9 @@ package gr.grnet.pithos.web.client.commands;
 
 import gr.grnet.pithos.web.client.DeleteFileDialog;
 import gr.grnet.pithos.web.client.DeleteFolderDialog;
-import gr.grnet.pithos.web.client.DeleteGroupDialog;
 import gr.grnet.pithos.web.client.EditMenu.Images;
 import gr.grnet.pithos.web.client.GSS;
 import gr.grnet.pithos.web.client.rest.resource.FileResource;
-import gr.grnet.pithos.web.client.rest.resource.GroupResource;
 import gr.grnet.pithos.web.client.rest.resource.GroupUserResource;
 import gr.grnet.pithos.web.client.rest.resource.RestResourceWrapper;
 
@@ -60,9 +58,6 @@ public class DeleteCommand implements Command{
                        dlg.center();
                } else if (selection instanceof GroupUserResource) {
                        // TODO implement user deletion
-               } else if (selection instanceof GroupResource) {
-                       DeleteGroupDialog dlg = new DeleteGroupDialog(newImages);
-                       dlg.center();
                }
-       }
+    }
 }
diff --git a/web_client/src/gr/grnet/pithos/web/client/commands/DeleteUserOrGroupCommand.java b/web_client/src/gr/grnet/pithos/web/client/commands/DeleteUserOrGroupCommand.java
deleted file mode 100644 (file)
index 5cd3551..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- *  Copyright (c) 2011 Greek Research and Technology Network
- */
-package gr.grnet.pithos.web.client.commands;
-
-import gr.grnet.pithos.web.client.DeleteGroupDialog;
-import gr.grnet.pithos.web.client.DeleteUserDialog;
-import gr.grnet.pithos.web.client.GSS;
-import gr.grnet.pithos.web.client.Groups.Images;
-import gr.grnet.pithos.web.client.rest.resource.GroupResource;
-import gr.grnet.pithos.web.client.rest.resource.GroupUserResource;
-
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-
-public class DeleteUserOrGroupCommand implements Command{
-       private PopupPanel containerPanel;
-       final Images images;
-
-       /**
-        * @param aContainerPanel
-        * @param newImages the images of the new folder dialog
-        */
-       public DeleteUserOrGroupCommand(PopupPanel aContainerPanel, final Images newImages){
-               containerPanel = aContainerPanel;
-               images = newImages;
-       }
-
-       @Override
-       public void execute() {
-               containerPanel.hide();
-               if(GSS.get().getCurrentSelection() instanceof GroupResource)
-                       displayNewGroup();
-               else if(GSS.get().getCurrentSelection() instanceof GroupUserResource)
-                       displayNewUser();
-               else
-                       GSS.get().displayError("No user or group selected");
-       }
-
-       void displayNewGroup() {
-               DeleteGroupDialog dlg = new DeleteGroupDialog(images);
-               dlg.center();
-       }
-
-       void displayNewUser() {
-               DeleteUserDialog dlg = new DeleteUserDialog(images);
-               dlg.center();
-       }
-
-}
diff --git a/web_client/src/gr/grnet/pithos/web/client/commands/NewGroupCommand.java b/web_client/src/gr/grnet/pithos/web/client/commands/NewGroupCommand.java
deleted file mode 100644 (file)
index 59a2c81..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- *  Copyright (c) 2011 Greek Research and Technology Network
- */
-package gr.grnet.pithos.web.client.commands;
-
-import gr.grnet.pithos.web.client.GroupPropertiesDialog;
-
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-
-public class NewGroupCommand implements Command{
-       private PopupPanel containerPanel;
-
-       /**
-        * @param _containerPanel
-        */
-       public NewGroupCommand(PopupPanel _containerPanel){
-               containerPanel = _containerPanel;
-       }
-
-       @Override
-       public void execute() {
-               containerPanel.hide();
-               displayNewGroup();
-       }
-
-       void displayNewGroup() {
-               GroupPropertiesDialog dlg = new GroupPropertiesDialog(true);
-               dlg.center();
-       }
-
-}
diff --git a/web_client/src/gr/grnet/pithos/web/client/commands/NewUserCommand.java b/web_client/src/gr/grnet/pithos/web/client/commands/NewUserCommand.java
deleted file mode 100644 (file)
index bb149b4..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- *  Copyright (c) 2011 Greek Research and Technology Network
- */
-package gr.grnet.pithos.web.client.commands;
-
-import gr.grnet.pithos.web.client.UserAddDialog;
-
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.PopupPanel;
-
-
-public class NewUserCommand implements Command {
-       private PopupPanel containerPanel;
-
-       /**
-        * @param _containerPanel
-        */
-       public NewUserCommand(PopupPanel _containerPanel){
-               containerPanel = _containerPanel;
-       }
-
-       @Override
-       public void execute() {
-               containerPanel.hide();
-               displayNewUser();
-       }
-
-       private void displayNewUser() {
-               UserAddDialog dlg = new UserAddDialog();
-               dlg.center();
-       }
-
-}
index d25019a..602b6d9 100644 (file)
@@ -34,43 +34,6 @@ public class PasteCommand implements Command {
        public void execute() {
                containerPanel.hide();
                Object selection = GSS.get().getCurrentSelection();
-               if(selection != null && selection instanceof GroupResource){
-                       final ClipboardItem citem = GSS.get().getClipboard().getItem();
-                       GroupResource group = (GroupResource) GSS.get().getCurrentSelection();
-                       if(citem.getUser() != null){
-                               PostCommand cg = new PostCommand(group.getUri()+"?name="+citem.getUser().getUsername(), "", 201){
-
-                                       @Override
-                                       public void onComplete() {
-                                               GSS.get().getGroups().updateGroups();
-                                               GSS.get().showUserList();
-                                               GSS.get().getClipboard().setItem(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("User does not exist");
-                                                       else if(statusCode == 409)
-                                                               GSS.get().displayError("A user with the same name already exists");
-                                                       else if(statusCode == 413)
-                                                               GSS.get().displayError("Your quota has been exceeded");
-                                                       else
-                                                               GSS.get().displayError("Unable to add user:"+((RestException)t).getHttpStatusText());
-                                               }
-                                               else
-                                                       GSS.get().displayError("System error adding user:"+t.getMessage());
-                                       }
-                               };
-                               DeferredCommand.addCommand(cg);
-                               return;
-                       }
-               }
                FolderResource selectedFolder = null;
                if(selection != null && selection instanceof RestResourceWrapper)
                        selectedFolder = ((RestResourceWrapper)selection).getResource();
diff --git a/web_client/src/gr/grnet/pithos/web/client/foldertree/AccountResource.java b/web_client/src/gr/grnet/pithos/web/client/foldertree/AccountResource.java
new file mode 100644 (file)
index 0000000..13b4c56
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2011 Greek Research and Technology Network
+ */
+
+package gr.grnet.pithos.web.client.foldertree;
+
+import com.google.gwt.http.client.Header;
+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 gr.grnet.pithos.web.client.rest.resource.RestResource;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by IntelliJ IDEA. User: chstath Date: 5/19/11 Time: 2:55 PM To change this template use File | Settings |
+ * File Templates.
+ */
+public class AccountResource extends Resource {
+
+    private List<ContainerResource> containers = new ArrayList<ContainerResource>();
+
+    @Override
+    public String getLastModifiedSince() {
+        return null;
+    }
+
+    public List<ContainerResource> getContainers() {
+        return containers;
+    }
+}
diff --git a/web_client/src/gr/grnet/pithos/web/client/foldertree/ContainerResource.java b/web_client/src/gr/grnet/pithos/web/client/foldertree/ContainerResource.java
new file mode 100644 (file)
index 0000000..324aee8
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2011 Greek Research and Technology Network
+ */
+
+package gr.grnet.pithos.web.client.foldertree;
+
+import com.google.gwt.http.client.Header;
+import com.google.gwt.json.client.JSONObject;
+import com.google.gwt.json.client.JSONParser;
+import gr.grnet.pithos.web.client.foldertree.Resource;
+import java.util.Date;
+
+public class ContainerResource extends Resource {
+    /*
+     * The name of the container
+     */
+    private String name;
+
+    /*
+     * The number of objects inside the container
+     */
+    private long count;
+
+    /*
+     * The total size of the objects inside the container
+     */
+    private long bytes;
+
+    /*
+     * The last object modification date
+     */
+    private Date lastModified;
+
+    /*
+     * The date the container was created
+     */
+    private Date created;
+
+    @Override
+    public String getLastModifiedSince() {
+        return "";
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public long getBytes() {
+        return bytes;
+    }
+
+    public long getCount() {
+        return count;
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+
+    public Date getLastModified() {
+        return lastModified;
+    }
+
+    public void setBytes(long bytes) {
+        this.bytes = bytes;
+    }
+
+    public void setCount(long count) {
+        this.count = count;
+    }
+
+    public void setCreated(Date created) {
+        this.created = created;
+    }
+
+    public void setLastModified(Date lastModified) {
+        this.lastModified = lastModified;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}
diff --git a/web_client/src/gr/grnet/pithos/web/client/foldertree/File.java b/web_client/src/gr/grnet/pithos/web/client/foldertree/File.java
new file mode 100644 (file)
index 0000000..8894514
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+ * Copyright (c) 2011 Greek Research and Technology Network
+ */
+
+package gr.grnet.pithos.web.client.foldertree;
+
+public class File {
+}
diff --git a/web_client/src/gr/grnet/pithos/web/client/foldertree/Folder.java b/web_client/src/gr/grnet/pithos/web/client/foldertree/Folder.java
new file mode 100644 (file)
index 0000000..2e23484
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2011 Greek Research and Technology Network
+ */
+
+package gr.grnet.pithos.web.client.foldertree;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Folder {
+    private String uri;
+
+    private String name;
+
+    private List<Folder> subfolders = new ArrayList<Folder>();
+
+    public Folder(String name) {
+        this.name = name;
+    }
+
+    public String getUri() {
+        return uri;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public List<Folder> getSubfolders() {
+        return subfolders;
+    }
+
+    public void setSubfolders(List<Folder> subfolders) {
+        this.subfolders = subfolders;
+    }
+}
diff --git a/web_client/src/gr/grnet/pithos/web/client/foldertree/FolderTreeView.java b/web_client/src/gr/grnet/pithos/web/client/foldertree/FolderTreeView.java
new file mode 100644 (file)
index 0000000..152faf7
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2011 Greek Research and Technology Network
+ */
+
+package gr.grnet.pithos.web.client.foldertree;
+
+import com.google.gwt.cell.client.AbstractCell;
+import com.google.gwt.cell.client.Cell;
+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.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.client.DeferredCommand;
+import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.IncrementalCommand;
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.Tree;
+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;
+import com.google.gwt.view.client.TreeViewModel.NodeInfo;
+import gr.grnet.pithos.web.client.CellTreeViewModel;
+import gr.grnet.pithos.web.client.CellTreeViewUtils;
+import gr.grnet.pithos.web.client.FolderContextMenu;
+import gr.grnet.pithos.web.client.GSS;
+import gr.grnet.pithos.web.client.rest.resource.FolderResource;
+import gr.grnet.pithos.web.client.rest.resource.RestResource;
+import gr.grnet.pithos.web.client.rest.resource.RestResourceWrapper;
+import gwtquery.plugins.droppable.client.gwt.DragAndDropCellTree;
+import java.util.Arrays;
+
+public class FolderTreeView extends Composite {
+
+    static interface BasicResources extends CellTree.Resources {
+
+        @ImageOptions(flipRtl = true)
+        @Source("cellTreeClosedItem.gif")
+        ImageResource cellTreeClosedItem();
+
+        @ImageOptions(flipRtl = true)
+        @Source("cellTreeLoadingBasic.gif")
+        ImageResource cellTreeLoading();
+
+        @ImageOptions(flipRtl = true)
+        @Source("cellTreeOpenItem.gif")
+        ImageResource cellTreeOpenItem();
+
+        @Source({"GssCellTreeBasic.css"})
+        CellTree.Style cellTreeStyle();
+    }
+
+    static interface Images extends ClientBundle,Tree.Resources, FolderContextMenu.Images {
+
+        @Source("gr/grnet/pithos/resources/folder_home.png")
+        ImageResource home();
+
+        @Source("gr/grnet/pithos/resources/folder_yellow.png")
+        ImageResource folderYellow();
+    }
+
+    private static Images images = GWT.create(Images.class);
+
+    static interface Templates extends SafeHtmlTemplates {
+        Templates INSTANCE = GWT.create(Templates.class);
+
+        @Template("<span>{0}</span>")
+        public SafeHtml nameSpan(String name);
+      }
+
+    static class FolderCell extends AbstractCell<Folder> {
+
+        @Override
+        public void render(Context context, Folder folder, SafeHtmlBuilder safeHtmlBuilder) {
+            String html = AbstractImagePrototype.create(images.folderYellow()).getHTML();
+            safeHtmlBuilder.appendHtmlConstant(html);
+            safeHtmlBuilder.append(Templates.INSTANCE.nameSpan(folder.getName()));
+        }
+    }
+
+    private SingleSelectionModel<Folder> selectionModel = new SingleSelectionModel<Folder>();
+
+    public FolderTreeView() {
+        final FolderTreeViewModel model = new FolderTreeViewModel(selectionModel);
+        /*
+         * 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);
+        DragAndDropCellTree tree = new DragAndDropCellTree(model,null, res);
+
+        tree.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
+
+        Handler selectionHandler = new SelectionChangeEvent.Handler() {
+            @Override
+            public void onSelectionChange(com.google.gwt.view.client.SelectionChangeEvent event) {
+                NodeInfo<Folder> nodeInfo = (NodeInfo<Folder>) model.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);
+        sinkEvents(Event.ONCONTEXTMENU);
+        sinkEvents(Event.ONMOUSEUP);
+        initWidget(tree);
+    }
+}
diff --git a/web_client/src/gr/grnet/pithos/web/client/foldertree/FolderTreeViewModel.java b/web_client/src/gr/grnet/pithos/web/client/foldertree/FolderTreeViewModel.java
new file mode 100644 (file)
index 0000000..9384e1b
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2011 Greek Research and Technology Network
+ */
+
+package gr.grnet.pithos.web.client.foldertree;
+
+import com.google.gwt.cell.client.AbstractCell;
+import com.google.gwt.cell.client.Cell;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.Scheduler;
+import com.google.gwt.core.client.Scheduler.ScheduledCommand;
+import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
+import com.google.gwt.view.client.ListDataProvider;
+import com.google.gwt.view.client.SingleSelectionModel;
+import com.google.gwt.view.client.TreeViewModel;
+import gr.grnet.pithos.web.client.GSS;
+import gr.grnet.pithos.web.client.foldertree.FolderTreeView.FolderCell;
+import gr.grnet.pithos.web.client.rest.GetRequest;
+import gr.grnet.pithos.web.client.rest.RestException;
+import gwtquery.plugins.droppable.client.gwt.DragAndDropNodeInfo;
+
+public class FolderTreeViewModel implements TreeViewModel {
+
+    private SingleSelectionModel<Folder> selectionModel;
+
+    public FolderTreeViewModel(SingleSelectionModel<Folder> selectionModel) {
+        this.selectionModel = selectionModel;
+    }
+    
+    @Override
+    public <T> NodeInfo<?> getNodeInfo(T value) {
+        if (value == null) {
+            final ListDataProvider<Folder> dataProvider = new ListDataProvider<Folder>();
+            Folder f = new Folder("Loading ...");
+            dataProvider.getList().add(f);
+            Scheduler.get().scheduleDeferred(new ScheduledCommand() {
+                @Override
+                public void execute() {
+                    fetchAccount(dataProvider);
+                }
+            });
+            return new DragAndDropNodeInfo<Folder>(dataProvider, new FolderCell(), selectionModel, null);
+        }
+        else {
+            final ListDataProvider<Folder> dataProvider = new ListDataProvider<Folder>();
+            return new DragAndDropNodeInfo<Folder>(dataProvider, new FolderCell(), selectionModel, null);
+        }
+    }
+
+    @Override
+    public boolean isLeaf(Object o) {
+        if (o instanceof Folder) {
+            Folder f = (Folder) o;
+            return f.getSubfolders().isEmpty();
+        }
+        return false;
+    }
+
+    public void fetchAccount(final ListDataProvider<Folder> dataProvider) {
+        GSS app = GSS.get();
+        String path = app.getApiPath() + app.getUsername() + "?format=json";
+
+        GetRequest<AccountResource> getAccount = new GetRequest<AccountResource>(AccountResource.class, path) {
+            @Override
+            public void onSuccess(AccountResource result) {
+                dataProvider.getList().clear();
+                for (ContainerResource c : result.getContainers()) {
+                    dataProvider.getList().add(new Folder(c.getName()));
+                }
+            }
+
+            @Override
+            public void onError(Throwable t) {
+                GWT.log("Error getting account", t);
+                if (t instanceof RestException)
+                    GSS.get().displayError("Error getting account: " + ((RestException) t).getHttpStatusText());
+                else
+                    GSS.get().displayError("System error fetching user data: " + t.getMessage());
+            }
+        };
+
+        Scheduler.get().scheduleDeferred(getAccount);
+    }
+}
diff --git a/web_client/src/gr/grnet/pithos/web/client/foldertree/GssCellTreeBasic.css b/web_client/src/gr/grnet/pithos/web/client/foldertree/GssCellTreeBasic.css
new file mode 100644 (file)
index 0000000..b37b22e
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+.cellTreeWidget {
+  
+}
+
+.cellTreeEmptyMessage {
+  padding-left: 16px;
+  font-style: italic;
+}
+
+.cellTreeItem {
+  padding-top: 4px;
+  padding-bottom: 4px;
+  cursor: hand;
+  cursor: pointer;
+  zoom: 1;
+}
+
+.cellTreeItemImage {
+  
+}
+
+.cellTreeItemImageValue {
+  zoom: 1;
+}
+
+.cellTreeItemValue {
+  padding-left: 3px;
+  padding-right: 3px;
+  outline: none;
+}
+
+.cellTreeOpenItem {
+  
+}
+
+.cellTreeTopItem {
+  
+}
+
+.cellTreeTopItemImage {
+  
+}
+
+.cellTreeTopItemImageValue {
+  
+}
+
+.cellTreeKeyboardSelectedItem {
+  background-color: #ffc;
+  outline: none;
+}
+
+.cellTreeSelectedItem {
+  background-color: #628cd5;
+  color: white;
+  height: auto;
+  overflow: visible;
+}
+
+.cellTreeShowMoreButton {
+  padding-left: 16px;
+  outline: none;
+}
\ No newline at end of file
diff --git a/web_client/src/gr/grnet/pithos/web/client/foldertree/ObjectResource.java b/web_client/src/gr/grnet/pithos/web/client/foldertree/ObjectResource.java
new file mode 100644 (file)
index 0000000..aae7e76
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+ * Copyright (c) 2011 Greek Research and Technology Network
+ */
+
+package gr.grnet.pithos.web.client.foldertree;
+
+public class ObjectResource {
+}
diff --git a/web_client/src/gr/grnet/pithos/web/client/foldertree/Resource.java b/web_client/src/gr/grnet/pithos/web/client/foldertree/Resource.java
new file mode 100644 (file)
index 0000000..314ac24
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2011 Greek Research and Technology Network
+ */
+
+package gr.grnet.pithos.web.client.foldertree;
+
+import com.google.gwt.http.client.Header;
+import com.google.gwt.http.client.Response;
+import com.google.gwt.i18n.client.DateTimeFormat;
+import com.google.gwt.json.client.JSONArray;
+import com.google.gwt.json.client.JSONNumber;
+import com.google.gwt.json.client.JSONObject;
+import com.google.gwt.json.client.JSONParser;
+import com.google.gwt.json.client.JSONString;
+import com.google.gwt.json.client.JSONValue;
+import java.util.Date;
+
+public abstract class Resource {
+
+    String uri;
+
+    public String getUri() {
+        return uri;
+    }
+
+    protected static String unmarshallString(JSONObject obj, String key){
+        if(obj.get(key) != null) {
+            JSONString s = obj.get(key).isString();
+            if(s != null)
+                return s.stringValue();
+        }
+        return null;
+    }
+
+    protected static int unmarshallInt(JSONObject obj, String key){
+        if(obj.get(key) != null)
+            if(obj.get(key).isNumber() != null)
+                return (int) obj.get(key).isNumber().getValue();
+        return -1;
+    }
+
+    protected static long unmarshallLong(JSONObject obj, String key){
+        if(obj.get(key) != null) {
+            JSONNumber value = obj.get(key).isNumber();
+            if(value != null)
+                return (long) value.doubleValue();
+        }
+        return -1;
+    }
+
+    protected static boolean unmarshallBoolean(JSONObject obj, String key){
+        if(obj.get(key) != null)
+            if(obj.get(key).isBoolean() != null)
+                return obj.get(key).isBoolean().booleanValue();
+        return false;
+    }
+
+    protected static Date unmarshallTimestamp(JSONObject obj, String key){
+        if(obj.get(key) != null) {
+            JSONString s = obj.get(key).isString();
+            if (s != null)
+                return new Date(Long.valueOf(s.stringValue()).longValue());
+        }
+        return null;
+    }
+
+    protected static Date unmarshallDate(JSONObject obj, String key){
+        if(obj.get(key) != null) {
+            JSONString s = obj.get(key).isString();
+            if (s != null)
+                return DateTimeFormat.getFormat("yyyy-MM-dd'T'HH:mm:ss").parse(s.stringValue());
+        }
+        return null;
+    }
+
+    public static native String getDate(Long ms)/*-{
+        return (new Date(ms)).toUTCString();
+    }-*/;
+
+    public abstract String getLastModifiedSince();
+
+    public static <T> T createFromResponse(Class<T> aClass, Response response) {
+        JSONValue json = JSONParser.parseStrict(response.getText());
+        T result = null;
+        if (aClass.equals(AccountResource.class)) {
+            AccountResource a = new AccountResource();
+            JSONArray array = json.isArray();
+            if (array != null) {
+                for (int i=0; i<array.size(); i++) {
+                    JSONObject o = array.get(i).isObject();
+                    if (o != null) {
+                        ContainerResource container = new ContainerResource();
+                        container.setName(unmarshallString(o, "name"));
+                        container.setCount(unmarshallLong(o, "count"));
+                        container.setBytes(unmarshallLong(o, "bytes"));
+                        container.setCreated(unmarshallTimestamp(o, "created"));
+                        container.setLastModified(unmarshallDate(o, "last_modified"));
+                        a.getContainers().add(container);
+                    }
+                }
+                result = (T) a;
+            }
+        }
+        return result;
+    }
+}
diff --git a/web_client/src/gr/grnet/pithos/web/client/foldertree/SubDirResource.java b/web_client/src/gr/grnet/pithos/web/client/foldertree/SubDirResource.java
new file mode 100644 (file)
index 0000000..546416f
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+ * Copyright (c) 2011 Greek Research and Technology Network
+ */
+
+package gr.grnet.pithos.web.client.foldertree;
+
+public class SubDirResource {
+}
diff --git a/web_client/src/gr/grnet/pithos/web/client/foldertree/cellTreeClosedItem.gif b/web_client/src/gr/grnet/pithos/web/client/foldertree/cellTreeClosedItem.gif
new file mode 100644 (file)
index 0000000..9051e56
Binary files /dev/null and b/web_client/src/gr/grnet/pithos/web/client/foldertree/cellTreeClosedItem.gif differ
diff --git a/web_client/src/gr/grnet/pithos/web/client/foldertree/cellTreeLoadingBasic.gif b/web_client/src/gr/grnet/pithos/web/client/foldertree/cellTreeLoadingBasic.gif
new file mode 100644 (file)
index 0000000..c5fedc3
Binary files /dev/null and b/web_client/src/gr/grnet/pithos/web/client/foldertree/cellTreeLoadingBasic.gif differ
diff --git a/web_client/src/gr/grnet/pithos/web/client/foldertree/cellTreeOpenItem.gif b/web_client/src/gr/grnet/pithos/web/client/foldertree/cellTreeOpenItem.gif
new file mode 100644 (file)
index 0000000..3d3691a
Binary files /dev/null and b/web_client/src/gr/grnet/pithos/web/client/foldertree/cellTreeOpenItem.gif differ
diff --git a/web_client/src/gr/grnet/pithos/web/client/rest/GetRequest.java b/web_client/src/gr/grnet/pithos/web/client/rest/GetRequest.java
new file mode 100644 (file)
index 0000000..4ae9e21
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2011 Greek Research and Technology Network
+ */
+
+package gr.grnet.pithos.web.client.rest;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.Scheduler.ScheduledCommand;
+import com.google.gwt.http.client.Request;
+import com.google.gwt.http.client.RequestBuilder;
+import com.google.gwt.http.client.RequestException;
+import com.google.gwt.http.client.Response;
+import gr.grnet.pithos.web.client.foldertree.Resource;
+import java.util.HashMap;
+import java.util.Map;
+
+public abstract class GetRequest<T extends Resource> implements ScheduledCommand {
+
+    private Class<T> aClass;
+
+    private String path;
+
+    private int okCode;
+    
+    private String username;
+
+    private T cached;
+
+    private Map<String, String> headers = new HashMap<String, String>();
+
+    public abstract void onSuccess(T result);
+
+    public abstract void onError(Throwable t);
+
+    public GetRequest(Class<T> aClass, String path, int okCode) {
+        this.aClass = aClass;
+        this.path = path;
+        this.okCode = okCode;
+    }
+
+    public GetRequest(Class<T> aClass, String path) {
+        this(aClass, path, -1);
+    }
+
+    @Override
+    public void execute() {
+        RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, path);
+        for (String header : headers.keySet())
+            builder.setHeader(header, headers.get(header));
+        try {
+            builder.sendRequest("", new RestRequestCallback<T>(path, okCode) {
+                @Override
+                public void onSuccess(T object) {
+                    GetRequest.this.onSuccess(object);
+                }
+
+                @Override
+                public T deserialize(Response response) {
+                    return Resource.createFromResponse(aClass, response);
+                }
+
+                @Override
+                public void onError(Request request, Throwable throwable) {
+                    if (throwable instanceof RestException) {
+                        if (((RestException) throwable).getHttpStatusCode() == 304 && cached != null){
+                            GWT.log("Using cache: " + cached.getUri(), null);
+                            onSuccess(cached);
+                            return;
+                        }
+                    }
+                    GetRequest.this.onError(throwable);
+                }
+            });
+        }
+        catch (RequestException e) {
+        }
+    }
+
+    public void setHeader(String header, String value) {
+        headers.put(header, value);
+    }
+}
index 97d73a6..9db1080 100644 (file)
@@ -26,7 +26,7 @@ public class RestException extends Throwable {
     }
 
     public RestException(String aPath, int aStatusCode, String aStatusText, String aText) {
-            super("HTTP error: " + aStatusCode+"\nPapth:"+aPath + "\nStatus text:" + aStatusText + "\nText:" + aText);
+            super("HTTP error: " + aStatusCode+"\nPath:"+aPath + "\nStatus text:" + aStatusText + "\nText:" + aText);
             httpStatusCode = aStatusCode;
             httpStatusText = aStatusText;
             text = aText;
diff --git a/web_client/src/gr/grnet/pithos/web/client/rest/RestRequestCallback.java b/web_client/src/gr/grnet/pithos/web/client/rest/RestRequestCallback.java
new file mode 100644 (file)
index 0000000..0f5e370
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011 Greek Research and Technology Network
+ */
+
+package gr.grnet.pithos.web.client.rest;
+
+import com.google.gwt.http.client.Request;
+import com.google.gwt.http.client.RequestCallback;
+import com.google.gwt.http.client.Response;
+import gr.grnet.pithos.web.client.foldertree.Resource;
+
+public abstract class RestRequestCallback<T extends Resource> implements RequestCallback {
+
+    private static final int HTTP_OK = 200;
+    private int okcode = -1;
+    private String path;
+
+    public RestRequestCallback(String path, int okCode) {
+        this.path = path;
+        this.okcode = okCode;
+    }
+
+    public RestRequestCallback(String path) {
+        this(path, -1);
+    }
+
+    @Override
+    public void onResponseReceived(Request request, Response response) {
+        try {
+            if (response.getStatusCode() == HTTP_OK || (okcode !=-1 && response.getStatusCode() == okcode))
+                onSuccess(deserialize(response));
+            else {
+                String statusText = "";
+                String text = "";
+                // Ignore JavaScript errors caused by non-existent text.
+                try {
+                    statusText = response.getStatusText();
+                }
+                catch (Exception e) {}
+
+                try {
+                    text = response.getText();
+                }
+                catch (Exception e) {}
+
+                onError(request, new RestException(path, response.getStatusCode(), statusText, text));
+            }
+        } catch (Exception e) {
+            onError(request, e);
+        }
+    }
+
+    public abstract void onSuccess(T result);
+
+    public abstract T deserialize(Response response);
+}
index 6bb8f2f..c939847 100644 (file)
@@ -8,7 +8,6 @@ import java.io.Serializable;
 import com.google.gwt.json.client.JSONObject;
 import com.google.gwt.user.client.ui.TreeItem;
 
-
 public abstract class RestResource implements Serializable{
        String uri;