diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/DialogUpload.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/DialogUpload.java index 30da0df..66b73be 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/DialogUpload.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/DialogUpload.java @@ -111,7 +111,7 @@ public class DialogUpload extends ClosableDialog implements HasWorskpaceUploadNo hpBottom.getElement().getStyle().setMarginTop(10, Unit.PX); 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
that you want to select"); + HTML msg = new HTML("To select multiple files, press and hold down the Ctrl key, and then click each item that you want to select"); msg.getElement().getStyle().setFontSize(10, Unit.PX); hpBottom.add(msg); } diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/UploaderProgressView.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/UploaderProgressView.java index a1d2fd8..3b1df0c 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/UploaderProgressView.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/UploaderProgressView.java @@ -34,6 +34,8 @@ public class UploaderProgressView { private HTML html = new HTML(); private ProgressBar bar = new ProgressBar(); private HandlerManager eventBus; + private boolean cancel = false; + private Image cancelImg = null; /** * Instantiates a new uploader progress view. @@ -44,6 +46,9 @@ public class UploaderProgressView { */ public UploaderProgressView(WorkspaceUploaderItem uploader, final String fileName, HandlerManager eventBus) { this.eventBus = eventBus; + cancelImg = WorkspaceUploaderResources.getImageCancel(); + cancelImg.setTitle("Cancel upload"); + cancelImg.addStyleName("cancel-upload"); String text = "
"; String msg = StringUtil.ellipsize("Uploading "+fileName, MAX_CHARS, 0); @@ -66,7 +71,6 @@ public class UploaderProgressView { * @param uploader the uploader */ public void update(WorkspaceUploaderItem uploader){ - String text; switch(uploader.getUploadStatus()){ case COMPLETED: @@ -76,11 +80,12 @@ public class UploaderProgressView { html.setHTML(text); html.setTitle(uploader.getStatusDescription()); bar.update(uploader.getUploadProgress().getLastEvent().getReadPercentage()); + try{ + hp.remove(cancelImg); + }catch (Exception e) {} try{ vp.remove(bar); - }catch (Exception e) { - // TODO: handle exception - } + }catch (Exception e) {} break; case FAILED: text = "
"; @@ -92,14 +97,18 @@ public class UploaderProgressView { break; case IN_PROGRESS: text = "
"; - 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+=""+msg+""; text+="
"; // GWT.log(text); html.setHTML(text); html.setTitle(uploader.getStatusDescription()); - if(uploader.getUploadProgress().getLastEvent().getReadPercentage()!=100) + + if(uploader.getUploadProgress().getLastEvent().getReadPercentage()!=100 && !cancel){ + cancel = true; hp.add(handleCancelUpload(uploader)); + } + bar.update(uploader.getUploadProgress().getLastEvent().getReadPercentage()); break; case WAIT: @@ -135,10 +144,7 @@ public class UploaderProgressView { */ private Image handleCancelUpload(final WorkspaceUploaderItem uploader){ - Image cancel = WorkspaceUploaderResources.getImageCancel(); - cancel.setTitle("Cancel upload"); - cancel.addStyleName("cancel-upload"); - cancel.addClickHandler(new ClickHandler() { + cancelImg.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { @@ -156,7 +162,7 @@ public class UploaderProgressView { } } }); - return cancel; + return cancelImg; }