Attach button disabled during progress upload

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@122571 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-01-27 16:49:48 +00:00
parent c7d0deca1b
commit 75fd148cea
1 changed files with 21 additions and 28 deletions

View File

@ -1,5 +1,4 @@
package org.gcube.portlets.user.shareupdates.client.view;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@ -26,7 +25,6 @@ import org.jsonmaker.gwt.client.Jsonizer;
import com.github.gwtbootstrap.client.ui.Button;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style.BorderStyle;
import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.dom.client.Style.FontWeight;
@ -82,7 +80,7 @@ public class ShareUpdateForm extends Composite {
private static final String DELETE_LINK_PREVIEW = "The link preview will be removed. Would you like to continue?";
private static final String DELETE_ATTACHMENTS = "The attachment(s) will be removed. Would you like to continue?";
private static final String TOO_MUCH_ATTACHMENT_ALERT = "Sorry, but you cannot upload more than " + MAX_NUMBER_ATTACHMENTS + " attachments!";
private static final String WAIT_CURRENT_UPLOAD_FINISHING = "Please, wait the current upload to finish";
// image urls
public static final String loading = GWT.getModuleBaseURL() + "../images/avatarLoader.gif";
public static final String avatar_default = GWT.getModuleBaseURL() + "../images/Avatar_default.png";
@ -309,27 +307,22 @@ public class ShareUpdateForm extends Composite {
return;
}
// check if an upload is happening
if(uploadProgress.isVisible()){
Window.alert(WAIT_CURRENT_UPLOAD_FINISHING);
return;
}
// proceed with the upload
FileUpload up = uploadProgress.initialize();
up.setVisible(false);
fileBrowse(up.getElement());
uploadProgress.setVisible(true);
attachButton.setEnabled(false);
// open the fileupload
up.click();
}
/**
* this simulates the click on the hidden native GWT FileUpload Button
* @param el
*/
public static native void fileBrowse(Element el) /*-{
el.click();
}-*/;
@UiHandler("submitButton")
void onClick(ClickEvent e) {
@ -460,7 +453,7 @@ public class ShareUpdateForm extends Composite {
else {
// publish a message with the refresh notification
try {
pageBusAdapter.PageBusPublish("org.gcube.portal.databook.shared", feed, (Jsonizer)GWT.create(ClientFeedJsonizer.class));
} catch (PageBusAdapterException ex) {
@ -498,7 +491,7 @@ public class ShareUpdateForm extends Composite {
@Override
public void onSuccess(ClientFeed feed) {
//GWT.log("Saved feed looks like " + feed.toString());
submitButton.setEnabled(true);
@ -671,7 +664,7 @@ public class ShareUpdateForm extends Composite {
// enable anyway the button
submitButton.setEnabled(true);
// enable attach button
attachButton.setEnabled(true);
}
@ -696,7 +689,7 @@ public class ShareUpdateForm extends Composite {
addPreviewAttachment(result, atPrev);
submitButton.setEnabled(true);
// enable attach button
attachButton.setEnabled(true);
}
@ -759,7 +752,7 @@ public class ShareUpdateForm extends Composite {
atPrev.setImagePreview(result.getImageUrls().get(0));
}
preview.add(atPrev);
// enable checkbox to save in workspace if it's the case
@ -890,7 +883,7 @@ public class ShareUpdateForm extends Composite {
// number of ignored files
var numberIgnoredFiles = 0;
// disable attach button
instance.@org.gcube.portlets.user.shareupdates.client.view.ShareUpdateForm::enableAttachButton(Z)(false);
@ -914,7 +907,7 @@ public class ShareUpdateForm extends Composite {
numberIgnoredFiles ++;
continue;
}
// create new progress bar
instance.@org.gcube.portlets.user.shareupdates.client.view.ShareUpdateForm::showProgressDND()();
@ -938,7 +931,7 @@ public class ShareUpdateForm extends Composite {
}
}
// enable attach button (the checFile method will do this...)
// alert the user that folder(s) can't be uploaded
@ -1150,15 +1143,15 @@ public class ShareUpdateForm extends Composite {
return Window.confirm(DELETE_LINK_PREVIEW);
}
/**
* Enables or disable the attach button
* @param enable
*/
private void enableAttachButton(boolean enable){
GWT.log("Enable attach button? " + enable);
attachButton.setEnabled(enable);
}
}