94 lines
1.9 KiB
Java
94 lines
1.9 KiB
Java
/**
|
|
*
|
|
*/
|
|
package org.gcube.portlets.user.workspace.client.view.windows;
|
|
|
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
|
import org.gcube.portlets.widgets.fileupload.client.view.UploadProgressDialog;
|
|
|
|
import com.extjs.gxt.ui.client.widget.Info;
|
|
import com.google.gwt.event.shared.HandlerManager;
|
|
|
|
/**
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
|
* @Jan 20, 2014
|
|
*
|
|
* This class calls the widget file uploader
|
|
*/
|
|
public class FileUploader {
|
|
|
|
|
|
private final UploadProgressDialog dlg;
|
|
private FileModel folderParent;
|
|
private UpdateServiceUploader updateServiceUploader;
|
|
private FileUploader INSTANCE = this;
|
|
private String uploadType;
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public FileUploader(HandlerManager eventBus, FileModel folderParent, String uploadType) {
|
|
this.folderParent = folderParent;
|
|
this.uploadType = uploadType;
|
|
|
|
/**
|
|
* Prepare new servlet uploader
|
|
*/
|
|
updateServiceUploader = new UpdateServiceUploader(INSTANCE, folderParent, uploadType);
|
|
|
|
this.dlg = new UploadProgressDialog("Upload File in: "+folderParent.getName(), eventBus, true);
|
|
dlg.center();
|
|
dlg.show();
|
|
}
|
|
|
|
|
|
public void submitForm() {
|
|
|
|
try {
|
|
|
|
dlg.submitForm();
|
|
|
|
} catch (Exception e) {
|
|
Info.display("Error", "Sorry an error occurred on the server "+e.getLocalizedMessage() + ". Please try again later");
|
|
e.printStackTrace();
|
|
}
|
|
|
|
}
|
|
|
|
public void overwrite(){
|
|
updateServiceUploader.setOverwrite();
|
|
}
|
|
|
|
public void submitServletForm(String absolutePathOnServer){
|
|
|
|
updateServiceUploader.setFileName(absolutePathOnServer);
|
|
|
|
try {
|
|
|
|
updateServiceUploader.submitForm();
|
|
|
|
} catch (Exception e) {
|
|
|
|
dlg.showRegisteringResult(false);
|
|
}
|
|
|
|
}
|
|
|
|
public FileModel getFolderParent() {
|
|
return folderParent;
|
|
}
|
|
|
|
public String getUploadType() {
|
|
return uploadType;
|
|
}
|
|
|
|
public UpdateServiceUploader getUpdateServiceUploader() {
|
|
return updateServiceUploader;
|
|
}
|
|
|
|
public UploadProgressDialog getDlg() {
|
|
return dlg;
|
|
}
|
|
|
|
}
|