\r
protected TabPanel inner = null;\r
\r
+ protected Pithos app;\r
+\r
/**\r
* The widget's constructor.\r
*\r
*/\r
- public AbstractPropertiesDialog() {\r
-\r
+ public AbstractPropertiesDialog(Pithos _app) {\r
+ app = _app;\r
// Enable IE selection for the dialog (must disable it upon closing it)\r
Pithos.enableIESelection();\r
\r
* Retrieves all user tags from the server and updates the FlowPanel\r
*/\r
protected void updateTags() {\r
- GetCommand<TagsResource> tc = new GetCommand<TagsResource>(TagsResource.class, Pithos.get().getCurrentUserResource().getTagsPath(),null) {\r
+ GetCommand<TagsResource> tc = new GetCommand<TagsResource>(app, TagsResource.class, app.getCurrentUserResource().getTagsPath(),null) {\r
\r
@Override\r
public void onComplete() {\r
@Override\r
public void onError(Throwable t) {\r
GWT.log("", t);\r
- Pithos.get().displayError("Unable to fetch user tags");\r
+ app.displayError("Unable to fetch user tags");\r
}\r
};\r
DeferredCommand.addCommand(tc);\r
public class CellTreeView extends Composite{
public static final boolean DONE = false;
+ private Pithos app;
Images images;
SingleSelectionModel<RestResource> selectionModel = new SingleSelectionModel<RestResource>(new ProvidesKey<RestResource>() {
/**
*
*/
- public CellTreeView(final Images _images) {
+ public CellTreeView(Pithos _app, final Images _images) {
+ this.app = _app;
images = _images;
- model = new CellTreeViewModel(images,selectionModel);
+ model = new CellTreeViewModel(app, images,selectionModel);
/*
* Create the tree using the model. We use <code>null</code> as the default
* value of the root node. The default value will be passed to
public void onSelectionChange(com.google.gwt.view.client.SelectionChangeEvent event) {
NodeInfo<RestResource> nodeInfo = (NodeInfo<RestResource>) getModel().getNodeInfo(selectionModel.getSelectedObject());
if(nodeInfo==null || nodeInfo.getValueUpdater()==null){
- Pithos.get().showFileList(getSelection());
+ app.showFileList(getSelection());
}
else
nodeInfo.getValueUpdater().update(selectionModel.getSelectedObject());
- Pithos.get().setCurrentSelection(selectionModel.getSelectedObject());
+ app.setCurrentSelection(selectionModel.getSelectedObject());
}
}
private boolean init=false;
public boolean fetchRootFolders() {
- UserResource userResource = Pithos.get().getCurrentUserResource();
+ UserResource userResource = app.getCurrentUserResource();
if (userResource == null)
return !DONE;
if(!init){
final String path = userResource.getFilesPath();
- GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, path, null) {
+ GetCommand<FolderResource> gf = new GetCommand<FolderResource>(app, FolderResource.class, path, null) {
@Override
public void onComplete() {
@Override
public void onError(Throwable t) {
GWT.log("Error fetching root folder", t);
- Pithos.get().displayError("Unable to fetch root folder");
+ app.displayError("Unable to fetch root folder");
}
};
DeferredCommand.addCommand(gf);
- DeferredCommand.addCommand(new GetCommand<TrashResource>(TrashResource.class, Pithos.get().getCurrentUserResource().getTrashPath(), null) {
+ DeferredCommand.addCommand(new GetCommand<TrashResource>(app, TrashResource.class, app.getCurrentUserResource().getTrashPath(), null) {
@Override
public void onComplete() {
trash = getResult();
int statusCode = ((RestException)t).getHttpStatusCode();
// On IE status code 1223 may be returned instead of 204.
if(statusCode == 204 || statusCode == 1223){
- trash = new TrashResource(Pithos.get().getCurrentUserResource().getTrashPath());
+ trash = new TrashResource(app.getCurrentUserResource().getTrashPath());
}
else{
GWT.log("", t);
- Pithos.get().displayError("Unable to fetch trash folder:"+t.getMessage());
- trash = new TrashResource(Pithos.get().getCurrentUserResource().getTrashPath());
+ app.displayError("Unable to fetch trash folder:"+t.getMessage());
+ trash = new TrashResource(app.getCurrentUserResource().getTrashPath());
}
}
}
});
- GetCommand<SharedResource> gs = new GetCommand<SharedResource>(SharedResource.class, userResource.getSharedPath(), null) {
+ GetCommand<SharedResource> gs = new GetCommand<SharedResource>(app, SharedResource.class, userResource.getSharedPath(), null) {
@Override
public void onComplete() {
@Override
public void onError(Throwable t) {
GWT.log("Error fetching Shared Root folder", t);
- Pithos.get().displayError("Unable to fetch Shared Root folder");
+ app.displayError("Unable to fetch Shared Root folder");
}
};
DeferredCommand.addCommand(gs);
- GetCommand<OthersResource> go = new GetCommand<OthersResource>(OthersResource.class,
+ GetCommand<OthersResource> go = new GetCommand<OthersResource>(app, OthersResource.class,
userResource.getOthersPath(), null) {
@Override
@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);
public void updateTrashNode(){
- DeferredCommand.addCommand(new GetCommand<TrashResource>(TrashResource.class, Pithos.get().getCurrentUserResource().getTrashPath(), null) {
+ DeferredCommand.addCommand(new GetCommand<TrashResource>(app, TrashResource.class, app.getCurrentUserResource().getTrashPath(), null) {
@Override
public void onComplete() {
trash = getResult();
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();
}
}
public void updateRootNode(){
- final String path = Pithos.get().getCurrentUserResource().getFilesPath();
- GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, path, null) {
+ final String path = app.getCurrentUserResource().getFilesPath();
+ GetCommand<FolderResource> gf = new GetCommand<FolderResource>(app, FolderResource.class, path, null) {
@Override
public void onComplete() {
@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");
}
};
}
public void updateMySharedNode(){
- GetCommand<SharedResource> gs = new GetCommand<SharedResource>(SharedResource.class, Pithos.get().getCurrentUserResource().getSharedPath(), null) {
+ GetCommand<SharedResource> gs = new GetCommand<SharedResource>(app, SharedResource.class, app.getCurrentUserResource().getSharedPath(), null) {
@Override
public void onComplete() {
@Override
public void onError(Throwable t) {
GWT.log("Error fetching Shared Root folder", t);
- Pithos.get().displayError("Unable to fetch Shared Root folder");
+ app.displayError("Unable to fetch Shared Root folder");
}
};
DeferredCommand.addCommand(gs);
}
public void updateOtherNode(){
- GetCommand<OthersResource> go = new GetCommand<OthersResource>(OthersResource.class,
- Pithos.get().getCurrentUserResource().getOthersPath(), null) {
+ GetCommand<OthersResource> go = new GetCommand<OthersResource>(app, OthersResource.class,
+ app.getCurrentUserResource().getOthersPath(), null) {
@Override
public void onComplete() {
@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);
}
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);
}
public void refreshCurrentNode(boolean clearSelection){
NodeInfo<RestResource> nodeInfo = (NodeInfo<RestResource>) getModel().getNodeInfo(selectionModel.getSelectedObject());
if(nodeInfo==null || nodeInfo.getValueUpdater()==null){
- Pithos.get().showFileList(getSelection(),clearSelection);
+ app.showFileList(getSelection(),clearSelection);
}
else{
if(!clearSelection)
private final ListDataProvider<RestResource> rootNodes = new ListDataProvider<RestResource>();
private Map<String,FolderResource> folderCache=new HashMap<String, FolderResource>();
final Images images;
+ private Pithos app;
SingleSelectionModel<RestResource> selectionModel;
Map<String, MyFolderDataProvider> mymap = new HashMap<String, MyFolderDataProvider>();
Map<String, MyFolderDataProvider> sharedmap = new HashMap<String, MyFolderDataProvider>();
/**
*
*/
- public CellTreeViewModel(final Images _images,SingleSelectionModel<RestResource> selectionModel ) {
+ public CellTreeViewModel(Pithos _app, final Images _images,SingleSelectionModel<RestResource> selectionModel ) {
super();
+ app = _app;
images=_images;
this.selectionModel=selectionModel;
}
public void onBrowserEvent(Cell.Context context, com.google.gwt.dom.client.Element parent, RestResource value, com.google.gwt.dom.client.NativeEvent event, com.google.gwt.cell.client.ValueUpdater<RestResource> valueUpdater) {
if(event.getType().equals("contextmenu")){
selectionModel.setSelected(value, true);
- Pithos.get().setCurrentSelection(value);
- Pithos.get().getTreeView().showPopup(event.getClientX(), event.getClientY());
+ app.setCurrentSelection(value);
+ app.getTreeView().showPopup(event.getClientX(), event.getClientY());
}
};
// Second level.
ListDataProvider<RestResource> trashProvider = new ListDataProvider<RestResource>();
List<RestResource> r = new ArrayList<RestResource>();
- for(FolderResource f : Pithos.get().getTreeView().getTrash().getFolders()){
+ for(FolderResource f : app.getTreeView().getTrash().getFolders()){
r.add(new TrashFolderResource(f));
}
trashProvider.setList(r);
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() {
@Override
public void update(final RestResource value) {
if(value instanceof MyFolderResource){
- GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, value.getUri(), null) {
+ GetCommand<FolderResource> gf = new GetCommand<FolderResource>(app, FolderResource.class, value.getUri(), null) {
@Override
public void onComplete() {
FolderResource rootResource = getResult();
//((MyFolderResource)value).getResource().setFiles(rootResource.getFiles());
((MyFolderResource)value).setResource(rootResource);
- if(Pithos.get().getTreeView().getSelection().getUri().equals(value.getUri()))
+ if(app.getTreeView().getSelection().getUri().equals(value.getUri()))
selectionModel.setSelected(value, true);
- Pithos.get().onResourceUpdate(value,clearSelection);
+ app.onResourceUpdate(value,clearSelection);
}
@Override
public void onError(Throwable t) {
GWT.log("Error fetching root folder", t);
- Pithos.get().displayError("Unable to fetch root folder");
+ app.displayError("Unable to fetch root folder");
}
};
DeferredCommand.addCommand(gf);
}
else if(value instanceof TrashResource){
- DeferredCommand.addCommand(new GetCommand<TrashResource>(TrashResource.class, Pithos.get().getCurrentUserResource().getTrashPath(), null) {
+ DeferredCommand.addCommand(new GetCommand<TrashResource>(app, TrashResource.class, app.getCurrentUserResource().getTrashPath(), null) {
@Override
public void onComplete() {
//trash = getResult();
((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
}
else{
GWT.log("", t);
- Pithos.get().displayError("Unable to fetch trash folder:"+t.getMessage());
- //Pithos.get().getTreeView().getTrash() = new TrashResource(Pithos.get().getCurrentUserResource().getTrashPath());
+ app.displayError("Unable to fetch trash folder:"+t.getMessage());
+ //app.getTreeView().getTrash() = new TrashResource(app.getCurrentUserResource().getTrashPath());
}
}
}
});
}
else if(value instanceof OthersFolderResource){
- GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, value.getUri(), null) {
+ GetCommand<FolderResource> gf = new GetCommand<FolderResource>(app, FolderResource.class, value.getUri(), null) {
@Override
public void onComplete() {
FolderResource rootResource = getResult();
//((MyFolderResource)value).getResource().setFiles(rootResource.getFiles());
((OthersFolderResource)value).setResource(rootResource);
- if(Pithos.get().getTreeView().getSelection().getUri().equals(value.getUri()))
+ if(app.getTreeView().getSelection().getUri().equals(value.getUri()))
selectionModel.setSelected(value, true);
- Pithos.get().onResourceUpdate(value,clearSelection);
+ app.onResourceUpdate(value,clearSelection);
}
@Override
public void onError(Throwable t) {
GWT.log("Error fetching root folder", t);
- Pithos.get().displayError("Unable to fetch root folder");
+ app.displayError("Unable to fetch root folder");
}
};
DeferredCommand.addCommand(gf);
}
else if(value instanceof SharedFolderResource){
- GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, value.getUri(), null) {
+ GetCommand<FolderResource> gf = new GetCommand<FolderResource>(app, FolderResource.class, value.getUri(), null) {
@Override
public void onComplete() {
FolderResource rootResource = getResult();
//((MyFolderResource)value).getResource().setFiles(rootResource.getFiles());
((SharedFolderResource)value).setResource(rootResource);
- if(Pithos.get().getTreeView().getSelection().getUri().equals(value.getUri()))
+ if(app.getTreeView().getSelection().getUri().equals(value.getUri()))
selectionModel.setSelected(value, true);
- Pithos.get().onResourceUpdate(value,clearSelection);
+ app.onResourceUpdate(value,clearSelection);
}
@Override
public void onError(Throwable t) {
GWT.log("Error fetching root folder", t);
- Pithos.get().displayError("Unable to fetch root folder");
+ app.displayError("Unable to fetch root folder");
}
};
DeferredCommand.addCommand(gf);
}
else if(value instanceof SharedResource){
- GetCommand<SharedResource> gf = new GetCommand<SharedResource>(SharedResource.class, value.getUri(), null) {
+ GetCommand<SharedResource> gf = new GetCommand<SharedResource>(app, SharedResource.class, value.getUri(), null) {
@Override
public void onComplete() {
((SharedResource)value).setFolders(getResult().getFolders());
((SharedResource)value).setFiles(getResult().getFiles());
- if(Pithos.get().getTreeView().getSelection().getUri().equals(value.getUri()))
+ if(app.getTreeView().getSelection().getUri().equals(value.getUri()))
selectionModel.setSelected(value, true);
- Pithos.get().onResourceUpdate(value,clearSelection);
+ app.onResourceUpdate(value,clearSelection);
}
@Override
public void onError(Throwable t) {
GWT.log("Error fetching root folder", t);
- Pithos.get().displayError("Unable to fetch root folder");
+ app.displayError("Unable to fetch root folder");
}
};
DeferredCommand.addCommand(gf);
}
else if(value instanceof OtherUserResource){
- GetCommand<OtherUserResource> gf = new GetCommand<OtherUserResource>(OtherUserResource.class, value.getUri(), null) {
+ GetCommand<OtherUserResource> gf = new GetCommand<OtherUserResource>(app, OtherUserResource.class, value.getUri(), null) {
@Override
public void onComplete() {
((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");
}
};
FolderResource cache = null;
if(restResource instanceof RestResourceWrapper && !((RestResourceWrapper)restResource).getResource().isNeedsExpanding())
cache = ((RestResourceWrapper)restResource).getResource();
- GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, restResource.getUri(),cache ) {
+ GetCommand<FolderResource> gf = new GetCommand<FolderResource>(app, FolderResource.class, restResource.getUri(),cache ) {
@Override
public void onComplete() {
MultipleGetCommand.Cached[] cached = null;
if(restResource instanceof RestResourceWrapper)
cached=((RestResourceWrapper)restResource).getResource().getCache();
- MultipleGetCommand<FolderResource> gf2 = new MultipleGetCommand<FolderResource>(FolderResource.class,
+ MultipleGetCommand<FolderResource> gf2 = new MultipleGetCommand<FolderResource>(app, FolderResource.class,
folderPaths, cached) {
@Override
@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);
}
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");
}
};
}
public void refresh(final RefreshHandler refresh){
- GetCommand<OthersResource> go = new GetCommand<OthersResource>(OthersResource.class,
+ GetCommand<OthersResource> go = new GetCommand<OthersResource>(app, OthersResource.class,
restResource.getUri(), null) {
@Override
public void onComplete() {
final OthersResource others = getResult();
- MultipleGetCommand<OtherUserResource> gogo = new MultipleGetCommand<OtherUserResource>(OtherUserResource.class,
+ MultipleGetCommand<OtherUserResource> gogo = new MultipleGetCommand<OtherUserResource>(app, OtherUserResource.class,
others.getOthers().toArray(new String[] {}), null) {
@Override
@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
@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);
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client;
-
-import gr.grnet.pithos.web.client.rest.PostCommand;
-import gr.grnet.pithos.web.client.rest.RestException;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.dom.client.NativeEvent;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.dom.client.KeyCodes;
-import com.google.gwt.user.client.DeferredCommand;
-import com.google.gwt.user.client.Event.NativePreviewEvent;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.DialogBox;
-import com.google.gwt.user.client.ui.FlexTable;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.TextBox;
-import com.google.gwt.user.client.ui.VerticalPanel;
-
-
-/**
- * A dialog box that displays the user credentials for use in other client
- * applications, such as WebDAV clients.
- */
-public class CredentialsDialog extends DialogBox {
-
- private final String WIDTH_FIELD = "35em";
- private final String WIDTH_TEXT = "42em";
-
- /**
- * The 'confirm reset password' dialog box.
- */
- private class ConfirmResetPasswordDialog extends DialogBox {
-
- /**
- * The widget's constructor.
- *
- * @param images the supplied images
- */
- private ConfirmResetPasswordDialog(MessagePanel.Images images) {
- // Set the dialog's caption.
- setText("Confirmation");
- setAnimationEnabled(true);
- // Create a VerticalPanel to contain the label and the buttons.
- VerticalPanel outer = new VerticalPanel();
- HorizontalPanel buttons = new HorizontalPanel();
-
- HTML text;
- text = new HTML("<table><tr><td>" +
- AbstractImagePrototype.create(images.warn()).getHTML() +
- "</td><td>" + "Are you sure you want to create a new " +
- "WebDAV password?</td></tr></table>");
- text.setStyleName("pithos-warnMessage");
- outer.add(text);
-
- // Create the 'Yes' button, along with a listener that hides the
- // dialog when the button is clicked and resets the password.
- Button ok = new Button("Yes", new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- resetPassword(Pithos.get().getCurrentUserResource().getUri());
- hide();
- }
- });
- buttons.add(ok);
- buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER);
- // Create the 'No' button, along with a listener that hides the
- // dialog when the button is clicked.
- Button cancel = new Button("No", new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- hide();
- }
- });
- buttons.add(cancel);
- buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);
- buttons.setSpacing(8);
- buttons.setStyleName("pithos-warnMessage");
- outer.setStyleName("pithos-warnMessage");
- outer.add(buttons);
- outer.setCellHorizontalAlignment(text, HasHorizontalAlignment.ALIGN_CENTER);
- outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);
- setWidget(outer);
- }
-
- @Override
- protected void onPreviewNativeEvent(NativePreviewEvent preview) {
- super.onPreviewNativeEvent(preview);
- NativeEvent evt = preview.getNativeEvent();
- if (evt.getType().equals("keydown"))
- // Use the popup's key preview hooks to close the dialog when either
- // enter or escape is pressed.
- switch (evt.getKeyCode()) {
- case KeyCodes.KEY_ENTER:
- case KeyCodes.KEY_ESCAPE:
- hide();
- break;
- }
- }
-
- }
-
- private class ReauthenticateDialog extends DialogBox {
- /**
- * The widget constructor.
- */
- public ReauthenticateDialog() {
- // Set the dialog's caption.
- setText("New Password Created");
- setAnimationEnabled(true);
- VerticalPanel outer = new VerticalPanel();
-
- // Create the text and set a style name so we can style it with CSS.
- HTML text = new HTML("<p>A new WebDAV password has been created." +
- "</p><p>You will now be redirected to the initial screen" +
- " for the changes to take effect. Choose \"Show " +
- "Credentials\" again afterwards to see the new password.</p>");
- text.setStyleName("pithos-AboutText");
- outer.add(text);
-
- // Create the 'OK' button, along with a listener that hides the
- // dialog when the button is clicked.
- Button confirm = new Button("Proceed", new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- Pithos.get().authenticateUser();
- hide();
- }
- });
- outer.add(confirm);
- outer.setCellHorizontalAlignment(confirm, HasHorizontalAlignment.ALIGN_CENTER);
- outer.setSpacing(8);
- setWidget(outer);
- }
-
- @Override
- protected void onPreviewNativeEvent(NativePreviewEvent preview) {
- super.onPreviewNativeEvent(preview);
- NativeEvent evt = preview.getNativeEvent();
- if (evt.getType().equals("keydown"))
- // Use the popup's key preview hooks to close the dialog when
- // either enter or escape is pressed.
- switch (evt.getKeyCode()) {
- case KeyCodes.KEY_ENTER:
- Pithos.get().authenticateUser();
- hide();
- break;
- case KeyCodes.KEY_ESCAPE:
- hide();
- break;
- }
- }
-
- }
-
- /**
- * The widget constructor.
- */
- public CredentialsDialog(final MessagePanel.Images images) {
- // Set the dialog's caption.
- setText("User Credentials");
- setAnimationEnabled(true);
- // A VerticalPanel that contains the 'about' label and the 'OK' button.
- VerticalPanel outer = new VerticalPanel();
- Configuration conf = (Configuration) GWT.create(Configuration.class);
- String service = conf.serviceName();
- // Create the text and set a style name so we can style it with CSS.
- HTML text = new HTML("<p>These are the user credentials that are " +
- "required for interacting with " + service + ".");
- text.setStyleName("pithos-AboutText");
- text.setWidth(WIDTH_TEXT);
- outer.add(text);
- FlexTable table = new FlexTable();
- table.setText(0, 0, "Username");
- table.setText(1, 0, "Token");
- TextBox username = new TextBox();
- final Pithos app = Pithos.get();
- username.setText(app.getCurrentUserResource().getUsername());
- username.setReadOnly(true);
- username.setWidth(WIDTH_FIELD);
- username.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- Pithos.enableIESelection();
- ((TextBox) event.getSource()).selectAll();
- Pithos.preventIESelection();
- }
-
- });
- table.setWidget(0, 1, username);
-
- TextBox tokenBox = new TextBox();
- tokenBox.setText(app.getToken());
- tokenBox.setReadOnly(true);
- tokenBox.setWidth(WIDTH_FIELD);
- tokenBox.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- Pithos.enableIESelection();
- ((TextBox) event.getSource()).selectAll();
- Pithos.preventIESelection();
- }
-
- });
- table.setWidget(1, 1, tokenBox);
-
- table.getFlexCellFormatter().setStyleName(0, 0, "props-labels");
- table.getFlexCellFormatter().setStyleName(0, 1, "props-values");
- table.getFlexCellFormatter().setStyleName(1, 0, "props-labels");
- table.getFlexCellFormatter().setStyleName(1, 1, "props-values");
- outer.add(table);
-
- // Create the 'OK' button, along with a listener that hides the dialog
- // when the button is clicked.
- Button confirm = new Button("Close", new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- hide();
- }
- });
- outer.add(confirm);
- outer.setCellHorizontalAlignment(confirm, HasHorizontalAlignment.ALIGN_CENTER);
-
- // Create the 'Reset password' button, along with a listener that hides
- // the dialog when the button is clicked.
- Button resetPassword = new Button("Reset Password", new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- ConfirmResetPasswordDialog dlg = new ConfirmResetPasswordDialog(images);
- dlg.center();
- }
- });
- outer.add(resetPassword);
- outer.setCellHorizontalAlignment(resetPassword, HasHorizontalAlignment.ALIGN_CENTER);
-
- outer.setSpacing(8);
- setWidget(outer);
- }
-
- @Override
- protected void onPreviewNativeEvent(NativePreviewEvent preview) {
- super.onPreviewNativeEvent(preview);
- NativeEvent evt = preview.getNativeEvent();
- if (evt.getType().equals("keydown"))
- // Use the popup's key preview hooks to close the dialog when
- // either enter or escape is pressed.
- switch (evt.getKeyCode()) {
- case KeyCodes.KEY_ENTER:
- case KeyCodes.KEY_ESCAPE:
- hide();
- break;
- }
- }
-
-
- /**
- * Generate an RPC request to reset WebDAV password.
- *
- */
- private void resetPassword(String userUri) {
-
- if (userUri == null || userUri.length() == 0) {
- Pithos.get().displayError("Empty user Uri!");
- return;
- }
- GWT.log("resetPassword(" + userUri + ")", null);
- PostCommand cg = new PostCommand(userUri + "?resetWebDAV", "", 200) {
-
- @Override
- public void onComplete() {
- ReauthenticateDialog dlg = new ReauthenticateDialog();
- dlg.center();
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if(t instanceof RestException){
- int statusCode = ((RestException)t).getHttpStatusCode();
- if(statusCode == 405)
- Pithos.get().displayError("You don't have the necessary" +
- " permissions");
- else if(statusCode == 404)
- Pithos.get().displayError("Resource does not exist");
- else
- Pithos.get().displayError("Unable to reset password:" +
- ((RestException)t).getHttpStatusText());
- }
- else
- Pithos.get().displayError("System error resetting password:" +
- t.getMessage());
- }
- };
- DeferredCommand.addCommand(cg);
- }
-
-}
public class DeleteFileDialog extends DialogBox {\r
\r
private List<File> files;\r
+\r
+ private Pithos app;\r
+\r
/**\r
* The widget's constructor.\r
*\r
* @param images the supplied images\r
*/\r
- public DeleteFileDialog(Images images, List<File> _files) {\r
+ public DeleteFileDialog(Pithos _app, Images images, List<File> _files) {\r
+ app = _app;\r
files = _files;\r
// Set the dialog's caption.\r
setText("Confirmation");\r
if (iter.hasNext()) {\r
File f = iter.next();\r
String path = f.getUri();\r
- DeleteRequest deleteFile = new DeleteRequest(Pithos.get().getApiPath(), Pithos.get().getUsername(), path) {\r
+ DeleteRequest deleteFile = new DeleteRequest(app.getApiPath(), app.getUsername(), path) {\r
@Override\r
public void onSuccess(Resource result) {\r
deleteFile(iter);\r
public void onError(Throwable t) {\r
GWT.log("", t);\r
if (t instanceof RestException) {\r
- Pithos.get().displayError("Unable to delete file: " + ((RestException) t).getHttpStatusText());\r
+ app.displayError("Unable to delete file: " + ((RestException) t).getHttpStatusText());\r
}\r
else\r
- Pithos.get().displayError("System error unable to delete file: "+t.getMessage());\r
+ app.displayError("System error unable to delete file: "+t.getMessage());\r
}\r
};\r
- deleteFile.setHeader("X-Auth-Token", Pithos.get().getToken());\r
+ deleteFile.setHeader("X-Auth-Token", app.getToken());\r
Scheduler.get().scheduleDeferred(deleteFile);\r
}\r
else {\r
- Pithos.get().updateFolder(files.get(0).getParent());\r
+ app.updateFolder(files.get(0).getParent());\r
}\r
}\r
\r
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() {
};
final MenuBar contextMenu = new MenuBar(true);
- final CellTreeView folders = Pithos.get().getTreeView();
+ final CellTreeView folders = app.getTreeView();
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Move</span>", true, new Command() {
moveFolder(target, (Folder) toCopy);
}
else if (toCopy instanceof List) {
- List<File> files = Pithos.get().getFileList().getSelectedFiles();
+ List<File> files = app.getFileList().getSelectedFiles();
moveFiles(target, files);
}
hide();
if (toCopy instanceof Folder)
copyFolder(target, (Folder) toCopy);
else if (toCopy instanceof List) {
- List<File> files = Pithos.get().getFileList().getSelectedFiles();
+ List<File> files = app.getFileList().getSelectedFiles();
copyFiles(target, files);
}
hide();
trashFolder(((RestResourceWrapper) toCopy).getResource());
}
else if (toCopy instanceof List) {
- List<File> files = Pithos.get().getFileList().getSelectedFiles();
+ List<File> files = app.getFileList().getSelectedFiles();
trashFiles(files);
}
hide();
//
// @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
// 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);
// @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
// 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);
}
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);
*/
}
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);
final List<String> fileIds = new ArrayList<String>();
for (File f : files)
fileIds.add(f.getUri() + "?trash=");
- MultiplePostCommand tot = new MultiplePostCommand(fileIds.toArray(new String[0]), 200) {
+ MultiplePostCommand tot = new MultiplePostCommand(app, fileIds.toArray(new String[0]), 200) {
@Override
public void onComplete() {
- Pithos.get().showFileList(true);
+ app.showFileList(true);
}
@Override
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);
private void executeCopyOrMoveFiles(final int index, final List<String> paths) {
if (index >= paths.size()) {
- Pithos.get().showFileList(true);
- Pithos.get().getStatusPanel().updateStats();
+ app.showFileList(true);
+ app.getStatusPanel().updateStats();
return;
}
- PostCommand cf = new PostCommand(paths.get(index), "", 200) {
+ PostCommand cf = new PostCommand(app, paths.get(index), "", 200) {
@Override
public void onComplete() {
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);
MenuItem moveToTrashItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(_app, null, cutObject));
addItem(moveToTrashItem);
- MenuItem deleteItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(null, cutObject, images));
+ MenuItem deleteItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(_app, null, cutObject, images));
addItem(deleteItem);
}
}
*
* @param newImages the image bundle passed on by the parent object
*/
- public FileContextMenu(Images newImages, Folder selectedFolder, List<File> selectedFiles, boolean isTrash) {
+ public FileContextMenu(final Pithos app, Images newImages, Folder selectedFolder, List<File> selectedFiles, boolean isTrash) {
// The popup's constructor's argument is a boolean specifying that it
// auto-close itself when the user clicks outside of it.
super(true);
- Pithos gss = Pithos.get();
setAnimationEnabled(true);
images = newImages;
MenuBar contextMenu = new MenuBar(true);
- if (Pithos.get().getClipboard().hasFiles()) {
- pasteItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.paste()).getHTML() + " Paste</span>", true, new PasteCommand(Pithos.get(), this, selectedFolder));
+ if (app.getClipboard().hasFiles()) {
+ pasteItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.paste()).getHTML() + " Paste</span>", true, new PasteCommand(app, this, selectedFolder));
contextMenu.addItem(pasteItem);
}
- MenuItem upload = new MenuItem("<span>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(this, selectedFolder));
+ MenuItem upload = new MenuItem("<span>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(app, this, selectedFolder));
contextMenu.addItem(upload);
// MenuItem refresh = new MenuItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images));
// MenuItem delete = new MenuItem("<span>" + AbstractImagePrototype.create(images.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, null, images));
// contextMenu.addItem(delete);
// } else {
- cutItem = new MenuItem("<span id='fileContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut</span>", true, new CutCommand(Pithos.get(), this, selectedFiles));
+ cutItem = new MenuItem("<span id='fileContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut</span>", true, new CutCommand(app, this, selectedFiles));
contextMenu.addItem(cutItem);
- copyItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy</span>", true, new CopyCommand(Pithos.get(), this, selectedFiles));
+ copyItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy</span>", true, new CopyCommand(app, this, selectedFiles));
contextMenu.addItem(copyItem);
- trashItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(Pithos.get(), this, selectedFiles));
+ trashItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(app, this, selectedFiles));
contextMenu.addItem(trashItem);
- deleteItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, selectedFiles, images));
+ deleteItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(app, this, selectedFiles, images));
contextMenu.addItem(deleteItem);
// sharingItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing</span>", true, new PropertiesCommand(this, images, 1));
// contextMenu.addItem(sharingItem);
- contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(Pithos.get(), this, selectedFiles, images, 0)));
+ contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(app, this, selectedFiles, images, 0)));
if (!selectedFiles.isEmpty())
- contextMenu.addItem(new MenuItem("<span><a class='hidden-link' href='" + Pithos.get().getApiPath() + Pithos.get().getUsername() + selectedFiles.get(0).getUri() + "?X-Auth-Token=" + Pithos.get().getToken() + "' target='_blank'>" + AbstractImagePrototype.create(newImages.download()).getHTML() + " Download</a></span>", true, (Command) null));
+ contextMenu.addItem(new MenuItem("<span><a class='hidden-link' href='" + app.getApiPath() + app.getUsername() + selectedFiles.get(0).getUri() + "?X-Auth-Token=" + app.getToken() + "' target='_blank'>" + AbstractImagePrototype.create(newImages.download()).getHTML() + " Download</a></span>", true, (Command) null));
MenuItem unSelect = new MenuItem("<span>" + AbstractImagePrototype.create(images.unselectAll()).getHTML() + " Unselect</span>", true, new Command() {
@Override
public void execute() {
hide();
- Pithos.get().getFileList().clearSelectedRows();
+ app.getFileList().clearSelectedRows();
}
});
contextMenu.addItem(unSelect);
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
*
* @param _images
*/
- public FileList(Images _images, FolderTreeView _treeView) {
+ public FileList(final Pithos _app, Images _images, FolderTreeView _treeView) {
+ app = _app;
images = _images;
this.treeView = _treeView;
@Override
public void onClick(ClickEvent event) {
- new UploadFileCommand(null, treeView.getSelection()).execute();
+ new UploadFileCommand(app, null, treeView.getSelection()).execute();
}
});
HorizontalPanel topPanel = new HorizontalPanel();
@Override
public void onClick(ClickEvent event) {
- new UploadFileCommand(null, treeView.getSelection()).execute();
+ new UploadFileCommand(app, null, treeView.getSelection()).execute();
}
});
HorizontalPanel bottomPanel = new HorizontalPanel();
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);
@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);
// 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();
* Update status panel with currently showing file stats.
*/
public void updateCurrentlyShowingStats() {
- Pithos.get().getStatusPanel().updateCurrentlyShowing(showingStats);
+ app.getStatusPanel().updateCurrentlyShowing(showingStats);
}
/**
Folder selectedFolder = _app.getFolderTreeView().getSelection();
List<File> selectedFiles = _app.getFileList().getSelectedFiles();
if (selectedFolder != null) {
- MenuItem newFolderItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(null, selectedFolder, images));
+ MenuItem newFolderItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(_app, null, selectedFolder, images));
addItem(newFolderItem);
- MenuItem uploadItem = new MenuItem("<span id='topMenu.file.upload'>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(null, selectedFolder));
+ MenuItem uploadItem = new MenuItem("<span id='topMenu.file.upload'>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(_app, null, selectedFolder));
addItem(uploadItem);
}
if (selectedFiles.size() == 1) {
- addItem(new MenuItem("<span><a class='hidden-link' href='" + Pithos.get().getApiPath() + Pithos.get().getUsername() + selectedFiles.get(0).getUri() + "?X-Auth-Token=" + Pithos.get().getToken() + "' target='_blank'>" + AbstractImagePrototype.create(images.download()).getHTML() + " Download</a></span>", true, (Command) null));
+ addItem(new MenuItem("<span><a class='hidden-link' href='" + _app.getApiPath() + _app.getUsername() + selectedFiles.get(0).getUri() + "?X-Auth-Token=" + _app.getToken() + "' target='_blank'>" + AbstractImagePrototype.create(images.download()).getHTML() + " Download</a></span>", true, (Command) null));
}
// MenuItem emptyTrashItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + " Empty Trash</span>", true, new EmptyTrashCommand(this));
// .setVisible(propertiesVisible);
//
if (selectedFiles.size() > 0 || selectedFolder != null) {
- MenuItem propertiesItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(Pithos.get(), null, selectedFiles.size() > 0 ? selectedFiles : selectedFolder, images, 0));
+ MenuItem propertiesItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(_app, null, selectedFiles.size() > 0 ? selectedFiles : selectedFolder, images, 0));
addItem(propertiesItem);
}
}
\r
private String userFullName;\r
\r
- private Pithos app;\r
\r
/**\r
* The widget's constructor.\r
*/\r
public FilePropertiesDialog(Pithos _app, File _file) {\r
- app = _app;\r
+ super(_app);\r
file = _file;\r
\r
// Set the dialog's caption.\r
//only update the read for all perm if the user is the owner\r
Boolean published = null;\r
if (readForAll.getValue() != file.isPublished())\r
- if (file.getOwner().equals(Pithos.get().getUsername()))\r
+ if (file.getOwner().equals(app.getUsername()))\r
published = readForAll.getValue();\r
final Boolean finalPublished = published;\r
// json.put("readForAll", JSONBoolean.getInstance(readForAll.getValue()));\r
JSONObject json = new JSONObject();\r
json.put("versioned", JSONBoolean.getInstance(false));\r
GWT.log(json.toString(), null);\r
- PostCommand cf = new PostCommand(file.getUri() + "?update=", json.toString(), 200) {\r
+ PostCommand cf = new PostCommand(app, file.getUri() + "?update=", json.toString(), 200) {\r
\r
@Override\r
public void onComplete() {\r
if (t instanceof RestException) {\r
int statusCode = ((RestException) t).getHttpStatusCode();\r
if (statusCode == 405)\r
- Pithos.get().displayError("You don't have the necessary permissions");\r
+ app.displayError("You don't have the necessary permissions");\r
else if (statusCode == 404)\r
- Pithos.get().displayError("User in permissions does not exist");\r
+ app.displayError("User in permissions does not exist");\r
else if (statusCode == 409)\r
- Pithos.get().displayError("A folder with the same name already exists");\r
+ app.displayError("A folder with the same name already exists");\r
else if (statusCode == 413)\r
- Pithos.get().displayError("Your quota has been exceeded");\r
+ app.displayError("Your quota has been exceeded");\r
else\r
- Pithos.get().displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText());\r
+ app.displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText());\r
} else\r
- Pithos.get().displayError("System error moifying file:" + t.getMessage());\r
+ app.displayError("System error moifying file:" + t.getMessage());\r
}\r
};\r
DeferredCommand.addCommand(cf);\r
JSONObject json = new JSONObject();\r
json.put("versioned", JSONBoolean.getInstance(versionedValue));\r
GWT.log(json.toString(), null);\r
- PostCommand cf = new PostCommand(file.getUri() + "?update=", json.toString(), 200) {\r
+ PostCommand cf = new PostCommand(app, file.getUri() + "?update=", json.toString(), 200) {\r
\r
@Override\r
public void onComplete() {\r
- Pithos.get().getTreeView().refreshCurrentNode(false);\r
+ app.getTreeView().refreshCurrentNode(false);\r
}\r
\r
@Override\r
if (t instanceof RestException) {\r
int statusCode = ((RestException) t).getHttpStatusCode();\r
if (statusCode == 405)\r
- Pithos.get().displayError("You don't have the necessary permissions");\r
+ app.displayError("You don't have the necessary permissions");\r
else if (statusCode == 404)\r
- Pithos.get().displayError("User in permissions does not exist");\r
+ app.displayError("User in permissions does not exist");\r
else if (statusCode == 409)\r
- Pithos.get().displayError("A folder with the same name already exists");\r
+ app.displayError("A folder with the same name already exists");\r
else if (statusCode == 413)\r
- Pithos.get().displayError("Your quota has been exceeded");\r
+ app.displayError("Your quota has been exceeded");\r
else\r
- Pithos.get().displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText());\r
+ app.displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText());\r
} else\r
- Pithos.get().displayError("System error moifying file:" + t.getMessage());\r
+ app.displayError("System error moifying file:" + t.getMessage());\r
}\r
};\r
DeferredCommand.addCommand(cf);\r
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...");
public void onClick(ClickEvent event) {
canContinue = false;
cancelUpload();
- Pithos.get().showFileList(true);
+ app.showFileList(true);
}
});
buttons.add(cancel);
@Override
public void prepareAndSubmit() {
- Pithos app = Pithos.get();
if (selectedFiles.size() == 0) {
app.displayError("You must select a file!");
hide();
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() {
@Override
public void onError(Throwable t) {
- Pithos app = Pithos.get();
GWT.log("", t);
if (t instanceof RestException) {
int statusCode = ((RestException) t).getHttpStatusCode();
* Perform the HTTP request to upload the specified file.
*/
protected void doSend(final List<File> filesRemaining) {
- final Pithos app = Pithos.get();
HttpRequest request = factory.createHttpRequest();
requests.add(request);
String method = "PUT";
doSend(filesRemaining);
break;
case 403:
- SessionExpiredDialog dlg = new SessionExpiredDialog();
+ SessionExpiredDialog dlg = new SessionExpiredDialog(app);
dlg.center();
break;
case 405:
*/
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();
}
/**
*/
@Override
protected void doSend(final List<File> filesRemaining) {
- final Pithos app = Pithos.get();
HttpRequest request = factory.createHttpRequest();
requests.add(request);
String method = "POST";
\r
private Boolean initialVersioned;\r
\r
-\r
/**\r
* The widget's constructor.\r
*\r
* @param _files\r
*/\r
public FilesPropertiesDialog(Pithos _app, final List<File> _files) {\r
- super();\r
+ super(_app);\r
\r
files = _files;\r
// int versionedNum = 0;\r
//\r
// @Override\r
// public void onComplete() {\r
-// Pithos.get().getTreeView().refreshCurrentNode(false);\r
+// app.getTreeView().refreshCurrentNode(false);\r
// }\r
//\r
// @Override\r
// if(t instanceof RestException){\r
// int statusCode = ((RestException)t).getHttpStatusCode();\r
// if(statusCode == 405)\r
-// Pithos.get().displayError("You don't have the necessary permissions");\r
+// app.displayError("You don't have the necessary permissions");\r
// else if(statusCode == 404)\r
-// Pithos.get().displayError("File does not exist");\r
+// app.displayError("File does not exist");\r
// else if(statusCode == 409)\r
-// Pithos.get().displayError("A file with the same name already exists");\r
+// app.displayError("A file with the same name already exists");\r
// else if(statusCode == 413)\r
-// Pithos.get().displayError("Your quota has been exceeded");\r
+// app.displayError("Your quota has been exceeded");\r
// else\r
-// Pithos.get().displayError("Unable to modify file::"+((RestException)t).getHttpStatusText());\r
+// app.displayError("Unable to modify file::"+((RestException)t).getHttpStatusText());\r
// }\r
// else\r
-// Pithos.get().displayError("System error modifying file:"+t.getMessage());\r
+// app.displayError("System error modifying file:"+t.getMessage());\r
// }\r
// };\r
// DeferredCommand.addCommand(rt);\r
*
* @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);
images = newImages;
MenuBar contextMenu = new MenuBar(true);
- MenuItem newFolder = new MenuItem("<span id = 'folderContextMenu.newFolder'>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(this, folder, images));
+ MenuItem newFolder = new MenuItem("<span id = 'folderContextMenu.newFolder'>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(app, this, folder, images));
contextMenu.addItem(newFolder);
if (!folder.isContainer()) {
- MenuItem cut = new MenuItem("<span id = 'folderContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut</span>", true, new CutCommand(Pithos.get(), this, folder));
+ MenuItem cut = new MenuItem("<span id = 'folderContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut</span>", true, new CutCommand(app, this, folder));
contextMenu.addItem(cut);
}
- MenuItem copy = new MenuItem("<span id = 'folderContextMenu.copy'>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy</span>", true, new CopyCommand(Pithos.get(), this, folder));
+ MenuItem copy = new MenuItem("<span id = 'folderContextMenu.copy'>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy</span>", true, new CopyCommand(app, this, folder));
contextMenu.addItem(copy);
- if (!Pithos.get().getClipboard().isEmpty()) {
- pasteItem = new MenuItem("<span id = 'folderContextMenu.paste'>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + " Paste</span>", true, new PasteCommand(Pithos.get(), this, folder));
+ if (!app.getClipboard().isEmpty()) {
+ pasteItem = new MenuItem("<span id = 'folderContextMenu.paste'>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + " Paste</span>", true, new PasteCommand(app, this, folder));
contextMenu.addItem(pasteItem);
}
if (!folder.isContainer()) {
- MenuItem moveToTrash = new MenuItem("<span id = 'folderContextMenu.moveToTrash'>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(Pithos.get(), this, folder));
+ MenuItem moveToTrash = new MenuItem("<span id = 'folderContextMenu.moveToTrash'>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(app, this, folder));
contextMenu.addItem(moveToTrash);
- MenuItem delete = new MenuItem("<span id = 'folderContextMenu.delete'>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, folder, newImages));
+ MenuItem delete = new MenuItem("<span id = 'folderContextMenu.delete'>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(app, this, folder, newImages));
contextMenu.addItem(delete);
}
// MenuItem sharing = new MenuItem("<span id = 'folderContextMenu.sharing'>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing</span>", true, new PropertiesCommand(this, newImages, 1));
// contextMenu.addItem(sharing);
- MenuItem properties = new MenuItem("<span id = 'folderContextMenu.properties'>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(Pithos.get(), this, folder, newImages, 0));
+ MenuItem properties = new MenuItem("<span id = 'folderContextMenu.properties'>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(app, this, folder, newImages, 0));
contextMenu.addItem(properties);
add(contextMenu);
boolean userAdd;
- public PermissionsAddDialog(List<GroupResource> _groups, PermissionsList _permList, boolean _userAdd) {
+ private Pithos app;
+
+ public PermissionsAddDialog(Pithos _app, List<GroupResource> _groups, PermissionsList _permList, boolean _userAdd) {
+ app = _app;
groups = _groups;
userAdd = _userAdd;
permList = _permList;
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);
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());
* Update the list of suggestions.
*/
protected void updateSuggestions() {
- final Pithos app = Pithos.get();
String query = selectedUser.substring(0, selectedUser.length()-1);
GWT.log("Searching for " + query, null);
- GetCommand<UserSearchResource> eg = new GetCommand<UserSearchResource>(UserSearchResource.class,
+ GetCommand<UserSearchResource> eg = new GetCommand<UserSearchResource>(app, UserSearchResource.class,
app.getApiPath() + "users/" + URL.encodeComponent(query), false, null) {
@Override
private boolean hasChanges = false;
private boolean hasAddition = false;
+
+ private Pithos app;
- public PermissionsList(final Images theImages, Set<PermissionHolder> thePermissions, String anOwner){
+ public PermissionsList(Pithos _app, final Images theImages, Set<PermissionHolder> thePermissions, String anOwner){
+ app = _app;
images = theImages;
owner = anOwner;
permissions = new HashSet<PermissionHolder>();
* If the user's full name does not exist in the map then a request is being made
* for the specific username.
*
- * @param filesInput
*/
private void handleFullNames(Set<PermissionHolder> aPermissions){
if(aPermissions.isEmpty()){
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);
/**
* Shows the permission table
*
- * @param aPermissions
*/
private void showPermissionTable(){
int i = 1;
permTable.setHTML(i, 0, "<span id=permissionList.Owner>" + AbstractImagePrototype.create(images.permUser()).getHTML() + " Owner</span>");
removeButton.setVisible(false);
}else{
- permTable.setHTML(i, 0, "<span id=permissionList."+ Pithos.get().findUserFullName(dto.getUser())+">"+ AbstractImagePrototype.create(images.permUser()).getHTML() + " "+ Pithos.get().findUserFullName(dto.getUser()) + "</span>");
+ permTable.setHTML(i, 0, "<span id=permissionList."+ app.findUserFullName(dto.getUser())+">"+ AbstractImagePrototype.create(images.permUser()).getHTML() + " "+ app.findUserFullName(dto.getUser()) + "</span>");
}
}else if(dto.getGroup() != null){
permTable.setHTML(i, 0, "<span id=permissionList."+dto.getGroup()+">" + AbstractImagePrototype.create(images.permGroup()).getHTML() + " "+ dto.getGroup() + "</span>");
* Makes a request to search for full name from a given username
* and continues checking the next element of the Set.
*
- * @param filesInput
*/
private void findFullNameAndUpdate(final Set<PermissionHolder> aPermissions){
final PermissionHolder dto = aPermissions.iterator().next();
- String path = Pithos.get().getApiPath() + "users/" + dto.getUser();
+ String path = app.getApiPath() + "users/" + dto.getUser();
- GetCommand<UserSearchResource> gg = new GetCommand<UserSearchResource>(UserSearchResource.class, path, false,null) {
+ GetCommand<UserSearchResource> gg = new GetCommand<UserSearchResource>(app, UserSearchResource.class, path, false,null) {
@Override
public void onComplete() {
final UserSearchResource result = getResult();
for (UserResource user : result.getUsers()){
String username = user.getUsername();
String userFullName = user.getName();
- Pithos.get().putUserToMap(username, userFullName);
+ app.putUserToMap(username, userFullName);
if(aPermissions.size() >= 1){
aPermissions.remove(dto);
if(aPermissions.isEmpty()){
}
@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()){
* 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();
}
/**
- * 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();
/**
* 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.
@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%");
}
});
- folderTreeViewModel = new FolderTreeViewModel(folderTreeSelectionModel);
+ folderTreeViewModel = new FolderTreeViewModel(this, folderTreeSelectionModel);
folderTreeView = new FolderTreeView(folderTreeViewModel);
- fileList = new FileList(images, folderTreeView);
+ fileList = new FileList(this, images, folderTreeView);
inner.add(fileList, createHeaderHTML(AbstractImagePrototype.create(images.folders()), "Files"), true);
tagTreeSelectionModel = new SingleSelectionModel<Tag>();
}
}
});
- tagTreeViewModel = new TagTreeViewModel(tagTreeSelectionModel);
+ tagTreeViewModel = new TagTreeViewModel(this, tagTreeSelectionModel);
tagTreeView = new TagTreeView(tagTreeViewModel);
VerticalPanel trees = new VerticalPanel();
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);
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");
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);
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());
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.
*
@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());
}
});
}
@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());
@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());
}
});
}
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());
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());
*/\r
public class QuitDialog extends DialogBox {\r
\r
+ private Pithos app;\r
/**\r
* The widget's constructor.\r
*/\r
- public QuitDialog() {\r
+ public QuitDialog(Pithos _app) {\r
+ app = _app;\r
Configuration conf = (Configuration) GWT.create(Configuration.class);\r
String service = conf.serviceName();\r
setText("Quit " + service);\r
@Override\r
public void onClick(ClickEvent event) {\r
hide();\r
- Pithos.get().logout();\r
+ app.logout();\r
}\r
});\r
buttons.add(quit);\r
switch (evt.getKeyCode()) {\r
case KeyCodes.KEY_ENTER:\r
hide();\r
- Pithos.get().logout();\r
+ app.logout();\r
break;\r
case KeyCodes.KEY_ESCAPE:\r
hide();\r
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);
Button confirm = new Button("Proceed", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
- Pithos.get().authenticateUser();
+ app.authenticateUser();
hide();
}
});
// enter or escape is pressed.
switch (evt.getKeyCode()) {
case KeyCodes.KEY_ENTER:
- Pithos.get().authenticateUser();
+ app.authenticateUser();
hide();
break;
case KeyCodes.KEY_ESCAPE:
+++ /dev/null
-/*\r
- * Copyright 2011 GRNET S.A. All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or\r
- * without modification, are permitted provided that the following\r
- * conditions are met:\r
- *\r
- * 1. Redistributions of source code must retain the above\r
- * copyright notice, this list of conditions and the following\r
- * disclaimer.\r
- *\r
- * 2. Redistributions in binary form must reproduce the above\r
- * copyright notice, this list of conditions and the following\r
- * disclaimer in the documentation and/or other materials\r
- * provided with the distribution.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS\r
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR\r
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED\r
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
- * POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- * The views and conclusions contained in the software and\r
- * documentation are those of the authors and should not be\r
- * interpreted as representing official policies, either expressed\r
- * or implied, of GRNET S.A.\r
- */\r
-package gr.grnet.pithos.web.client;\r
-\r
-import com.google.gwt.event.dom.client.ClickEvent;\r
-import com.google.gwt.event.dom.client.ClickHandler;\r
-import com.google.gwt.resources.client.ClientBundle;\r
-import com.google.gwt.resources.client.ImageResource;\r
-import com.google.gwt.user.client.Command;\r
-import com.google.gwt.user.client.ui.AbstractImagePrototype;\r
-import com.google.gwt.user.client.ui.MenuBar;\r
-import com.google.gwt.user.client.ui.MenuItem;\r
-import com.google.gwt.user.client.ui.PopupPanel;\r
-\r
-/**\r
- * The 'settings' menu implementation.\r
- */\r
-public class SettingsMenu extends PopupPanel implements ClickHandler {\r
-\r
- /**\r
- * The widget's images.\r
- */\r
- private Images images;\r
- private final MenuBar contextMenu;\r
- /**\r
- * An image bundle for this widgets images.\r
- */\r
- public interface Images extends ClientBundle,MessagePanel.Images {\r
-\r
- /**\r
- * Will bundle the file 'advancedsettings.png' residing in the package\r
- * 'gr.grnet.pithos.web.resources'.\r
- *\r
- * @return the image prototype\r
- */\r
- @Source("gr/grnet/pithos/resources/advancedsettings.png")\r
- ImageResource preferences();\r
-\r
- @Source("gr/grnet/pithos/resources/lock.png")\r
- ImageResource credentials();\r
-\r
- }\r
-\r
- /**\r
- * The widget's constructor.\r
- *\r
- * @param newImages the image bundle passed on by the parent object\r
- */\r
- public SettingsMenu(final Images newImages) {\r
- // The popup's constructor's argument is a boolean specifying that it\r
- // auto-close itself when the user clicks outside of it.\r
- super(true);\r
- setAnimationEnabled(true);\r
- images = newImages;\r
-\r
- Command userCredentialsCommand = new Command(){\r
- @Override\r
- public void execute() {\r
- CredentialsDialog dlg = new CredentialsDialog(newImages);\r
- dlg.center();\r
- }\r
- };\r
- contextMenu = new MenuBar(true);\r
-// contextMenu.addItem("<span>" + newImages.preferences().getHTML() + " Preferences</span>", true, cmd);\r
- MenuItem showCredentialsItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.credentials()).getHTML() + " Show Credentials</span>", true, userCredentialsCommand);\r
- showCredentialsItem.getElement().setId("topMenu.settingsMenu.showCredentials");\r
- contextMenu.addItem(showCredentialsItem);\r
- \r
- add(contextMenu);\r
- // setStyleName("toolbarPopup");\r
- }\r
-\r
- @Override\r
- public void onClick(final ClickEvent event) {\r
- final SettingsMenu menu = new SettingsMenu(images);\r
- final int left = event.getRelativeElement().getAbsoluteLeft();\r
- final int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight();\r
- menu.setPopupPosition(left, top);\r
-\r
- menu.show();\r
- }\r
-\r
-\r
- /**\r
- * Retrieve the contextMenu.\r
- *\r
- * @return the contextMenu\r
- */\r
- public MenuBar getContextMenu() {\r
- contextMenu.setAutoOpen(false);\r
- return contextMenu;\r
- }\r
-\r
-\r
-}\r
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%");
*/
//TODO: This should not be done here
public void updateStats() {
- final Pithos app = Pithos.get();
GetRequest<AccountResource> getAccount = new GetRequest<AccountResource>(AccountResource.class, app.getApiPath(), app.getUsername(), "") {
@Override
public void onSuccess(AccountResource result) {
*/
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")
*
* @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();
Command quitCommand = new Command(){
@Override
public void execute() {
- QuitDialog dlg = new QuitDialog();
+ QuitDialog dlg = new QuitDialog(app);
dlg.center();
}
};
AbstractImagePrototype.create(images.folder()).getHTML() + "</td><td>File</td></tr></table>", true, new MenuBar(true)){
@Override
public MenuBar getSubMenu() {
- return new FileMenu(Pithos.get(), images);
+ return new FileMenu(app, images);
}
};
AbstractImagePrototype.create(images.edit()).getHTML() + "</td><td>Edit</td></tr></table>", true, new MenuBar(true)){
@Override
public MenuBar getSubMenu() {
- return new EditMenu(Pithos.get(), images);
+ return new EditMenu(app, images);
}
};
*/
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(" ");
* @return true if the work has been carried out successfully
*/
protected boolean displayUserInfo() {
- UserResource user = Pithos.get().getCurrentUserResource();
+ UserResource user = app.getCurrentUserResource();
if (user == null)
return !DONE;
userInfoLabel.setHTML("<b>" + user.getName() + " \u0387 " + user.getUsername() + "</b>");
- Pithos.get().putUserToMap(user.getUsername(), user.getName());
+ app.putUserToMap(user.getUsername(), user.getName());
return DONE;
}
public class VersionsList extends Composite {
+ private Pithos app;
+
int selectedRow = -1;
int permissionCount = -1;
FilePropertiesDialog container;
- public VersionsList(FilePropertiesDialog aContainer, final Images theImages, List<FileResource> theVersions) {
+ public VersionsList(Pithos _app, FilePropertiesDialog aContainer, final Images theImages, List<FileResource> theVersions) {
+ app = _app;
images = theImages;
container = aContainer;
versions = theVersions;
});
permTable.setHTML(i, 0, "<span>" + dto.getVersion() + "</span>");
- permTable.setHTML(i, 1, "<span>" + formatDate(dto.getCreationDate()) + " by " + Pithos.get().findUserFullName(dto.getCreatedBy()) + "</span>");
- permTable.setHTML(i, 2, "<span>" + formatDate(dto.getModificationDate()) + " by " + Pithos.get().findUserFullName(dto.getModifiedBy()) + "</span>");
+ permTable.setHTML(i, 1, "<span>" + formatDate(dto.getCreationDate()) + " by " + app.findUserFullName(dto.getCreatedBy()) + "</span>");
+ permTable.setHTML(i, 2, "<span>" + formatDate(dto.getModificationDate()) + " by " + app.findUserFullName(dto.getModifiedBy()) + "</span>");
permTable.setHTML(i, 3, "<span>" + dto.getFileSizeAsString() + "</span>");
HTML downloadHtml = new HTML("<a class='hidden-link info' href='#'><span>"+AbstractImagePrototype.create(images.download()).getHTML()+"</span><div>View this Version</div></a>");
downloadHtml.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
- Pithos app = Pithos.get();
String dateString = RestCommand.getDate();
String resource = dto.getUri().substring(app.getApiPath().length()-1, dto.getUri().length());
String sig = app.getCurrentUserResource().getUsername()+" "+RestCommand.calculateSig("GET", dateString, resource, RestCommand.base64decode(app.getToken()));
}
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
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);
}
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());
}
};
return;
}
- if(Pithos.get().findUserFullName(input.get(0).getOwner()) == null){
+ if(app.findUserFullName(input.get(0).getOwner()) == null){
findFullNameAndUpdate(input);
return;
}
private void findFullNameAndUpdate(final List<FileResource> input){
final String aUserName = input.get(0).getOwner();
- String path = Pithos.get().getApiPath() + "users/" + aUserName;
+ String path = app.getApiPath() + "users/" + aUserName;
- GetCommand<UserSearchResource> gg = new GetCommand<UserSearchResource>(UserSearchResource.class, path, false,null) {
+ GetCommand<UserSearchResource> gg = new GetCommand<UserSearchResource>(app, UserSearchResource.class, path, false,null) {
@Override
public void onComplete() {
final UserSearchResource result = getResult();
for (UserResource user : result.getUsers()){
String username = user.getUsername();
String userFullName = user.getName();
- Pithos.get().putUserToMap(username, userFullName);
+ app.putUserToMap(username, userFullName);
if(input.size() >= 1){
input.remove(input.get(0));
if(input.isEmpty()){
}
@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);
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;
containerPanel.hide();
if (resource instanceof Folder) {
- DeleteFolderDialog dlg = new DeleteFolderDialog(Pithos.get(), newImages, (Folder) resource);
+ DeleteFolderDialog dlg = new DeleteFolderDialog(app, newImages, (Folder) resource);
dlg.center();
} else if (resource instanceof List) {
- DeleteFileDialog dlg = new DeleteFileDialog(newImages, (List<File>) resource);
+ DeleteFileDialog dlg = new DeleteFileDialog(app, newImages, (List<File>) resource);
dlg.center();
}
}
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
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);
*/
private String userName;
- public GetUserCommand(String _userName){
+ private Pithos app;
+
+ public GetUserCommand(Pithos _app, String _userName){
+ app = _app;
userName = _userName;
}
@Override
public void execute() {
- String path = Pithos.get().getApiPath() + "users/" + userName;
- GetCommand<UserSearchResource> gg = new GetCommand<UserSearchResource>(UserSearchResource.class,
+ String path = app.getApiPath() + "users/" + userName;
+ GetCommand<UserSearchResource> gg = new GetCommand<UserSearchResource>(app, UserSearchResource.class,
path, false ,null) {
@Override
public void onComplete() {
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);
private List<GroupResource> groups = null;
+ private Pithos app;
+
/**
* @param aContainerPanel
* @param newImages the images of the new folder dialog
*/
- public NewFolderCommand(PopupPanel aContainerPanel, Folder folder, final Images newImages){
+ public NewFolderCommand(Pithos _app, PopupPanel aContainerPanel, Folder folder, final Images newImages){
+ app = _app;
containerPanel = aContainerPanel;
images=newImages;
this.folder = folder;
void displayNewFolderDialog() {
if (folder != null) {
- FolderPropertiesDialog dlg = new FolderPropertiesDialog(Pithos.get(), true, folder);
+ FolderPropertiesDialog dlg = new FolderPropertiesDialog(app, true, folder);
dlg.center();
}
}
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());
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;
}
@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);
//}
}
}
public void execute() {
containerPanel.hide();
//TODO:CELLTREE
- //Pithos.get().getFolders().update( Pithos.get().getFolders().getCurrent());
+ //app.getFolders().update( app.getFolders().getCurrent());
}
}
*/
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;
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
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);
final List<String> fileIds = new ArrayList<String>();
for(FileResource f : fdtos)
fileIds.add(f.getUri()+"?restore=");
- MultiplePostCommand rt = new MultiplePostCommand(fileIds.toArray(new String[0]), 200){
+ MultiplePostCommand rt = new MultiplePostCommand(app, fileIds.toArray(new String[0]), 200){
@Override
public void onComplete() {
//TODO:CELLTREE
- //Pithos.get().getFolders().update(Pithos.get().getFolders().getTrashItem());
- Pithos.get().showFileList(true);
+ //app.getFolders().update(app.getFolders().getTrashItem());
+ app.showFileList(true);
}
@Override
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
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);
trashFiles(iter, new Command() {
@Override
public void execute() {
- app.get().updateFolder(((List<File>) resource).get(0).getParent());
+ app.updateFolder(((List<File>) resource).get(0).getParent());
}
});
}
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());
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;
}
*/
private void displayNewFile() {
FileUploadDialog dlg = GWT.create(FileUploadDialog.class);
- dlg.setApp(Pithos.get());
+ dlg.setApp(app);
dlg.setFolder(folder);
dlg.center();
}
public class FolderTreeViewModel implements TreeViewModel {
+ private Pithos app;
+
private Cell<Folder> folderCell = new AbstractCell<Folder>(ContextMenuEvent.getType().getName()) {
@Override
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();
}
private SingleSelectionModel<Folder> selectionModel;
- public FolderTreeViewModel(SingleSelectionModel<Folder> selectionModel) {
+ public FolderTreeViewModel(Pithos _app, SingleSelectionModel<Folder> selectionModel) {
+ app = _app;
this.selectionModel = selectionModel;
}
}
private void fetchFolder(final Iterator<Folder> iter, final ListDataProvider<Folder> dataProvider, final Set<Folder> folders) {
- final Pithos app = Pithos.get();
if (iter.hasNext()) {
final Folder f = iter.next();
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());
f.setTrash(true);
f.setContainer("trash");
dataProvider.getList().add(f);
- Pithos.get().updateTags();
+ app.updateTags();
}
}
}
if (!folder.isTrash())
fetchFolder(folder, dataProvider);
else
- Pithos.get().showFiles(folder);
+ app.showFiles(folder);
}
public void fetchFolder(final Folder f, final ListDataProvider<Folder> dataProvider) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
- final Pithos app = Pithos.get();
String path = "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + f.getPrefix();
GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), app.getUsername(), path, f) {
@Override
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());
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;
boolean com = isComplete();
if(com){
if(isShowLoadingIndicator())
- Pithos.get().hideLoadingIndicator();
+ app.hideLoadingIndicator();
return false;
}
return true;
private static Map<RequestData, ResponseData> cache = new HashMap<RequestData, ResponseData>();
- public GetCommand(Class<T> theclass, String pathToGet, T theCached){
- this(theclass, pathToGet, true, theCached);
+ public GetCommand(Pithos _app, Class<T> theclass, String pathToGet, T theCached){
+ this(_app, theclass, pathToGet, true, theCached);
}
- public GetCommand(Class<T> theclass, String pathToGet, boolean showLoading, T theCached){
+ public GetCommand(Pithos _app, Class<T> theclass, String pathToGet, boolean showLoading, T theCached){
+ super(_app);
setShowLoadingIndicator(showLoading);
if(isShowLoadingIndicator())
- Pithos.get().showLoadingIndicator("Getting ",pathToGet);
+ app.showLoadingIndicator("Getting ",pathToGet);
this.aclass = theclass;
if(pathToGet.indexOf("?") != -1)
path = pathToGet;
this.cached = theCached;
}
- public GetCommand(Class<T> theclass, String aUsername , String pathToGet, T theCached){
- this(theclass, aUsername, pathToGet, true, theCached);
+ public GetCommand(Pithos _app, Class<T> theclass, String aUsername , String pathToGet, T theCached){
+ this(_app, theclass, aUsername, pathToGet, true, theCached);
}
- public GetCommand(Class<T> theclass, String aUsername , String pathToGet, boolean showLoading, T theCached){
+ public GetCommand(Pithos _app, Class<T> theclass, String aUsername , String pathToGet, boolean showLoading, T theCached){
+ super(_app);
setShowLoadingIndicator(showLoading);
if(isShowLoadingIndicator())
- Pithos.get().showLoadingIndicator("Getting ",pathToGet);
+ app.showLoadingIndicator("Getting ",pathToGet);
this.aclass = theclass;
path = fixPath(pathToGet);
this.username = aUsername;
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;
if(com){
if(isShowLoadingIndicator())
- Pithos.get().hideLoadingIndicator();
+ app.hideLoadingIndicator();
if(getResult() != null) {
// Add to cache
cache.put(key, new ResponseData(System.currentTimeMillis(), getResult()));
T cached;
final String path;
- public HeadCommand(Class<T> theclass, String pathToGet, T theCached){
- this(theclass, pathToGet, true, theCached);
+ public HeadCommand(Pithos _app, Class<T> theclass, String pathToGet, T theCached){
+ this(_app, theclass, pathToGet, true, theCached);
}
- public HeadCommand(Class<T> theClass, String pathToGet, boolean showLoading, T theCached){
+ public HeadCommand(Pithos _app, Class<T> theClass, String pathToGet, boolean showLoading, T theCached){
+ super(_app);
setShowLoadingIndicator(showLoading);
this.aclass = theClass;
if(isShowLoadingIndicator())
- Pithos.get().showLoadingIndicator("Getting ",pathToGet);
+ app.showLoadingIndicator("Getting ",pathToGet);
if(theClass.equals(FileResource.class))
path = pathToGet;
boolean com = isComplete();
if(com){
if(isShowLoadingIndicator())
- Pithos.get().hideLoadingIndicator();
+ app.hideLoadingIndicator();
if(getResult() != null)
onComplete();
else
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);
onError(p, errors.get(p));
onComplete();
if(isShowLoadingIndicator())
- Pithos.get().hideLoadingIndicator();
+ app.hideLoadingIndicator();
return false;
}
return true;
String[] paths;
private boolean requestSent=false;
- public MultipleGetCommand(Class<T> aNewClass, String[] pathToGet, Cached[] theCached) {
- this(aNewClass, pathToGet, true, theCached);
+ public MultipleGetCommand(Pithos _app, Class<T> aNewClass, String[] pathToGet, Cached[] theCached) {
+ this(_app, aNewClass, pathToGet, true, theCached);
}
- public MultipleGetCommand(Class<T> aNewClass, String[] pathToGet, boolean showLoading, Cached[] theCached) {
+ public MultipleGetCommand(Pithos _app, Class<T> aNewClass, String[] pathToGet, boolean showLoading, Cached[] theCached) {
+ super(_app);
setShowLoadingIndicator(showLoading);
if (isShowLoadingIndicator())
- Pithos.get().showLoadingIndicator("Getting "+pathToGet.length+" items", null);
+ app.showLoadingIndicator("Getting "+pathToGet.length+" items", null);
aclass = aNewClass;
paths = pathToGet;
this.cached = theCached;
requestSent=true;
if (cached!=null)
for (final Cached pathg : cached)
- DeferredCommand.addCommand(new GetCommand<T>(aclass,pathg.uri,false,(T)pathg.cache) {
+ DeferredCommand.addCommand(new GetCommand<T>(app, aclass,pathg.uri,false,(T)pathg.cache) {
@Override
public void onComplete() {
});
else
for (final String pathg : paths)
- DeferredCommand.addCommand(new GetCommand<T>(aclass,pathg,false,null) {
+ DeferredCommand.addCommand(new GetCommand<T>(app, aclass,pathg,false,null) {
@Override
public void onComplete() {
boolean com = isComplete();
if (com) {
if (isShowLoadingIndicator())
- Pithos.get().hideLoadingIndicator();
+ app.hideLoadingIndicator();
if (hasErrors())
for(String p : errors.keySet())
onError(p, errors.get(p));
+++ /dev/null
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.pithos.web.client.rest;
-
-import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.rest.MultipleGetCommand.Cached;
-import gr.grnet.pithos.web.client.rest.resource.FileResource;
-import gr.grnet.pithos.web.client.rest.resource.FolderResource;
-import gr.grnet.pithos.web.client.rest.resource.GroupResource;
-import gr.grnet.pithos.web.client.rest.resource.GroupUserResource;
-import gr.grnet.pithos.web.client.rest.resource.GroupsResource;
-import gr.grnet.pithos.web.client.rest.resource.RestResource;
-import gr.grnet.pithos.web.client.rest.resource.SharedResource;
-import gr.grnet.pithos.web.client.rest.resource.TrashResource;
-import gr.grnet.pithos.web.client.rest.resource.UserResource;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.user.client.DeferredCommand;
-
-
-public abstract class MultipleHeadCommand <T extends RestResource> extends RestCommand {
- String[] paths;
- Class<T> aclass;
- List<T> result = new ArrayList<T>();
- Map<String, Throwable> errors = new HashMap<String, Throwable>();
- private boolean requestSent=false;
- Cached[] cached;
-
- public MultipleHeadCommand(Class<T> theClass, String[] pathToGet, Cached[] theCached) {
- this(theClass, pathToGet, true, theCached);
- }
-
- public MultipleHeadCommand(Class<T> theClass, String[] pathToGet, boolean showLoading, Cached[] theCached) {
- setShowLoadingIndicator(showLoading);
- if(isShowLoadingIndicator())
- Pithos.get().showLoadingIndicator("Getting "+pathToGet.length+" items", null);
- paths = pathToGet;
- this.aclass = theClass;
- this.cached = theCached;
- //sendRequest();
- }
-
- private void sendRequest() {
- if(requestSent)
- return;
- requestSent=true;
- if(cached!=null)
- for (final Cached c : cached){
- final String path;
- if(aclass.equals(FileResource.class)){
- if(c.uri.indexOf("?") == -1)
- path=c.uri+"?"+Math.random();
- else
- path=c.uri;
- }
- else
- path = fixPath(c.uri);
- DeferredCommand.addCommand(new HeadCommand<T>(aclass,path,false, (T)c.cache) {
-
- @Override
- public void onComplete() {
- MultipleHeadCommand.this.result.add(getResult());
- }
-
- @Override
- public void onError(Throwable t) {
- errors.put(path, t);
- }
-
- });
- }
- else
- for (String pathg : paths) {
- final String path;
- if(aclass.equals(FileResource.class))
- path = pathg;
- else
- path = fixPath(pathg);
- DeferredCommand.addCommand(new HeadCommand<T>(aclass,path,false, null) {
- @Override
- public void onComplete() {
- MultipleHeadCommand.this.result.add(getResult());
- }
-
- @Override
- public void onError(Throwable t) {
- errors.put(path, t);
- }
- });
- }
- }
- public boolean isComplete() {
- return result.size()+errors.size() == paths.length;
- }
-
- public List<T> getResult() {
- return result;
- }
-
- @Override
- public boolean execute() {
- if(!requestSent)
- sendRequest();
- boolean com = isComplete();
- if (com) {
- if(isShowLoadingIndicator())
- Pithos.get().hideLoadingIndicator();
- if(hasErrors())
- for(String p : errors.keySet())
- onError(p, errors.get(p));
- onComplete();
- return false;
- }
- return true;
- }
-
- /**
- * @param p
- * @param throwable
- */
- public abstract void onError(String p, Throwable throwable);
-
- public Object deserializeResponse(String path, Response response) {
- RestResource result1 = null;
- if (aclass.equals(FolderResource.class)) {
- result1 = new FolderResource(path);
- result1.createFromJSON(response.getText());
- } else if (aclass.equals(FileResource.class)) {
- result1 = new FileResource(path);
- result1.createFromJSON(response.getHeader("X-Pithos-Metadata"));
- } else if (aclass.equals(GroupsResource.class)) {
- result1 = new GroupsResource(path);
- result1.createFromJSON(response.getText());
- } else if (aclass.equals(TrashResource.class)) {
- result1 = new TrashResource(path);
- result1.createFromJSON(response.getText());
- } else if (aclass.equals(SharedResource.class)) {
- result1 = new SharedResource(path);
- result1.createFromJSON(response.getText());
- } else if (aclass.equals(GroupResource.class)) {
- result1 = new GroupResource(path);
- result1.createFromJSON(response.getText());
- } else if (aclass.equals(GroupUserResource.class)) {
- result1 = new GroupUserResource(path);
- result1.createFromJSON(response.getText());
- } else if (aclass.equals(UserResource.class)) {
- result1 = new UserResource(path);
- result1.createFromJSON(response.getText());
- }
- return result1;
- }
-
- public boolean hasErrors(){
- return errors.size() >0;
- }
-
- /**
- * Retrieve the errors.
- *
- * @return the errors
- */
- public Map<String, Throwable> getErrors() {
- return errors;
- }
-
- public void debug(){
- GWT.log("--->"+result.size(), null);
- GWT.log("-ERRORS-->"+getErrors().size(), null);
- for(String p : getErrors().keySet())
- GWT.log("error:"+p, getErrors().get(p));
- }
-}
public abstract class MultiplePostCommand extends RestCommand {
-
Map<String, Throwable> errors = new HashMap<String, Throwable>();
List<String> successPaths = new ArrayList<String>();
String[] paths;
- public MultiplePostCommand(String[] pathToDelete, final int okStatusCode){
- this(pathToDelete, okStatusCode, true);
+ public MultiplePostCommand(Pithos app, String[] pathToDelete, final int okStatusCode){
+ this(app, pathToDelete, okStatusCode, true);
}
- public MultiplePostCommand(String[] pathToDelete, String data, final int okStatusCode){
- this(pathToDelete, data, okStatusCode, true);
+ public MultiplePostCommand(Pithos app, String[] pathToDelete, String data, final int okStatusCode){
+ this(app, pathToDelete, data, okStatusCode, true);
}
- public MultiplePostCommand(String[] pathToDelete, final int okStatusCode, boolean showLoading){
- this(pathToDelete, "", okStatusCode, showLoading);
+ public MultiplePostCommand(Pithos app, String[] pathToDelete, final int okStatusCode, boolean showLoading){
+ this(app, pathToDelete, "", okStatusCode, showLoading);
}
- public MultiplePostCommand(String[] pathToDelete, String data, final int okStatusCode, boolean showLoading){
+ public MultiplePostCommand(Pithos app, String[] pathToDelete, String data, final int okStatusCode, boolean showLoading){
+ super(app);
setShowLoadingIndicator(showLoading);
if(isShowLoadingIndicator())
- Pithos.get().showLoadingIndicator("Updating "+pathToDelete.length+" items", null);
+ app.showLoadingIndicator("Updating "+pathToDelete.length+" items", null);
paths = pathToDelete;
for (final String pathg : pathToDelete) {
GWT.log("[DEL]"+pathg, null);
onError(p, errors.get(p));
onComplete();
if(isShowLoadingIndicator())
- Pithos.get().hideLoadingIndicator();
+ app.hideLoadingIndicator();
return false;
}
return true;
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);
boolean com = isComplete();
if (com) {
if (isShowLoadingIndicator())
- Pithos.get().hideLoadingIndicator();
+ app.hideLoadingIndicator();
return false;
}
return true;
//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 = "";
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";
}
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()/*-{
showLoadingIndicator = newShowLoadingIndicator;
}
- static void sessionExpired() {
- SessionExpiredDialog dlg = new SessionExpiredDialog();
+ void sessionExpired() {
+ SessionExpiredDialog dlg = new SessionExpiredDialog(app);
dlg.center();
}
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;
private SingleSelectionModel<Tag> selectionModel;
- public TagTreeViewModel(SingleSelectionModel<Tag> selectionModel) {
+ private Pithos app;
+
+ public TagTreeViewModel(Pithos _app, SingleSelectionModel<Tag> selectionModel) {
+ app = _app;
this.selectionModel = selectionModel;
}
}
private void fetchTags(final Iterator<Folder> iter) {
- final Pithos app = Pithos.get();
if (iter.hasNext()) {
final Folder f = iter.next();
// 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());
}
public void fetchTag(Tag t) {
- Pithos app = Pithos.get();
AccountResource account = app.getAccount();
Iterator<Folder> iter = account.getContainers().iterator();
fetchTag(iter, t, new LinkedHashSet<File>());
}
private void fetchTag(final Iterator<Folder> iter, final Tag t, final Set<File> files) {
- final Pithos app = Pithos.get();
if (iter.hasNext()) {
Folder f = iter.next();
String path = f.getUri() + "?format=json&meta=" + t.getName();
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());