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:
parent
c7d0deca1b
commit
75fd148cea
|
@ -1,5 +1,4 @@
|
||||||
package org.gcube.portlets.user.shareupdates.client.view;
|
package org.gcube.portlets.user.shareupdates.client.view;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -26,7 +25,6 @@ import org.jsonmaker.gwt.client.Jsonizer;
|
||||||
import com.github.gwtbootstrap.client.ui.Button;
|
import com.github.gwtbootstrap.client.ui.Button;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.dom.client.Document;
|
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.BorderStyle;
|
||||||
import com.google.gwt.dom.client.Style.Display;
|
import com.google.gwt.dom.client.Style.Display;
|
||||||
import com.google.gwt.dom.client.Style.FontWeight;
|
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_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 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 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
|
// image urls
|
||||||
public static final String loading = GWT.getModuleBaseURL() + "../images/avatarLoader.gif";
|
public static final String loading = GWT.getModuleBaseURL() + "../images/avatarLoader.gif";
|
||||||
public static final String avatar_default = GWT.getModuleBaseURL() + "../images/Avatar_default.png";
|
public static final String avatar_default = GWT.getModuleBaseURL() + "../images/Avatar_default.png";
|
||||||
|
@ -309,27 +307,22 @@ public class ShareUpdateForm extends Composite {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if an upload is happening
|
||||||
|
if(uploadProgress.isVisible()){
|
||||||
|
|
||||||
|
Window.alert(WAIT_CURRENT_UPLOAD_FINISHING);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// proceed with the upload
|
// proceed with the upload
|
||||||
FileUpload up = uploadProgress.initialize();
|
FileUpload up = uploadProgress.initialize();
|
||||||
up.setVisible(false);
|
up.setVisible(false);
|
||||||
fileBrowse(up.getElement());
|
|
||||||
uploadProgress.setVisible(true);
|
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")
|
@UiHandler("submitButton")
|
||||||
void onClick(ClickEvent e) {
|
void onClick(ClickEvent e) {
|
||||||
|
|
||||||
|
@ -460,7 +453,7 @@ public class ShareUpdateForm extends Composite {
|
||||||
else {
|
else {
|
||||||
// publish a message with the refresh notification
|
// publish a message with the refresh notification
|
||||||
try {
|
try {
|
||||||
|
|
||||||
pageBusAdapter.PageBusPublish("org.gcube.portal.databook.shared", feed, (Jsonizer)GWT.create(ClientFeedJsonizer.class));
|
pageBusAdapter.PageBusPublish("org.gcube.portal.databook.shared", feed, (Jsonizer)GWT.create(ClientFeedJsonizer.class));
|
||||||
|
|
||||||
} catch (PageBusAdapterException ex) {
|
} catch (PageBusAdapterException ex) {
|
||||||
|
@ -498,7 +491,7 @@ public class ShareUpdateForm extends Composite {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(ClientFeed feed) {
|
public void onSuccess(ClientFeed feed) {
|
||||||
|
|
||||||
//GWT.log("Saved feed looks like " + feed.toString());
|
//GWT.log("Saved feed looks like " + feed.toString());
|
||||||
|
|
||||||
submitButton.setEnabled(true);
|
submitButton.setEnabled(true);
|
||||||
|
@ -671,7 +664,7 @@ public class ShareUpdateForm extends Composite {
|
||||||
|
|
||||||
// enable anyway the button
|
// enable anyway the button
|
||||||
submitButton.setEnabled(true);
|
submitButton.setEnabled(true);
|
||||||
|
|
||||||
// enable attach button
|
// enable attach button
|
||||||
attachButton.setEnabled(true);
|
attachButton.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
@ -696,7 +689,7 @@ public class ShareUpdateForm extends Composite {
|
||||||
|
|
||||||
addPreviewAttachment(result, atPrev);
|
addPreviewAttachment(result, atPrev);
|
||||||
submitButton.setEnabled(true);
|
submitButton.setEnabled(true);
|
||||||
|
|
||||||
// enable attach button
|
// enable attach button
|
||||||
attachButton.setEnabled(true);
|
attachButton.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
@ -759,7 +752,7 @@ public class ShareUpdateForm extends Composite {
|
||||||
atPrev.setImagePreview(result.getImageUrls().get(0));
|
atPrev.setImagePreview(result.getImageUrls().get(0));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
preview.add(atPrev);
|
preview.add(atPrev);
|
||||||
|
|
||||||
// enable checkbox to save in workspace if it's the case
|
// enable checkbox to save in workspace if it's the case
|
||||||
|
@ -890,7 +883,7 @@ public class ShareUpdateForm extends Composite {
|
||||||
|
|
||||||
// number of ignored files
|
// number of ignored files
|
||||||
var numberIgnoredFiles = 0;
|
var numberIgnoredFiles = 0;
|
||||||
|
|
||||||
// disable attach button
|
// disable attach button
|
||||||
instance.@org.gcube.portlets.user.shareupdates.client.view.ShareUpdateForm::enableAttachButton(Z)(false);
|
instance.@org.gcube.portlets.user.shareupdates.client.view.ShareUpdateForm::enableAttachButton(Z)(false);
|
||||||
|
|
||||||
|
@ -914,7 +907,7 @@ public class ShareUpdateForm extends Composite {
|
||||||
numberIgnoredFiles ++;
|
numberIgnoredFiles ++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create new progress bar
|
// create new progress bar
|
||||||
instance.@org.gcube.portlets.user.shareupdates.client.view.ShareUpdateForm::showProgressDND()();
|
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...)
|
// enable attach button (the checFile method will do this...)
|
||||||
|
|
||||||
// alert the user that folder(s) can't be uploaded
|
// 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);
|
return Window.confirm(DELETE_LINK_PREVIEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables or disable the attach button
|
* Enables or disable the attach button
|
||||||
* @param enable
|
* @param enable
|
||||||
*/
|
*/
|
||||||
private void enableAttachButton(boolean enable){
|
private void enableAttachButton(boolean enable){
|
||||||
|
|
||||||
GWT.log("Enable attach button? " + enable);
|
GWT.log("Enable attach button? " + enable);
|
||||||
attachButton.setEnabled(enable);
|
attachButton.setEnabled(enable);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue