/** * */ package org.gcube.portlets.user.td.informationwidget.client.progress; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import com.allen_sauer.gwt.log.client.Log; import com.sencha.gxt.widget.core.client.ProgressBar; /** * * @author "Giancarlo Panichi" * g.panichi@isti.cnr.it * */ public class ChangeTableTypeProgressBarUpdater implements ChangeTableTypeProgressListener { protected ProgressBar progressBar; /** * Creates a new {@link ProgressBar} updater. * @param progressBar the {@link ProgressBar} to update. */ public ChangeTableTypeProgressBarUpdater(ProgressBar progressBar) { this.progressBar = progressBar; } /** * {@inheritDoc} */ public void operationComplete(TRId trId) { Log.info("Completed"); progressBar.updateProgress(1, "Completed"); } /** * {@inheritDoc} */ public void operationFailed(Throwable caught, String reason, String failureDetails) { Log.info("Failed"); progressBar.updateText("Failed"); } public void operationInitializing() { Log.info("Inizializing"); progressBar.updateProgress(0, "Initializing..."); } public void operationUpdate(float elaborated) { Log.info("Import 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+"% Progress..."); } if (elaborated == 1) progressBar.updateProgress(1, "Completing..."); } @Override public void operationStopped(TRId trId,String reason, String details) { Log.debug("Operation Stopped: ["+trId.toString()+", "+reason+", "+details+"]"); progressBar.updateText("Stopped"); } }