X-Git-Url: https://code.grnet.gr/git/pithos/blobdiff_plain/a8ede55340853936950dea858cbff6fba4ddd851..f656aeb2ce96e9aac60b06d5eb231622d080e3be:/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..fa261c6 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", ""); @@ -249,8 +255,10 @@ public class FileUploadDialog extends DialogBox implements Updateable { return true; } - - 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 +444,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 +459,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()); } };