*/\r
package gr.grnet.pithos.web.client;\r
\r
-import com.google.gwt.core.client.Scheduler;\r
import com.google.gwt.event.dom.client.KeyDownEvent;\r
-import com.google.gwt.user.client.Event;\r
import gr.grnet.pithos.web.client.MessagePanel.Images;\r
import gr.grnet.pithos.web.client.foldertree.Folder;\r
-import gr.grnet.pithos.web.client.foldertree.Resource;\r
-import gr.grnet.pithos.web.client.rest.DeleteCommand;\r
-import gr.grnet.pithos.web.client.rest.DeleteRequest;\r
-import gr.grnet.pithos.web.client.rest.RestException;\r
-import gr.grnet.pithos.web.client.rest.resource.FolderResource;\r
-import gr.grnet.pithos.web.client.rest.resource.RestResource;\r
-import gr.grnet.pithos.web.client.rest.resource.RestResourceWrapper;\r
-import gr.grnet.pithos.web.client.rest.resource.TrashFolderResource;\r
\r
-import com.google.gwt.core.client.GWT;\r
import com.google.gwt.dom.client.NativeEvent;\r
import com.google.gwt.event.dom.client.ClickEvent;\r
import com.google.gwt.event.dom.client.ClickHandler;\r
import com.google.gwt.event.dom.client.KeyCodes;\r
-import com.google.gwt.user.client.DeferredCommand;\r
import com.google.gwt.user.client.Event.NativePreviewEvent;\r
import com.google.gwt.user.client.ui.AbstractImagePrototype;\r
import com.google.gwt.user.client.ui.Button;\r
*/\r
public class DeleteFolderDialog extends DialogBox {\r
\r
- private GSS app;\r
- private Folder folder;\r
+ protected Pithos app;\r
+ protected Folder folder;\r
\r
/**\r
* The widget's constructor.\r
* @param images the supplied images\r
*/\r
- public DeleteFolderDialog(GSS app, Images images, Folder folder) {\r
- this.app = app;\r
- this.folder = folder;\r
+ public DeleteFolderDialog(Pithos _app, Images images, Folder _folder) {\r
+ this.app = _app;\r
+ this.folder = _folder;\r
// Set the dialog's caption.\r
setText("Confirmation");\r
setAnimationEnabled(true);\r
// when the button is clicked and deletes the folder.\r
Button ok = new Button("Delete", new ClickHandler() {\r
@Override\r
- public void onClick(ClickEvent event) {\r
- deleteFolder();\r
+ public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
+ app.deleteFolder(folder);\r
hide();\r
}\r
});\r
// dialog when the button is clicked.\r
Button cancel = new Button("Cancel", new ClickHandler() {\r
@Override\r
- public void onClick(ClickEvent event) {\r
+ public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
hide();\r
}\r
});\r
setWidget(outer);\r
}\r
\r
- /**\r
- * Generate an RPC request to delete a folder.\r
- *\r
- */\r
- private void deleteFolder() {\r
- String prefix = folder.getPrefix();\r
- String path = app.getApiPath() + app.getUsername() + "/" + folder.getContainer() + (prefix.length() == 0 ? "" : "/" + prefix);\r
- DeleteRequest deleteFolder = new DeleteRequest(path) {\r
- @Override\r
- public void onSuccess(Resource result) {\r
- app.updateFolder(folder.getParent());\r
- }\r
-\r
- @Override\r
- public void onError(Throwable t) {\r
- GWT.log("", t);\r
- if (t instanceof RestException) {\r
- app.displayError("Unable to delete folder: "+((RestException) t).getHttpStatusText());\r
- }\r
- else\r
- GSS.get().displayError("System error unable to delete folder: " + t.getMessage());\r
- }\r
- };\r
- deleteFolder.setHeader("X-Auth-Token", app.getToken());\r
- Scheduler.get().scheduleDeferred(deleteFolder);\r
- }\r
-\r
@Override\r
protected void onPreviewNativeEvent(NativePreviewEvent preview) {\r
super.onPreviewNativeEvent(preview);\r
switch (evt.getKeyCode()) {\r
case KeyCodes.KEY_ENTER:\r
hide();\r
- deleteFolder();\r
+ app.deleteFolder(folder);\r
break;\r
case KeyCodes.KEY_ESCAPE:\r
hide();\r