From f52cd6a6a63fc6a707b2424b5c041b58e6a9ed14 Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Thu, 28 Jan 2016 12:55:35 +0000 Subject: [PATCH] Fixed attach button behaviour while uploading a file. git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@122591 82a268e6-3cf1-43bd-a215-b396298e98cf --- .settings/org.eclipse.wst.common.component | 6 ---- .../client/view/ShareUpdateForm.java | 30 +++++++++---------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index cfc5846..adde6d9 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -4,12 +4,6 @@ - - uses - - - uses - diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.java b/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.java index aef2dbe..d24cf39 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.java @@ -30,6 +30,8 @@ import com.google.gwt.dom.client.Style.Display; import com.google.gwt.dom.client.Style.FontWeight; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Visibility; +import com.google.gwt.event.dom.client.ChangeEvent; +import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.DragLeaveEvent; import com.google.gwt.event.dom.client.DragLeaveHandler; @@ -307,21 +309,23 @@ public class ShareUpdateForm extends Composite { return; } - - // check if an upload is already running - if(uploadProgress.isVisible()){ - - Window.alert(WAIT_CURRENT_UPLOAD_FINISHING); - return; - } // proceed with the upload FileUpload up = uploadProgress.initialize(); - up.setVisible(false); - uploadProgress.setVisible(true); - - // open the fileupload up.click(); + up.setVisible(false); + + // disable attach button when users select a file + up.addChangeHandler(new ChangeHandler() { + + @Override + public void onChange(ChangeEvent event) { + attachButton.setEnabled(false); + } + }); + + uploadProgress.setVisible(true); + } @UiHandler("submitButton") @@ -638,10 +642,6 @@ public class ShareUpdateForm extends Composite { // create temp view of the attached file and add to the previewer final AttachmentPreviewer atPrev = new AttachmentPreviewer(fileName, attachedDefaultImageUrl, preview, this); - //preview.add(atPrev); - - // disable the submit button till we know the result of the upload process - submitButton.setEnabled(false); shareupdateService.checkUploadedFile(fileName, absolutePathOnServer, new AsyncCallback() { public void onFailure(Throwable caught) {