Removed all static references to the Pithos class
authorChristos Stathis <chstath@ebs.gr>
Wed, 3 Aug 2011 12:14:40 +0000 (15:14 +0300)
committerChristos Stathis <chstath@ebs.gr>
Wed, 3 Aug 2011 12:14:40 +0000 (15:14 +0300)
48 files changed:
web_client/src/gr/grnet/pithos/web/client/AbstractPropertiesDialog.java
web_client/src/gr/grnet/pithos/web/client/CellTreeView.java
web_client/src/gr/grnet/pithos/web/client/CellTreeViewModel.java
web_client/src/gr/grnet/pithos/web/client/CredentialsDialog.java [deleted file]
web_client/src/gr/grnet/pithos/web/client/DeleteFileDialog.java
web_client/src/gr/grnet/pithos/web/client/DnDFolderPopupMenu.java
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/FileList.java
web_client/src/gr/grnet/pithos/web/client/FileMenu.java
web_client/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java
web_client/src/gr/grnet/pithos/web/client/FileUploadGearsDialog.java
web_client/src/gr/grnet/pithos/web/client/FileUploadGearsIEDialog.java
web_client/src/gr/grnet/pithos/web/client/FilesPropertiesDialog.java
web_client/src/gr/grnet/pithos/web/client/FolderContextMenu.java
web_client/src/gr/grnet/pithos/web/client/PermissionsAddDialog.java
web_client/src/gr/grnet/pithos/web/client/PermissionsList.java
web_client/src/gr/grnet/pithos/web/client/Pithos.java
web_client/src/gr/grnet/pithos/web/client/QuitDialog.java
web_client/src/gr/grnet/pithos/web/client/SessionExpiredDialog.java
web_client/src/gr/grnet/pithos/web/client/SettingsMenu.java [deleted file]
web_client/src/gr/grnet/pithos/web/client/StatusPanel.java
web_client/src/gr/grnet/pithos/web/client/TopPanel.java
web_client/src/gr/grnet/pithos/web/client/UserDetailsPanel.java
web_client/src/gr/grnet/pithos/web/client/VersionsList.java
web_client/src/gr/grnet/pithos/web/client/commands/DeleteCommand.java
web_client/src/gr/grnet/pithos/web/client/commands/EmptyTrashCommand.java
web_client/src/gr/grnet/pithos/web/client/commands/GetUserCommand.java
web_client/src/gr/grnet/pithos/web/client/commands/NewFolderCommand.java
web_client/src/gr/grnet/pithos/web/client/commands/PasteCommand.java
web_client/src/gr/grnet/pithos/web/client/commands/RefreshCommand.java
web_client/src/gr/grnet/pithos/web/client/commands/ResreshOthersSharesCommand.java
web_client/src/gr/grnet/pithos/web/client/commands/RestoreTrashCommand.java
web_client/src/gr/grnet/pithos/web/client/commands/ToTrashCommand.java
web_client/src/gr/grnet/pithos/web/client/commands/UploadFileCommand.java
web_client/src/gr/grnet/pithos/web/client/foldertree/FolderTreeViewModel.java
web_client/src/gr/grnet/pithos/web/client/rest/DeleteCommand.java
web_client/src/gr/grnet/pithos/web/client/rest/GetCommand.java
web_client/src/gr/grnet/pithos/web/client/rest/HeadCommand.java
web_client/src/gr/grnet/pithos/web/client/rest/MultipleDeleteCommand.java
web_client/src/gr/grnet/pithos/web/client/rest/MultipleGetCommand.java
web_client/src/gr/grnet/pithos/web/client/rest/MultipleHeadCommand.java [deleted file]
web_client/src/gr/grnet/pithos/web/client/rest/MultiplePostCommand.java
web_client/src/gr/grnet/pithos/web/client/rest/PostCommand.java
web_client/src/gr/grnet/pithos/web/client/rest/RestCallback.java
web_client/src/gr/grnet/pithos/web/client/rest/RestCommand.java
web_client/src/gr/grnet/pithos/web/client/rest/resource/FolderResource.java
web_client/src/gr/grnet/pithos/web/client/tagtree/TagTreeViewModel.java

