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.Command;
+import com.google.gwt.user.client.Cookies;
import com.google.gwt.user.client.Event.NativePreviewEvent;
+import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.FileUpload;
import com.google.gwt.user.client.ui.FormPanel.SubmitEvent;
import com.google.gwt.user.client.ui.FormPanel.SubmitHandler;
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;
/**
* The Form element that performs the file upload.
*/
- private final FormPanel form = new FormPanel();
+ protected final FormPanel form = new FormPanel();
private final FileUpload upload = new FileUpload();
* The widget's constructor.
*/
public FileUploadDialog() {
+ Anchor close = new Anchor();
+ close.addStyleName("close");
+ close.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ hide();
+ }
+ });
// Set the dialog's caption.
setText("File upload");
setAnimationEnabled(true);
+ setGlassEnabled(true);
+ setStyleName("pithos-DialogBox");
// Since we're going to add a FileUpload widget, we'll need to set the
// form to use the POST method, and multipart MIME encoding.
form.setEncoding(FormPanel.ENCODING_MULTIPART);
// Create a panel to hold all of the form widgets.
VerticalPanel panel = new VerticalPanel();
+ panel.add(close);
form.setWidget(panel);
- final HTML info = new HTML("You may select a file to upload. Install" +
- " <a href='http://gears.google.com/' target='_blank'>Google " +
- "Gears</a><br> for uploading multiple files simultaneously.");
- info.addStyleName("pithos-uploadNote");
- panel.add(info);
-
- final Hidden auth = new Hidden("X-Auth-Token", "");
- panel.add(auth);
+
+ VerticalPanel inner = new VerticalPanel();
+ inner.addStyleName("inner");
+
+ final Hidden auth = new Hidden("X-Auth-Token");
+ inner.add(auth);
upload.setName("X-Object-Data");
filenameLabel.setText("");
filenameLabel.setVisible(false);
generalTable.getCellFormatter().setStyleName(1, 1, "props-values");
generalTable.setCellSpacing(4);
- panel.add(generalTable);
-
- // Create a panel to hold the buttons.
- HorizontalPanel buttons = new HorizontalPanel();
+ inner.add(generalTable);
// Create the 'upload' button, along with a listener that submits the
// form.
prepareAndSubmit();
}
});
- buttons.add(submit);
- buttons.setCellHorizontalAlignment(submit, HasHorizontalAlignment.ALIGN_CENTER);
- // Create the 'Cancel' button, along with a listener that hides the
- // dialog when the button is clicked.
- final Button cancel = new Button("Cancel", new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- hide();
- }
- });
- buttons.add(cancel);
- buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);
- buttons.setSpacing(8);
- buttons.addStyleName("pithos-DialogBox");
- panel.add(buttons);
- panel.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);
+ submit.addStyleName("button");
+ inner.add(submit);
// Add an event handler to the form.
form.addSubmitHandler(new SubmitHandler() {
@Override
public void onSubmit(SubmitEvent event) {
auth.setValue(app.getToken()); //This is done here because the app object is not available in the constructor
+ Cookies.setCookie("X-Auth-Token", app.getToken(), null, "", "/", false);
}
});
form.addSubmitCompleteHandler(new SubmitCompleteHandler() {
GWT.log(results, null);
app.displayError(results);
}
- app.updateFolder(folder, true);
+ if (app.getSelectedTree().equals(app.getFolderTreeView()))
+ app.updateFolder(folder, true, new Command() {
+
+ @Override
+ public void execute() {
+ app.updateStatistics();
+ }
+ });
+ else
+ app.updateOtherSharedFolder(folder, true);
hide();
}
});
-
- panel.addStyleName("pithos-DialogBox");
- addStyleName("pithos-DialogBox");
+ panel.add(inner);
+ panel.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);
+
setWidget(form);
}
return;
}
final String fname = getFilename(upload.getFilename());
- String apath = app.getApiPath() + app.getUsername() + folder.getUri() + "/" + fname;
+ String apath = app.getApiPath() + folder.getOwner() + folder.getUri() + "/" + fname + "?X-Auth-Token=" + app.getToken();
form.setAction(apath);
submit.setEnabled(false);
upload.setVisible(false);
protected File getFileForName(String name){
for (File f : folder.getFiles())
- if (!f.isInTrash() && f.getName().equals(name))
+ if (f.getName().equals(name))
return f;
return null;
}