429: Workspace: uploading big files

Task-Url: https://support.d4science.org/issues/429

Fixed css to msg multiple file upload
Fixed bug on cancel upload

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@119654 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2015-10-13 09:16:50 +00:00
parent 0d02c0b4d2
commit 12f2c82ced
2 changed files with 18 additions and 12 deletions

View File

@ -111,7 +111,7 @@ public class DialogUpload extends ClosableDialog implements HasWorskpaceUploadNo
hpBottom.getElement().getStyle().setMarginTop(10, Unit.PX); hpBottom.getElement().getStyle().setMarginTop(10, Unit.PX);
if(uploadType.equals(UPLOAD_TYPE.File)){ if(uploadType.equals(UPLOAD_TYPE.File)){
HTML msg = new HTML("To select multiple files, press and hold down the Ctrl key, and then click each item <br/> that you want to select"); HTML msg = new HTML("<span>To select multiple files, press and hold down the Ctrl key,</span><span style='dispaly:block; margin-top:-5px'> and then click each item that you want to select</span>");
msg.getElement().getStyle().setFontSize(10, Unit.PX); msg.getElement().getStyle().setFontSize(10, Unit.PX);
hpBottom.add(msg); hpBottom.add(msg);
} }

View File

@ -34,6 +34,8 @@ public class UploaderProgressView {
private HTML html = new HTML(); private HTML html = new HTML();
private ProgressBar bar = new ProgressBar(); private ProgressBar bar = new ProgressBar();
private HandlerManager eventBus; private HandlerManager eventBus;
private boolean cancel = false;
private Image cancelImg = null;
/** /**
* Instantiates a new uploader progress view. * Instantiates a new uploader progress view.
@ -44,6 +46,9 @@ public class UploaderProgressView {
*/ */
public UploaderProgressView(WorkspaceUploaderItem uploader, final String fileName, HandlerManager eventBus) { public UploaderProgressView(WorkspaceUploaderItem uploader, final String fileName, HandlerManager eventBus) {
this.eventBus = eventBus; this.eventBus = eventBus;
cancelImg = WorkspaceUploaderResources.getImageCancel();
cancelImg.setTitle("Cancel upload");
cancelImg.addStyleName("cancel-upload");
String text = "<div><img src='"+WorkspaceUploaderResources.getImageLoading().getUrl()+"'>"; String text = "<div><img src='"+WorkspaceUploaderResources.getImageLoading().getUrl()+"'>";
String msg = StringUtil.ellipsize("Uploading "+fileName, MAX_CHARS, 0); String msg = StringUtil.ellipsize("Uploading "+fileName, MAX_CHARS, 0);
@ -66,7 +71,6 @@ public class UploaderProgressView {
* @param uploader the uploader * @param uploader the uploader
*/ */
public void update(WorkspaceUploaderItem uploader){ public void update(WorkspaceUploaderItem uploader){
String text; String text;
switch(uploader.getUploadStatus()){ switch(uploader.getUploadStatus()){
case COMPLETED: case COMPLETED:
@ -76,11 +80,12 @@ public class UploaderProgressView {
html.setHTML(text); html.setHTML(text);
html.setTitle(uploader.getStatusDescription()); html.setTitle(uploader.getStatusDescription());
bar.update(uploader.getUploadProgress().getLastEvent().getReadPercentage()); bar.update(uploader.getUploadProgress().getLastEvent().getReadPercentage());
try{
hp.remove(cancelImg);
}catch (Exception e) {}
try{ try{
vp.remove(bar); vp.remove(bar);
}catch (Exception e) { }catch (Exception e) {}
// TODO: handle exception
}
break; break;
case FAILED: case FAILED:
text = "<div><img src='"+WorkspaceUploaderResources.getImageFailed().getUrl()+"'>"; text = "<div><img src='"+WorkspaceUploaderResources.getImageFailed().getUrl()+"'>";
@ -92,14 +97,18 @@ public class UploaderProgressView {
break; break;
case IN_PROGRESS: case IN_PROGRESS:
text = "<div><img src='"+WorkspaceUploaderResources.getImageUpload().getUrl()+"'>"; text = "<div><img src='"+WorkspaceUploaderResources.getImageUpload().getUrl()+"'>";
String msg = StringUtil.ellipsize(uploader.getUploadProgress().getLastEvent().getReadPercentage()+"% "+uploader.getFile().getFileName(), MAX_CHARS, 0); String msg = StringUtil.ellipsize(uploader.getFile().getFileName(), MAX_CHARS, 0);
text+="<span style='margin-left:5px; vertical-align: top;'>"+msg+"</span>"; text+="<span style='margin-left:5px; vertical-align: top;'>"+msg+"</span>";
text+="</div>"; text+="</div>";
// GWT.log(text); // GWT.log(text);
html.setHTML(text); html.setHTML(text);
html.setTitle(uploader.getStatusDescription()); html.setTitle(uploader.getStatusDescription());
if(uploader.getUploadProgress().getLastEvent().getReadPercentage()!=100)
if(uploader.getUploadProgress().getLastEvent().getReadPercentage()!=100 && !cancel){
cancel = true;
hp.add(handleCancelUpload(uploader)); hp.add(handleCancelUpload(uploader));
}
bar.update(uploader.getUploadProgress().getLastEvent().getReadPercentage()); bar.update(uploader.getUploadProgress().getLastEvent().getReadPercentage());
break; break;
case WAIT: case WAIT:
@ -135,10 +144,7 @@ public class UploaderProgressView {
*/ */
private Image handleCancelUpload(final WorkspaceUploaderItem uploader){ private Image handleCancelUpload(final WorkspaceUploaderItem uploader){
Image cancel = WorkspaceUploaderResources.getImageCancel(); cancelImg.addClickHandler(new ClickHandler() {
cancel.setTitle("Cancel upload");
cancel.addStyleName("cancel-upload");
cancel.addClickHandler(new ClickHandler() {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
@ -156,7 +162,7 @@ public class UploaderProgressView {
} }
} }
}); });
return cancel; return cancelImg;
} }