index b63350a..2fbda4c 100644 (file)
@@ -76,12 +76,14 @@ public abstract class AbstractPropertiesDialog extends DialogBox {
 \r
        protected TabPanel inner = null;\r
 \r
+    protected Pithos app;\r
+\r
        /**\r
         * The widget's constructor.\r
         *\r
         */\r
-       public AbstractPropertiesDialog() {\r
-\r
+       public AbstractPropertiesDialog(Pithos _app) {\r
+        app = _app;\r
                // Enable IE selection for the dialog (must disable it upon closing it)\r
                Pithos.enableIESelection();\r
 \r
@@ -92,7 +94,7 @@ public abstract class AbstractPropertiesDialog extends DialogBox {
         * Retrieves all user tags from the server and updates the FlowPanel\r
         */\r
        protected void updateTags() {\r
-               GetCommand<TagsResource> tc = new GetCommand<TagsResource>(TagsResource.class, Pithos.get().getCurrentUserResource().getTagsPath(),null) {\r
+               GetCommand<TagsResource> tc = new GetCommand<TagsResource>(app, TagsResource.class, app.getCurrentUserResource().getTagsPath(),null) {\r
 \r
                        @Override\r
                        public void onComplete() {\r
@@ -128,7 +130,7 @@ public abstract class AbstractPropertiesDialog extends DialogBox {
                        @Override\r
                        public void onError(Throwable t) {\r
                                GWT.log("", t);\r
-                               Pithos.get().displayError("Unable to fetch user tags");\r
+                               app.displayError("Unable to fetch user tags");\r
                        }\r
                };\r
                DeferredCommand.addCommand(tc);\r
index 3cfd28d..4c033b8 100644 (file)
@@ -74,6 +74,7 @@ import com.google.gwt.view.client.TreeViewModel.NodeInfo;
 
 public class CellTreeView extends Composite{
        public static final boolean DONE = false;
+    private Pithos app;
        Images images;
        
        SingleSelectionModel<RestResource> selectionModel = new SingleSelectionModel<RestResource>(new ProvidesKey<RestResource>() {
@@ -146,9 +147,10 @@ public class CellTreeView extends Composite{
        /**
         * 
         */
-       public CellTreeView(final Images _images) {
+       public CellTreeView(Pithos _app, final Images _images) {
+        this.app = _app;
                images = _images;
-               model = new CellTreeViewModel(images,selectionModel);
+               model = new CellTreeViewModel(app, images,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
@@ -193,11 +195,11 @@ public class CellTreeView extends Composite{
             public void onSelectionChange(com.google.gwt.view.client.SelectionChangeEvent event) {
                NodeInfo<RestResource> nodeInfo = (NodeInfo<RestResource>) getModel().getNodeInfo(selectionModel.getSelectedObject());
                if(nodeInfo==null || nodeInfo.getValueUpdater()==null){
-                       Pithos.get().showFileList(getSelection());
+                       app.showFileList(getSelection());
                }
                else
                        nodeInfo.getValueUpdater().update(selectionModel.getSelectedObject());
-               Pithos.get().setCurrentSelection(selectionModel.getSelectedObject());
+               app.setCurrentSelection(selectionModel.getSelectedObject());
                
                
             }
@@ -341,12 +343,12 @@ public class CellTreeView extends Composite{
        }
        private boolean init=false;
        public boolean fetchRootFolders() {
-               UserResource userResource = Pithos.get().getCurrentUserResource();
+               UserResource userResource = app.getCurrentUserResource();
                if (userResource == null)
                        return !DONE;
                if(!init){
                        final String path = userResource.getFilesPath();
-                       GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, path, null) {
+                       GetCommand<FolderResource> gf = new GetCommand<FolderResource>(app, FolderResource.class, path, null) {
        
                                @Override
                                public void onComplete() {
@@ -359,12 +361,12 @@ public class CellTreeView extends Composite{
                                @Override
                                public void onError(Throwable t) {
                                        GWT.log("Error fetching root folder", t);
-                                       Pithos.get().displayError("Unable to fetch root folder");
+                                       app.displayError("Unable to fetch root folder");
                                }
        
                        };
                        DeferredCommand.addCommand(gf);
-                       DeferredCommand.addCommand(new GetCommand<TrashResource>(TrashResource.class, Pithos.get().getCurrentUserResource().getTrashPath(), null) {
+                       DeferredCommand.addCommand(new GetCommand<TrashResource>(app, TrashResource.class, app.getCurrentUserResource().getTrashPath(), null) {
                                @Override
                                public void onComplete() {
                                        trash = getResult();
@@ -376,17 +378,17 @@ public class CellTreeView extends Composite{
                                                int statusCode = ((RestException)t).getHttpStatusCode();
                                                // On IE status code 1223 may be returned instead of 204.
                                                if(statusCode == 204 || statusCode == 1223){
-                                                       trash = new TrashResource(Pithos.get().getCurrentUserResource().getTrashPath());
+                                                       trash = new TrashResource(app.getCurrentUserResource().getTrashPath());
                                        }
                                        else{
                                                GWT.log("", t);
-                                               Pithos.get().displayError("Unable to fetch trash folder:"+t.getMessage());
-                                               trash = new TrashResource(Pithos.get().getCurrentUserResource().getTrashPath());
+                                               app.displayError("Unable to fetch trash folder:"+t.getMessage());
+                                               trash = new TrashResource(app.getCurrentUserResource().getTrashPath());
                                        }
                                }
                        }
                        });
-                       GetCommand<SharedResource> gs = new GetCommand<SharedResource>(SharedResource.class, userResource.getSharedPath(), null) {
+                       GetCommand<SharedResource> gs = new GetCommand<SharedResource>(app, SharedResource.class, userResource.getSharedPath(), null) {
 
                                @Override
                                public void onComplete() {
@@ -396,11 +398,11 @@ public class CellTreeView extends Composite{
                                @Override
                                public void onError(Throwable t) {
                                        GWT.log("Error fetching Shared Root folder", t);
-                                       Pithos.get().displayError("Unable to fetch Shared Root folder");
+                                       app.displayError("Unable to fetch Shared Root folder");
                                }
                        };
                        DeferredCommand.addCommand(gs);
-                       GetCommand<OthersResource> go = new GetCommand<OthersResource>(OthersResource.class,
+                       GetCommand<OthersResource> go = new GetCommand<OthersResource>(app, OthersResource.class,
                                                userResource.getOthersPath(), null) {
 
                                @Override
@@ -411,7 +413,7 @@ public class CellTreeView extends Composite{
                                @Override
                                public void onError(Throwable t) {
                                        GWT.log("Error fetching Others Root folder", t);
-                                       Pithos.get().displayError("Unable to fetch Others Root folder");
+                                       app.displayError("Unable to fetch Others Root folder");
                                }
                        };
                        DeferredCommand.addCommand(go);
@@ -430,7 +432,7 @@ public class CellTreeView extends Composite{
        
        
        public void updateTrashNode(){
-               DeferredCommand.addCommand(new GetCommand<TrashResource>(TrashResource.class, Pithos.get().getCurrentUserResource().getTrashPath(), null) {
+               DeferredCommand.addCommand(new GetCommand<TrashResource>(app, TrashResource.class, app.getCurrentUserResource().getTrashPath(), null) {
                        @Override
                        public void onComplete() {
                                trash = getResult();
@@ -446,14 +448,14 @@ public class CellTreeView extends Composite{
                                        int statusCode = ((RestException)t).getHttpStatusCode();
                                        // On IE status code 1223 may be returned instead of 204.
                                        if(statusCode == 204 || statusCode == 1223){
-                                               trash = new TrashResource(Pithos.get().getCurrentUserResource().getTrashPath());
+                                               trash = new TrashResource(app.getCurrentUserResource().getTrashPath());
                                                model.getRootNodes().getList().set(1, trash);
                                                //model.getRootNodes().refresh();
                                }
                                else{
                                        GWT.log("", t);
-                                       Pithos.get().displayError("Unable to fetch trash folder:"+t.getMessage());
-                                       trash = new TrashResource(Pithos.get().getCurrentUserResource().getTrashPath());
+                                       app.displayError("Unable to fetch trash folder:"+t.getMessage());
+                                       trash = new TrashResource(app.getCurrentUserResource().getTrashPath());
                                        model.getRootNodes().getList().set(1, trash);
                                        //model.getRootNodes().refresh();
                                }
@@ -463,8 +465,8 @@ public class CellTreeView extends Composite{
        }
        
        public void updateRootNode(){
-               final String path = Pithos.get().getCurrentUserResource().getFilesPath();
-               GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, path, null) {
+               final String path = app.getCurrentUserResource().getFilesPath();
+               GetCommand<FolderResource> gf = new GetCommand<FolderResource>(app, FolderResource.class, path, null) {
 
                        @Override
                        public void onComplete() {
@@ -478,7 +480,7 @@ public class CellTreeView extends Composite{
                        @Override
                        public void onError(Throwable t) {
                                GWT.log("Error fetching root folder", t);
-                               Pithos.get().displayError("Unable to fetch root folder");
+                               app.displayError("Unable to fetch root folder");
                        }
 
                };
@@ -486,7 +488,7 @@ public class CellTreeView extends Composite{
        }
        
        public void updateMySharedNode(){
-               GetCommand<SharedResource> gs = new GetCommand<SharedResource>(SharedResource.class, Pithos.get().getCurrentUserResource().getSharedPath(), null) {
+               GetCommand<SharedResource> gs = new GetCommand<SharedResource>(app, SharedResource.class, app.getCurrentUserResource().getSharedPath(), null) {
 
                        @Override
                        public void onComplete() {
@@ -497,15 +499,15 @@ public class CellTreeView extends Composite{
                        @Override
                        public void onError(Throwable t) {
                                GWT.log("Error fetching Shared Root folder", t);
-                               Pithos.get().displayError("Unable to fetch Shared Root folder");
+                               app.displayError("Unable to fetch Shared Root folder");
                        }
                };
                DeferredCommand.addCommand(gs);
        }
        
        public void updateOtherNode(){
-               GetCommand<OthersResource> go = new GetCommand<OthersResource>(OthersResource.class,
-                                       Pithos.get().getCurrentUserResource().getOthersPath(), null) {
+               GetCommand<OthersResource> go = new GetCommand<OthersResource>(app, OthersResource.class,
+                                       app.getCurrentUserResource().getOthersPath(), null) {
 
                        @Override
                        public void onComplete() {
@@ -516,7 +518,7 @@ public class CellTreeView extends Composite{
                        @Override
                        public void onError(Throwable t) {
                                GWT.log("Error fetching Others Root folder", t);
-                               Pithos.get().displayError("Unable to fetch Others Root folder");
+                               app.displayError("Unable to fetch Others Root folder");
                        }
                };
                DeferredCommand.addCommand(go);
@@ -528,8 +530,8 @@ public class CellTreeView extends Composite{
        }
        
        public void clearSelection(){
-               if(Pithos.get().getCurrentSelection().equals(getSelection()))
-                       Pithos.get().setCurrentSelection(null);
+               if(app.getCurrentSelection().equals(getSelection()))
+                       app.setCurrentSelection(null);
                selectionModel.setSelected(getSelection(), false);
        }
        
@@ -623,7 +625,7 @@ public class CellTreeView extends Composite{
        public void refreshCurrentNode(boolean clearSelection){
                NodeInfo<RestResource> nodeInfo = (NodeInfo<RestResource>) getModel().getNodeInfo(selectionModel.getSelectedObject());
        if(nodeInfo==null || nodeInfo.getValueUpdater()==null){
-               Pithos.get().showFileList(getSelection(),clearSelection);
+               app.showFileList(getSelection(),clearSelection);
        }
        else{
                if(!clearSelection)
index 05a33c2..eebec0e 100644 (file)
@@ -93,6 +93,7 @@ public class CellTreeViewModel implements TreeViewModel{
        private final ListDataProvider<RestResource> rootNodes = new ListDataProvider<RestResource>();
        private Map<String,FolderResource> folderCache=new HashMap<String, FolderResource>();
        final Images images;
+    private Pithos app;
        SingleSelectionModel<RestResource> selectionModel;
        Map<String, MyFolderDataProvider> mymap = new HashMap<String, MyFolderDataProvider>();
        Map<String, MyFolderDataProvider> sharedmap = new HashMap<String, MyFolderDataProvider>();
@@ -153,8 +154,9 @@ public class CellTreeViewModel implements TreeViewModel{
        /**
         * 
         */
-       public CellTreeViewModel(final Images _images,SingleSelectionModel<RestResource> selectionModel ) {
+       public CellTreeViewModel(Pithos _app, final Images _images,SingleSelectionModel<RestResource> selectionModel ) {
                super();
+        app = _app;
                images=_images;
                this.selectionModel=selectionModel;
        }
@@ -217,8 +219,8 @@ public class CellTreeViewModel implements TreeViewModel{
                public void onBrowserEvent(Cell.Context context, com.google.gwt.dom.client.Element parent, RestResource value, com.google.gwt.dom.client.NativeEvent event, com.google.gwt.cell.client.ValueUpdater<RestResource> valueUpdater) {
                        if(event.getType().equals("contextmenu")){
                                selectionModel.setSelected(value, true);
-                               Pithos.get().setCurrentSelection(value);
-                               Pithos.get().getTreeView().showPopup(event.getClientX(), event.getClientY());
+                               app.setCurrentSelection(value);
+                               app.getTreeView().showPopup(event.getClientX(), event.getClientY());
                        }
                };
                
@@ -265,7 +267,7 @@ public class CellTreeViewModel implements TreeViewModel{
                // Second level.
                        ListDataProvider<RestResource> trashProvider = new ListDataProvider<RestResource>();
                        List<RestResource> r = new ArrayList<RestResource>();
-                       for(FolderResource f : Pithos.get().getTreeView().getTrash().getFolders()){
+                       for(FolderResource f : app.getTreeView().getTrash().getFolders()){
                                r.add(new TrashFolderResource(f));
                        }
                        trashProvider.setList(r);
@@ -333,7 +335,7 @@ public class CellTreeViewModel implements TreeViewModel{
                        public void f(final DragAndDropContext context) {
                                if(context.getDroppableData()!=null && context.getDroppableData() instanceof RestResource){
                                        
-                                       Pithos.get().getTreeView().getUtils().openNodeContainingResource((RestResource) context.getDroppableData(), new RefreshHandler() {
+                                       app.getTreeView().getUtils().openNodeContainingResource((RestResource) context.getDroppableData(), new RefreshHandler() {
                                                
                                                @Override
                                                public void onRefresh() {
@@ -415,30 +417,30 @@ public class CellTreeViewModel implements TreeViewModel{
                @Override
                public void update(final RestResource value) {
                        if(value instanceof MyFolderResource){
-                               GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, value.getUri(), null) {
+                               GetCommand<FolderResource> gf = new GetCommand<FolderResource>(app, FolderResource.class, value.getUri(), null) {
 
                                        @Override
                                        public void onComplete() {
                                                FolderResource rootResource = getResult();
                                                //((MyFolderResource)value).getResource().setFiles(rootResource.getFiles());
                                                ((MyFolderResource)value).setResource(rootResource);
-                                               if(Pithos.get().getTreeView().getSelection().getUri().equals(value.getUri()))
+                                               if(app.getTreeView().getSelection().getUri().equals(value.getUri()))
                                                        selectionModel.setSelected(value, true);
-                                               Pithos.get().onResourceUpdate(value,clearSelection);
+                                               app.onResourceUpdate(value,clearSelection);
                                                
                                        }
        
                                        @Override
                                        public void onError(Throwable t) {
                                                GWT.log("Error fetching root folder", t);
-                                               Pithos.get().displayError("Unable to fetch root folder");
+                                               app.displayError("Unable to fetch root folder");
                                        }
        
                                };
                                DeferredCommand.addCommand(gf);
                        }
                        else if(value instanceof TrashResource){
-                               DeferredCommand.addCommand(new GetCommand<TrashResource>(TrashResource.class, Pithos.get().getCurrentUserResource().getTrashPath(), null) {
+                               DeferredCommand.addCommand(new GetCommand<TrashResource>(app, TrashResource.class, app.getCurrentUserResource().getTrashPath(), null) {
                                        @Override
                                        public void onComplete() {
                                                //trash = getResult();
@@ -446,11 +448,11 @@ public class CellTreeViewModel implements TreeViewModel{
                                                ((TrashResource)value).setFiles(getResult().getFiles());
                                                for(RestResource r : getRootNodes().getList()){
                                                        if(r instanceof TrashResource)
-                                                               getRootNodes().getList().set(getRootNodes().getList().indexOf(r), Pithos.get().getTreeView().getTrash());
+                                                               getRootNodes().getList().set(getRootNodes().getList().indexOf(r), app.getTreeView().getTrash());
                                                }
-                                               Pithos.get().getTreeView().updateNodeChildren(Pithos.get().getTreeView().getTrash());
-                                               //Pithos.get().showFileList(true);
-                                               Pithos.get().onResourceUpdate(value,clearSelection);
+                                               app.getTreeView().updateNodeChildren(app.getTreeView().getTrash());
+                                               //app.showFileList(true);
+                                               app.onResourceUpdate(value,clearSelection);
                                        }
 
                                        @Override
@@ -464,61 +466,61 @@ public class CellTreeViewModel implements TreeViewModel{
                                                }
                                                else{
                                                        GWT.log("", t);
-                                                       Pithos.get().displayError("Unable to fetch trash folder:"+t.getMessage());
-                                                       //Pithos.get().getTreeView().getTrash() = new TrashResource(Pithos.get().getCurrentUserResource().getTrashPath());
+                                                       app.displayError("Unable to fetch trash folder:"+t.getMessage());
+                                                       //app.getTreeView().getTrash() = new TrashResource(app.getCurrentUserResource().getTrashPath());
                                                }
                                        }
                                }
                                });
                        }
                        else if(value instanceof OthersFolderResource){
-                               GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, value.getUri(), null) {
+                               GetCommand<FolderResource> gf = new GetCommand<FolderResource>(app, FolderResource.class, value.getUri(), null) {
 
                                        @Override
                                        public void onComplete() {
                                                FolderResource rootResource = getResult();
                                                //((MyFolderResource)value).getResource().setFiles(rootResource.getFiles());
                                                ((OthersFolderResource)value).setResource(rootResource);
-                                               if(Pithos.get().getTreeView().getSelection().getUri().equals(value.getUri()))
+                                               if(app.getTreeView().getSelection().getUri().equals(value.getUri()))
                                                        selectionModel.setSelected(value, true);
-                                               Pithos.get().onResourceUpdate(value,clearSelection);
+                                               app.onResourceUpdate(value,clearSelection);
                                                
                                        }
        
                                        @Override
                                        public void onError(Throwable t) {
                                                GWT.log("Error fetching root folder", t);
-                                               Pithos.get().displayError("Unable to fetch root folder");
+                                               app.displayError("Unable to fetch root folder");
                                        }
        
                                };
                                DeferredCommand.addCommand(gf);
                        }
                        else if(value instanceof SharedFolderResource){
-                               GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, value.getUri(), null) {
+                               GetCommand<FolderResource> gf = new GetCommand<FolderResource>(app, FolderResource.class, value.getUri(), null) {
 
                                        @Override
                                        public void onComplete() {
                                                FolderResource rootResource = getResult();
                                                //((MyFolderResource)value).getResource().setFiles(rootResource.getFiles());
                                                ((SharedFolderResource)value).setResource(rootResource);
-                                               if(Pithos.get().getTreeView().getSelection().getUri().equals(value.getUri()))
+                                               if(app.getTreeView().getSelection().getUri().equals(value.getUri()))
                                                        selectionModel.setSelected(value, true);
-                                               Pithos.get().onResourceUpdate(value,clearSelection);
+                                               app.onResourceUpdate(value,clearSelection);
                                                
                                        }
        
                                        @Override
                                        public void onError(Throwable t) {
                                                GWT.log("Error fetching root folder", t);
-                                               Pithos.get().displayError("Unable to fetch root folder");
+                                               app.displayError("Unable to fetch root folder");
                                        }
        
                                };
                                DeferredCommand.addCommand(gf);
                        }
                        else if(value instanceof SharedResource){
-                               GetCommand<SharedResource> gf = new GetCommand<SharedResource>(SharedResource.class, value.getUri(), null) {
+                               GetCommand<SharedResource> gf = new GetCommand<SharedResource>(app, SharedResource.class, value.getUri(), null) {
 
                                        @Override
                                        public void onComplete() {
@@ -526,23 +528,23 @@ public class CellTreeViewModel implements TreeViewModel{
                                                ((SharedResource)value).setFolders(getResult().getFolders());
                                                ((SharedResource)value).setFiles(getResult().getFiles());
                                                
-                                               if(Pithos.get().getTreeView().getSelection().getUri().equals(value.getUri()))
+                                               if(app.getTreeView().getSelection().getUri().equals(value.getUri()))
                                                        selectionModel.setSelected(value, true);
-                                               Pithos.get().onResourceUpdate(value,clearSelection);
+                                               app.onResourceUpdate(value,clearSelection);
                                                
                                        }
        
                                        @Override
                                        public void onError(Throwable t) {
                                                GWT.log("Error fetching root folder", t);
-                                               Pithos.get().displayError("Unable to fetch root folder");
+                                               app.displayError("Unable to fetch root folder");
                                        }
        
                                };
                                DeferredCommand.addCommand(gf);
                        }
                        else if(value instanceof OtherUserResource){
-                               GetCommand<OtherUserResource> gf = new GetCommand<OtherUserResource>(OtherUserResource.class, value.getUri(), null) {
+                               GetCommand<OtherUserResource> gf = new GetCommand<OtherUserResource>(app, OtherUserResource.class, value.getUri(), null) {
 
                                        @Override
                                        public void onComplete() {
@@ -550,16 +552,16 @@ public class CellTreeViewModel implements TreeViewModel{
                                                ((OtherUserResource)value).setFolders(getResult().getFolders());
                                                ((OtherUserResource)value).setFiles(getResult().getFiles());
                                                
-                                               if(Pithos.get().getTreeView().getSelection().getUri().equals(value.getUri()))
+                                               if(app.getTreeView().getSelection().getUri().equals(value.getUri()))
                                                        selectionModel.setSelected(value, true);
-                                               Pithos.get().onResourceUpdate(value,clearSelection);
+                                               app.onResourceUpdate(value,clearSelection);
                                                
                                        }
        
                                        @Override
                                        public void onError(Throwable t) {
                                                GWT.log("Error fetching root folder", t);
-                                               Pithos.get().displayError("Unable to fetch root folder");
+                                               app.displayError("Unable to fetch root folder");
                                        }
        
                                };
@@ -611,7 +613,7 @@ public class CellTreeViewModel implements TreeViewModel{
                          FolderResource cache = null;
                          if(restResource instanceof RestResourceWrapper && !((RestResourceWrapper)restResource).getResource().isNeedsExpanding())
                                  cache = ((RestResourceWrapper)restResource).getResource();
-                         GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, restResource.getUri(),cache ) {
+                         GetCommand<FolderResource> gf = new GetCommand<FolderResource>(app, FolderResource.class, restResource.getUri(),cache ) {
 
                                        @Override
                                        public void onComplete() {
@@ -643,7 +645,7 @@ public class CellTreeViewModel implements TreeViewModel{
                                                MultipleGetCommand.Cached[] cached = null;
                                                if(restResource instanceof RestResourceWrapper)
                                                        cached=((RestResourceWrapper)restResource).getResource().getCache();
-                                               MultipleGetCommand<FolderResource> gf2 = new MultipleGetCommand<FolderResource>(FolderResource.class,
+                                               MultipleGetCommand<FolderResource> gf2 = new MultipleGetCommand<FolderResource>(app, FolderResource.class,
                                                                        folderPaths, cached) {
 
                                                        @Override
@@ -673,7 +675,7 @@ public class CellTreeViewModel implements TreeViewModel{
 
                                                        @Override
                                                        public void onError(Throwable t) {
-                                                               Pithos.get().displayError("Unable to fetch subfolders");
+                                                               app.displayError("Unable to fetch subfolders");
                                                                GWT.log("Unable to fetch subfolders", t);
                                                        }
 
@@ -691,7 +693,7 @@ public class CellTreeViewModel implements TreeViewModel{
                                        public void onError(Throwable t) {
                                                
                                                GWT.log("Error fetching root folder", t);
-                                               Pithos.get().displayError("Unable to fetch root folder");
+                                               app.displayError("Unable to fetch root folder");
                                        }
 
                                };
@@ -739,13 +741,13 @@ public class CellTreeViewModel implements TreeViewModel{
                }
                
                  public void refresh(final RefreshHandler refresh){
-                         GetCommand<OthersResource> go = new GetCommand<OthersResource>(OthersResource.class,
+                         GetCommand<OthersResource> go = new GetCommand<OthersResource>(app, OthersResource.class,
                           restResource.getUri(), null) {
 
                                  @Override
                                  public void onComplete() {
                                          final OthersResource others = getResult();
-                          MultipleGetCommand<OtherUserResource> gogo = new MultipleGetCommand<OtherUserResource>(OtherUserResource.class,
+                          MultipleGetCommand<OtherUserResource> gogo = new MultipleGetCommand<OtherUserResource>(app, OtherUserResource.class,
                                                   others.getOthers().toArray(new String[] {}), null) {
 
                                   @Override
@@ -760,7 +762,7 @@ public class CellTreeViewModel implements TreeViewModel{
                                   @Override
                                   public void onError(Throwable t) {
                                           GWT.log("Error fetching Others Root folder", t);
-                                          Pithos.get().displayError("Unable to fetch Others Root folder");
+                                          app.displayError("Unable to fetch Others Root folder");
                                   }
 
                                   @Override
@@ -774,7 +776,7 @@ public class CellTreeViewModel implements TreeViewModel{
                                  @Override
                                  public void onError(Throwable t) {
                                          GWT.log("Error fetching Others Root folder", t);
-                                         Pithos.get().displayError("Unable to fetch Others Root folder");
+                                         app.displayError("Unable to fetch Others Root folder");
                                  }
                          };
                          DeferredCommand.addCommand(go);
diff --git a/web_client/src/gr/grnet/pithos/web/client/CredentialsDialog.java b/web_client/src/gr/grnet/pithos/web/client/CredentialsDialog.java
deleted file mode 100644 (file)
index fa29cb2..0000000
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- *   1. Redistributions of source code must retain the above
- *      copyright notice, this list of conditions and the following
- *      disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above
- *      copyright notice, this list of conditions and the following
- *      disclaimer in the documentation and/or other materials
- *      provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-import gr.grnet.pithos.web.client.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.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.FlexTable;
-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.TextBox;
-import com.google.gwt.user.client.ui.VerticalPanel;
-
-
-/**
- * A dialog box that displays the user credentials for use in other client
- * applications, such as WebDAV clients.
- */
-public class CredentialsDialog extends DialogBox {
-
-       private final String WIDTH_FIELD = "35em";
-       private final String WIDTH_TEXT = "42em";
-
-       /**
-        * The 'confirm reset password' dialog box.
-        */
-       private class ConfirmResetPasswordDialog extends DialogBox {
-
-               /**
-                * The widget's constructor.
-                *
-                * @param images the supplied images
-                */
-               private ConfirmResetPasswordDialog(MessagePanel.Images images) {
-                       // Set the dialog's caption.
-                       setText("Confirmation");
-                       setAnimationEnabled(true);
-                       // Create a VerticalPanel to contain the label and the buttons.
-                       VerticalPanel outer = new VerticalPanel();
-                       HorizontalPanel buttons = new HorizontalPanel();
-
-                       HTML text;
-                       text = new HTML("<table><tr><td>" +
-                                       AbstractImagePrototype.create(images.warn()).getHTML() +
-                                       "</td><td>" + "Are you sure you want to create a new " +
-                                       "WebDAV password?</td></tr></table>");
-                       text.setStyleName("pithos-warnMessage");
-                       outer.add(text);
-
-                       // Create the 'Yes' button, along with a listener that hides the
-                       // dialog when the button is clicked and resets the password.
-                       Button ok = new Button("Yes", new ClickHandler() {
-                               @Override
-                               public void onClick(ClickEvent event) {
-                                       resetPassword(Pithos.get().getCurrentUserResource().getUri());
-                                       hide();
-                               }
-                       });
-                       buttons.add(ok);
-                       buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER);
-                       // Create the 'No' button, along with a listener that hides the
-                       // dialog when the button is clicked.
-                       Button cancel = new Button("No", new ClickHandler() {
-                               @Override
-                               public void onClick(ClickEvent event) {
-                                       hide();
-                               }
-                       });
-                       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);
-               }
-
-               @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:
-                                       case KeyCodes.KEY_ESCAPE:
-                                               hide();
-                                               break;
-                               }
-               }
-
-       }
-
-       private class ReauthenticateDialog extends DialogBox {
-               /**
-                * The widget constructor.
-                */
-               public ReauthenticateDialog() {
-                       // Set the dialog's caption.
-                       setText("New Password Created");
-                       setAnimationEnabled(true);
-                       VerticalPanel outer = new VerticalPanel();
-
-                       // Create the text and set a style name so we can style it with CSS.
-                       HTML text = new HTML("<p>A new WebDAV password has been created." +
-                                       "</p><p>You will now be redirected to the initial screen" +
-                                       " for the changes to take effect. Choose \"Show " +
-                                       "Credentials\" again afterwards to see the new password.</p>");
-                       text.setStyleName("pithos-AboutText");
-                       outer.add(text);
-
-                       // Create the 'OK' button, along with a listener that hides the
-                       // dialog when the button is clicked.
-                       Button confirm = new Button("Proceed", new ClickHandler() {
-                               @Override
-                               public void onClick(ClickEvent event) {
-                                       Pithos.get().authenticateUser();
-                                       hide();
-                               }
-                       });
-                       outer.add(confirm);
-                       outer.setCellHorizontalAlignment(confirm, HasHorizontalAlignment.ALIGN_CENTER);
-                       outer.setSpacing(8);
-                       setWidget(outer);
-               }
-
-               @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:
-                                               Pithos.get().authenticateUser();
-                                               hide();
-                                               break;
-                                       case KeyCodes.KEY_ESCAPE:
-                                               hide();
-                                               break;
-                               }
-               }
-
-       }
-
-       /**
-        * The widget constructor.
-        */
-       public CredentialsDialog(final MessagePanel.Images images) {
-               // Set the dialog's caption.
-               setText("User Credentials");
-               setAnimationEnabled(true);
-               // A VerticalPanel that contains the 'about' label and the 'OK' button.
-               VerticalPanel outer = new VerticalPanel();
-               Configuration conf = (Configuration) GWT.create(Configuration.class);
-               String service = conf.serviceName();
-               // Create the text and set a style name so we can style it with CSS.
-               HTML text = new HTML("<p>These are the user credentials that are " +
-                               "required for interacting with " + service + ".");
-               text.setStyleName("pithos-AboutText");
-               text.setWidth(WIDTH_TEXT);
-               outer.add(text);
-               FlexTable table = new FlexTable();
-               table.setText(0, 0, "Username");
-               table.setText(1, 0, "Token");
-               TextBox username = new TextBox();
-               final Pithos app = Pithos.get();
-               username.setText(app.getCurrentUserResource().getUsername());
-               username.setReadOnly(true);
-               username.setWidth(WIDTH_FIELD);
-               username.addClickHandler(new ClickHandler() {
-                       @Override
-                       public void onClick(ClickEvent event) {
-                               Pithos.enableIESelection();
-                               ((TextBox) event.getSource()).selectAll();
-                               Pithos.preventIESelection();
-                       }
-
-               });
-               table.setWidget(0, 1, username);
-
-               TextBox tokenBox = new TextBox();
-               tokenBox.setText(app.getToken());
-               tokenBox.setReadOnly(true);
-               tokenBox.setWidth(WIDTH_FIELD);
-               tokenBox.addClickHandler(new ClickHandler() {
-                       @Override
-                       public void onClick(ClickEvent event) {
-                               Pithos.enableIESelection();
-                               ((TextBox) event.getSource()).selectAll();
-                               Pithos.preventIESelection();
-                       }
-
-               });
-               table.setWidget(1, 1, tokenBox);
-
-               table.getFlexCellFormatter().setStyleName(0, 0, "props-labels");
-               table.getFlexCellFormatter().setStyleName(0, 1, "props-values");
-               table.getFlexCellFormatter().setStyleName(1, 0, "props-labels");
-               table.getFlexCellFormatter().setStyleName(1, 1, "props-values");
-               outer.add(table);
-
-               // Create the 'OK' button, along with a listener that hides the dialog
-               // when the button is clicked.
-               Button confirm = new Button("Close", new ClickHandler() {
-                       @Override
-                       public void onClick(ClickEvent event) {
-                               hide();
-                       }
-               });
-               outer.add(confirm);
-               outer.setCellHorizontalAlignment(confirm, HasHorizontalAlignment.ALIGN_CENTER);
-
-               // Create the 'Reset password' button, along with a listener that hides
-               // the dialog when the button is clicked.
-               Button resetPassword = new Button("Reset Password", new ClickHandler() {
-                       @Override
-                       public void onClick(ClickEvent event) {
-                               ConfirmResetPasswordDialog dlg = new ConfirmResetPasswordDialog(images);
-                               dlg.center();
-                       }
-               });
-               outer.add(resetPassword);
-               outer.setCellHorizontalAlignment(resetPassword, HasHorizontalAlignment.ALIGN_CENTER);
-
-               outer.setSpacing(8);
-               setWidget(outer);
-       }
-
-       @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:
-                               case KeyCodes.KEY_ESCAPE:
-                                       hide();
-                                       break;
-                       }
-       }
-
-
-       /**
-        * Generate an RPC request to reset WebDAV password.
-        *
-        */
-       private void resetPassword(String userUri) {
-
-               if (userUri == null || userUri.length() == 0) {
-                       Pithos.get().displayError("Empty user Uri!");
-                       return;
-               }
-               GWT.log("resetPassword(" + userUri + ")", null);
-               PostCommand cg = new PostCommand(userUri + "?resetWebDAV", "", 200) {
-
-                       @Override
-                       public void onComplete() {
-                               ReauthenticateDialog dlg = new ReauthenticateDialog();
-                               dlg.center();
-                       }
-
-                       @Override
-                       public void onError(Throwable t) {
-                               GWT.log("", t);
-                               if(t instanceof RestException){
-                                       int statusCode = ((RestException)t).getHttpStatusCode();
-                                       if(statusCode == 405)
-                                               Pithos.get().displayError("You don't have the necessary" +
-                                                               " permissions");
-                                       else if(statusCode == 404)
-                                               Pithos.get().displayError("Resource does not exist");
-                                       else
-                                               Pithos.get().displayError("Unable to reset password:" +
-                                                                       ((RestException)t).getHttpStatusText());
-                               }
-                               else
-                                       Pithos.get().displayError("System error resetting password:" +
-                                                               t.getMessage());
-                       }
-               };
-               DeferredCommand.addCommand(cg);
-       }
-
-}
index a1ee721..8c0db5f 100644 (file)
@@ -64,12 +64,16 @@ import com.google.gwt.user.client.ui.VerticalPanel;
 public class DeleteFileDialog extends DialogBox {\r
 \r
     private List<File> files;\r
+\r
+    private Pithos app;\r
+\r
        /**\r
         * The widget's constructor.\r
         *\r
         * @param images the supplied images\r
         */\r
-       public DeleteFileDialog(Images images, List<File> _files) {\r
+       public DeleteFileDialog(Pithos _app, Images images, List<File> _files) {\r
+        app = _app;\r
         files = _files;\r
                // Set the dialog's caption.\r
                setText("Confirmation");\r
@@ -130,7 +134,7 @@ public class DeleteFileDialog extends DialogBox {
         if (iter.hasNext()) {\r
             File f = iter.next();\r
             String path = f.getUri();\r
-            DeleteRequest deleteFile = new DeleteRequest(Pithos.get().getApiPath(), Pithos.get().getUsername(), path) {\r
+            DeleteRequest deleteFile = new DeleteRequest(app.getApiPath(), app.getUsername(), path) {\r
                 @Override\r
                 public void onSuccess(Resource result) {\r
                     deleteFile(iter);\r
@@ -140,17 +144,17 @@ public class DeleteFileDialog extends DialogBox {
                 public void onError(Throwable t) {\r
                     GWT.log("", t);\r
                     if (t instanceof RestException) {\r
-                        Pithos.get().displayError("Unable to delete file: " + ((RestException) t).getHttpStatusText());\r
+                        app.displayError("Unable to delete file: " + ((RestException) t).getHttpStatusText());\r
                     }\r
                     else\r
-                        Pithos.get().displayError("System error unable to delete file: "+t.getMessage());\r
+                        app.displayError("System error unable to delete file: "+t.getMessage());\r
                 }\r
             };\r
-            deleteFile.setHeader("X-Auth-Token", Pithos.get().getToken());\r
+            deleteFile.setHeader("X-Auth-Token", app.getToken());\r
             Scheduler.get().scheduleDeferred(deleteFile);\r
         }\r
         else {\r
-            Pithos.get().updateFolder(files.get(0).getParent());\r
+            app.updateFolder(files.get(0).getParent());\r
         }\r
     }\r
 \r
index 055cbcc..65052e1 100644 (file)
@@ -54,10 +54,13 @@ import com.google.gwt.user.client.ui.PopupPanel;
 
 public class DnDFolderPopupMenu extends PopupPanel {
 
-    public DnDFolderPopupMenu(final CellTreeView.Images newImages, final Folder target, final Object toCopy) {
+    private Pithos app;
+
+    public DnDFolderPopupMenu(Pithos _app, final CellTreeView.Images newImages, final Folder target, final Object toCopy) {
         // The popup's constructor's argument is a boolean specifying that it
         // auto-close itself when the user clicks outside of it.
         super(true);
+        app = _app;
         setAnimationEnabled(true);
         // A dummy command that we will execute from unimplemented leaves.
         final Command cancelCmd = new Command() {
@@ -69,7 +72,7 @@ public class DnDFolderPopupMenu extends PopupPanel {
         };
 
         final MenuBar contextMenu = new MenuBar(true);
-        final CellTreeView folders = Pithos.get().getTreeView();
+        final CellTreeView folders = app.getTreeView();
 
         contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Move</span>", true, new Command() {
 
@@ -79,7 +82,7 @@ public class DnDFolderPopupMenu extends PopupPanel {
                     moveFolder(target, (Folder) toCopy);
                 }
                 else if (toCopy instanceof List) {
-                    List<File> files = Pithos.get().getFileList().getSelectedFiles();
+                    List<File> files = app.getFileList().getSelectedFiles();
                     moveFiles(target, files);
                 }
                 hide();
@@ -93,7 +96,7 @@ public class DnDFolderPopupMenu extends PopupPanel {
                 if (toCopy instanceof Folder)
                     copyFolder(target, (Folder) toCopy);
                 else if (toCopy instanceof List) {
-                    List<File> files = Pithos.get().getFileList().getSelectedFiles();
+                    List<File> files = app.getFileList().getSelectedFiles();
                     copyFiles(target, files);
                 }
                 hide();
@@ -109,7 +112,7 @@ public class DnDFolderPopupMenu extends PopupPanel {
                     trashFolder(((RestResourceWrapper) toCopy).getResource());
                 }
                 else if (toCopy instanceof List) {
-                    List<File> files = Pithos.get().getFileList().getSelectedFiles();
+                    List<File> files = app.getFileList().getSelectedFiles();
                     trashFiles(files);
                 }
                 hide();
@@ -128,8 +131,8 @@ public class DnDFolderPopupMenu extends PopupPanel {
 //
 //            @Override
 //            public void onComplete() {
-//                Pithos.get().getTreeView().updateNodeChildren(new RestResourceWrapper(target));
-//                Pithos.get().getStatusPanel().updateStats();
+//                app.getTreeView().updateNodeChildren(new RestResourceWrapper(target));
+//                app.getStatusPanel().updateStats();
 //            }
 //
 //            @Override
@@ -138,17 +141,17 @@ public class DnDFolderPopupMenu extends PopupPanel {
 //                if (t instanceof RestException) {
 //                    int statusCode = ((RestException) t).getHttpStatusCode();
 //                    if (statusCode == 405)
-//                        Pithos.get().displayError("You don't have the necessary permissions");
+//                        app.displayError("You don't have the necessary permissions");
 //
 //                    else if (statusCode == 409)
-//                        Pithos.get().displayError("A folder with the same name already exists");
+//                        app.displayError("A folder with the same name already exists");
 //                    else if (statusCode == 413)
-//                        Pithos.get().displayError("Your quota has been exceeded");
+//                        app.displayError("Your quota has been exceeded");
 //                    else
-//                        Pithos.get().displayError("Unable to copy folder:" + ((RestException) t).getHttpStatusText());
+//                        app.displayError("Unable to copy folder:" + ((RestException) t).getHttpStatusText());
 //                }
 //                else
-//                    Pithos.get().displayError("System error copying folder:" + t.getMessage());
+//                    app.displayError("System error copying folder:" + t.getMessage());
 //            }
 //        };
 //        DeferredCommand.addCommand(cf);
@@ -164,9 +167,9 @@ public class DnDFolderPopupMenu extends PopupPanel {
 //            @Override
 //            public void onComplete() {
 //                GWT.log("[MOVE]" + target.getUri() + "   " + toCopy.getParentURI());
-//                Pithos.get().getTreeView().updateNodeChildren(new RestResourceWrapper(target));
-//                Pithos.get().getTreeView().updateNodeChildrenForRemove(toCopy.getParentURI());
-//                Pithos.get().getStatusPanel().updateStats();
+//                app.getTreeView().updateNodeChildren(new RestResourceWrapper(target));
+//                app.getTreeView().updateNodeChildrenForRemove(toCopy.getParentURI());
+//                app.getStatusPanel().updateStats();
 //            }
 //
 //            @Override
@@ -175,17 +178,17 @@ public class DnDFolderPopupMenu extends PopupPanel {
 //                if (t instanceof RestException) {
 //                    int statusCode = ((RestException) t).getHttpStatusCode();
 //                    if (statusCode == 405)
-//                        Pithos.get().displayError("You don't have the necessary permissions");
+//                        app.displayError("You don't have the necessary permissions");
 //
 //                    else if (statusCode == 409)
-//                        Pithos.get().displayError("A folder with the same name already exists");
+//                        app.displayError("A folder with the same name already exists");
 //                    else if (statusCode == 413)
-//                        Pithos.get().displayError("Your quota has been exceeded");
+//                        app.displayError("Your quota has been exceeded");
 //                    else
-//                        Pithos.get().displayError("Unable to copy folder:" + ((RestException) t).getHttpStatusText());
+//                        app.displayError("Unable to copy folder:" + ((RestException) t).getHttpStatusText());
 //                }
 //                else
-//                    Pithos.get().displayError("System error copying folder:" + t.getMessage());
+//                    app.displayError("System error copying folder:" + t.getMessage());
 //            }
 //        };
 //        DeferredCommand.addCommand(cf);
@@ -216,17 +219,17 @@ public class DnDFolderPopupMenu extends PopupPanel {
     }
 
     private void trashFolder(final FolderResource folder) {
-        PostCommand tot = new PostCommand(folder.getUri() + "?trash=", "", 200) {
+        PostCommand tot = new PostCommand(app, folder.getUri() + "?trash=", "", 200) {
 
             @Override
             public void onComplete() {
-                Pithos.get().getTreeView().updateNodeChildrenForRemove(folder.getParentURI());
-                Pithos.get().getTreeView().updateTrashNode();
+                app.getTreeView().updateNodeChildrenForRemove(folder.getParentURI());
+                app.getTreeView().updateTrashNode();
                 /*for(TreeItem item : items)
-                        Pithos.get().getFolders().updateFolder((DnDTreeItem) item);
-                Pithos.get().getFolders().update(Pithos.get().getFolders().getTrashItem());
+                        app.getFolders().updateFolder((DnDTreeItem) item);
+                app.getFolders().update(app.getFolders().getTrashItem());
 
-                Pithos.get().showFileList(true);
+                app.showFileList(true);
                 */
             }
 
@@ -236,14 +239,14 @@ public class DnDFolderPopupMenu extends PopupPanel {
                 if (t instanceof RestException) {
                     int statusCode = ((RestException) t).getHttpStatusCode();
                     if (statusCode == 405)
-                        Pithos.get().displayError("You don't have the necessary permissions");
+                        app.displayError("You don't have the necessary permissions");
                     else if (statusCode == 404)
-                        Pithos.get().displayError("Folder does not exist");
+                        app.displayError("Folder does not exist");
                     else
-                        Pithos.get().displayError("Unable to trash folder:" + ((RestException) t).getHttpStatusText());
+                        app.displayError("Unable to trash folder:" + ((RestException) t).getHttpStatusText());
                 }
                 else
-                    Pithos.get().displayError("System error trashing folder:" + t.getMessage());
+                    app.displayError("System error trashing folder:" + t.getMessage());
             }
         };
         DeferredCommand.addCommand(tot);
@@ -253,11 +256,11 @@ public class DnDFolderPopupMenu extends PopupPanel {
         final List<String> fileIds = new ArrayList<String>();
         for (File f : files)
             fileIds.add(f.getUri() + "?trash=");
-        MultiplePostCommand tot = new MultiplePostCommand(fileIds.toArray(new String[0]), 200) {
+        MultiplePostCommand tot = new MultiplePostCommand(app, fileIds.toArray(new String[0]), 200) {
 
             @Override
             public void onComplete() {
-                Pithos.get().showFileList(true);
+                app.showFileList(true);
             }
 
             @Override
@@ -266,14 +269,14 @@ public class DnDFolderPopupMenu extends PopupPanel {
                 if (t instanceof RestException) {
                     int statusCode = ((RestException) t).getHttpStatusCode();
                     if (statusCode == 405)
-                        Pithos.get().displayError("You don't have the necessary permissions");
+                        app.displayError("You don't have the necessary permissions");
                     else if (statusCode == 404)
-                        Pithos.get().displayError("File does not exist");
+                        app.displayError("File does not exist");
                     else
-                        Pithos.get().displayError("Unable to trash file:" + ((RestException) t).getHttpStatusText());
+                        app.displayError("Unable to trash file:" + ((RestException) t).getHttpStatusText());
                 }
                 else
-                    Pithos.get().displayError("System error trashing file:" + t.getMessage());
+                    app.displayError("System error trashing file:" + t.getMessage());
             }
         };
         DeferredCommand.addCommand(tot);
@@ -281,11 +284,11 @@ public class DnDFolderPopupMenu extends PopupPanel {
 
     private void executeCopyOrMoveFiles(final int index, final List<String> paths) {
         if (index >= paths.size()) {
-            Pithos.get().showFileList(true);
-            Pithos.get().getStatusPanel().updateStats();
+            app.showFileList(true);
+            app.getStatusPanel().updateStats();
             return;
         }
-        PostCommand cf = new PostCommand(paths.get(index), "", 200) {
+        PostCommand cf = new PostCommand(app, paths.get(index), "", 200) {
 
             @Override
             public void onComplete() {
@@ -298,18 +301,18 @@ public class DnDFolderPopupMenu extends PopupPanel {
                 if (t instanceof RestException) {
                     int statusCode = ((RestException) t).getHttpStatusCode();
                     if (statusCode == 405)
-                        Pithos.get().displayError("You don't have the necessary permissions");
+                        app.displayError("You don't have the necessary permissions");
                     else if (statusCode == 404)
-                        Pithos.get().displayError("File not found");
+                        app.displayError("File not found");
                     else if (statusCode == 409)
-                        Pithos.get().displayError("A file with the same name already exists");
+                        app.displayError("A file with the same name already exists");
                     else if (statusCode == 413)
-                        Pithos.get().displayError("Your quota has been exceeded");
+                        app.displayError("Your quota has been exceeded");
                     else
-                        Pithos.get().displayError("Unable to copy file:" + ((RestException) t).getHttpStatusText());
+                        app.displayError("Unable to copy file:" + ((RestException) t).getHttpStatusText());
                 }
                 else
-                    Pithos.get().displayError("System error copying file:" + t.getMessage());
+                    app.displayError("System error copying file:" + t.getMessage());
             }
         };
         DeferredCommand.addCommand(cf);
index 751fafe..e1fd7eb 100644 (file)
@@ -179,7 +179,7 @@ public class EditMenu extends MenuBar {
                 MenuItem moveToTrashItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + "&nbsp;Move to Trash</span>", true, new ToTrashCommand(_app, null, cutObject));
                 addItem(moveToTrashItem);
 
-                MenuItem deleteItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(null, cutObject, images));
+                MenuItem deleteItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(_app, null, cutObject, images));
                 addItem(deleteItem);
             }
         }
index dfc2060..382d616 100644 (file)
@@ -117,21 +117,20 @@ public class FileContextMenu extends PopupPanel {
         *
         * @param newImages the image bundle passed on by the parent object
         */
-       public FileContextMenu(Images newImages, Folder selectedFolder, List<File> selectedFiles, boolean isTrash) {
+       public FileContextMenu(final Pithos app, Images newImages, Folder selectedFolder, List<File> selectedFiles, boolean isTrash) {
                // The popup's constructor's argument is a boolean specifying that it
                // auto-close itself when the user clicks outside of it.
                super(true);
-               Pithos gss = Pithos.get();
                setAnimationEnabled(true);
                images = newImages;
         MenuBar contextMenu = new MenuBar(true);
 
-        if (Pithos.get().getClipboard().hasFiles()) {
-            pasteItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.paste()).getHTML() + "&nbsp;Paste</span>", true, new PasteCommand(Pithos.get(), this, selectedFolder));
+        if (app.getClipboard().hasFiles()) {
+            pasteItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.paste()).getHTML() + "&nbsp;Paste</span>", true, new PasteCommand(app, this, selectedFolder));
             contextMenu.addItem(pasteItem);
         }
 
-        MenuItem upload = new MenuItem("<span>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this, selectedFolder));
+        MenuItem upload = new MenuItem("<span>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(app, this, selectedFolder));
         contextMenu.addItem(upload);
 
 //        MenuItem refresh = new MenuItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + "&nbsp;Refresh</span>", true, new RefreshCommand(this, images));
@@ -144,31 +143,31 @@ public class FileContextMenu extends PopupPanel {
 //                     MenuItem delete = new MenuItem("<span>" + AbstractImagePrototype.create(images.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(this, null, images));
 //                     contextMenu.addItem(delete);
 //             } else {
-                       cutItem = new MenuItem("<span id='fileContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Cut</span>", true, new CutCommand(Pithos.get(), this, selectedFiles));
+                       cutItem = new MenuItem("<span id='fileContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Cut</span>", true, new CutCommand(app, this, selectedFiles));
             contextMenu.addItem(cutItem);
 
-                       copyItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + "&nbsp;Copy</span>", true, new CopyCommand(Pithos.get(), this, selectedFiles));
+                       copyItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + "&nbsp;Copy</span>", true, new CopyCommand(app, this, selectedFiles));
             contextMenu.addItem(copyItem);
 
-                       trashItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + "&nbsp;Move to Trash</span>", true, new ToTrashCommand(Pithos.get(), this, selectedFiles));
+                       trashItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + "&nbsp;Move to Trash</span>", true, new ToTrashCommand(app, this, selectedFiles));
             contextMenu.addItem(trashItem);
 
-                       deleteItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(this, selectedFiles, images));
+                       deleteItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(app, this, selectedFiles, images));
             contextMenu.addItem(deleteItem);
 
 //                     sharingItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + "&nbsp;Sharing</span>", true, new PropertiesCommand(this, images, 1));
 //            contextMenu.addItem(sharingItem);
 
-            contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(Pithos.get(), this, selectedFiles, images, 0)));
+            contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(app, this, selectedFiles, images, 0)));
 
             if (!selectedFiles.isEmpty())
-                           contextMenu.addItem(new MenuItem("<span><a class='hidden-link' href='" + Pithos.get().getApiPath() + Pithos.get().getUsername() + selectedFiles.get(0).getUri() + "?X-Auth-Token=" + Pithos.get().getToken() + "' target='_blank'>" + AbstractImagePrototype.create(newImages.download()).getHTML() + " Download</a></span>", true, (Command) null));
+                           contextMenu.addItem(new MenuItem("<span><a class='hidden-link' href='" + app.getApiPath() + app.getUsername() + selectedFiles.get(0).getUri() + "?X-Auth-Token=" + app.getToken() + "' target='_blank'>" + AbstractImagePrototype.create(newImages.download()).getHTML() + " Download</a></span>", true, (Command) null));
 
                        MenuItem unSelect = new MenuItem("<span>" + AbstractImagePrototype.create(images.unselectAll()).getHTML() + "&nbsp;Unselect</span>", true, new Command() {
                 @Override
                 public void execute() {
                     hide();
-                    Pithos.get().getFileList().clearSelectedRows();
+                    app.getFileList().clearSelectedRows();
                 }
             });
                        contextMenu.addItem(unSelect);
index 858a61f..3e7a96b 100644 (file)
@@ -256,6 +256,8 @@ public class FileList extends Composite {
 
     FolderTreeView treeView;
 
+    private Pithos app;
+
     /**
         * Construct the file list widget. This entails setting up the widget
         * layout, fetching the number of files in the current folder from the
@@ -264,7 +266,8 @@ public class FileList extends Composite {
         *
         * @param _images
         */
-       public FileList(Images _images, FolderTreeView _treeView) {
+       public FileList(final Pithos _app, Images _images, FolderTreeView _treeView) {
+        app = _app;
                images = _images;
         this.treeView = _treeView;
 
@@ -417,7 +420,7 @@ public class FileList extends Composite {
                        
                        @Override
                        public void onClick(ClickEvent event) {
-                               new UploadFileCommand(null, treeView.getSelection()).execute();
+                               new UploadFileCommand(app, null, treeView.getSelection()).execute();
                        }
                });
                HorizontalPanel topPanel = new HorizontalPanel();
@@ -435,7 +438,7 @@ public class FileList extends Composite {
                        
                        @Override
                        public void onClick(ClickEvent event) {
-                               new UploadFileCommand(null, treeView.getSelection()).execute();
+                               new UploadFileCommand(app, null, treeView.getSelection()).execute();
                        }
                });
         HorizontalPanel bottomPanel = new HorizontalPanel();
@@ -449,7 +452,7 @@ public class FileList extends Composite {
             public void onContextMenu(ContextMenuEvent event) {
                 Folder selectedFolder = treeView.getSelection();
                 if (!selectedFolder.isTrash()) {
-                    FileContextMenu contextMenu = new FileContextMenu(images, selectedFolder, getSelectedFiles(), false);
+                    FileContextMenu contextMenu = new FileContextMenu(app, images, selectedFolder, getSelectedFiles(), false);
                     int x = event.getNativeEvent().getClientX();
                     int y = event.getNativeEvent().getClientY();
                     contextMenu.setPopupPosition(x, y);
@@ -465,9 +468,9 @@ public class FileList extends Composite {
              @Override 
              public void onSelectionChange(SelectionChangeEvent event) {
                 if(getSelectedFiles().size() == 1)
-                        Pithos.get().setCurrentSelection(getSelectedFiles().get(0));
+                        app.setCurrentSelection(getSelectedFiles().get(0));
                 else
-                        Pithos.get().setCurrentSelection(getSelectedFiles());
+                        app.setCurrentSelection(getSelectedFiles());
              }
          };
          selectionModel.addSelectionChangeHandler(selectionHandler);
@@ -541,7 +544,7 @@ public class FileList extends Composite {
 //                     event.preventDefault();
 //             } else if (DOM.eventGetType(event) == Event.ONDBLCLICK)
 //                     if (getSelectedFiles().size() == 1) {
-//                             Pithos app = Pithos.get();
+//                             Pithos app = app;
 //                             File file = getSelectedFiles().get(0);
 //                             Window.open(file.getUri(), "_blank", "");
 //                             event.preventDefault();
@@ -622,7 +625,7 @@ public class FileList extends Composite {
         * Update status panel with currently showing file stats.
         */
        public void updateCurrentlyShowingStats() {
-               Pithos.get().getStatusPanel().updateCurrentlyShowing(showingStats);
+               app.getStatusPanel().updateCurrentlyShowing(showingStats);
        }
        
        /**
index eefd992..101c21b 100644 (file)
@@ -103,14 +103,14 @@ public class FileMenu extends MenuBar {
         Folder selectedFolder = _app.getFolderTreeView().getSelection();
         List<File> selectedFiles = _app.getFileList().getSelectedFiles();
         if (selectedFolder != null) {
-                   MenuItem newFolderItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.folderNew()).getHTML() + "&nbsp;New Folder</span>", true, new NewFolderCommand(null, selectedFolder, images));
+                   MenuItem newFolderItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.folderNew()).getHTML() + "&nbsp;New Folder</span>", true, new NewFolderCommand(_app,  null, selectedFolder, images));
                    addItem(newFolderItem);
 
-            MenuItem uploadItem = new MenuItem("<span id='topMenu.file.upload'>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(null, selectedFolder));
+            MenuItem uploadItem = new MenuItem("<span id='topMenu.file.upload'>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(_app, null, selectedFolder));
             addItem(uploadItem);
         }
         if (selectedFiles.size() == 1) {
-            addItem(new MenuItem("<span><a class='hidden-link' href='" + Pithos.get().getApiPath() + Pithos.get().getUsername() + selectedFiles.get(0).getUri() + "?X-Auth-Token=" + Pithos.get().getToken() + "' target='_blank'>" + AbstractImagePrototype.create(images.download()).getHTML() + " Download</a></span>", true, (Command) null));
+            addItem(new MenuItem("<span><a class='hidden-link' href='" + _app.getApiPath() + _app.getUsername() + selectedFiles.get(0).getUri() + "?X-Auth-Token=" + _app.getToken() + "' target='_blank'>" + AbstractImagePrototype.create(images.download()).getHTML() + " Download</a></span>", true, (Command) null));
         }
 
 //        MenuItem emptyTrashItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + "&nbsp;Empty Trash</span>", true, new EmptyTrashCommand(this));
@@ -127,7 +127,7 @@ public class FileMenu extends MenuBar {
 //                       .setVisible(propertiesVisible);
 //
         if (selectedFiles.size() > 0 || selectedFolder != null) {
-            MenuItem propertiesItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.viewText()).getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(Pithos.get(), null, selectedFiles.size() > 0 ? selectedFiles : selectedFolder, images, 0));
+            MenuItem propertiesItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.viewText()).getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(_app, null, selectedFiles.size() > 0 ? selectedFiles : selectedFolder, images, 0));
             addItem(propertiesItem);
         }
        }
index fb4ba59..2638aab 100644 (file)
@@ -112,13 +112,12 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
 \r
        private String userFullName;\r
 \r
-    private Pithos app;\r
 \r
        /**\r
         * The widget's constructor.\r
         */\r
        public FilePropertiesDialog(Pithos _app, File _file) {\r
-        app = _app;\r
+        super(_app);\r
         file = _file;\r
 \r
                // Set the dialog's caption.\r
@@ -411,7 +410,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                //only update the read for all perm if the user is the owner\r
         Boolean published = null;\r
                if (readForAll.getValue() != file.isPublished())\r
-                       if (file.getOwner().equals(Pithos.get().getUsername()))\r
+                       if (file.getOwner().equals(app.getUsername()))\r
                 published = readForAll.getValue();\r
         final Boolean finalPublished = published;\r
 //                             json.put("readForAll", JSONBoolean.getInstance(readForAll.getValue()));\r
@@ -496,7 +495,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                JSONObject json = new JSONObject();\r
                json.put("versioned", JSONBoolean.getInstance(false));\r
                GWT.log(json.toString(), null);\r
-               PostCommand cf = new PostCommand(file.getUri() + "?update=", json.toString(), 200) {\r
+               PostCommand cf = new PostCommand(app, file.getUri() + "?update=", json.toString(), 200) {\r
 \r
                        @Override\r
                        public void onComplete() {\r
@@ -509,17 +508,17 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                                if (t instanceof RestException) {\r
                                        int statusCode = ((RestException) t).getHttpStatusCode();\r
                                        if (statusCode == 405)\r
-                                               Pithos.get().displayError("You don't have the necessary permissions");\r
+                                               app.displayError("You don't have the necessary permissions");\r
                                        else if (statusCode == 404)\r
-                                               Pithos.get().displayError("User in permissions does not exist");\r
+                                               app.displayError("User in permissions does not exist");\r
                                        else if (statusCode == 409)\r
-                                               Pithos.get().displayError("A folder with the same name already exists");\r
+                                               app.displayError("A folder with the same name already exists");\r
                                        else if (statusCode == 413)\r
-                                               Pithos.get().displayError("Your quota has been exceeded");\r
+                                               app.displayError("Your quota has been exceeded");\r
                                        else\r
-                                               Pithos.get().displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText());\r
+                                               app.displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText());\r
                                } else\r
-                                       Pithos.get().displayError("System error moifying file:" + t.getMessage());\r
+                                       app.displayError("System error moifying file:" + t.getMessage());\r
                        }\r
                };\r
                DeferredCommand.addCommand(cf);\r
@@ -529,11 +528,11 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                JSONObject json = new JSONObject();\r
                json.put("versioned", JSONBoolean.getInstance(versionedValue));\r
                GWT.log(json.toString(), null);\r
-               PostCommand cf = new PostCommand(file.getUri() + "?update=", json.toString(), 200) {\r
+               PostCommand cf = new PostCommand(app, file.getUri() + "?update=", json.toString(), 200) {\r
 \r
                        @Override\r
                        public void onComplete() {\r
-                               Pithos.get().getTreeView().refreshCurrentNode(false);\r
+                               app.getTreeView().refreshCurrentNode(false);\r
                        }\r
 \r
                        @Override\r
@@ -542,17 +541,17 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                                if (t instanceof RestException) {\r
                                        int statusCode = ((RestException) t).getHttpStatusCode();\r
                                        if (statusCode == 405)\r
-                                               Pithos.get().displayError("You don't have the necessary permissions");\r
+                                               app.displayError("You don't have the necessary permissions");\r
                                        else if (statusCode == 404)\r
-                                               Pithos.get().displayError("User in permissions does not exist");\r
+                                               app.displayError("User in permissions does not exist");\r
                                        else if (statusCode == 409)\r
-                                               Pithos.get().displayError("A folder with the same name already exists");\r
+                                               app.displayError("A folder with the same name already exists");\r
                                        else if (statusCode == 413)\r
-                                               Pithos.get().displayError("Your quota has been exceeded");\r
+                                               app.displayError("Your quota has been exceeded");\r
                                        else\r
-                                               Pithos.get().displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText());\r
+                                               app.displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText());\r
                                } else\r
-                                       Pithos.get().displayError("System error moifying file:" + t.getMessage());\r
+                                       app.displayError("System error moifying file:" + t.getMessage());\r
                        }\r
                };\r
                DeferredCommand.addCommand(cf);\r
index a9804ea..46a86d4 100644 (file)
@@ -120,7 +120,7 @@ public class FileUploadGearsDialog extends FileUploadDialog {
                info.addStyleName("pithos-uploadNote");
                panel.add(info);
                // Add an informative label with the folder name.
-               Object selection = Pithos.get().getTreeView().getSelection();
+               Object selection = app.getTreeView().getSelection();
 
                browse = new Button("Browse...");
 
@@ -160,7 +160,7 @@ public class FileUploadGearsDialog extends FileUploadDialog {
                        public void onClick(ClickEvent event) {
                                canContinue = false;                            
                                cancelUpload();                         
-                               Pithos.get().showFileList(true);
+                               app.showFileList(true);
                        }
                });
                buttons.add(cancel);
@@ -211,7 +211,6 @@ public class FileUploadGearsDialog extends FileUploadDialog {
 
        @Override
        public void prepareAndSubmit() {
-               Pithos app = Pithos.get();
                if (selectedFiles.size() == 0) {
                        app.displayError("You must select a file!");
                        hide();
@@ -299,7 +298,7 @@ public class FileUploadGearsDialog extends FileUploadDialog {
                for (final String name: toRename.keySet()) {
                        JSONObject json = new JSONObject();
                        json.put("name", new JSONString(name));
-                       PostCommand cf = new PostCommand(toRename.get(name).getUri() + "?update=", json.toString(), 200) {
+                       PostCommand cf = new PostCommand(app, toRename.get(name).getUri() + "?update=", json.toString(), 200) {
 
                                @Override
                                public void onComplete() {
@@ -309,7 +308,6 @@ public class FileUploadGearsDialog extends FileUploadDialog {
 
                                @Override
                                public void onError(Throwable t) {
-                                       Pithos app = Pithos.get();
                                        GWT.log("", t);
                                        if (t instanceof RestException) {
                                                int statusCode = ((RestException) t).getHttpStatusCode();
@@ -347,7 +345,6 @@ public class FileUploadGearsDialog extends FileUploadDialog {
         * Perform the HTTP request to upload the specified file.
         */
        protected void doSend(final List<File> filesRemaining) {
-               final Pithos app = Pithos.get();
                HttpRequest request = factory.createHttpRequest();
                requests.add(request);
                String method = "PUT";
@@ -382,7 +379,7 @@ public class FileUploadGearsDialog extends FileUploadDialog {
                                                doSend(filesRemaining);                         
                                                break;
                                        case 403:
-                                               SessionExpiredDialog dlg = new SessionExpiredDialog();
+                                               SessionExpiredDialog dlg = new SessionExpiredDialog(app);
                                                dlg.center();
                                                break;
                                        case 405:
@@ -420,9 +417,9 @@ public class FileUploadGearsDialog extends FileUploadDialog {
         */
        protected void finish() {
                hide();
-               //Pithos.get().showFileList(true);
-               Pithos.get().getTreeView().updateNode(Pithos.get().getTreeView().getSelection());//showFileList(true);
-               Pithos.get().getStatusPanel().updateStats();
+               //app.showFileList(true);
+               app.getTreeView().updateNode(app.getTreeView().getSelection());//showFileList(true);
+               app.getStatusPanel().updateStats();
        }
 
        /**
index 33251bf..6402558 100644 (file)
@@ -55,7 +55,6 @@ public class FileUploadGearsIEDialog extends FileUploadGearsDialog {
         */     
        @Override
        protected void doSend(final List<File> filesRemaining) {
-               final Pithos app = Pithos.get();
                HttpRequest request = factory.createHttpRequest();
                requests.add(request);
                String method = "POST";
index 77dce20..4d124e9 100644 (file)
@@ -63,14 +63,13 @@ public class FilesPropertiesDialog extends AbstractPropertiesDialog {
 \r
        private Boolean initialVersioned;\r
 \r
-\r
        /**\r
         * The widget's constructor.\r
         *\r
         * @param _files\r
         */\r
        public FilesPropertiesDialog(Pithos _app, final List<File> _files) {\r
-               super();\r
+               super(_app);\r
 \r
                files = _files;\r
 //             int versionedNum = 0;\r
@@ -254,7 +253,7 @@ public class FilesPropertiesDialog extends AbstractPropertiesDialog {
 //\r
 //                     @Override\r
 //                     public void onComplete() {\r
-//                             Pithos.get().getTreeView().refreshCurrentNode(false);\r
+//                             app.getTreeView().refreshCurrentNode(false);\r
 //                     }\r
 //\r
 //                     @Override\r
@@ -263,18 +262,18 @@ public class FilesPropertiesDialog extends AbstractPropertiesDialog {
 //                             if(t instanceof RestException){\r
 //                                     int statusCode = ((RestException)t).getHttpStatusCode();\r
 //                                     if(statusCode == 405)\r
-//                                             Pithos.get().displayError("You don't have the necessary permissions");\r
+//                                             app.displayError("You don't have the necessary permissions");\r
 //                                     else if(statusCode == 404)\r
-//                                             Pithos.get().displayError("File does not exist");\r
+//                                             app.displayError("File does not exist");\r
 //                                     else if(statusCode == 409)\r
-//                                             Pithos.get().displayError("A file with the same name already exists");\r
+//                                             app.displayError("A file with the same name already exists");\r
 //                                     else if(statusCode == 413)\r
-//                                             Pithos.get().displayError("Your quota has been exceeded");\r
+//                                             app.displayError("Your quota has been exceeded");\r
 //                                     else\r
-//                                             Pithos.get().displayError("Unable to modify file::"+((RestException)t).getHttpStatusText());\r
+//                                             app.displayError("Unable to modify file::"+((RestException)t).getHttpStatusText());\r
 //                             }\r
 //                             else\r
-//                                     Pithos.get().displayError("System error modifying file:"+t.getMessage());\r
+//                                     app.displayError("System error modifying file:"+t.getMessage());\r
 //                     }\r
 //             };\r
 //             DeferredCommand.addCommand(rt);\r
index 8582519..ea8553f 100644 (file)
@@ -73,7 +73,7 @@ public class FolderContextMenu extends PopupPanel {
         *
         * @param newImages the image bundle passed on by the parent object
         */
-       public FolderContextMenu(final Images newImages, Folder folder) {
+       public FolderContextMenu(Pithos app, final Images newImages, Folder folder) {
                // The popup's constructor's argument is a boolean specifying that it
                // auto-close itself when the user clicks outside of it.
                super(true);
@@ -81,27 +81,27 @@ public class FolderContextMenu extends PopupPanel {
                images = newImages;
         MenuBar contextMenu = new MenuBar(true);
 
-        MenuItem newFolder = new MenuItem("<span id = 'folderContextMenu.newFolder'>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + "&nbsp;New Folder</span>", true, new NewFolderCommand(this, folder, images));
+        MenuItem newFolder = new MenuItem("<span id = 'folderContextMenu.newFolder'>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + "&nbsp;New Folder</span>", true, new NewFolderCommand(app, this, folder, images));
         contextMenu.addItem(newFolder);
 
         if (!folder.isContainer()) {
-            MenuItem cut = new MenuItem("<span id = 'folderContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Cut</span>", true, new CutCommand(Pithos.get(), this, folder));
+            MenuItem cut = new MenuItem("<span id = 'folderContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Cut</span>", true, new CutCommand(app, this, folder));
             contextMenu.addItem(cut);
         }
 
-        MenuItem copy = new MenuItem("<span id = 'folderContextMenu.copy'>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + "&nbsp;Copy</span>", true, new CopyCommand(Pithos.get(), this, folder));
+        MenuItem copy = new MenuItem("<span id = 'folderContextMenu.copy'>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + "&nbsp;Copy</span>", true, new CopyCommand(app, this, folder));
         contextMenu.addItem(copy);
 
-        if (!Pithos.get().getClipboard().isEmpty()) {
-            pasteItem = new MenuItem("<span id = 'folderContextMenu.paste'>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + "&nbsp;Paste</span>", true, new PasteCommand(Pithos.get(), this, folder));
+        if (!app.getClipboard().isEmpty()) {
+            pasteItem = new MenuItem("<span id = 'folderContextMenu.paste'>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + "&nbsp;Paste</span>", true, new PasteCommand(app, this, folder));
             contextMenu.addItem(pasteItem);
         }
 
         if (!folder.isContainer()) {
-            MenuItem moveToTrash = new MenuItem("<span id = 'folderContextMenu.moveToTrash'>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + "&nbsp;Move to Trash</span>", true, new ToTrashCommand(Pithos.get(), this, folder));
+            MenuItem moveToTrash = new MenuItem("<span id = 'folderContextMenu.moveToTrash'>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + "&nbsp;Move to Trash</span>", true, new ToTrashCommand(app, this, folder));
             contextMenu.addItem(moveToTrash);
 
-            MenuItem delete = new MenuItem("<span id = 'folderContextMenu.delete'>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(this, folder, newImages));
+            MenuItem delete = new MenuItem("<span id = 'folderContextMenu.delete'>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(app, this, folder, newImages));
             contextMenu.addItem(delete);
         }
 
@@ -111,7 +111,7 @@ public class FolderContextMenu extends PopupPanel {
 //        MenuItem sharing = new MenuItem("<span id = 'folderContextMenu.sharing'>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + "&nbsp;Sharing</span>", true, new PropertiesCommand(this, newImages, 1));
 //        contextMenu.addItem(sharing);
 
-        MenuItem properties = new MenuItem("<span id = 'folderContextMenu.properties'>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(Pithos.get(), this, folder, newImages, 0));
+        MenuItem properties = new MenuItem("<span id = 'folderContextMenu.properties'>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(app, this, folder, newImages, 0));
         contextMenu.addItem(properties);
 
                add(contextMenu);
index 83e75ba..1e53619 100644 (file)
@@ -87,7 +87,10 @@ public class PermissionsAddDialog extends DialogBox {
 
        boolean userAdd;
 
-       public PermissionsAddDialog(List<GroupResource> _groups, PermissionsList _permList, boolean _userAdd) {
+    private Pithos app;
+
+       public PermissionsAddDialog(Pithos _app, List<GroupResource> _groups, PermissionsList _permList, boolean _userAdd) {
+        app = _app;
                groups = _groups;
                userAdd = _userAdd;
                permList = _permList;
@@ -200,7 +203,7 @@ public class PermissionsAddDialog extends DialogBox {
                        selectedUser = suggestBox.getText();
                        for(PermissionHolder p : permList.permissions)
                                if (selectedUser.equals(p.getUser())){
-                                       Pithos.get().displayError("User already has access to the resource");
+                                       app.displayError("User already has access to the resource");
                                        return;
                                }
                        perm.setUser(selectedUser);
@@ -214,7 +217,7 @@ public class PermissionsAddDialog extends DialogBox {
                                return;
                        for(PermissionHolder p : permList.permissions)
                                if (selected.getName().equals(p.getGroup())){
-                                       Pithos.get().displayError("Group already has access to the resource");
+                                       app.displayError("Group already has access to the resource");
                                        return;
                                }
                        perm.setGroup(selected.getName());
@@ -261,11 +264,10 @@ public class PermissionsAddDialog extends DialogBox {
         * Update the list of suggestions.
         */
        protected void updateSuggestions() {
-               final Pithos app = Pithos.get();
                String query = selectedUser.substring(0, selectedUser.length()-1);
                GWT.log("Searching for " + query, null);
 
-               GetCommand<UserSearchResource> eg = new GetCommand<UserSearchResource>(UserSearchResource.class,
+               GetCommand<UserSearchResource> eg = new GetCommand<UserSearchResource>(app, UserSearchResource.class,
                                        app.getApiPath() + "users/" + URL.encodeComponent(query), false, null) {
 
                        @Override
index 739809f..745321c 100644 (file)
@@ -76,8 +76,11 @@ public class PermissionsList extends Composite {
        private boolean hasChanges = false;
        
        private boolean hasAddition = false;
+
+    private Pithos app;
        
-       public PermissionsList(final Images theImages, Set<PermissionHolder> thePermissions, String anOwner){
+       public PermissionsList(Pithos _app, final Images theImages, Set<PermissionHolder> thePermissions, String anOwner){
+        app = _app;
                images = theImages;
                owner = anOwner;
                permissions =  new HashSet<PermissionHolder>();
@@ -159,7 +162,6 @@ public class PermissionsList extends Composite {
         * If the user's full name does not exist in the map then a request is being made
         * for the specific username.  
         * 
-        * @param filesInput
         */
        private void handleFullNames(Set<PermissionHolder> aPermissions){               
                if(aPermissions.isEmpty()){
@@ -173,7 +175,7 @@ public class PermissionsList extends Composite {
                                aPermissions.remove(dto);                               
                                handleFullNames(aPermissions);                          
                        }
-               }else if(Pithos.get().findUserFullName(dto.getUser()) != null){
+               }else if(app.findUserFullName(dto.getUser()) != null){
                        if(aPermissions.size() >= 1){
                                aPermissions.remove(dto);                               
                                handleFullNames(aPermissions);                          
@@ -186,7 +188,6 @@ public class PermissionsList extends Composite {
        /**
         * Shows the permission table 
         * 
-        * @param aPermissions
         */
        private void showPermissionTable(){
                int i = 1;
@@ -209,7 +210,7 @@ public class PermissionsList extends Composite {
                                        permTable.setHTML(i, 0, "<span id=permissionList.Owner>" + AbstractImagePrototype.create(images.permUser()).getHTML() + "&nbsp;Owner</span>");
                                        removeButton.setVisible(false);
                                }else{
-                                       permTable.setHTML(i, 0, "<span id=permissionList."+ Pithos.get().findUserFullName(dto.getUser())+">"+ AbstractImagePrototype.create(images.permUser()).getHTML() + "&nbsp;"+ Pithos.get().findUserFullName(dto.getUser()) + "</span>");
+                                       permTable.setHTML(i, 0, "<span id=permissionList."+ app.findUserFullName(dto.getUser())+">"+ AbstractImagePrototype.create(images.permUser()).getHTML() + "&nbsp;"+ app.findUserFullName(dto.getUser()) + "</span>");
                                }
                        }else if(dto.getGroup() != null){
                                permTable.setHTML(i, 0, "<span id=permissionList."+dto.getGroup()+">" + AbstractImagePrototype.create(images.permGroup()).getHTML() + "&nbsp;"+ dto.getGroup() + "</span>");
@@ -252,21 +253,20 @@ public class PermissionsList extends Composite {
         * Makes a request to search for full name from a given username
         * and continues checking the next element of the Set.
         *  
-        * @param filesInput
         */
 
        private void findFullNameAndUpdate(final Set<PermissionHolder> aPermissions){                           
                final PermissionHolder dto = aPermissions.iterator().next();
-               String path = Pithos.get().getApiPath() + "users/" + dto.getUser();
+               String path = app.getApiPath() + "users/" + dto.getUser();
 
-               GetCommand<UserSearchResource> gg = new GetCommand<UserSearchResource>(UserSearchResource.class, path, false,null) {
+               GetCommand<UserSearchResource> gg = new GetCommand<UserSearchResource>(app, 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();
-                                       Pithos.get().putUserToMap(username, userFullName);
+                                       app.putUserToMap(username, userFullName);
                                        if(aPermissions.size() >= 1){
                                                aPermissions.remove(dto);                                               
                                                if(aPermissions.isEmpty()){
@@ -279,7 +279,7 @@ public class PermissionsList extends Composite {
                        }
                        @Override
                        public void onError(Throwable t) {                              
-                               Pithos.get().displayError("Unable to fetch user's full name from the given username " + dto.getUser());
+                               app.displayError("Unable to fetch user's full name from the given username " + dto.getUser());
                                if(aPermissions.size() >= 1){
                                        aPermissions.remove(dto);
                                        if(aPermissions.isEmpty()){
index bf4219b..fb16b0b 100644 (file)
@@ -159,7 +159,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
         * 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, FilePropertiesDialog.Images, MessagePanel.Images, FileList.Images, Search.Images, CellTreeView.Images {
+       public interface Images extends ClientBundle, TopPanel.Images, StatusPanel.Images, FileMenu.Images, EditMenu.Images, FilePropertiesDialog.Images, MessagePanel.Images, FileList.Images, Search.Images, CellTreeView.Images {
 
                @Source("gr/grnet/pithos/resources/document.png")
                ImageResource folders();
@@ -172,22 +172,6 @@ public class Pithos implements EntryPoint, ResizeHandler {
        }
 
        /**
-        * The single Pithos instance.
-        */
-       private static Pithos singleton;
-
-       /**
-        * Gets the singleton Pithos instance.
-        *
-        * @return the Pithos object
-        */
-       public static Pithos get() {
-               if (Pithos.singleton == null)
-                       Pithos.singleton = new Pithos();
-               return Pithos.singleton;
-       }
-
-       /**
         * The Application Clipboard implementation;
         */
        private Clipboard clipboard = new Clipboard();
@@ -212,7 +196,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
        /**
         * The top right panel that displays the logged in user details
         */
-       private UserDetailsPanel userDetailsPanel = new UserDetailsPanel();
+       private UserDetailsPanel userDetailsPanel = new UserDetailsPanel(this);
 
        /**
         * The file list widget.
@@ -277,15 +261,12 @@ public class Pithos implements EntryPoint, ResizeHandler {
 
        @Override
        public void onModuleLoad() {
-               // Initialize the singleton before calling the constructors of the
-               // various widgets that might call Pithos.get().
-               singleton = this;
                if (parseUserCredentials())
             initialize();
        }
 
     private void initialize() {
-        topPanel = new TopPanel(Pithos.images);
+        topPanel = new TopPanel(this, Pithos.images);
         topPanel.setWidth("100%");
 
         messagePanel.setWidth("100%");
@@ -325,10 +306,10 @@ public class Pithos implements EntryPoint, ResizeHandler {
             }
         });
 
-        folderTreeViewModel = new FolderTreeViewModel(folderTreeSelectionModel);
+        folderTreeViewModel = new FolderTreeViewModel(this, folderTreeSelectionModel);
         folderTreeView = new FolderTreeView(folderTreeViewModel);
 
-        fileList = new FileList(images, folderTreeView);
+        fileList = new FileList(this, images, folderTreeView);
         inner.add(fileList, createHeaderHTML(AbstractImagePrototype.create(images.folders()), "Files"), true);
 
         tagTreeSelectionModel = new SingleSelectionModel<Tag>();
@@ -342,7 +323,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
                 }
             }
         });
-        tagTreeViewModel = new TagTreeViewModel(tagTreeSelectionModel);
+        tagTreeViewModel = new TagTreeViewModel(this, tagTreeSelectionModel);
         tagTreeView = new TagTreeView(tagTreeViewModel);
 
         VerticalPanel trees = new VerticalPanel();
@@ -362,7 +343,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
         outer.add(topPanel);
         outer.add(messagePanel);
         outer.add(splitPanel);
-        statusPanel = new StatusPanel(Pithos.images);
+        statusPanel = new StatusPanel(this, Pithos.images);
         outer.add(statusPanel);
         outer.setWidth("100%");
         outer.setCellHorizontalAlignment(messagePanel, HasHorizontalAlignment.ALIGN_CENTER);
@@ -427,9 +408,9 @@ public class Pithos implements EntryPoint, ResizeHandler {
                 public void onError(Throwable t) {
                     GWT.log("Error getting file", t);
                     if (t instanceof RestException)
-                        Pithos.get().displayError("Error getting file: " + ((RestException) t).getHttpStatusText());
+                        displayError("Error getting file: " + ((RestException) t).getHttpStatusText());
                     else
-                        Pithos.get().displayError("System error fetching file: " + t.getMessage());
+                        displayError("System error fetching file: " + t.getMessage());
                 }
             };
             getFile.setHeader("X-Auth-Token", "0000");
@@ -494,9 +475,9 @@ public class Pithos implements EntryPoint, ResizeHandler {
             public void onError(Throwable t) {
                 GWT.log("Error getting account", t);
                 if (t instanceof RestException)
-                    Pithos.get().displayError("Error getting account: " + ((RestException) t).getHttpStatusText());
+                    displayError("Error getting account: " + ((RestException) t).getHttpStatusText());
                 else
-                    Pithos.get().displayError("System error fetching user data: " + t.getMessage());
+                    displayError("System error fetching user data: " + t.getMessage());
             }
         };
         getAccount.setHeader("X-Auth-Token", token);
@@ -515,9 +496,9 @@ public class Pithos implements EntryPoint, ResizeHandler {
             public void onError(Throwable t) {
                 GWT.log("Error creating pithos", t);
                 if (t instanceof RestException)
-                    Pithos.get().displayError("Error creating pithos: " + ((RestException) t).getHttpStatusText());
+                    displayError("Error creating pithos: " + ((RestException) t).getHttpStatusText());
                 else
-                    Pithos.get().displayError("System error Error creating pithos: " + t.getMessage());
+                    displayError("System error Error creating pithos: " + t.getMessage());
             }
         };
         createPithos.setHeader("X-Auth-Token", getToken());
@@ -860,19 +841,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
        public String findUserFullName(String _userName){
                return userFullNameMap.get(_userName);
        }
-       public String getUserFullName(String _userName) {
-               
-        if (Pithos.get().findUserFullName(_userName) == null)
-                //if there is no userFullName found then the map fills with the given _userName,
-                //so userFullName = _userName
-                Pithos.get().putUserToMap(_userName, _userName);
-        else if(Pithos.get().findUserFullName(_userName).indexOf('@') != -1){
-                //if the userFullName = _userName the GetUserCommand updates the userFullName in the map
-                GetUserCommand guc = new GetUserCommand(_userName);
-                guc.execute();
-        }
-        return Pithos.get().findUserFullName(_userName);
-       }
+
        /**
         * Retrieve the treeView.
         *
@@ -911,7 +880,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
 
                 @Override
                 public void onError(Request request, Throwable exception) {
-                    Pithos.get().displayError("System error unable to delete folder: " + exception.getMessage());
+                    displayError("System error unable to delete folder: " + exception.getMessage());
                 }
             });
         }
@@ -934,7 +903,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
                     @Override
                     public void onError(Throwable t) {
                         GWT.log("", t);
-                        Pithos.get().displayError("System error unable to delete folder: " + t.getMessage());
+                        displayError("System error unable to delete folder: " + t.getMessage());
                     }
                 };
                 delete.setHeader("X-Auth-Token", getToken());
@@ -966,7 +935,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
 
                         @Override
                         public void onError(Request request, Throwable exception) {
-                            Pithos.get().displayError("System error unable to delete folder: " + exception.getMessage());
+                            displayError("System error unable to delete folder: " + exception.getMessage());
                         }
                     });
                 }
@@ -989,7 +958,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
                         displayError("Unable to delete folder: "+((RestException) t).getHttpStatusText());
                     }
                     else
-                        Pithos.get().displayError("System error unable to delete folder: " + t.getMessage());
+                        displayError("System error unable to delete folder: " + t.getMessage());
                 }
             };
             deleteFolder.setHeader("X-Auth-Token", getToken());
@@ -1015,10 +984,10 @@ public class Pithos implements EntryPoint, ResizeHandler {
                 public void onError(Throwable t) {
                     GWT.log("", t);
                     if (t instanceof RestException) {
-                        Pithos.get().displayError("Unable to copy file: " + ((RestException) t).getHttpStatusText());
+                        displayError("Unable to copy file: " + ((RestException) t).getHttpStatusText());
                     }
                     else
-                        Pithos.get().displayError("System error unable to copy file: "+t.getMessage());
+                        displayError("System error unable to copy file: "+t.getMessage());
                 }
             };
             copyFile.setHeader("X-Auth-Token", getToken());
index 8f64da2..3ea1adb 100644 (file)
@@ -52,10 +52,12 @@ import com.google.gwt.user.client.ui.VerticalPanel;
  */\r
 public class QuitDialog extends DialogBox {\r
 \r
+    private Pithos app;\r
        /**\r
         * The widget's constructor.\r
         */\r
-       public QuitDialog() {\r
+       public QuitDialog(Pithos _app) {\r
+        app = _app;\r
                Configuration conf = (Configuration) GWT.create(Configuration.class);\r
                String service = conf.serviceName();\r
                setText("Quit " + service);\r
@@ -73,7 +75,7 @@ public class QuitDialog extends DialogBox {
                        @Override\r
                        public void onClick(ClickEvent event) {\r
                                hide();\r
-                               Pithos.get().logout();\r
+                               app.logout();\r
                        }\r
                });\r
                buttons.add(quit);\r
@@ -105,7 +107,7 @@ public class QuitDialog extends DialogBox {
                        switch (evt.getKeyCode()) {\r
                                case KeyCodes.KEY_ENTER:\r
                                        hide();\r
-                                       Pithos.get().logout();\r
+                                       app.logout();\r
                                        break;\r
                                case KeyCodes.KEY_ESCAPE:\r
                                        hide();\r
index e0b0d1f..b74e374 100644 (file)
@@ -47,10 +47,12 @@ import com.google.gwt.user.client.ui.VerticalPanel;
 
 
 public class SessionExpiredDialog extends DialogBox {
+    private Pithos app;
        /**
         * The widget constructor.
         */
-       public SessionExpiredDialog() {
+       public SessionExpiredDialog(Pithos _app) {
+        app = _app;
                // Set the dialog's caption.
                setText("Session Expired");
                setAnimationEnabled(true);
@@ -66,7 +68,7 @@ public class SessionExpiredDialog extends DialogBox {
                Button confirm = new Button("Proceed", new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
-                               Pithos.get().authenticateUser();
+                               app.authenticateUser();
                                hide();
                        }
                });
@@ -86,7 +88,7 @@ public class SessionExpiredDialog extends DialogBox {
                        // enter or escape is pressed.
                        switch (evt.getKeyCode()) {
                                case KeyCodes.KEY_ENTER:
-                                       Pithos.get().authenticateUser();
+                                       app.authenticateUser();
                                        hide();
                                        break;
                                case KeyCodes.KEY_ESCAPE:
diff --git a/web_client/src/gr/grnet/pithos/web/client/SettingsMenu.java b/web_client/src/gr/grnet/pithos/web/client/SettingsMenu.java
deleted file mode 100644 (file)
index 1708e2d..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/*\r
- * Copyright 2011 GRNET S.A. All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or\r
- * without modification, are permitted provided that the following\r
- * conditions are met:\r
- *\r
- *   1. Redistributions of source code must retain the above\r
- *      copyright notice, this list of conditions and the following\r
- *      disclaimer.\r
- *\r
- *   2. Redistributions in binary form must reproduce the above\r
- *      copyright notice, this list of conditions and the following\r
- *      disclaimer in the documentation and/or other materials\r
- *      provided with the distribution.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS\r
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR\r
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED\r
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
- * POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- * The views and conclusions contained in the software and\r
- * documentation are those of the authors and should not be\r
- * interpreted as representing official policies, either expressed\r
- * or implied, of GRNET S.A.\r
- */\r
-package gr.grnet.pithos.web.client;\r
-\r
-import com.google.gwt.event.dom.client.ClickEvent;\r
-import com.google.gwt.event.dom.client.ClickHandler;\r
-import com.google.gwt.resources.client.ClientBundle;\r
-import com.google.gwt.resources.client.ImageResource;\r
-import com.google.gwt.user.client.Command;\r
-import com.google.gwt.user.client.ui.AbstractImagePrototype;\r
-import com.google.gwt.user.client.ui.MenuBar;\r
-import com.google.gwt.user.client.ui.MenuItem;\r
-import com.google.gwt.user.client.ui.PopupPanel;\r
-\r
-/**\r
- * The 'settings' menu implementation.\r
- */\r
-public class SettingsMenu extends PopupPanel implements ClickHandler {\r
-\r
-       /**\r
-        * The widget's images.\r
-        */\r
-       private Images images;\r
-       private final MenuBar contextMenu;\r
-       /**\r
-        * An image bundle for this widgets images.\r
-        */\r
-       public interface Images extends ClientBundle,MessagePanel.Images {\r
-\r
-               /**\r
-                * Will bundle the file 'advancedsettings.png' residing in the package\r
-                * 'gr.grnet.pithos.web.resources'.\r
-                *\r
-                * @return the image prototype\r
-                */\r
-               @Source("gr/grnet/pithos/resources/advancedsettings.png")\r
-               ImageResource preferences();\r
-\r
-               @Source("gr/grnet/pithos/resources/lock.png")\r
-               ImageResource credentials();\r
-\r
-       }\r
-\r
-       /**\r
-        * The widget's constructor.\r
-        *\r
-        * @param newImages the image bundle passed on by the parent object\r
-        */\r
-       public SettingsMenu(final Images newImages) {\r
-               // The popup's constructor's argument is a boolean specifying that it\r
-               // auto-close itself when the user clicks outside of it.\r
-               super(true);\r
-               setAnimationEnabled(true);\r
-               images = newImages;\r
-\r
-               Command userCredentialsCommand = new Command(){\r
-                       @Override\r
-                       public void execute() {\r
-                               CredentialsDialog dlg = new CredentialsDialog(newImages);\r
-                               dlg.center();\r
-                       }\r
-               };\r
-               contextMenu = new MenuBar(true);\r
-//             contextMenu.addItem("<span>" + newImages.preferences().getHTML() + "&nbsp;Preferences</span>", true, cmd);\r
-               MenuItem showCredentialsItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.credentials()).getHTML() + "&nbsp;Show Credentials</span>", true, userCredentialsCommand);\r
-               showCredentialsItem.getElement().setId("topMenu.settingsMenu.showCredentials");\r
-               contextMenu.addItem(showCredentialsItem);\r
-               \r
-               add(contextMenu);\r
-               // setStyleName("toolbarPopup");\r
-       }\r
-\r
-       @Override\r
-       public void onClick(final ClickEvent event) {\r
-               final SettingsMenu menu = new SettingsMenu(images);\r
-               final int left = event.getRelativeElement().getAbsoluteLeft();\r
-               final int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight();\r
-               menu.setPopupPosition(left, top);\r
-\r
-               menu.show();\r
-       }\r
-\r
-\r
-       /**\r
-        * Retrieve the contextMenu.\r
-        *\r
-        * @return the contextMenu\r
-        */\r
-       public MenuBar getContextMenu() {\r
-               contextMenu.setAutoOpen(false);\r
-               return contextMenu;\r
-       }\r
-\r
-\r
-}\r
index 5126404..99a420c 100644 (file)
@@ -89,12 +89,15 @@ public class StatusPanel extends Composite {
 
        private final Images images;
 
+    private Pithos app;
+    
        /**
         * The constructor of the status panel.
         *
         * @param theImages the supplied images
         */
-       public StatusPanel(Images theImages) {
+       public StatusPanel(Pithos _app, Images theImages) {
+        app = _app;
                images = theImages;
                HorizontalPanel outer = new HorizontalPanel();
                outer.setWidth("100%");
@@ -166,7 +169,6 @@ public class StatusPanel extends Composite {
         */
     //TODO: This should not be done here
        public void updateStats() {
-               final Pithos app = Pithos.get();
         GetRequest<AccountResource> getAccount = new GetRequest<AccountResource>(AccountResource.class, app.getApiPath(), app.getUsername(), "") {
             @Override
             public void onSuccess(AccountResource result) {
index b27b033..d9d5677 100644 (file)
@@ -56,11 +56,13 @@ public class TopPanel extends Composite {
         */
        public static final boolean DONE = false;
 
+    private Pithos app;
+
        /**
         * An image bundle for this widgets images.
         */
        public interface Images extends ClientBundle, FileMenu.Images, EditMenu.Images,
-                       SettingsMenu.Images, FilePropertiesDialog.Images,
+                       FilePropertiesDialog.Images,
                        HelpMenu.Images, LoadingIndicator.Images {
 
                @Source("gr/grnet/pithos/resources/exit.png")
@@ -99,7 +101,8 @@ public class TopPanel extends Composite {
         *
         * @param images the supplied images
         */
-       public TopPanel(final Images images) {
+       public TopPanel(Pithos _app, final Images images) {
+        this.app = _app;
                loading = new LoadingIndicator(images);
         loading.hide();
                HorizontalPanel outer = new HorizontalPanel();
@@ -115,7 +118,7 @@ public class TopPanel extends Composite {
                Command quitCommand = new Command(){
                        @Override
                        public void execute() {
-                               QuitDialog dlg = new QuitDialog();
+                               QuitDialog dlg = new QuitDialog(app);
                                dlg.center();
                        }
                };
@@ -126,7 +129,7 @@ public class TopPanel extends Composite {
                                        AbstractImagePrototype.create(images.folder()).getHTML() + "</td><td>File</td></tr></table>", true, new MenuBar(true)){
                        @Override
                        public MenuBar getSubMenu() {
-                               return new FileMenu(Pithos.get(), images);
+                               return new FileMenu(app, images);
                        }
                };
 
@@ -134,7 +137,7 @@ public class TopPanel extends Composite {
                                        AbstractImagePrototype.create(images.edit()).getHTML() + "</td><td>Edit</td></tr></table>", true, new MenuBar(true)){
                        @Override
                        public MenuBar getSubMenu() {
-                               return new EditMenu(Pithos.get(), images);
+                               return new EditMenu(app, images);
                        }
                };
 
index 86ed573..96c6623 100644 (file)
@@ -52,10 +52,13 @@ public class UserDetailsPanel extends Composite {
         */
        private HTML userInfoLabel;
 
+    private Pithos app;
+
        /**
         * The constructor of the user details panel.
         */
-       public UserDetailsPanel() {
+       public UserDetailsPanel(Pithos _app) {
+        app = _app;
                final HorizontalPanel outer = new HorizontalPanel();
                outer.setSpacing(8);
                userInfoLabel = new HTML("&nbsp;");
@@ -80,11 +83,11 @@ public class UserDetailsPanel extends Composite {
         * @return true if the work has been carried out successfully
         */
        protected boolean displayUserInfo() {
-               UserResource user = Pithos.get().getCurrentUserResource();
+               UserResource user = app.getCurrentUserResource();
                if (user == null)
                        return !DONE;
                userInfoLabel.setHTML("<b>" + user.getName() + " \u0387 " + user.getUsername() + "</b>");
-               Pithos.get().putUserToMap(user.getUsername(), user.getName());
+               app.putUserToMap(user.getUsername(), user.getName());
                return DONE;
        }
 
index 89bee2d..0771d08 100644 (file)
@@ -67,6 +67,8 @@ import com.google.gwt.user.client.ui.VerticalPanel;
 
 public class VersionsList extends Composite {
 
+    private Pithos app;
+
        int selectedRow = -1;
 
        int permissionCount = -1;
@@ -83,7 +85,8 @@ public class VersionsList extends Composite {
 
        FilePropertiesDialog container;
 
-       public VersionsList(FilePropertiesDialog aContainer, final Images theImages, List<FileResource> theVersions) {
+       public VersionsList(Pithos _app, FilePropertiesDialog aContainer, final Images theImages, List<FileResource> theVersions) {
+        app = _app;
                images = theImages;
                container = aContainer;
                versions = theVersions;
@@ -137,14 +140,13 @@ public class VersionsList extends Composite {
                        });
 
                        permTable.setHTML(i, 0, "<span>" + dto.getVersion() + "</span>");
-                       permTable.setHTML(i, 1, "<span>" + formatDate(dto.getCreationDate()) + " by " + Pithos.get().findUserFullName(dto.getCreatedBy()) + "</span>");
-                       permTable.setHTML(i, 2, "<span>" + formatDate(dto.getModificationDate()) + " by " + Pithos.get().findUserFullName(dto.getModifiedBy()) + "</span>");
+                       permTable.setHTML(i, 1, "<span>" + formatDate(dto.getCreationDate()) + " by " + app.findUserFullName(dto.getCreatedBy()) + "</span>");
+                       permTable.setHTML(i, 2, "<span>" + formatDate(dto.getModificationDate()) + " by " + app.findUserFullName(dto.getModifiedBy()) + "</span>");
                        permTable.setHTML(i, 3, "<span>" + dto.getFileSizeAsString() + "</span>");
                        HTML downloadHtml = new HTML("<a class='hidden-link info' href='#'><span>"+AbstractImagePrototype.create(images.download()).getHTML()+"</span><div>View this Version</div></a>");
                        downloadHtml.addClickHandler(new ClickHandler() {
                                @Override
                                public void onClick(ClickEvent event) {
-                                       Pithos app = Pithos.get();
                                        String dateString = RestCommand.getDate();
                                        String resource = dto.getUri().substring(app.getApiPath().length()-1, dto.getUri().length());
                                        String sig = app.getCurrentUserResource().getUsername()+" "+RestCommand.calculateSig("GET", dateString, resource, RestCommand.base64decode(app.getToken()));
@@ -167,13 +169,13 @@ public class VersionsList extends Composite {
        }
 
        void removeVersion(final FileResource version) {
-               DeleteCommand df = new DeleteCommand(version.getUri()){
+               DeleteCommand df = new DeleteCommand(app, version.getUri()){
 
                        @Override
                        public void onComplete() {
                                toRemove = version;
                                updateTable();
-                               Pithos.get().getTreeView().refreshCurrentNode(false);
+                               app.getTreeView().refreshCurrentNode(false);
                        }
 
                        @Override
@@ -182,14 +184,14 @@ public class VersionsList extends Composite {
                                if(t instanceof RestException){
                                        int statusCode = ((RestException)t).getHttpStatusCode();
                                        if(statusCode == 405)
-                                               Pithos.get().displayError("You don't have the necessary permissions");
+                                               app.displayError("You don't have the necessary permissions");
                                        else if(statusCode == 404)
-                                               Pithos.get().displayError("Versions does not exist");
+                                               app.displayError("Versions does not exist");
                                        else
-                                               Pithos.get().displayError("Unable to remove version:"+((RestException)t).getHttpStatusText());
+                                               app.displayError("Unable to remove version:"+((RestException)t).getHttpStatusText());
                                }
                                else
-                                       Pithos.get().displayError("System error removing version:"+t.getMessage());
+                                       app.displayError("System error removing version:"+t.getMessage());
                        }
                };
                DeferredCommand.addCommand(df);
@@ -197,23 +199,23 @@ public class VersionsList extends Composite {
        }
 
        void restoreVersion(final FileResource version) {
-               FileResource selectedFile = (FileResource) Pithos.get().getCurrentSelection();
-               PostCommand ep = new PostCommand(selectedFile.getUri()+"?restoreVersion="+version.getVersion(),"",200){
+               FileResource selectedFile = (FileResource) app.getCurrentSelection();
+               PostCommand ep = new PostCommand(app, selectedFile.getUri()+"?restoreVersion="+version.getVersion(),"",200){
 
 
                        @Override
                        public void onComplete() {
                                container.hide();
-                Pithos.get().getTreeView().refreshCurrentNode(false);
+                app.getTreeView().refreshCurrentNode(false);
                        }
 
                        @Override
                        public void onError(Throwable t) {
                                GWT.log("", t);
                                if(t instanceof RestException)
-                                       Pithos.get().displayError("Unable to restore version:"+((RestException)t).getHttpStatusText());
+                                       app.displayError("Unable to restore version:"+((RestException)t).getHttpStatusText());
                                else
-                                       Pithos.get().displayError("System error restoring version:"+t.getMessage());
+                                       app.displayError("System error restoring version:"+t.getMessage());
                        }
 
                };
@@ -251,7 +253,7 @@ public class VersionsList extends Composite {
                        return;
                }
                
-               if(Pithos.get().findUserFullName(input.get(0).getOwner()) == null){
+               if(app.findUserFullName(input.get(0).getOwner()) == null){
                        findFullNameAndUpdate(input);           
                        return;
                }
@@ -275,16 +277,16 @@ public class VersionsList extends Composite {
 
        private void findFullNameAndUpdate(final List<FileResource> input){                             
                final String aUserName = input.get(0).getOwner();
-               String path = Pithos.get().getApiPath() + "users/" + aUserName;
+               String path = app.getApiPath() + "users/" + aUserName;
 
-               GetCommand<UserSearchResource> gg = new GetCommand<UserSearchResource>(UserSearchResource.class, path, false,null) {
+               GetCommand<UserSearchResource> gg = new GetCommand<UserSearchResource>(app, 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();
-                                       Pithos.get().putUserToMap(username, userFullName);
+                                       app.putUserToMap(username, userFullName);
                                        if(input.size() >= 1){
                                                input.remove(input.get(0));                                             
                                                if(input.isEmpty()){
@@ -297,7 +299,7 @@ public class VersionsList extends Composite {
                        }
                        @Override
                        public void onError(Throwable t) {                              
-                               Pithos.get().displayError("Unable to fetch user's full name from the given username " + aUserName);
+                               app.displayError("Unable to fetch user's full name from the given username " + aUserName);
                                if(input.size() >= 1){
                                        input.remove(input.get(0));
                                        handleFullNames(input);                                 
index 22478f5..d392456 100644 (file)
@@ -57,11 +57,13 @@ public class DeleteCommand implements Command{
 
     private Object resource;
 
+    private Pithos app;
        /**
         * @param _containerPanel
         * @param _newImages the images of all the possible delete dialogs
         */
-       public DeleteCommand( PopupPanel _containerPanel, Object resource, final Images _newImages ){
+       public DeleteCommand(Pithos _app, PopupPanel _containerPanel, Object resource, final Images _newImages ){
+        app = _app;
                containerPanel = _containerPanel;
                newImages = _newImages;
         this.resource = resource;
@@ -73,10 +75,10 @@ public class DeleteCommand implements Command{
                containerPanel.hide();
 
         if (resource instanceof Folder) {
-            DeleteFolderDialog dlg = new DeleteFolderDialog(Pithos.get(), newImages, (Folder) resource);
+            DeleteFolderDialog dlg = new DeleteFolderDialog(app, newImages, (Folder) resource);
             dlg.center();
         } else if (resource instanceof List) {
-            DeleteFileDialog dlg = new DeleteFileDialog(newImages, (List<File>) resource);
+            DeleteFileDialog dlg = new DeleteFileDialog(app, newImages, (List<File>) resource);
             dlg.center();
         }
        }
index ed0fed1..27a60e8 100644 (file)
@@ -50,19 +50,22 @@ import com.google.gwt.user.client.ui.PopupPanel;
 public class EmptyTrashCommand implements Command{
        private PopupPanel containerPanel;
 
-       public EmptyTrashCommand(PopupPanel _containerPanel){
+    private Pithos app;
+
+       public EmptyTrashCommand(Pithos _app, PopupPanel _containerPanel){
+        app = _app;
                containerPanel = _containerPanel;
        }
 
        @Override
        public void execute() {
                containerPanel.hide();
-               DeleteCommand df = new DeleteCommand(Pithos.get().getTreeView().getTrash().getUri()){
+               DeleteCommand df = new DeleteCommand(app, app.getTreeView().getTrash().getUri()){
 
                        @Override
                        public void onComplete() {
-                               Pithos.get().getTreeView().updateTrashNode();
-                               Pithos.get().showFileList(true);
+                               app.getTreeView().updateTrashNode();
+                               app.showFileList(true);
                        }
 
                        @Override
@@ -71,14 +74,14 @@ public class EmptyTrashCommand implements Command{
                                if(t instanceof RestException){
                                        int statusCode = ((RestException)t).getHttpStatusCode();
                                        if(statusCode == 405)
-                                               Pithos.get().displayError("You don't have the necessary permissions");
+                                               app.displayError("You don't have the necessary permissions");
                                        else if(statusCode == 404)
-                                               Pithos.get().displayError("Resource does not exist");
+                                               app.displayError("Resource does not exist");
                                        else
-                                               Pithos.get().displayError("Unable to empty trash:"+((RestException)t).getHttpStatusText());
+                                               app.displayError("Unable to empty trash:"+((RestException)t).getHttpStatusText());
                                }
                                else
-                                       Pithos.get().displayError("System error emptying trash:"+t.getMessage());
+                                       app.displayError("System error emptying trash:"+t.getMessage());
                        }
                };
                DeferredCommand.addCommand(df);
index 97882c5..ce2a173 100644 (file)
@@ -57,14 +57,17 @@ public class GetUserCommand implements Command{
         */
        private String userName;
 
-       public GetUserCommand(String _userName){
+    private Pithos app;
+
+       public GetUserCommand(Pithos _app, String _userName){
+        app = _app;
                userName = _userName;
        }
 
        @Override
        public void execute() {
-               String path = Pithos.get().getApiPath() + "users/" + userName;
-               GetCommand<UserSearchResource> gg = new GetCommand<UserSearchResource>(UserSearchResource.class,
+               String path = app.getApiPath() + "users/" + userName;
+               GetCommand<UserSearchResource> gg = new GetCommand<UserSearchResource>(app, UserSearchResource.class,
                                        path, false ,null) {
                        @Override
                        public void onComplete() {
@@ -72,13 +75,13 @@ public class GetUserCommand implements Command{
                                for (UserResource user : result.getUsers()){
                                        String username = user.getUsername();
                                        String _userFullName = user.getName();
-                                       Pithos.get().putUserToMap(username, _userFullName);
+                                       app.putUserToMap(username, _userFullName);
                                }
                        }
                        @Override
                        public void onError(Throwable t) {
                                GWT.log("", t);
-                               Pithos.get().displayError("Unable to fetch user's full name from the given username " + userName);
+                               app.displayError("Unable to fetch user's full name from the given username " + userName);
                        }
                };
                DeferredCommand.addCommand(gg);
index 3235379..e3bcb71 100644 (file)
@@ -57,11 +57,14 @@ public class NewFolderCommand implements Command{
 
        private List<GroupResource> groups = null;
 
+    private Pithos app;
+
        /**
         * @param aContainerPanel
         * @param newImages the images of the new folder dialog
         */
-       public NewFolderCommand(PopupPanel aContainerPanel, Folder folder, final Images newImages){
+       public NewFolderCommand(Pithos _app, PopupPanel aContainerPanel, Folder folder, final Images newImages){
+        app = _app;
                containerPanel = aContainerPanel;
                images=newImages;
         this.folder = folder;
@@ -76,7 +79,7 @@ public class NewFolderCommand implements Command{
 
        void displayNewFolderDialog() {
         if (folder != null) {
-            FolderPropertiesDialog dlg = new FolderPropertiesDialog(Pithos.get(), true, folder);
+            FolderPropertiesDialog dlg = new FolderPropertiesDialog(app, true, folder);
             dlg.center();
         }
        }
index d660a85..35980bb 100644 (file)
@@ -131,10 +131,10 @@ public class PasteCommand implements Command {
                 public void onError(Throwable t) {
                     GWT.log("", t);
                     if (t instanceof RestException) {
-                        Pithos.get().displayError("Unable to copy file: " + ((RestException) t).getHttpStatusText());
+                        app.displayError("Unable to copy file: " + ((RestException) t).getHttpStatusText());
                     }
                     else
-                        Pithos.get().displayError("System error unable to copy file: "+t.getMessage());
+                        app.displayError("System error unable to copy file: "+t.getMessage());
                 }
             };
             copyFile.setHeader("X-Auth-Token", app.getToken());
index 1a969fd..d4627f3 100644 (file)
@@ -51,11 +51,14 @@ public class RefreshCommand implements Command {
 
        private PopupPanel containerPanel;
 
+    private Pithos app;
+
        /**
         * @param _containerPanel
         * @param _newImages the images of all the possible delete dialogs
         */
-       public RefreshCommand(PopupPanel _containerPanel, final FileMenu.Images _newImages) {
+       public RefreshCommand(Pithos _app, PopupPanel _containerPanel, final FileMenu.Images _newImages) {
+        app = _app;
                containerPanel = _containerPanel;
                newImages = _newImages;
        }
@@ -63,17 +66,17 @@ public class RefreshCommand implements Command {
        @Override
        public void execute() {
                containerPanel.hide();
-               if (Pithos.get().getCurrentSelection() instanceof FileResource || Pithos.get().getCurrentSelection() instanceof List)
-                       Pithos.get().showFileList(true);
-               else if (Pithos.get().getCurrentSelection() instanceof GroupUserResource)
+               if (app.getCurrentSelection() instanceof FileResource || app.getCurrentSelection() instanceof List)
+                       app.showFileList(true);
+               else if (app.getCurrentSelection() instanceof GroupUserResource)
                        return;
                else{
                        //TODO:CELLTREE
-                       //DnDTreeItem selectedTreeItem = (DnDTreeItem) Pithos.get().getFolders().getCurrent();
+                       //DnDTreeItem selectedTreeItem = (DnDTreeItem) app.getFolders().getCurrent();
                        //if(selectedTreeItem != null){
-                               //Pithos.get().getFolders().updateFolder(selectedTreeItem);
-                       Pithos.get().getTreeView().updateNode(Pithos.get().getTreeView().getSelection());
-                               Pithos.get().showFileList(true);
+                               //app.getFolders().updateFolder(selectedTreeItem);
+                       app.getTreeView().updateNode(app.getTreeView().getSelection());
+                               app.showFileList(true);
                        //}
                }
        }
index f708bd6..1fc5e36 100644 (file)
@@ -49,7 +49,7 @@ public class ResreshOthersSharesCommand implements Command{
        public void execute() {
                containerPanel.hide();
                //TODO:CELLTREE
-               //Pithos.get().getFolders().update( Pithos.get().getFolders().getCurrent());
+               //app.getFolders().update( app.getFolders().getCurrent());
        }
 
 }
index e4a971e..f4f26e8 100644 (file)
@@ -59,19 +59,21 @@ import com.google.gwt.user.client.ui.PopupPanel;
  */
 public class RestoreTrashCommand implements Command{
        private PopupPanel containerPanel;
+    private Pithos app;
 
-       public RestoreTrashCommand(PopupPanel _containerPanel){
+       public RestoreTrashCommand(Pithos _app, PopupPanel _containerPanel){
+        app = _app;
                containerPanel = _containerPanel;
        }
 
        @Override
        public void execute() {
                containerPanel.hide();
-               Object selection = Pithos.get().getCurrentSelection();
+               Object selection = app.getCurrentSelection();
                if (selection == null){
                        // Check to see if Trash Node is selected.
                        List folderList = new ArrayList();
-                       TrashResource trashItem = Pithos.get().getTreeView().getTrash();
+                       TrashResource trashItem = app.getTreeView().getTrash();
                        for(int i=0 ; i < trashItem.getFolders().size() ; i++)
                                folderList.add(trashItem.getFolders().get(i));
                        return;
@@ -79,14 +81,14 @@ public class RestoreTrashCommand implements Command{
                GWT.log("selection: " + selection.toString(), null);
                if (selection instanceof FileResource) {
                        final FileResource resource = (FileResource)selection;
-                       PostCommand rt = new PostCommand(resource.getUri()+"?restore=","", 200){
+                       PostCommand rt = new PostCommand(app, resource.getUri()+"?restore=","", 200){
 
                                @Override
                                public void onComplete() {
                                        //TODO:CELLTREE
-                                       //Pithos.get().getFolders().update(Pithos.get().getFolders().getTrashItem());
+                                       //app.getFolders().update(app.getFolders().getTrashItem());
                                        
-                                       Pithos.get().showFileList(true);
+                                       app.showFileList(true);
                                }
 
                                @Override
@@ -95,18 +97,18 @@ public class RestoreTrashCommand implements Command{
                                        if(t instanceof RestException){
                                                int statusCode = ((RestException)t).getHttpStatusCode();
                                                if(statusCode == 405)
-                                                       Pithos.get().displayError("You don't have the necessary permissions");
+                                                       app.displayError("You don't have the necessary permissions");
                                                else if(statusCode == 404)
-                                                       Pithos.get().displayError("File does not exist");
+                                                       app.displayError("File does not exist");
                                                else if(statusCode == 409)
-                                                       Pithos.get().displayError("A file with the same name already exists");
+                                                       app.displayError("A file with the same name already exists");
                                                else if(statusCode == 413)
-                                                       Pithos.get().displayError("Your quota has been exceeded");
+                                                       app.displayError("Your quota has been exceeded");
                                                else
-                                                       Pithos.get().displayError("Unable to restore file:"+((RestException)t).getHttpStatusText());
+                                                       app.displayError("Unable to restore file:"+((RestException)t).getHttpStatusText());
                                        }
                                        else
-                                               Pithos.get().displayError("System error restoring file:"+t.getMessage());
+                                               app.displayError("System error restoring file:"+t.getMessage());
                                }
                        };
                        DeferredCommand.addCommand(rt);
@@ -116,13 +118,13 @@ public class RestoreTrashCommand implements Command{
                        final List<String> fileIds = new ArrayList<String>();
                        for(FileResource f : fdtos)
                                fileIds.add(f.getUri()+"?restore=");
-                       MultiplePostCommand rt = new MultiplePostCommand(fileIds.toArray(new String[0]), 200){
+                       MultiplePostCommand rt = new MultiplePostCommand(app, fileIds.toArray(new String[0]), 200){
 
                                @Override
                                public void onComplete() {
                                        //TODO:CELLTREE
-                                       //Pithos.get().getFolders().update(Pithos.get().getFolders().getTrashItem());
-                                       Pithos.get().showFileList(true);
+                                       //app.getFolders().update(app.getFolders().getTrashItem());
+                                       app.showFileList(true);
                                }
 
                                @Override
@@ -131,37 +133,37 @@ public class RestoreTrashCommand implements Command{
                                        if(t instanceof RestException){
                                                int statusCode = ((RestException)t).getHttpStatusCode();
                                                if(statusCode == 405)
-                                                       Pithos.get().displayError("You don't have the necessary permissions");
+                                                       app.displayError("You don't have the necessary permissions");
                                                else if(statusCode == 404)
-                                                       Pithos.get().displayError("File does not exist");
+                                                       app.displayError("File does not exist");
                                                else if(statusCode == 409)
-                                                       Pithos.get().displayError("A file with the same name already exists");
+                                                       app.displayError("A file with the same name already exists");
                                                else if(statusCode == 413)
-                                                       Pithos.get().displayError("Your quota has been exceeded");
+                                                       app.displayError("Your quota has been exceeded");
                                                else
-                                                       Pithos.get().displayError("Unable to restore file::"+((RestException)t).getHttpStatusText());
+                                                       app.displayError("Unable to restore file::"+((RestException)t).getHttpStatusText());
                                        }
                                        else
-                                               Pithos.get().displayError("System error restoring file:"+t.getMessage());
+                                               app.displayError("System error restoring file:"+t.getMessage());
                                }
                        };
                        DeferredCommand.addCommand(rt);
                }
                else if (selection instanceof TrashFolderResource) {
                        final FolderResource resource = ((TrashFolderResource)selection).getResource();
-                       PostCommand rt = new PostCommand(resource.getUri()+"?restore=","", 200){
+                       PostCommand rt = new PostCommand(app, resource.getUri()+"?restore=","", 200){
 
                                @Override
                                public void onComplete() {
                                        //TODO:CELLTREE
                                        /*
-                                       Pithos.get().getFolders().updateFolder((DnDTreeItem) Pithos.get().getFolders().getRootItem());
+                                       app.getFolders().updateFolder((DnDTreeItem) app.getFolders().getRootItem());
 
-                                       Pithos.get().getFolders().update(Pithos.get().getFolders().getTrashItem());
+                                       app.getFolders().update(app.getFolders().getTrashItem());
                                        */
                                        
-                                       Pithos.get().getTreeView().updateTrashNode();
-                                       Pithos.get().getTreeView().updateRootNode();
+                                       app.getTreeView().updateTrashNode();
+                                       app.getTreeView().updateRootNode();
                                }
 
                                @Override
@@ -170,18 +172,18 @@ public class RestoreTrashCommand implements Command{
                                        if(t instanceof RestException){
                                                int statusCode = ((RestException)t).getHttpStatusCode();
                                                if(statusCode == 405)
-                                                       Pithos.get().displayError("You don't have the necessary permissions");
+                                                       app.displayError("You don't have the necessary permissions");
                                                else if(statusCode == 404)
-                                                       Pithos.get().displayError("Folder does not exist");
+                                                       app.displayError("Folder does not exist");
                                                else if(statusCode == 409)
-                                                       Pithos.get().displayError("A folder with the same name already exists");
+                                                       app.displayError("A folder with the same name already exists");
                                                else if(statusCode == 413)
-                                                       Pithos.get().displayError("Your quota has been exceeded");
+                                                       app.displayError("Your quota has been exceeded");
                                                else
-                                                       Pithos.get().displayError("Unable to restore folder::"+((RestException)t).getHttpStatusText());
+                                                       app.displayError("Unable to restore folder::"+((RestException)t).getHttpStatusText());
                                        }
                                        else
-                                               Pithos.get().displayError("System error restoring folder:"+t.getMessage());
+                                               app.displayError("System error restoring folder:"+t.getMessage());
                                }
                        };
                        DeferredCommand.addCommand(rt);
index 4ab6200..6795ac8 100644 (file)
@@ -76,7 +76,7 @@ public class ToTrashCommand implements Command{
             trashFiles(iter, new Command() {
                 @Override
                 public void execute() {
-                    app.get().updateFolder(((List<File>) resource).get(0).getParent());
+                    app.updateFolder(((List<File>) resource).get(0).getParent());
                 }
             });
         }
@@ -141,10 +141,10 @@ public class ToTrashCommand implements Command{
                 public void onError(Throwable t) {
                     GWT.log("", t);
                     if (t instanceof RestException) {
-                        Pithos.get().displayError("Unable to copy file: " + ((RestException) t).getHttpStatusText());
+                        app.displayError("Unable to copy file: " + ((RestException) t).getHttpStatusText());
                     }
                     else
-                        Pithos.get().displayError("System error unable to copy file: "+t.getMessage());
+                        app.displayError("System error unable to copy file: "+t.getMessage());
                 }
             };
             trashFile.setHeader("X-Auth-Token", app.getToken());
index 211ad7a..1c8f1ff 100644 (file)
@@ -50,12 +50,15 @@ public class UploadFileCommand implements Command {
 
        private PopupPanel containerPanel;
 
+    private Pithos app;
+
     /*
      * The folder that is the target of the upload
      */
     private Folder folder;
 
-       public UploadFileCommand(PopupPanel _containerPanel, Folder _folder) {
+       public UploadFileCommand(Pithos _app, PopupPanel _containerPanel, Folder _folder) {
+        app = _app;
                containerPanel = _containerPanel;
         folder = _folder;
        }
@@ -72,7 +75,7 @@ public class UploadFileCommand implements Command {
         */
        private void displayNewFile() {
         FileUploadDialog dlg = GWT.create(FileUploadDialog.class);
-        dlg.setApp(Pithos.get());
+        dlg.setApp(app);
         dlg.setFolder(folder);
                dlg.center();
        }
index 0f3cc65..4c65304 100644 (file)
@@ -58,6 +58,8 @@ import java.util.Set;
 
 public class FolderTreeViewModel implements TreeViewModel {
 
+    private Pithos app;
+    
     private Cell<Folder> folderCell = new AbstractCell<Folder>(ContextMenuEvent.getType().getName()) {
 
        @Override
@@ -76,7 +78,7 @@ public class FolderTreeViewModel implements TreeViewModel {
             if (event.getType().equals(ContextMenuEvent.getType().getName())) {
                 FolderTreeViewModel.this.selectionModel.setSelected(folder, true);
                 if (!folder.isTrash()) {
-                    FolderContextMenu menu = new FolderContextMenu(FolderTreeView.images, folder);
+                    FolderContextMenu menu = new FolderContextMenu(app, FolderTreeView.images, folder);
                     menu.setPopupPosition(event.getClientX(), event.getClientY());
                     menu.show();
                 }
@@ -90,7 +92,8 @@ public class FolderTreeViewModel implements TreeViewModel {
 
     private SingleSelectionModel<Folder> selectionModel;
 
-    public FolderTreeViewModel(SingleSelectionModel<Folder> selectionModel) {
+    public FolderTreeViewModel(Pithos _app, SingleSelectionModel<Folder> selectionModel) {
+        app = _app;
         this.selectionModel = selectionModel;
     }
 
@@ -122,7 +125,6 @@ public class FolderTreeViewModel implements TreeViewModel {
     }
 
     private void fetchFolder(final Iterator<Folder> iter, final ListDataProvider<Folder> dataProvider, final Set<Folder> folders) {
-        final Pithos app = Pithos.get();
         if (iter.hasNext()) {
             final Folder f = iter.next();
 
@@ -137,9 +139,9 @@ public class FolderTreeViewModel implements TreeViewModel {
                 public void onError(Throwable t) {
                     GWT.log("Error getting folder", t);
                     if (t instanceof RestException)
-                        Pithos.get().displayError("Error getting folder: " + ((RestException) t).getHttpStatusText());
+                        app.displayError("Error getting folder: " + ((RestException) t).getHttpStatusText());
                     else
-                        Pithos.get().displayError("System error fetching folder: " + t.getMessage());
+                        app.displayError("System error fetching folder: " + t.getMessage());
                 }
             };
             getFolder.setHeader("X-Auth-Token", app.getToken());
@@ -154,7 +156,7 @@ public class FolderTreeViewModel implements TreeViewModel {
                 f.setTrash(true);
                 f.setContainer("trash");
                 dataProvider.getList().add(f);
-                Pithos.get().updateTags();
+                app.updateTags();
             }
         }
     }
@@ -176,7 +178,7 @@ public class FolderTreeViewModel implements TreeViewModel {
         if (!folder.isTrash())
             fetchFolder(folder, dataProvider);
         else
-            Pithos.get().showFiles(folder);
+            app.showFiles(folder);
     }
 
     public void fetchFolder(final Folder f, final ListDataProvider<Folder> dataProvider) {
@@ -184,7 +186,6 @@ public class FolderTreeViewModel implements TreeViewModel {
         Scheduler.get().scheduleDeferred(new ScheduledCommand() {
             @Override
             public void execute() {
-                final Pithos app = Pithos.get();
                 String path = "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + f.getPrefix();
                 GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), app.getUsername(), path, f) {
                     @Override
@@ -198,9 +199,9 @@ public class FolderTreeViewModel implements TreeViewModel {
                     public void onError(Throwable t) {
                         GWT.log("Error getting folder", t);
                         if (t instanceof RestException)
-                            Pithos.get().displayError("Error getting folder: " + ((RestException) t).getHttpStatusText());
+                            app.displayError("Error getting folder: " + ((RestException) t).getHttpStatusText());
                         else
-                            Pithos.get().displayError("System error fetching folder: " + t.getMessage());
+                            app.displayError("System error fetching folder: " + t.getMessage());
                     }
                 };
                 getFolder.setHeader("X-Auth-Token", app.getToken());
index 641ba10..c88e4ff 100644 (file)
@@ -46,15 +46,16 @@ public abstract class DeleteCommand extends RestCommand{
 
        boolean complete = false;
 
-       public DeleteCommand(String pathToDelete){
-               this(pathToDelete, true);
+       public DeleteCommand(Pithos app, String pathToDelete){
+               this(app, pathToDelete, true);
        }
 
 
-       public DeleteCommand(String pathToDelete, boolean showLoading){
+       public DeleteCommand(Pithos app, String pathToDelete, boolean showLoading){
+        super(app);
                setShowLoadingIndicator(showLoading);
                if(isShowLoadingIndicator())
-                       Pithos.get().showLoadingIndicator("Deleting ",pathToDelete);
+                       app.showLoadingIndicator("Deleting ",pathToDelete);
                final String path;
                if(pathToDelete.endsWith("/"))
                        path = pathToDelete;
@@ -101,7 +102,7 @@ public abstract class DeleteCommand extends RestCommand{
                boolean com = isComplete();
                if(com){
                        if(isShowLoadingIndicator())
-                               Pithos.get().hideLoadingIndicator();
+                               app.hideLoadingIndicator();
                        return false;
                }
                return true;
index 57ab365..69cdfeb 100644 (file)
@@ -125,14 +125,15 @@ public abstract class GetCommand<T extends RestResource> extends RestCommand{
        private static Map<RequestData, ResponseData> cache = new HashMap<RequestData, ResponseData>();
        
 
-       public GetCommand(Class<T> theclass, String pathToGet, T theCached){
-               this(theclass, pathToGet, true, theCached);
+       public GetCommand(Pithos _app, Class<T> theclass, String pathToGet, T theCached){
+               this(_app, theclass, pathToGet, true, theCached);
        }
 
-       public GetCommand(Class<T> theclass, String pathToGet, boolean showLoading, T theCached){
+       public GetCommand(Pithos _app, Class<T> theclass, String pathToGet, boolean showLoading, T theCached){
+        super(_app);
                setShowLoadingIndicator(showLoading);
                if(isShowLoadingIndicator())
-                       Pithos.get().showLoadingIndicator("Getting ",pathToGet);
+                       app.showLoadingIndicator("Getting ",pathToGet);
                this.aclass = theclass;
                if(pathToGet.indexOf("?") != -1)
                        path = pathToGet;
@@ -141,14 +142,15 @@ public abstract class GetCommand<T extends RestResource> extends RestCommand{
                this.cached = theCached;
        }
 
-       public GetCommand(Class<T> theclass, String aUsername , String pathToGet, T theCached){
-               this(theclass, aUsername, pathToGet, true, theCached);
+       public GetCommand(Pithos _app, Class<T> theclass, String aUsername , String pathToGet, T theCached){
+               this(_app, theclass, aUsername, pathToGet, true, theCached);
        }
 
-       public GetCommand(Class<T> theclass, String aUsername , String pathToGet, boolean showLoading, T theCached){
+       public GetCommand(Pithos _app, Class<T> theclass, String aUsername , String pathToGet, boolean showLoading, T theCached){
+        super(_app);
                setShowLoadingIndicator(showLoading);
                if(isShowLoadingIndicator())
-                       Pithos.get().showLoadingIndicator("Getting ",pathToGet);
+                       app.showLoadingIndicator("Getting ",pathToGet);
                this.aclass = theclass;
                path = fixPath(pathToGet);
                this.username = aUsername;
@@ -227,7 +229,7 @@ public abstract class GetCommand<T extends RestResource> extends RestCommand{
                                else {
                                        // Use cache data
                                        if(isShowLoadingIndicator())
-                                               Pithos.get().hideLoadingIndicator();
+                                               app.hideLoadingIndicator();
                                        if (resp.result instanceof Throwable) {
                                                // Error to be handled
                                                Throwable ex = (Throwable) resp.result;
@@ -251,7 +253,7 @@ public abstract class GetCommand<T extends RestResource> extends RestCommand{
                
                if(com){
                        if(isShowLoadingIndicator())
-                               Pithos.get().hideLoadingIndicator();
+                               app.hideLoadingIndicator();
                        if(getResult() != null) {
                                // Add to cache
                                cache.put(key, new ResponseData(System.currentTimeMillis(), getResult()));
index 6c16e31..685310e 100644 (file)
@@ -61,15 +61,16 @@ public  abstract class HeadCommand<T extends RestResource> extends RestCommand{
        T cached;
        final String path;
 
-       public HeadCommand(Class<T> theclass, String pathToGet, T theCached){
-               this(theclass, pathToGet, true, theCached);
+       public HeadCommand(Pithos _app, Class<T> theclass, String pathToGet, T theCached){
+               this(_app, theclass, pathToGet, true, theCached);
        }
 
-       public HeadCommand(Class<T> theClass, String pathToGet, boolean showLoading, T theCached){
+       public HeadCommand(Pithos _app, Class<T> theClass, String pathToGet, boolean showLoading, T theCached){
+        super(_app);
                setShowLoadingIndicator(showLoading);
                this.aclass = theClass;
                if(isShowLoadingIndicator())
-                       Pithos.get().showLoadingIndicator("Getting ",pathToGet);
+                       app.showLoadingIndicator("Getting ",pathToGet);
 
                if(theClass.equals(FileResource.class))
                        path = pathToGet;
@@ -137,7 +138,7 @@ public  abstract class HeadCommand<T extends RestResource> extends RestCommand{
                boolean com = isComplete();
                if(com){
                        if(isShowLoadingIndicator())
-                               Pithos.get().hideLoadingIndicator();
+                               app.hideLoadingIndicator();
                        if(getResult() != null)
                                onComplete();
                        else
index 50d527d..2ede472 100644 (file)
@@ -57,14 +57,15 @@ public abstract class MultipleDeleteCommand extends RestCommand {
 
        String[] paths;
 
-       public MultipleDeleteCommand(String[] pathToDelete){
-               this(pathToDelete, true);
+       public MultipleDeleteCommand(Pithos _app, String[] pathToDelete){
+               this(_app, pathToDelete, true);
        }
 
-       public MultipleDeleteCommand(String[] pathToDelete, boolean showLoading){
+       public MultipleDeleteCommand(Pithos _app, String[] pathToDelete, boolean showLoading){
+        super(_app);
                setShowLoadingIndicator(showLoading);
                if(isShowLoadingIndicator())
-                       Pithos.get().showLoadingIndicator("Deleting "+pathToDelete.length+" items",null);
+                       app.showLoadingIndicator("Deleting "+pathToDelete.length+" items",null);
                paths = pathToDelete;
                for (final String pathg : pathToDelete) {
                        GWT.log("[DEL]"+pathg, null);
@@ -111,7 +112,7 @@ public abstract class MultipleDeleteCommand extends RestCommand {
                                        onError(p, errors.get(p));
                        onComplete();
                        if(isShowLoadingIndicator())
-                               Pithos.get().hideLoadingIndicator();
+                               app.hideLoadingIndicator();
                        return false;
                }
                return true;
index 3a58695..fe75f39 100644 (file)
@@ -67,14 +67,15 @@ public abstract class MultipleGetCommand<T extends RestResource> extends RestCom
        String[] paths;
        private boolean requestSent=false;
 
-       public MultipleGetCommand(Class<T> aNewClass, String[] pathToGet, Cached[] theCached) {
-               this(aNewClass, pathToGet, true, theCached);
+       public MultipleGetCommand(Pithos _app, Class<T> aNewClass, String[] pathToGet, Cached[] theCached) {
+               this(_app, aNewClass, pathToGet, true, theCached);
        }
 
-       public MultipleGetCommand(Class<T> aNewClass, String[] pathToGet, boolean showLoading, Cached[] theCached) {
+       public MultipleGetCommand(Pithos _app, Class<T> aNewClass, String[] pathToGet, boolean showLoading, Cached[] theCached) {
+        super(_app);
                setShowLoadingIndicator(showLoading);
                if (isShowLoadingIndicator())
-                       Pithos.get().showLoadingIndicator("Getting "+pathToGet.length+" items", null);
+                       app.showLoadingIndicator("Getting "+pathToGet.length+" items", null);
                aclass = aNewClass;
                paths = pathToGet;
                this.cached = theCached;
@@ -87,7 +88,7 @@ public abstract class MultipleGetCommand<T extends RestResource> extends RestCom
                requestSent=true;
                if (cached!=null)
                        for (final Cached pathg : cached)
-                               DeferredCommand.addCommand(new GetCommand<T>(aclass,pathg.uri,false,(T)pathg.cache) {
+                               DeferredCommand.addCommand(new GetCommand<T>(app, aclass,pathg.uri,false,(T)pathg.cache) {
 
                                        @Override
                                        public void onComplete() {
@@ -102,7 +103,7 @@ public abstract class MultipleGetCommand<T extends RestResource> extends RestCom
                                });
                else
                        for (final String pathg : paths)
-                               DeferredCommand.addCommand(new GetCommand<T>(aclass,pathg,false,null) {
+                               DeferredCommand.addCommand(new GetCommand<T>(app, aclass,pathg,false,null) {
 
                                        @Override
                                        public void onComplete() {
@@ -156,7 +157,7 @@ public abstract class MultipleGetCommand<T extends RestResource> extends RestCom
                boolean com = isComplete();
                if (com) {
                        if (isShowLoadingIndicator())
-                               Pithos.get().hideLoadingIndicator();
+                               app.hideLoadingIndicator();
                        if (hasErrors())
                                for(String p : errors.keySet())
                                        onError(p, errors.get(p));
diff --git a/web_client/src/gr/grnet/pithos/web/client/rest/MultipleHeadCommand.java b/web_client/src/gr/grnet/pithos/web/client/rest/MultipleHeadCommand.java
deleted file mode 100644 (file)
index b065e06..0000000
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- *   1. Redistributions of source code must retain the above
- *      copyright notice, this list of conditions and the following
- *      disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above
- *      copyright notice, this list of conditions and the following
- *      disclaimer in the documentation and/or other materials
- *      provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.rest;
-
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.rest.MultipleGetCommand.Cached;
-import gr.grnet.pithos.web.client.rest.resource.FileResource;
-import gr.grnet.pithos.web.client.rest.resource.FolderResource;
-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.GroupsResource;
-import gr.grnet.pithos.web.client.rest.resource.RestResource;
-import gr.grnet.pithos.web.client.rest.resource.SharedResource;
-import gr.grnet.pithos.web.client.rest.resource.TrashResource;
-import gr.grnet.pithos.web.client.rest.resource.UserResource;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.user.client.DeferredCommand;
-
-
-public abstract class MultipleHeadCommand <T extends RestResource> extends RestCommand {
-       String[] paths;
-       Class<T> aclass;
-       List<T> result = new ArrayList<T>();
-       Map<String, Throwable> errors = new HashMap<String, Throwable>();
-       private boolean requestSent=false;
-       Cached[] cached;
-
-       public MultipleHeadCommand(Class<T> theClass, String[] pathToGet, Cached[] theCached) {
-               this(theClass, pathToGet, true, theCached);
-       }
-
-       public MultipleHeadCommand(Class<T> theClass, String[] pathToGet, boolean showLoading, Cached[] theCached) {
-               setShowLoadingIndicator(showLoading);
-               if(isShowLoadingIndicator())
-                       Pithos.get().showLoadingIndicator("Getting "+pathToGet.length+" items", null);
-               paths = pathToGet;
-               this.aclass = theClass;
-               this.cached = theCached;
-               //sendRequest();
-       }
-
-       private void sendRequest() {
-               if(requestSent)
-                       return;
-               requestSent=true;
-               if(cached!=null)
-                       for (final Cached c : cached){
-                               final String path;
-                               if(aclass.equals(FileResource.class)){
-                                       if(c.uri.indexOf("?") == -1)
-                                               path=c.uri+"?"+Math.random();
-                                       else
-                                               path=c.uri;
-                               }
-                               else
-                                       path = fixPath(c.uri);
-                               DeferredCommand.addCommand(new HeadCommand<T>(aclass,path,false, (T)c.cache) {
-
-                                       @Override
-                                       public void onComplete() {
-                                               MultipleHeadCommand.this.result.add(getResult());
-                                       }
-
-                                       @Override
-                                       public void onError(Throwable t) {
-                                               errors.put(path, t);
-                                       }
-
-                               });
-                       }
-               else
-                       for (String pathg : paths) {
-                               final String path;
-                               if(aclass.equals(FileResource.class))
-                                       path = pathg;
-                               else
-                                       path = fixPath(pathg);
-                               DeferredCommand.addCommand(new HeadCommand<T>(aclass,path,false, null) {
-                                       @Override
-                                       public void onComplete() {
-                                               MultipleHeadCommand.this.result.add(getResult());
-                                       }
-
-                                       @Override
-                                       public void onError(Throwable t) {
-                                               errors.put(path, t);
-                                       }
-                               });
-                       }
-       }
-       public boolean isComplete() {
-               return result.size()+errors.size() == paths.length;
-       }
-
-       public List<T> getResult() {
-               return result;
-       }
-
-       @Override
-       public boolean execute() {
-               if(!requestSent)
-                       sendRequest();
-               boolean com = isComplete();
-               if (com) {
-                       if(isShowLoadingIndicator())
-                               Pithos.get().hideLoadingIndicator();
-                       if(hasErrors())
-                               for(String p : errors.keySet())
-                                       onError(p, errors.get(p));
-                       onComplete();
-                       return false;
-               }
-               return true;
-       }
-
-       /**
-        * @param p
-        * @param throwable
-        */
-       public abstract void onError(String p, Throwable throwable);
-
-       public Object deserializeResponse(String path, Response response) {
-               RestResource result1 = null;
-               if (aclass.equals(FolderResource.class)) {
-                       result1 = new FolderResource(path);
-                       result1.createFromJSON(response.getText());
-               } else if (aclass.equals(FileResource.class)) {
-                       result1 = new FileResource(path);
-                       result1.createFromJSON(response.getHeader("X-Pithos-Metadata"));
-               } else if (aclass.equals(GroupsResource.class)) {
-                       result1 = new GroupsResource(path);
-                       result1.createFromJSON(response.getText());
-               } else if (aclass.equals(TrashResource.class)) {
-                       result1 = new TrashResource(path);
-                       result1.createFromJSON(response.getText());
-               } else if (aclass.equals(SharedResource.class)) {
-                       result1 = new SharedResource(path);
-                       result1.createFromJSON(response.getText());
-               } else if (aclass.equals(GroupResource.class)) {
-                       result1 = new GroupResource(path);
-                       result1.createFromJSON(response.getText());
-               } else if (aclass.equals(GroupUserResource.class)) {
-                       result1 = new GroupUserResource(path);
-                       result1.createFromJSON(response.getText());
-               } else if (aclass.equals(UserResource.class)) {
-                       result1 = new UserResource(path);
-                       result1.createFromJSON(response.getText());
-               }
-               return result1;
-       }
-
-       public boolean hasErrors(){
-               return errors.size() >0;
-       }
-
-       /**
-        * Retrieve the errors.
-        *
-        * @return the errors
-        */
-       public Map<String, Throwable> getErrors() {
-               return errors;
-       }
-
-       public void debug(){
-               GWT.log("--->"+result.size(), null);
-               GWT.log("-ERRORS-->"+getErrors().size(), null);
-               for(String p : getErrors().keySet())
-                       GWT.log("error:"+p, getErrors().get(p));
-       }
-}
index 37a394c..9b86ac8 100644 (file)
@@ -51,29 +51,29 @@ import com.google.gwt.http.client.Response;
 
 public abstract class MultiplePostCommand extends RestCommand {
 
-
        Map<String, Throwable> errors = new HashMap<String, Throwable>();
 
        List<String> successPaths = new ArrayList<String>();
 
        String[] paths;
 
-       public MultiplePostCommand(String[] pathToDelete, final int okStatusCode){
-               this(pathToDelete, okStatusCode, true);
+       public MultiplePostCommand(Pithos app, String[] pathToDelete, final int okStatusCode){
+               this(app, pathToDelete, okStatusCode, true);
        }
 
-       public MultiplePostCommand(String[] pathToDelete, String data, final int okStatusCode){
-               this(pathToDelete, data, okStatusCode, true);
+       public MultiplePostCommand(Pithos app, String[] pathToDelete, String data, final int okStatusCode){
+               this(app, pathToDelete, data, okStatusCode, true);
        }
 
-       public MultiplePostCommand(String[] pathToDelete, final int okStatusCode, boolean showLoading){
-               this(pathToDelete, "", okStatusCode, showLoading);
+       public MultiplePostCommand(Pithos app, String[] pathToDelete, final int okStatusCode, boolean showLoading){
+               this(app, pathToDelete, "", okStatusCode, showLoading);
        }
 
-       public MultiplePostCommand(String[] pathToDelete, String data, final int okStatusCode, boolean showLoading){
+       public MultiplePostCommand(Pithos app, String[] pathToDelete, String data, final int okStatusCode, boolean showLoading){
+        super(app);
                setShowLoadingIndicator(showLoading);
                if(isShowLoadingIndicator())
-                       Pithos.get().showLoadingIndicator("Updating "+pathToDelete.length+" items", null);
+                       app.showLoadingIndicator("Updating "+pathToDelete.length+" items", null);
                paths = pathToDelete;
                for (final String pathg : pathToDelete) {
                        GWT.log("[DEL]"+pathg, null);
@@ -120,7 +120,7 @@ public abstract class MultiplePostCommand extends RestCommand {
                                        onError(p, errors.get(p));
                        onComplete();
                        if(isShowLoadingIndicator())
-                               Pithos.get().hideLoadingIndicator();
+                               app.hideLoadingIndicator();
                        return false;
                }
                return true;
index a09a841..0bb1cc3 100644 (file)
@@ -45,14 +45,15 @@ public abstract class PostCommand extends RestCommand{
        boolean complete = false;
        String postBody=null;
 
-       public PostCommand(final String path, String data, final int okStatusCode) {
-               this(path, data, okStatusCode, true);
+       public PostCommand(Pithos _app, final String path, String data, final int okStatusCode) {
+               this(_app, path, data, okStatusCode, true);
        }
 
-       public PostCommand(final String path, String data, final int okStatusCode, boolean showLoading) {
+       public PostCommand(Pithos app, final String path, String data, final int okStatusCode, boolean showLoading) {
+        super(app);
                setShowLoadingIndicator(showLoading);
                if(isShowLoadingIndicator())
-                       Pithos.get().showLoadingIndicator("Updating ",path);
+                       app.showLoadingIndicator("Updating ",path);
 
                RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, path);
 
@@ -99,7 +100,7 @@ public abstract class PostCommand extends RestCommand{
                boolean com = isComplete();
                if (com) {
                        if (isShowLoadingIndicator())
-                               Pithos.get().hideLoadingIndicator();
+                               app.hideLoadingIndicator();
                        return false;
                }
                return true;
index acfdd1b..57a24db 100644 (file)
@@ -67,8 +67,8 @@ public abstract class RestCallback  implements RequestCallback {
                        //this one is only used for trash handling where empty trash has 201 status code
                        else if(okcode !=-1 && (response.getStatusCode() == okcode || response.getStatusCode() == HTTP_OK))
                                handleSuccess(deserialize(response));
-                       else if(response.getStatusCode() == 403)
-                               RestCommand.sessionExpired();
+                       else if(response.getStatusCode() == 403);
+//                             RestCommand.sessionExpired();
                        else {
                                String statusText = "";
                                String text = "";
index 24b5988..82d2465 100644 (file)
@@ -41,13 +41,17 @@ import com.google.gwt.http.client.RequestBuilder;
 import com.google.gwt.user.client.IncrementalCommand;
 
 public abstract class RestCommand implements IncrementalCommand {
+    protected Pithos app;
        protected boolean showLoadingIndicator = true;
 
+    public RestCommand(Pithos _app) {
+        app = _app;
+    }
+
        protected void handleHeaders(String username, RequestBuilder requestBuilder, String path) {
                String date = getDate();
                requestBuilder.setHeader("X-Pithos-Date", date);
 
-               Pithos app = Pithos.get();
                String token = app.getToken();
                if (token == null)
                        token = "aa";
@@ -58,11 +62,11 @@ public abstract class RestCommand implements IncrementalCommand {
        }
 
        protected void handleHeaders(RequestBuilder requestBuilder, String path) {
-               if (Pithos.get().getCurrentUserResource() != null) {
-                       String username = Pithos.get().getCurrentUserResource().getUsername();
+               if (app.getCurrentUserResource() != null) {
+                       String username = app.getCurrentUserResource().getUsername();
                        handleHeaders(username, requestBuilder, path);
                } else
-                       Pithos.get().displayError("no username");
+                       app.displayError("no username");
        }
 
        public static native String getDate()/*-{
@@ -133,8 +137,8 @@ public abstract class RestCommand implements IncrementalCommand {
                showLoadingIndicator = newShowLoadingIndicator;
        }
 
-       static void sessionExpired() {
-               SessionExpiredDialog dlg = new SessionExpiredDialog();
+       void sessionExpired() {
+               SessionExpiredDialog dlg = new SessionExpiredDialog(app);
                dlg.center();
        }
 
index 34e42cb..8bae03e 100644 (file)
@@ -597,14 +597,6 @@ public class FolderResource extends RestResource {
                        constructedUri = constructedUri + "Files/files/" + getName();
                        return constructedUri;
                }
-               else if(treeItem.getParentItem() == null){
-                       //this is the case when the user uses the browser's forward arrow to navigate through other's
-                       //shared folders and item.getParentItem is null only inside other's shared folder
-                       String apiPath = Pithos.get().getApiPath();
-                       String newPath = getParentURI().substring(apiPath.lastIndexOf("/"));
-                       constructedUri = constructedUri + "Files"+ newPath + getName();
-                       return constructedUri;
-               }
                else{
                        String finalUri = getParentURI().substring(path.lastIndexOf("/")) + getName();
                        constructedUri = constructedUri + "Files"+ finalUri;
index d863f8e..b9f0840 100644 (file)
@@ -87,7 +87,10 @@ public class TagTreeViewModel implements TreeViewModel {
 
     private SingleSelectionModel<Tag> selectionModel;
 
-    public TagTreeViewModel(SingleSelectionModel<Tag> selectionModel) {
+    private Pithos app;
+
+    public TagTreeViewModel(Pithos _app, SingleSelectionModel<Tag> selectionModel) {
+        app = _app;
         this.selectionModel = selectionModel;
     }
 
@@ -129,7 +132,6 @@ public class TagTreeViewModel implements TreeViewModel {
     }
 
     private void fetchTags(final Iterator<Folder> iter) {
-        final Pithos app = Pithos.get();
         if (iter.hasNext()) {
             final Folder f = iter.next();
 
@@ -144,9 +146,9 @@ public class TagTreeViewModel implements TreeViewModel {
 //                public void onError(Throwable t) {
 //                    GWT.log("Error getting folder", t);
 //                    if (t instanceof RestException)
-//                        Pithos.get().displayError("Error getting folder: " + ((RestException) t).getHttpStatusText());
+//                        app.displayError("Error getting folder: " + ((RestException) t).getHttpStatusText());
 //                    else
-//                        Pithos.get().displayError("System error fetching folder: " + t.getMessage());
+//                        app.displayError("System error fetching folder: " + t.getMessage());
 //                }
 //            };
 //            getFolder.setHeader("X-Auth-Token", app.getToken());
@@ -168,14 +170,12 @@ public class TagTreeViewModel implements TreeViewModel {
     }
 
     public void fetchTag(Tag t) {
-        Pithos app = Pithos.get();
         AccountResource account = app.getAccount();
         Iterator<Folder> iter = account.getContainers().iterator();
         fetchTag(iter, t, new LinkedHashSet<File>());
     }
 
     private void fetchTag(final Iterator<Folder> iter, final Tag t, final Set<File> files) {
-        final Pithos app = Pithos.get();
         if (iter.hasNext()) {
             Folder f = iter.next();
             String path = f.getUri() + "?format=json&meta=" + t.getName();
@@ -190,9 +190,9 @@ public class TagTreeViewModel implements TreeViewModel {
                 public void onError(Throwable t) {
                     GWT.log("Error getting folder", t);
                     if (t instanceof RestException)
-                        Pithos.get().displayError("Error getting folder: " + ((RestException) t).getHttpStatusText());
+                        app.displayError("Error getting folder: " + ((RestException) t).getHttpStatusText());
                     else
-                        Pithos.get().displayError("System error fetching folder: " + t.getMessage());
+                        app.displayError("System error fetching folder: " + t.getMessage());
                 }
             };
             getFolder.setHeader("X-Auth-Token", app.getToken());