X-Git-Url: https://code.grnet.gr/git/pithos/blobdiff_plain/a8ede55340853936950dea858cbff6fba4ddd851..d3e41d001c5565e4ae62ee10b910509538f5c151:/src/gr/ebs/gss/client/FileUploadDialog.java
diff --git a/src/gr/ebs/gss/client/FileUploadDialog.java b/src/gr/ebs/gss/client/FileUploadDialog.java
index b3d8ad3..fbcbffa 100644
--- a/src/gr/ebs/gss/client/FileUploadDialog.java
+++ b/src/gr/ebs/gss/client/FileUploadDialog.java
@@ -44,6 +44,7 @@ import com.google.gwt.user.client.ui.FormPanel;
import com.google.gwt.user.client.ui.FormSubmitCompleteEvent;
import com.google.gwt.user.client.ui.FormSubmitEvent;
import com.google.gwt.user.client.ui.Grid;
+import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.Hidden;
import com.google.gwt.user.client.ui.HorizontalPanel;
@@ -59,7 +60,7 @@ public class FileUploadDialog extends DialogBox implements Updateable {
protected int prgBarInterval = 1500;
- protected ProgressBar progressBar;
+ private ProgressBar progressBar;
protected RepeatingTimer repeater = new RepeatingTimer(this, prgBarInterval);
@@ -97,6 +98,11 @@ public class FileUploadDialog extends DialogBox implements Updateable {
// Create a panel to hold all of the form widgets.
VerticalPanel panel = new VerticalPanel();
form.setWidget(panel);
+ final HTML info = new HTML("You may select a file to upload. Install" +
+ " Google " +
+ "Gears
for uploading multiple files simultaneously.");
+ info.addStyleName("gss-uploadNote");
+ panel.add(info);
final Hidden date = new Hidden("Date", "");
panel.add(date);
final Hidden auth = new Hidden("Authorization", "");
@@ -214,8 +220,7 @@ public class FileUploadDialog extends DialogBox implements Updateable {
GSS.get().displayError(results);
}
progressBar.setProgress(100);
- repeater.finish();
- hide();
+ cancelUpload();
GSS.get().showFileList(true);
GSS.get().getStatusPanel().updateStats();
}
@@ -241,16 +246,25 @@ public class FileUploadDialog extends DialogBox implements Updateable {
prepareAndSubmit();
break;
case KeyboardListener.KEY_ESCAPE:
- repeater.finish();
- hide();
+ cancelUpload();
break;
}
return true;
}
+ /**
+ * Cancels the file upload.
+ */
+ private void cancelUpload() {
+ repeater.finish();
+ hide();
+ }
- public void prepareAndSubmit(){
+ /**
+ * Make any last minute checks and start the upload.
+ */
+ public void prepareAndSubmit() {
final String fname = getFilename(upload.getFilename());
if (getFileForName(fname) == null) {
//we are going to create a file, so we check to see if there is a trashed file with the same name
@@ -436,6 +450,9 @@ public class FileUploadDialog extends DialogBox implements Updateable {
return filename + " " + i;
}
+ /**
+ * Rename the conflicting trashed file with the supplied new name.
+ */
private void updateTrashedFile(String newName, FileResource trashedFile) {
JSONObject json = new JSONObject();
json.put("name", new JSONString(newName));
@@ -448,21 +465,22 @@ public class FileUploadDialog extends DialogBox implements Updateable {
@Override
public void onError(Throwable t) {
+ GSS app = GSS.get();
GWT.log("", t);
if (t instanceof RestException) {
int statusCode = ((RestException) t).getHttpStatusCode();
if (statusCode == 405)
- GSS.get().displayError("You don't have the necessary permissions");
+ app.displayError("You don't have the necessary permissions");
else if (statusCode == 404)
- GSS.get().displayError("User in permissions does not exist");
+ app.displayError("User in permissions does not exist");
else if (statusCode == 409)
- GSS.get().displayError("A file with the same name already exists");
+ app.displayError("A file with the same name already exists");
else if (statusCode == 413)
- GSS.get().displayError("Your quota has been exceeded");
+ app.displayError("Your quota has been exceeded");
else
- GSS.get().displayError("Unable to modify file:" +((RestException)t).getHttpStatusText());
+ app.displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText());
} else
- GSS.get().displayError("System error modifying file:" + t.getMessage());
+ app.displayError("System error modifying file:" + t.getMessage());
}
};
@@ -481,11 +499,8 @@ public class FileUploadDialog extends DialogBox implements Updateable {
* Same as URL.encodeComponent, but also
* encode apostrophe since browsers aren't consistent about it
* (FF encodes, IE does not).
- *
- * @param decodedURLComponent
- * @return
*/
- protected String encodeComponent(String decodedURLComponent) {
+ private String encodeComponent(String decodedURLComponent) {
String retv = URL.encodeComponent(decodedURLComponent);
retv = retv.replaceAll("'", "%27");
return retv;