You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.7 KiB
Java

/**
*
*/
package org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress;
import com.allen_sauer.gwt.log.client.Log;
import com.sencha.gxt.widget.core.client.ProgressBar;
/**
* Updates a {@link ProgressBar} progress and text based on {@link CodelistMappingImportProgressListener} events.
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class FileUploadProgressBarUpdater implements FileUploadProgressListener {
protected ProgressBar progressBar;
/**
* Creates a new {@link ProgressBar} updater.
* @param progressBar the {@link ProgressBar} to update.
*/
public FileUploadProgressBarUpdater(ProgressBar progressBar) {
this.progressBar = progressBar;
}
/**
* {@inheritDoc}
*/
public void operationComplete() {
Log.info("File upload complete");
progressBar.updateProgress(1, "File upload completed.");
}
/**
* {@inheritDoc}
*/
public void operationFailed(Throwable caught, String reason, String failureDetails) {
Log.info("File upload failed");
progressBar.updateText("File upload failed.");
}
public void operationInitializing() {
Log.info("File upload inizializing");
progressBar.updateProgress(0, "Initializing...");
}
public void operationUpdate(float elaborated) {
Log.info("File upload elaborated: "+elaborated);
if (elaborated == 0) progressBar.updateProgress(0, "Initializing...");
if (elaborated>0 && elaborated<1) {
Log.trace("progress "+elaborated);
int elab=new Float(elaborated*100).intValue();
progressBar.updateProgress(elaborated,elab+"% Uploading...");
}
if (elaborated == 1) progressBar.updateProgress(1, "Completed.");
}
}