From e9c9f408bef9e1270fb8a1ff721af8c7b97f3608 Mon Sep 17 00:00:00 2001 From: Christos Stathis Date: Wed, 3 Aug 2011 15:14:40 +0300 Subject: [PATCH] Removed all static references to the Pithos class --- .../web/client/AbstractPropertiesDialog.java | 10 +- .../gr/grnet/pithos/web/client/CellTreeView.java | 62 ++-- .../grnet/pithos/web/client/CellTreeViewModel.java | 82 ++--- .../grnet/pithos/web/client/CredentialsDialog.java | 334 -------------------- .../grnet/pithos/web/client/DeleteFileDialog.java | 16 +- .../pithos/web/client/DnDFolderPopupMenu.java | 93 +++--- .../src/gr/grnet/pithos/web/client/EditMenu.java | 2 +- .../grnet/pithos/web/client/FileContextMenu.java | 23 +- .../src/gr/grnet/pithos/web/client/FileList.java | 19 +- .../src/gr/grnet/pithos/web/client/FileMenu.java | 8 +- .../pithos/web/client/FilePropertiesDialog.java | 35 +- .../pithos/web/client/FileUploadGearsDialog.java | 17 +- .../pithos/web/client/FileUploadGearsIEDialog.java | 1 - .../pithos/web/client/FilesPropertiesDialog.java | 17 +- .../grnet/pithos/web/client/FolderContextMenu.java | 18 +- .../pithos/web/client/PermissionsAddDialog.java | 12 +- .../grnet/pithos/web/client/PermissionsList.java | 20 +- .../src/gr/grnet/pithos/web/client/Pithos.java | 71 ++--- .../src/gr/grnet/pithos/web/client/QuitDialog.java | 8 +- .../pithos/web/client/SessionExpiredDialog.java | 8 +- .../gr/grnet/pithos/web/client/SettingsMenu.java | 127 -------- .../gr/grnet/pithos/web/client/StatusPanel.java | 6 +- .../src/gr/grnet/pithos/web/client/TopPanel.java | 13 +- .../grnet/pithos/web/client/UserDetailsPanel.java | 9 +- .../gr/grnet/pithos/web/client/VersionsList.java | 42 +-- .../pithos/web/client/commands/DeleteCommand.java | 8 +- .../web/client/commands/EmptyTrashCommand.java | 19 +- .../pithos/web/client/commands/GetUserCommand.java | 13 +- .../web/client/commands/NewFolderCommand.java | 7 +- .../pithos/web/client/commands/PasteCommand.java | 4 +- .../pithos/web/client/commands/RefreshCommand.java | 19 +- .../commands/ResreshOthersSharesCommand.java | 2 +- .../web/client/commands/RestoreTrashCommand.java | 66 ++-- .../pithos/web/client/commands/ToTrashCommand.java | 6 +- .../web/client/commands/UploadFileCommand.java | 7 +- .../web/client/foldertree/FolderTreeViewModel.java | 21 +- .../pithos/web/client/rest/DeleteCommand.java | 11 +- .../grnet/pithos/web/client/rest/GetCommand.java | 22 +- .../grnet/pithos/web/client/rest/HeadCommand.java | 11 +- .../web/client/rest/MultipleDeleteCommand.java | 11 +- .../pithos/web/client/rest/MultipleGetCommand.java | 15 +- .../web/client/rest/MultipleHeadCommand.java | 210 ------------ .../web/client/rest/MultiplePostCommand.java | 20 +- .../grnet/pithos/web/client/rest/PostCommand.java | 11 +- .../grnet/pithos/web/client/rest/RestCallback.java | 4 +- .../grnet/pithos/web/client/rest/RestCommand.java | 16 +- .../web/client/rest/resource/FolderResource.java | 8 - .../web/client/tagtree/TagTreeViewModel.java | 16 +- 48 files changed, 463 insertions(+), 1117 deletions(-) delete mode 100644 web_client/src/gr/grnet/pithos/web/client/CredentialsDialog.java delete mode 100644 web_client/src/gr/grnet/pithos/web/client/SettingsMenu.java delete mode 100644 web_client/src/gr/grnet/pithos/web/client/rest/MultipleHeadCommand.java diff --git a/web_client/src/gr/grnet/pithos/web/client/AbstractPropertiesDialog.java b/web_client/src/gr/grnet/pithos/web/client/AbstractPropertiesDialog.java index b63350a..2fbda4c 100644 --- a/web_client/src/gr/grnet/pithos/web/client/AbstractPropertiesDialog.java +++ b/web_client/src/gr/grnet/pithos/web/client/AbstractPropertiesDialog.java @@ -76,12 +76,14 @@ public abstract class AbstractPropertiesDialog extends DialogBox { protected TabPanel inner = null; + protected Pithos app; + /** * The widget's constructor. * */ - public AbstractPropertiesDialog() { - + public AbstractPropertiesDialog(Pithos _app) { + app = _app; // Enable IE selection for the dialog (must disable it upon closing it) Pithos.enableIESelection(); @@ -92,7 +94,7 @@ public abstract class AbstractPropertiesDialog extends DialogBox { * Retrieves all user tags from the server and updates the FlowPanel */ protected void updateTags() { - GetCommand tc = new GetCommand(TagsResource.class, Pithos.get().getCurrentUserResource().getTagsPath(),null) { + GetCommand tc = new GetCommand(app, TagsResource.class, app.getCurrentUserResource().getTagsPath(),null) { @Override public void onComplete() { @@ -128,7 +130,7 @@ public abstract class AbstractPropertiesDialog extends DialogBox { @Override public void onError(Throwable t) { GWT.log("", t); - Pithos.get().displayError("Unable to fetch user tags"); + app.displayError("Unable to fetch user tags"); } }; DeferredCommand.addCommand(tc); diff --git a/web_client/src/gr/grnet/pithos/web/client/CellTreeView.java b/web_client/src/gr/grnet/pithos/web/client/CellTreeView.java index 3cfd28d..4c033b8 100644 --- a/web_client/src/gr/grnet/pithos/web/client/CellTreeView.java +++ b/web_client/src/gr/grnet/pithos/web/client/CellTreeView.java @@ -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 selectionModel = new SingleSelectionModel(new ProvidesKey() { @@ -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 null 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 nodeInfo = (NodeInfo) 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 gf = new GetCommand(FolderResource.class, path, null) { + GetCommand gf = new GetCommand(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.class, Pithos.get().getCurrentUserResource().getTrashPath(), null) { + DeferredCommand.addCommand(new GetCommand(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 gs = new GetCommand(SharedResource.class, userResource.getSharedPath(), null) { + GetCommand gs = new GetCommand(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 go = new GetCommand(OthersResource.class, + GetCommand go = new GetCommand(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.class, Pithos.get().getCurrentUserResource().getTrashPath(), null) { + DeferredCommand.addCommand(new GetCommand(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 gf = new GetCommand(FolderResource.class, path, null) { + final String path = app.getCurrentUserResource().getFilesPath(); + GetCommand gf = new GetCommand(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 gs = new GetCommand(SharedResource.class, Pithos.get().getCurrentUserResource().getSharedPath(), null) { + GetCommand gs = new GetCommand(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 go = new GetCommand(OthersResource.class, - Pithos.get().getCurrentUserResource().getOthersPath(), null) { + GetCommand go = new GetCommand(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 nodeInfo = (NodeInfo) getModel().getNodeInfo(selectionModel.getSelectedObject()); if(nodeInfo==null || nodeInfo.getValueUpdater()==null){ - Pithos.get().showFileList(getSelection(),clearSelection); + app.showFileList(getSelection(),clearSelection); } else{ if(!clearSelection) diff --git a/web_client/src/gr/grnet/pithos/web/client/CellTreeViewModel.java b/web_client/src/gr/grnet/pithos/web/client/CellTreeViewModel.java index 05a33c2..eebec0e 100644 --- a/web_client/src/gr/grnet/pithos/web/client/CellTreeViewModel.java +++ b/web_client/src/gr/grnet/pithos/web/client/CellTreeViewModel.java @@ -93,6 +93,7 @@ public class CellTreeViewModel implements TreeViewModel{ private final ListDataProvider rootNodes = new ListDataProvider(); private Map folderCache=new HashMap(); final Images images; + private Pithos app; SingleSelectionModel selectionModel; Map mymap = new HashMap(); Map sharedmap = new HashMap(); @@ -153,8 +154,9 @@ public class CellTreeViewModel implements TreeViewModel{ /** * */ - public CellTreeViewModel(final Images _images,SingleSelectionModel selectionModel ) { + public CellTreeViewModel(Pithos _app, final Images _images,SingleSelectionModel 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 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 trashProvider = new ListDataProvider(); List r = new ArrayList(); - 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 gf = new GetCommand(FolderResource.class, value.getUri(), null) { + GetCommand gf = new GetCommand(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.class, Pithos.get().getCurrentUserResource().getTrashPath(), null) { + DeferredCommand.addCommand(new GetCommand(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 gf = new GetCommand(FolderResource.class, value.getUri(), null) { + GetCommand gf = new GetCommand(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 gf = new GetCommand(FolderResource.class, value.getUri(), null) { + GetCommand gf = new GetCommand(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 gf = new GetCommand(SharedResource.class, value.getUri(), null) { + GetCommand gf = new GetCommand(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 gf = new GetCommand(OtherUserResource.class, value.getUri(), null) { + GetCommand gf = new GetCommand(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 gf = new GetCommand(FolderResource.class, restResource.getUri(),cache ) { + GetCommand gf = new GetCommand(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 gf2 = new MultipleGetCommand(FolderResource.class, + MultipleGetCommand gf2 = new MultipleGetCommand(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 go = new GetCommand(OthersResource.class, + GetCommand go = new GetCommand(app, OthersResource.class, restResource.getUri(), null) { @Override public void onComplete() { final OthersResource others = getResult(); - MultipleGetCommand gogo = new MultipleGetCommand(OtherUserResource.class, + MultipleGetCommand gogo = new MultipleGetCommand(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 index fa29cb2..0000000 --- a/web_client/src/gr/grnet/pithos/web/client/CredentialsDialog.java +++ /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("
" + - AbstractImagePrototype.create(images.warn()).getHTML() + - "" + "Are you sure you want to create a new " + - "WebDAV password?
"); - 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("

A new WebDAV password has been created." + - "

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.

"); - 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("

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); - } - -} diff --git a/web_client/src/gr/grnet/pithos/web/client/DeleteFileDialog.java b/web_client/src/gr/grnet/pithos/web/client/DeleteFileDialog.java index a1ee721..8c0db5f 100644 --- a/web_client/src/gr/grnet/pithos/web/client/DeleteFileDialog.java +++ b/web_client/src/gr/grnet/pithos/web/client/DeleteFileDialog.java @@ -64,12 +64,16 @@ import com.google.gwt.user.client.ui.VerticalPanel; public class DeleteFileDialog extends DialogBox { private List files; + + private Pithos app; + /** * The widget's constructor. * * @param images the supplied images */ - public DeleteFileDialog(Images images, List _files) { + public DeleteFileDialog(Pithos _app, Images images, List _files) { + app = _app; files = _files; // Set the dialog's caption. setText("Confirmation"); @@ -130,7 +134,7 @@ public class DeleteFileDialog extends DialogBox { if (iter.hasNext()) { File f = iter.next(); String path = f.getUri(); - DeleteRequest deleteFile = new DeleteRequest(Pithos.get().getApiPath(), Pithos.get().getUsername(), path) { + DeleteRequest deleteFile = new DeleteRequest(app.getApiPath(), app.getUsername(), path) { @Override public void onSuccess(Resource result) { deleteFile(iter); @@ -140,17 +144,17 @@ public class DeleteFileDialog extends DialogBox { public void onError(Throwable t) { GWT.log("", t); if (t instanceof RestException) { - Pithos.get().displayError("Unable to delete file: " + ((RestException) t).getHttpStatusText()); + app.displayError("Unable to delete file: " + ((RestException) t).getHttpStatusText()); } else - Pithos.get().displayError("System error unable to delete file: "+t.getMessage()); + app.displayError("System error unable to delete file: "+t.getMessage()); } }; - deleteFile.setHeader("X-Auth-Token", Pithos.get().getToken()); + deleteFile.setHeader("X-Auth-Token", app.getToken()); Scheduler.get().scheduleDeferred(deleteFile); } else { - Pithos.get().updateFolder(files.get(0).getParent()); + app.updateFolder(files.get(0).getParent()); } } diff --git a/web_client/src/gr/grnet/pithos/web/client/DnDFolderPopupMenu.java b/web_client/src/gr/grnet/pithos/web/client/DnDFolderPopupMenu.java index 055cbcc..65052e1 100644 --- a/web_client/src/gr/grnet/pithos/web/client/DnDFolderPopupMenu.java +++ b/web_client/src/gr/grnet/pithos/web/client/DnDFolderPopupMenu.java @@ -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("" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Move", true, new Command() { @@ -79,7 +82,7 @@ public class DnDFolderPopupMenu extends PopupPanel { moveFolder(target, (Folder) toCopy); } else if (toCopy instanceof List) { - List files = Pithos.get().getFileList().getSelectedFiles(); + List 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 files = Pithos.get().getFileList().getSelectedFiles(); + List 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 files = Pithos.get().getFileList().getSelectedFiles(); + List 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 fileIds = new ArrayList(); 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 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); diff --git a/web_client/src/gr/grnet/pithos/web/client/EditMenu.java b/web_client/src/gr/grnet/pithos/web/client/EditMenu.java index 751fafe..e1fd7eb 100644 --- a/web_client/src/gr/grnet/pithos/web/client/EditMenu.java +++ b/web_client/src/gr/grnet/pithos/web/client/EditMenu.java @@ -179,7 +179,7 @@ public class EditMenu extends MenuBar { MenuItem moveToTrashItem = new MenuItem("" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + " Move to Trash", true, new ToTrashCommand(_app, null, cutObject)); addItem(moveToTrashItem); - MenuItem deleteItem = new MenuItem("" + AbstractImagePrototype.create(images.delete()).getHTML() + " Delete", true, new DeleteCommand(null, cutObject, images)); + MenuItem deleteItem = new MenuItem("" + AbstractImagePrototype.create(images.delete()).getHTML() + " Delete", true, new DeleteCommand(_app, null, cutObject, images)); addItem(deleteItem); } } diff --git a/web_client/src/gr/grnet/pithos/web/client/FileContextMenu.java b/web_client/src/gr/grnet/pithos/web/client/FileContextMenu.java index dfc2060..382d616 100644 --- a/web_client/src/gr/grnet/pithos/web/client/FileContextMenu.java +++ b/web_client/src/gr/grnet/pithos/web/client/FileContextMenu.java @@ -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 selectedFiles, boolean isTrash) { + public FileContextMenu(final Pithos app, Images newImages, Folder selectedFolder, List 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("" + AbstractImagePrototype.create(images.paste()).getHTML() + " Paste", true, new PasteCommand(Pithos.get(), this, selectedFolder)); + if (app.getClipboard().hasFiles()) { + pasteItem = new MenuItem("" + AbstractImagePrototype.create(images.paste()).getHTML() + " Paste", true, new PasteCommand(app, this, selectedFolder)); contextMenu.addItem(pasteItem); } - MenuItem upload = new MenuItem("" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + " Upload", true, new UploadFileCommand(this, selectedFolder)); + MenuItem upload = new MenuItem("" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + " Upload", true, new UploadFileCommand(app, this, selectedFolder)); contextMenu.addItem(upload); // MenuItem refresh = new MenuItem("" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh", true, new RefreshCommand(this, images)); @@ -144,31 +143,31 @@ public class FileContextMenu extends PopupPanel { // MenuItem delete = new MenuItem("" + AbstractImagePrototype.create(images.delete()).getHTML() + " Delete", true, new DeleteCommand(this, null, images)); // contextMenu.addItem(delete); // } else { - cutItem = new MenuItem("" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut", true, new CutCommand(Pithos.get(), this, selectedFiles)); + cutItem = new MenuItem("" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut", true, new CutCommand(app, this, selectedFiles)); contextMenu.addItem(cutItem); - copyItem = new MenuItem("" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy", true, new CopyCommand(Pithos.get(), this, selectedFiles)); + copyItem = new MenuItem("" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy", true, new CopyCommand(app, this, selectedFiles)); contextMenu.addItem(copyItem); - trashItem = new MenuItem("" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash", true, new ToTrashCommand(Pithos.get(), this, selectedFiles)); + trashItem = new MenuItem("" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash", true, new ToTrashCommand(app, this, selectedFiles)); contextMenu.addItem(trashItem); - deleteItem = new MenuItem("" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete", true, new DeleteCommand(this, selectedFiles, images)); + deleteItem = new MenuItem("" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete", true, new DeleteCommand(app, this, selectedFiles, images)); contextMenu.addItem(deleteItem); // sharingItem = new MenuItem("" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing", true, new PropertiesCommand(this, images, 1)); // contextMenu.addItem(sharingItem); - contextMenu.addItem(new MenuItem("" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties", true, new PropertiesCommand(Pithos.get(), this, selectedFiles, images, 0))); + contextMenu.addItem(new MenuItem("" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties", true, new PropertiesCommand(app, this, selectedFiles, images, 0))); if (!selectedFiles.isEmpty()) - contextMenu.addItem(new MenuItem("" + AbstractImagePrototype.create(newImages.download()).getHTML() + " Download", true, (Command) null)); + contextMenu.addItem(new MenuItem("" + AbstractImagePrototype.create(newImages.download()).getHTML() + " Download", true, (Command) null)); MenuItem unSelect = new MenuItem("" + AbstractImagePrototype.create(images.unselectAll()).getHTML() + " Unselect", true, new Command() { @Override public void execute() { hide(); - Pithos.get().getFileList().clearSelectedRows(); + app.getFileList().clearSelectedRows(); } }); contextMenu.addItem(unSelect); diff --git a/web_client/src/gr/grnet/pithos/web/client/FileList.java b/web_client/src/gr/grnet/pithos/web/client/FileList.java index 858a61f..3e7a96b 100644 --- a/web_client/src/gr/grnet/pithos/web/client/FileList.java +++ b/web_client/src/gr/grnet/pithos/web/client/FileList.java @@ -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); } /** diff --git a/web_client/src/gr/grnet/pithos/web/client/FileMenu.java b/web_client/src/gr/grnet/pithos/web/client/FileMenu.java index eefd992..101c21b 100644 --- a/web_client/src/gr/grnet/pithos/web/client/FileMenu.java +++ b/web_client/src/gr/grnet/pithos/web/client/FileMenu.java @@ -103,14 +103,14 @@ public class FileMenu extends MenuBar { Folder selectedFolder = _app.getFolderTreeView().getSelection(); List selectedFiles = _app.getFileList().getSelectedFiles(); if (selectedFolder != null) { - MenuItem newFolderItem = new MenuItem("" + AbstractImagePrototype.create(images.folderNew()).getHTML() + " New Folder", true, new NewFolderCommand(null, selectedFolder, images)); + MenuItem newFolderItem = new MenuItem("" + AbstractImagePrototype.create(images.folderNew()).getHTML() + " New Folder", true, new NewFolderCommand(_app, null, selectedFolder, images)); addItem(newFolderItem); - MenuItem uploadItem = new MenuItem("" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + " Upload", true, new UploadFileCommand(null, selectedFolder)); + MenuItem uploadItem = new MenuItem("" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + " Upload", true, new UploadFileCommand(_app, null, selectedFolder)); addItem(uploadItem); } if (selectedFiles.size() == 1) { - addItem(new MenuItem("" + AbstractImagePrototype.create(images.download()).getHTML() + " Download", true, (Command) null)); + addItem(new MenuItem("" + AbstractImagePrototype.create(images.download()).getHTML() + " Download", true, (Command) null)); } // MenuItem emptyTrashItem = new MenuItem("" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + " Empty Trash", 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("" + AbstractImagePrototype.create(images.viewText()).getHTML() + " Properties", true, new PropertiesCommand(Pithos.get(), null, selectedFiles.size() > 0 ? selectedFiles : selectedFolder, images, 0)); + MenuItem propertiesItem = new MenuItem("" + AbstractImagePrototype.create(images.viewText()).getHTML() + " Properties", true, new PropertiesCommand(_app, null, selectedFiles.size() > 0 ? selectedFiles : selectedFolder, images, 0)); addItem(propertiesItem); } } diff --git a/web_client/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java b/web_client/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java index fb4ba59..2638aab 100644 --- a/web_client/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java +++ b/web_client/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java @@ -112,13 +112,12 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog { private String userFullName; - private Pithos app; /** * The widget's constructor. */ public FilePropertiesDialog(Pithos _app, File _file) { - app = _app; + super(_app); file = _file; // Set the dialog's caption. @@ -411,7 +410,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog { //only update the read for all perm if the user is the owner Boolean published = null; if (readForAll.getValue() != file.isPublished()) - if (file.getOwner().equals(Pithos.get().getUsername())) + if (file.getOwner().equals(app.getUsername())) published = readForAll.getValue(); final Boolean finalPublished = published; // json.put("readForAll", JSONBoolean.getInstance(readForAll.getValue())); @@ -496,7 +495,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog { JSONObject json = new JSONObject(); json.put("versioned", JSONBoolean.getInstance(false)); GWT.log(json.toString(), null); - PostCommand cf = new PostCommand(file.getUri() + "?update=", json.toString(), 200) { + PostCommand cf = new PostCommand(app, file.getUri() + "?update=", json.toString(), 200) { @Override public void onComplete() { @@ -509,17 +508,17 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog { 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("User in permissions does not exist"); + app.displayError("User in permissions 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 modify file:" + ((RestException) t).getHttpStatusText()); + app.displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText()); } else - Pithos.get().displayError("System error moifying file:" + t.getMessage()); + app.displayError("System error moifying file:" + t.getMessage()); } }; DeferredCommand.addCommand(cf); @@ -529,11 +528,11 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog { JSONObject json = new JSONObject(); json.put("versioned", JSONBoolean.getInstance(versionedValue)); GWT.log(json.toString(), null); - PostCommand cf = new PostCommand(file.getUri() + "?update=", json.toString(), 200) { + PostCommand cf = new PostCommand(app, file.getUri() + "?update=", json.toString(), 200) { @Override public void onComplete() { - Pithos.get().getTreeView().refreshCurrentNode(false); + app.getTreeView().refreshCurrentNode(false); } @Override @@ -542,17 +541,17 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog { 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("User in permissions does not exist"); + app.displayError("User in permissions 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 modify file:" + ((RestException) t).getHttpStatusText()); + app.displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText()); } else - Pithos.get().displayError("System error moifying file:" + t.getMessage()); + app.displayError("System error moifying file:" + t.getMessage()); } }; DeferredCommand.addCommand(cf); diff --git a/web_client/src/gr/grnet/pithos/web/client/FileUploadGearsDialog.java b/web_client/src/gr/grnet/pithos/web/client/FileUploadGearsDialog.java index a9804ea..46a86d4 100644 --- a/web_client/src/gr/grnet/pithos/web/client/FileUploadGearsDialog.java +++ b/web_client/src/gr/grnet/pithos/web/client/FileUploadGearsDialog.java @@ -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 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(); } /** diff --git a/web_client/src/gr/grnet/pithos/web/client/FileUploadGearsIEDialog.java b/web_client/src/gr/grnet/pithos/web/client/FileUploadGearsIEDialog.java index 33251bf..6402558 100644 --- a/web_client/src/gr/grnet/pithos/web/client/FileUploadGearsIEDialog.java +++ b/web_client/src/gr/grnet/pithos/web/client/FileUploadGearsIEDialog.java @@ -55,7 +55,6 @@ public class FileUploadGearsIEDialog extends FileUploadGearsDialog { */ @Override protected void doSend(final List filesRemaining) { - final Pithos app = Pithos.get(); HttpRequest request = factory.createHttpRequest(); requests.add(request); String method = "POST"; diff --git a/web_client/src/gr/grnet/pithos/web/client/FilesPropertiesDialog.java b/web_client/src/gr/grnet/pithos/web/client/FilesPropertiesDialog.java index 77dce20..4d124e9 100644 --- a/web_client/src/gr/grnet/pithos/web/client/FilesPropertiesDialog.java +++ b/web_client/src/gr/grnet/pithos/web/client/FilesPropertiesDialog.java @@ -63,14 +63,13 @@ public class FilesPropertiesDialog extends AbstractPropertiesDialog { private Boolean initialVersioned; - /** * The widget's constructor. * * @param _files */ public FilesPropertiesDialog(Pithos _app, final List _files) { - super(); + super(_app); files = _files; // int versionedNum = 0; @@ -254,7 +253,7 @@ public class FilesPropertiesDialog extends AbstractPropertiesDialog { // // @Override // public void onComplete() { -// Pithos.get().getTreeView().refreshCurrentNode(false); +// app.getTreeView().refreshCurrentNode(false); // } // // @Override @@ -263,18 +262,18 @@ public class FilesPropertiesDialog extends AbstractPropertiesDialog { // 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 modify file::"+((RestException)t).getHttpStatusText()); +// app.displayError("Unable to modify file::"+((RestException)t).getHttpStatusText()); // } // else -// Pithos.get().displayError("System error modifying file:"+t.getMessage()); +// app.displayError("System error modifying file:"+t.getMessage()); // } // }; // DeferredCommand.addCommand(rt); diff --git a/web_client/src/gr/grnet/pithos/web/client/FolderContextMenu.java b/web_client/src/gr/grnet/pithos/web/client/FolderContextMenu.java index 8582519..ea8553f 100644 --- a/web_client/src/gr/grnet/pithos/web/client/FolderContextMenu.java +++ b/web_client/src/gr/grnet/pithos/web/client/FolderContextMenu.java @@ -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("" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder", true, new NewFolderCommand(this, folder, images)); + MenuItem newFolder = new MenuItem("" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder", true, new NewFolderCommand(app, this, folder, images)); contextMenu.addItem(newFolder); if (!folder.isContainer()) { - MenuItem cut = new MenuItem("" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut", true, new CutCommand(Pithos.get(), this, folder)); + MenuItem cut = new MenuItem("" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut", true, new CutCommand(app, this, folder)); contextMenu.addItem(cut); } - MenuItem copy = new MenuItem("" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy", true, new CopyCommand(Pithos.get(), this, folder)); + MenuItem copy = new MenuItem("" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy", true, new CopyCommand(app, this, folder)); contextMenu.addItem(copy); - if (!Pithos.get().getClipboard().isEmpty()) { - pasteItem = new MenuItem("" + AbstractImagePrototype.create(newImages.paste()).getHTML() + " Paste", true, new PasteCommand(Pithos.get(), this, folder)); + if (!app.getClipboard().isEmpty()) { + pasteItem = new MenuItem("" + AbstractImagePrototype.create(newImages.paste()).getHTML() + " Paste", true, new PasteCommand(app, this, folder)); contextMenu.addItem(pasteItem); } if (!folder.isContainer()) { - MenuItem moveToTrash = new MenuItem("" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash", true, new ToTrashCommand(Pithos.get(), this, folder)); + MenuItem moveToTrash = new MenuItem("" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash", true, new ToTrashCommand(app, this, folder)); contextMenu.addItem(moveToTrash); - MenuItem delete = new MenuItem("" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete", true, new DeleteCommand(this, folder, newImages)); + MenuItem delete = new MenuItem("" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete", true, new DeleteCommand(app, this, folder, newImages)); contextMenu.addItem(delete); } @@ -111,7 +111,7 @@ public class FolderContextMenu extends PopupPanel { // MenuItem sharing = new MenuItem("" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing", true, new PropertiesCommand(this, newImages, 1)); // contextMenu.addItem(sharing); - MenuItem properties = new MenuItem("" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties", true, new PropertiesCommand(Pithos.get(), this, folder, newImages, 0)); + MenuItem properties = new MenuItem("" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties", true, new PropertiesCommand(app, this, folder, newImages, 0)); contextMenu.addItem(properties); add(contextMenu); diff --git a/web_client/src/gr/grnet/pithos/web/client/PermissionsAddDialog.java b/web_client/src/gr/grnet/pithos/web/client/PermissionsAddDialog.java index 83e75ba..1e53619 100644 --- a/web_client/src/gr/grnet/pithos/web/client/PermissionsAddDialog.java +++ b/web_client/src/gr/grnet/pithos/web/client/PermissionsAddDialog.java @@ -87,7 +87,10 @@ public class PermissionsAddDialog extends DialogBox { boolean userAdd; - public PermissionsAddDialog(List _groups, PermissionsList _permList, boolean _userAdd) { + private Pithos app; + + public PermissionsAddDialog(Pithos _app, List _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 eg = new GetCommand(UserSearchResource.class, + GetCommand eg = new GetCommand(app, UserSearchResource.class, app.getApiPath() + "users/" + URL.encodeComponent(query), false, null) { @Override diff --git a/web_client/src/gr/grnet/pithos/web/client/PermissionsList.java b/web_client/src/gr/grnet/pithos/web/client/PermissionsList.java index 739809f..745321c 100644 --- a/web_client/src/gr/grnet/pithos/web/client/PermissionsList.java +++ b/web_client/src/gr/grnet/pithos/web/client/PermissionsList.java @@ -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 thePermissions, String anOwner){ + public PermissionsList(Pithos _app, final Images theImages, Set thePermissions, String anOwner){ + app = _app; images = theImages; owner = anOwner; permissions = new HashSet(); @@ -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 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, "" + AbstractImagePrototype.create(images.permUser()).getHTML() + " Owner"); removeButton.setVisible(false); }else{ - permTable.setHTML(i, 0, ""+ AbstractImagePrototype.create(images.permUser()).getHTML() + " "+ Pithos.get().findUserFullName(dto.getUser()) + ""); + permTable.setHTML(i, 0, ""+ AbstractImagePrototype.create(images.permUser()).getHTML() + " "+ app.findUserFullName(dto.getUser()) + ""); } }else if(dto.getGroup() != null){ permTable.setHTML(i, 0, "" + AbstractImagePrototype.create(images.permGroup()).getHTML() + " "+ dto.getGroup() + ""); @@ -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 aPermissions){ final PermissionHolder dto = aPermissions.iterator().next(); - String path = Pithos.get().getApiPath() + "users/" + dto.getUser(); + String path = app.getApiPath() + "users/" + dto.getUser(); - GetCommand gg = new GetCommand(UserSearchResource.class, path, false,null) { + GetCommand gg = new GetCommand(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()){ diff --git a/web_client/src/gr/grnet/pithos/web/client/Pithos.java b/web_client/src/gr/grnet/pithos/web/client/Pithos.java index bf4219b..fb16b0b 100644 --- a/web_client/src/gr/grnet/pithos/web/client/Pithos.java +++ b/web_client/src/gr/grnet/pithos/web/client/Pithos.java @@ -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(); @@ -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()); diff --git a/web_client/src/gr/grnet/pithos/web/client/QuitDialog.java b/web_client/src/gr/grnet/pithos/web/client/QuitDialog.java index 8f64da2..3ea1adb 100644 --- a/web_client/src/gr/grnet/pithos/web/client/QuitDialog.java +++ b/web_client/src/gr/grnet/pithos/web/client/QuitDialog.java @@ -52,10 +52,12 @@ import com.google.gwt.user.client.ui.VerticalPanel; */ public class QuitDialog extends DialogBox { + private Pithos app; /** * The widget's constructor. */ - public QuitDialog() { + public QuitDialog(Pithos _app) { + app = _app; Configuration conf = (Configuration) GWT.create(Configuration.class); String service = conf.serviceName(); setText("Quit " + service); @@ -73,7 +75,7 @@ public class QuitDialog extends DialogBox { @Override public void onClick(ClickEvent event) { hide(); - Pithos.get().logout(); + app.logout(); } }); buttons.add(quit); @@ -105,7 +107,7 @@ public class QuitDialog extends DialogBox { switch (evt.getKeyCode()) { case KeyCodes.KEY_ENTER: hide(); - Pithos.get().logout(); + app.logout(); break; case KeyCodes.KEY_ESCAPE: hide(); diff --git a/web_client/src/gr/grnet/pithos/web/client/SessionExpiredDialog.java b/web_client/src/gr/grnet/pithos/web/client/SessionExpiredDialog.java index e0b0d1f..b74e374 100644 --- a/web_client/src/gr/grnet/pithos/web/client/SessionExpiredDialog.java +++ b/web_client/src/gr/grnet/pithos/web/client/SessionExpiredDialog.java @@ -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 index 1708e2d..0000000 --- a/web_client/src/gr/grnet/pithos/web/client/SettingsMenu.java +++ /dev/null @@ -1,127 +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 com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.resources.client.ClientBundle; -import com.google.gwt.resources.client.ImageResource; -import com.google.gwt.user.client.Command; -import com.google.gwt.user.client.ui.AbstractImagePrototype; -import com.google.gwt.user.client.ui.MenuBar; -import com.google.gwt.user.client.ui.MenuItem; -import com.google.gwt.user.client.ui.PopupPanel; - -/** - * The 'settings' menu implementation. - */ -public class SettingsMenu extends PopupPanel implements ClickHandler { - - /** - * The widget's images. - */ - private Images images; - private final MenuBar contextMenu; - /** - * An image bundle for this widgets images. - */ - public interface Images extends ClientBundle,MessagePanel.Images { - - /** - * Will bundle the file 'advancedsettings.png' residing in the package - * 'gr.grnet.pithos.web.resources'. - * - * @return the image prototype - */ - @Source("gr/grnet/pithos/resources/advancedsettings.png") - ImageResource preferences(); - - @Source("gr/grnet/pithos/resources/lock.png") - ImageResource credentials(); - - } - - /** - * The widget's constructor. - * - * @param newImages the image bundle passed on by the parent object - */ - public SettingsMenu(final Images newImages) { - // The popup's constructor's argument is a boolean specifying that it - // auto-close itself when the user clicks outside of it. - super(true); - setAnimationEnabled(true); - images = newImages; - - Command userCredentialsCommand = new Command(){ - @Override - public void execute() { - CredentialsDialog dlg = new CredentialsDialog(newImages); - dlg.center(); - } - }; - contextMenu = new MenuBar(true); -// contextMenu.addItem("" + newImages.preferences().getHTML() + " Preferences", true, cmd); - MenuItem showCredentialsItem = new MenuItem("" + AbstractImagePrototype.create(newImages.credentials()).getHTML() + " Show Credentials", true, userCredentialsCommand); - showCredentialsItem.getElement().setId("topMenu.settingsMenu.showCredentials"); - contextMenu.addItem(showCredentialsItem); - - add(contextMenu); - // setStyleName("toolbarPopup"); - } - - @Override - public void onClick(final ClickEvent event) { - final SettingsMenu menu = new SettingsMenu(images); - final int left = event.getRelativeElement().getAbsoluteLeft(); - final int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight(); - menu.setPopupPosition(left, top); - - menu.show(); - } - - - /** - * Retrieve the contextMenu. - * - * @return the contextMenu - */ - public MenuBar getContextMenu() { - contextMenu.setAutoOpen(false); - return contextMenu; - } - - -} diff --git a/web_client/src/gr/grnet/pithos/web/client/StatusPanel.java b/web_client/src/gr/grnet/pithos/web/client/StatusPanel.java index 5126404..99a420c 100644 --- a/web_client/src/gr/grnet/pithos/web/client/StatusPanel.java +++ b/web_client/src/gr/grnet/pithos/web/client/StatusPanel.java @@ -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 getAccount = new GetRequest(AccountResource.class, app.getApiPath(), app.getUsername(), "") { @Override public void onSuccess(AccountResource result) { diff --git a/web_client/src/gr/grnet/pithos/web/client/TopPanel.java b/web_client/src/gr/grnet/pithos/web/client/TopPanel.java index b27b033..d9d5677 100644 --- a/web_client/src/gr/grnet/pithos/web/client/TopPanel.java +++ b/web_client/src/gr/grnet/pithos/web/client/TopPanel.java @@ -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() + "File", 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() + "Edit", true, new MenuBar(true)){ @Override public MenuBar getSubMenu() { - return new EditMenu(Pithos.get(), images); + return new EditMenu(app, images); } }; diff --git a/web_client/src/gr/grnet/pithos/web/client/UserDetailsPanel.java b/web_client/src/gr/grnet/pithos/web/client/UserDetailsPanel.java index 86ed573..96c6623 100644 --- a/web_client/src/gr/grnet/pithos/web/client/UserDetailsPanel.java +++ b/web_client/src/gr/grnet/pithos/web/client/UserDetailsPanel.java @@ -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(" "); @@ -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("" + user.getName() + " \u0387 " + user.getUsername() + ""); - Pithos.get().putUserToMap(user.getUsername(), user.getName()); + app.putUserToMap(user.getUsername(), user.getName()); return DONE; } diff --git a/web_client/src/gr/grnet/pithos/web/client/VersionsList.java b/web_client/src/gr/grnet/pithos/web/client/VersionsList.java index 89bee2d..0771d08 100644 --- a/web_client/src/gr/grnet/pithos/web/client/VersionsList.java +++ b/web_client/src/gr/grnet/pithos/web/client/VersionsList.java @@ -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 theVersions) { + public VersionsList(Pithos _app, FilePropertiesDialog aContainer, final Images theImages, List theVersions) { + app = _app; images = theImages; container = aContainer; versions = theVersions; @@ -137,14 +140,13 @@ public class VersionsList extends Composite { }); permTable.setHTML(i, 0, "" + dto.getVersion() + ""); - permTable.setHTML(i, 1, "" + formatDate(dto.getCreationDate()) + " by " + Pithos.get().findUserFullName(dto.getCreatedBy()) + ""); - permTable.setHTML(i, 2, "" + formatDate(dto.getModificationDate()) + " by " + Pithos.get().findUserFullName(dto.getModifiedBy()) + ""); + permTable.setHTML(i, 1, "" + formatDate(dto.getCreationDate()) + " by " + app.findUserFullName(dto.getCreatedBy()) + ""); + permTable.setHTML(i, 2, "" + formatDate(dto.getModificationDate()) + " by " + app.findUserFullName(dto.getModifiedBy()) + ""); permTable.setHTML(i, 3, "" + dto.getFileSizeAsString() + ""); HTML downloadHtml = new HTML(""+AbstractImagePrototype.create(images.download()).getHTML()+"

"); 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 input){ final String aUserName = input.get(0).getOwner(); - String path = Pithos.get().getApiPath() + "users/" + aUserName; + String path = app.getApiPath() + "users/" + aUserName; - GetCommand gg = new GetCommand(UserSearchResource.class, path, false,null) { + GetCommand gg = new GetCommand(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); diff --git a/web_client/src/gr/grnet/pithos/web/client/commands/DeleteCommand.java b/web_client/src/gr/grnet/pithos/web/client/commands/DeleteCommand.java index 22478f5..d392456 100644 --- a/web_client/src/gr/grnet/pithos/web/client/commands/DeleteCommand.java +++ b/web_client/src/gr/grnet/pithos/web/client/commands/DeleteCommand.java @@ -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) resource); + DeleteFileDialog dlg = new DeleteFileDialog(app, newImages, (List) resource); dlg.center(); } } diff --git a/web_client/src/gr/grnet/pithos/web/client/commands/EmptyTrashCommand.java b/web_client/src/gr/grnet/pithos/web/client/commands/EmptyTrashCommand.java index ed0fed1..27a60e8 100644 --- a/web_client/src/gr/grnet/pithos/web/client/commands/EmptyTrashCommand.java +++ b/web_client/src/gr/grnet/pithos/web/client/commands/EmptyTrashCommand.java @@ -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); diff --git a/web_client/src/gr/grnet/pithos/web/client/commands/GetUserCommand.java b/web_client/src/gr/grnet/pithos/web/client/commands/GetUserCommand.java index 97882c5..ce2a173 100644 --- a/web_client/src/gr/grnet/pithos/web/client/commands/GetUserCommand.java +++ b/web_client/src/gr/grnet/pithos/web/client/commands/GetUserCommand.java @@ -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 gg = new GetCommand(UserSearchResource.class, + String path = app.getApiPath() + "users/" + userName; + GetCommand gg = new GetCommand(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); diff --git a/web_client/src/gr/grnet/pithos/web/client/commands/NewFolderCommand.java b/web_client/src/gr/grnet/pithos/web/client/commands/NewFolderCommand.java index 3235379..e3bcb71 100644 --- a/web_client/src/gr/grnet/pithos/web/client/commands/NewFolderCommand.java +++ b/web_client/src/gr/grnet/pithos/web/client/commands/NewFolderCommand.java @@ -57,11 +57,14 @@ public class NewFolderCommand implements Command{ private List 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(); } } diff --git a/web_client/src/gr/grnet/pithos/web/client/commands/PasteCommand.java b/web_client/src/gr/grnet/pithos/web/client/commands/PasteCommand.java index d660a85..35980bb 100644 --- a/web_client/src/gr/grnet/pithos/web/client/commands/PasteCommand.java +++ b/web_client/src/gr/grnet/pithos/web/client/commands/PasteCommand.java @@ -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()); diff --git a/web_client/src/gr/grnet/pithos/web/client/commands/RefreshCommand.java b/web_client/src/gr/grnet/pithos/web/client/commands/RefreshCommand.java index 1a969fd..d4627f3 100644 --- a/web_client/src/gr/grnet/pithos/web/client/commands/RefreshCommand.java +++ b/web_client/src/gr/grnet/pithos/web/client/commands/RefreshCommand.java @@ -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); //} } } diff --git a/web_client/src/gr/grnet/pithos/web/client/commands/ResreshOthersSharesCommand.java b/web_client/src/gr/grnet/pithos/web/client/commands/ResreshOthersSharesCommand.java index f708bd6..1fc5e36 100644 --- a/web_client/src/gr/grnet/pithos/web/client/commands/ResreshOthersSharesCommand.java +++ b/web_client/src/gr/grnet/pithos/web/client/commands/ResreshOthersSharesCommand.java @@ -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()); } } diff --git a/web_client/src/gr/grnet/pithos/web/client/commands/RestoreTrashCommand.java b/web_client/src/gr/grnet/pithos/web/client/commands/RestoreTrashCommand.java index e4a971e..f4f26e8 100644 --- a/web_client/src/gr/grnet/pithos/web/client/commands/RestoreTrashCommand.java +++ b/web_client/src/gr/grnet/pithos/web/client/commands/RestoreTrashCommand.java @@ -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 fileIds = new ArrayList(); 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); diff --git a/web_client/src/gr/grnet/pithos/web/client/commands/ToTrashCommand.java b/web_client/src/gr/grnet/pithos/web/client/commands/ToTrashCommand.java index 4ab6200..6795ac8 100644 --- a/web_client/src/gr/grnet/pithos/web/client/commands/ToTrashCommand.java +++ b/web_client/src/gr/grnet/pithos/web/client/commands/ToTrashCommand.java @@ -76,7 +76,7 @@ public class ToTrashCommand implements Command{ trashFiles(iter, new Command() { @Override public void execute() { - app.get().updateFolder(((List) resource).get(0).getParent()); + app.updateFolder(((List) 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()); diff --git a/web_client/src/gr/grnet/pithos/web/client/commands/UploadFileCommand.java b/web_client/src/gr/grnet/pithos/web/client/commands/UploadFileCommand.java index 211ad7a..1c8f1ff 100644 --- a/web_client/src/gr/grnet/pithos/web/client/commands/UploadFileCommand.java +++ b/web_client/src/gr/grnet/pithos/web/client/commands/UploadFileCommand.java @@ -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(); } diff --git a/web_client/src/gr/grnet/pithos/web/client/foldertree/FolderTreeViewModel.java b/web_client/src/gr/grnet/pithos/web/client/foldertree/FolderTreeViewModel.java index 0f3cc65..4c65304 100644 --- a/web_client/src/gr/grnet/pithos/web/client/foldertree/FolderTreeViewModel.java +++ b/web_client/src/gr/grnet/pithos/web/client/foldertree/FolderTreeViewModel.java @@ -58,6 +58,8 @@ import java.util.Set; public class FolderTreeViewModel implements TreeViewModel { + private Pithos app; + private Cell folderCell = new AbstractCell(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 selectionModel; - public FolderTreeViewModel(SingleSelectionModel selectionModel) { + public FolderTreeViewModel(Pithos _app, SingleSelectionModel selectionModel) { + app = _app; this.selectionModel = selectionModel; } @@ -122,7 +125,6 @@ public class FolderTreeViewModel implements TreeViewModel { } private void fetchFolder(final Iterator iter, final ListDataProvider dataProvider, final Set 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 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 getFolder = new GetRequest(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()); diff --git a/web_client/src/gr/grnet/pithos/web/client/rest/DeleteCommand.java b/web_client/src/gr/grnet/pithos/web/client/rest/DeleteCommand.java index 641ba10..c88e4ff 100644 --- a/web_client/src/gr/grnet/pithos/web/client/rest/DeleteCommand.java +++ b/web_client/src/gr/grnet/pithos/web/client/rest/DeleteCommand.java @@ -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; diff --git a/web_client/src/gr/grnet/pithos/web/client/rest/GetCommand.java b/web_client/src/gr/grnet/pithos/web/client/rest/GetCommand.java index 57ab365..69cdfeb 100644 --- a/web_client/src/gr/grnet/pithos/web/client/rest/GetCommand.java +++ b/web_client/src/gr/grnet/pithos/web/client/rest/GetCommand.java @@ -125,14 +125,15 @@ public abstract class GetCommand extends RestCommand{ private static Map cache = new HashMap(); - public GetCommand(Class theclass, String pathToGet, T theCached){ - this(theclass, pathToGet, true, theCached); + public GetCommand(Pithos _app, Class theclass, String pathToGet, T theCached){ + this(_app, theclass, pathToGet, true, theCached); } - public GetCommand(Class theclass, String pathToGet, boolean showLoading, T theCached){ + public GetCommand(Pithos _app, Class 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 extends RestCommand{ this.cached = theCached; } - public GetCommand(Class theclass, String aUsername , String pathToGet, T theCached){ - this(theclass, aUsername, pathToGet, true, theCached); + public GetCommand(Pithos _app, Class theclass, String aUsername , String pathToGet, T theCached){ + this(_app, theclass, aUsername, pathToGet, true, theCached); } - public GetCommand(Class theclass, String aUsername , String pathToGet, boolean showLoading, T theCached){ + public GetCommand(Pithos _app, Class 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 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 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())); diff --git a/web_client/src/gr/grnet/pithos/web/client/rest/HeadCommand.java b/web_client/src/gr/grnet/pithos/web/client/rest/HeadCommand.java index 6c16e31..685310e 100644 --- a/web_client/src/gr/grnet/pithos/web/client/rest/HeadCommand.java +++ b/web_client/src/gr/grnet/pithos/web/client/rest/HeadCommand.java @@ -61,15 +61,16 @@ public abstract class HeadCommand extends RestCommand{ T cached; final String path; - public HeadCommand(Class theclass, String pathToGet, T theCached){ - this(theclass, pathToGet, true, theCached); + public HeadCommand(Pithos _app, Class theclass, String pathToGet, T theCached){ + this(_app, theclass, pathToGet, true, theCached); } - public HeadCommand(Class theClass, String pathToGet, boolean showLoading, T theCached){ + public HeadCommand(Pithos _app, Class 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 extends RestCommand{ boolean com = isComplete(); if(com){ if(isShowLoadingIndicator()) - Pithos.get().hideLoadingIndicator(); + app.hideLoadingIndicator(); if(getResult() != null) onComplete(); else diff --git a/web_client/src/gr/grnet/pithos/web/client/rest/MultipleDeleteCommand.java b/web_client/src/gr/grnet/pithos/web/client/rest/MultipleDeleteCommand.java index 50d527d..2ede472 100644 --- a/web_client/src/gr/grnet/pithos/web/client/rest/MultipleDeleteCommand.java +++ b/web_client/src/gr/grnet/pithos/web/client/rest/MultipleDeleteCommand.java @@ -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; diff --git a/web_client/src/gr/grnet/pithos/web/client/rest/MultipleGetCommand.java b/web_client/src/gr/grnet/pithos/web/client/rest/MultipleGetCommand.java index 3a58695..fe75f39 100644 --- a/web_client/src/gr/grnet/pithos/web/client/rest/MultipleGetCommand.java +++ b/web_client/src/gr/grnet/pithos/web/client/rest/MultipleGetCommand.java @@ -67,14 +67,15 @@ public abstract class MultipleGetCommand extends RestCom String[] paths; private boolean requestSent=false; - public MultipleGetCommand(Class aNewClass, String[] pathToGet, Cached[] theCached) { - this(aNewClass, pathToGet, true, theCached); + public MultipleGetCommand(Pithos _app, Class aNewClass, String[] pathToGet, Cached[] theCached) { + this(_app, aNewClass, pathToGet, true, theCached); } - public MultipleGetCommand(Class aNewClass, String[] pathToGet, boolean showLoading, Cached[] theCached) { + public MultipleGetCommand(Pithos _app, Class 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 extends RestCom requestSent=true; if (cached!=null) for (final Cached pathg : cached) - DeferredCommand.addCommand(new GetCommand(aclass,pathg.uri,false,(T)pathg.cache) { + DeferredCommand.addCommand(new GetCommand(app, aclass,pathg.uri,false,(T)pathg.cache) { @Override public void onComplete() { @@ -102,7 +103,7 @@ public abstract class MultipleGetCommand extends RestCom }); else for (final String pathg : paths) - DeferredCommand.addCommand(new GetCommand(aclass,pathg,false,null) { + DeferredCommand.addCommand(new GetCommand(app, aclass,pathg,false,null) { @Override public void onComplete() { @@ -156,7 +157,7 @@ public abstract class MultipleGetCommand 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 index b065e06..0000000 --- a/web_client/src/gr/grnet/pithos/web/client/rest/MultipleHeadCommand.java +++ /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 extends RestCommand { - String[] paths; - Class aclass; - List result = new ArrayList(); - Map errors = new HashMap(); - private boolean requestSent=false; - Cached[] cached; - - public MultipleHeadCommand(Class theClass, String[] pathToGet, Cached[] theCached) { - this(theClass, pathToGet, true, theCached); - } - - public MultipleHeadCommand(Class 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(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(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 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 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)); - } -} diff --git a/web_client/src/gr/grnet/pithos/web/client/rest/MultiplePostCommand.java b/web_client/src/gr/grnet/pithos/web/client/rest/MultiplePostCommand.java index 37a394c..9b86ac8 100644 --- a/web_client/src/gr/grnet/pithos/web/client/rest/MultiplePostCommand.java +++ b/web_client/src/gr/grnet/pithos/web/client/rest/MultiplePostCommand.java @@ -51,29 +51,29 @@ import com.google.gwt.http.client.Response; public abstract class MultiplePostCommand extends RestCommand { - Map errors = new HashMap(); List successPaths = new ArrayList(); 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; diff --git a/web_client/src/gr/grnet/pithos/web/client/rest/PostCommand.java b/web_client/src/gr/grnet/pithos/web/client/rest/PostCommand.java index a09a841..0bb1cc3 100644 --- a/web_client/src/gr/grnet/pithos/web/client/rest/PostCommand.java +++ b/web_client/src/gr/grnet/pithos/web/client/rest/PostCommand.java @@ -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; diff --git a/web_client/src/gr/grnet/pithos/web/client/rest/RestCallback.java b/web_client/src/gr/grnet/pithos/web/client/rest/RestCallback.java index acfdd1b..57a24db 100644 --- a/web_client/src/gr/grnet/pithos/web/client/rest/RestCallback.java +++ b/web_client/src/gr/grnet/pithos/web/client/rest/RestCallback.java @@ -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 = ""; diff --git a/web_client/src/gr/grnet/pithos/web/client/rest/RestCommand.java b/web_client/src/gr/grnet/pithos/web/client/rest/RestCommand.java index 24b5988..82d2465 100644 --- a/web_client/src/gr/grnet/pithos/web/client/rest/RestCommand.java +++ b/web_client/src/gr/grnet/pithos/web/client/rest/RestCommand.java @@ -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(); } diff --git a/web_client/src/gr/grnet/pithos/web/client/rest/resource/FolderResource.java b/web_client/src/gr/grnet/pithos/web/client/rest/resource/FolderResource.java index 34e42cb..8bae03e 100644 --- a/web_client/src/gr/grnet/pithos/web/client/rest/resource/FolderResource.java +++ b/web_client/src/gr/grnet/pithos/web/client/rest/resource/FolderResource.java @@ -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; diff --git a/web_client/src/gr/grnet/pithos/web/client/tagtree/TagTreeViewModel.java b/web_client/src/gr/grnet/pithos/web/client/tagtree/TagTreeViewModel.java index d863f8e..b9f0840 100644 --- a/web_client/src/gr/grnet/pithos/web/client/tagtree/TagTreeViewModel.java +++ b/web_client/src/gr/grnet/pithos/web/client/tagtree/TagTreeViewModel.java @@ -87,7 +87,10 @@ public class TagTreeViewModel implements TreeViewModel { private SingleSelectionModel selectionModel; - public TagTreeViewModel(SingleSelectionModel selectionModel) { + private Pithos app; + + public TagTreeViewModel(Pithos _app, SingleSelectionModel selectionModel) { + app = _app; this.selectionModel = selectionModel; } @@ -129,7 +132,6 @@ public class TagTreeViewModel implements TreeViewModel { } private void fetchTags(final Iterator 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 iter = account.getContainers().iterator(); fetchTag(iter, t, new LinkedHashSet()); } private void fetchTag(final Iterator iter, final Tag t, final Set 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()); -- 1.7.10.4