/*\r
- * Copyright 2011 GRNET S.A. All rights reserved.\r
+ * Copyright 2011-2012 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
*/\r
package gr.grnet.pithos.web.client;\r
\r
-import com.google.gwt.core.client.Scheduler;\r
import gr.grnet.pithos.web.client.MessagePanel.Images;\r
import gr.grnet.pithos.web.client.foldertree.File;\r
import gr.grnet.pithos.web.client.foldertree.Resource;\r
import java.util.List;\r
\r
import com.google.gwt.core.client.GWT;\r
+import com.google.gwt.core.client.Scheduler;\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.http.client.Response;\r
+import com.google.gwt.http.client.URL;\r
+import com.google.gwt.user.client.Command;\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.Anchor;\r
import com.google.gwt.user.client.ui.Button;\r
import com.google.gwt.user.client.ui.DialogBox;\r
import com.google.gwt.user.client.ui.HTML;\r
import com.google.gwt.user.client.ui.HasHorizontalAlignment;\r
-import com.google.gwt.user.client.ui.HorizontalPanel;\r
import com.google.gwt.user.client.ui.VerticalPanel;\r
\r
/**\r
public DeleteFileDialog(Pithos _app, Images images, List<File> _files) {\r
app = _app;\r
files = _files;\r
+ Anchor close = new Anchor();\r
+ close.addStyleName("close");\r
+ close.addClickHandler(new ClickHandler() {\r
+ \r
+ @Override\r
+ public void onClick(ClickEvent event) {\r
+ hide();\r
+ }\r
+ });\r
// Set the dialog's caption.\r
setText("Confirmation");\r
setAnimationEnabled(true);\r
+ setGlassEnabled(true);\r
+ setStyleName("pithos-DialogBox");\r
// Create a VerticalPanel to contain the label and the buttons.\r
VerticalPanel outer = new VerticalPanel();\r
- HorizontalPanel buttons = new HorizontalPanel();\r
+ outer.add(close);\r
+ \r
+ VerticalPanel inner = new VerticalPanel();\r
+ inner.addStyleName("inner");\r
\r
HTML text;\r
if (files.size() == 1)\r
else\r
text = new HTML("<table><tr><td>" + AbstractImagePrototype.create(images.warn()).getHTML() + "</td><td>" + "Are you sure you want to <b>permanently</b> delete the selected files?</td></tr></table>");\r
text.setStyleName("pithos-warnMessage");\r
- outer.add(text);\r
+ inner.add(text);\r
\r
// Create the 'Delete' button, along with a listener that hides the dialog\r
// when the button is clicked and deletes the file.\r
Button ok = new Button("Delete", new ClickHandler() {\r
@Override\r
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
+ public void onClick(ClickEvent event) {\r
deleteFiles();\r
hide();\r
}\r
});\r
- ok.getElement().setId("confirmation.ok");\r
- buttons.add(ok);\r
- buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER);\r
- // Create the 'Cancel' button, along with a listener that hides the\r
- // dialog when the button is clicked.\r
- Button cancel = new Button("Cancel", new ClickHandler() {\r
- @Override\r
- public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
- hide();\r
- }\r
- });\r
- cancel.getElement().setId("confirmation.cancel");\r
- buttons.add(cancel);\r
- buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);\r
- buttons.setSpacing(8);\r
- buttons.setStyleName("pithos-warnMessage");\r
- outer.setStyleName("pithos-warnMessage");\r
- outer.add(buttons);\r
- outer.setCellHorizontalAlignment(text, HasHorizontalAlignment.ALIGN_CENTER);\r
- outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);\r
+ ok.addStyleName("button");\r
+ inner.add(ok);\r
+ inner.setCellHorizontalAlignment(text, HasHorizontalAlignment.ALIGN_CENTER);\r
+ outer.add(inner);\r
+ outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);\r
setWidget(outer);\r
}\r
\r
if (iter.hasNext()) {\r
File f = iter.next();\r
String path = f.getUri();\r
- DeleteRequest deleteFile = new DeleteRequest(app.getApiPath(), f.getOwner(), path) {\r
+ DeleteRequest deleteFile = new DeleteRequest(app.getApiPath(), f.getOwner(), URL.encode(path)) {\r
@Override\r
- public void onSuccess(@SuppressWarnings("unused") Resource result) {\r
+ public void onSuccess(Resource result) {\r
deleteFile(iter);\r
}\r
\r
@Override\r
public void onError(Throwable t) {\r
GWT.log("", t);\r
+ app.setError(t);\r
if (t instanceof RestException) {\r
app.displayError("Unable to delete file: " + ((RestException) t).getHttpStatusText());\r
}\r
else\r
app.displayError("System error unable to delete file: "+t.getMessage());\r
}\r
+\r
+ @Override\r
+ protected void onUnauthorized(Response response) {\r
+ app.sessionExpired();\r
+ }\r
};\r
deleteFile.setHeader("X-Auth-Token", app.getToken());\r
Scheduler.get().scheduleDeferred(deleteFile);\r
}\r
else {\r
- app.updateFolder(files.get(0).getParent(), true, null);\r
+ app.updateFolder(files.get(0).getParent(), true, new Command() {\r
+ \r
+ @Override\r
+ public void execute() {\r
+ app.updateStatistics();\r
+ }\r
+ }, true);\r
}\r
}\r
\r