Minor updated
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-sdmx-import-widget@84885 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
f40992a719
commit
8329a4061a
|
@ -21,16 +21,13 @@ import com.sencha.gxt.widget.core.client.ProgressBar;
|
||||||
public class ImportProgressBarUpdater implements OperationProgressListener {
|
public class ImportProgressBarUpdater implements OperationProgressListener {
|
||||||
|
|
||||||
protected ProgressBar progressBar;
|
protected ProgressBar progressBar;
|
||||||
//protected FramedPanel operationResult;
|
|
||||||
//protected WizardWindow wizardWindow;
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@link ProgressBar} updater.
|
* Creates a new {@link ProgressBar} updater.
|
||||||
* @param progressBar the {@link ProgressBar} to update.
|
* @param progressBar the {@link ProgressBar} to update.
|
||||||
*/
|
*/
|
||||||
public ImportProgressBarUpdater(ProgressBar progressBar) {
|
public ImportProgressBarUpdater(ProgressBar progressBar) {
|
||||||
this.progressBar = progressBar;
|
this.progressBar = progressBar;
|
||||||
//this.wizardWindow = w;
|
|
||||||
//this.operationResult = operationResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,21 +35,9 @@ public class ImportProgressBarUpdater implements OperationProgressListener {
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void operationComplete(TRId trId) {// TODO Auto-generated method stub
|
public void operationComplete(TRId trId) {
|
||||||
Log.info("Import complete");
|
Log.info("Import complete");
|
||||||
progressBar.updateProgress(1, "Import complete.");
|
progressBar.updateProgress(1, "Import complete.");
|
||||||
/*final FlexTable descriptionResult = new FlexTable();
|
|
||||||
descriptionResult.setCellSpacing(10);
|
|
||||||
descriptionResult.setCellPadding(4);
|
|
||||||
descriptionResult.setBorderWidth(0);
|
|
||||||
descriptionResult.setText(0, 0, "Result: ");
|
|
||||||
descriptionResult.setText(0, 1, "Import complete");
|
|
||||||
|
|
||||||
operationResult.add(descriptionResult);
|
|
||||||
operationResult.setVisible(true);
|
|
||||||
*/
|
|
||||||
//wizardWindow.setEnableNextButton(true);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,19 +53,19 @@ public class ImportProgressBarUpdater implements OperationProgressListener {
|
||||||
@Override
|
@Override
|
||||||
public void operationInitializing() {
|
public void operationInitializing() {
|
||||||
Log.info("Inport inizializing");
|
Log.info("Inport inizializing");
|
||||||
progressBar.updateProgress(0, "initializing...");
|
progressBar.updateProgress(0, "Initializing...");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void operationUpdate(float elaborated) {
|
public void operationUpdate(float elaborated) {
|
||||||
Log.info("Import elaborated: "+elaborated);
|
Log.info("Import elaborated: "+elaborated);
|
||||||
if (elaborated == 0) progressBar.updateProgress(0, "initializing...");
|
if (elaborated == 0) progressBar.updateProgress(0, "Initializing...");
|
||||||
if (elaborated>0 && elaborated<1) {
|
if (elaborated>0 && elaborated<1) {
|
||||||
Log.trace("progress "+elaborated);
|
Log.trace("progress "+elaborated);
|
||||||
int elab=new Float(elaborated*100).intValue();
|
int elab=new Float(elaborated*100).intValue();
|
||||||
progressBar.updateProgress(elaborated,elab+"% importing...");
|
progressBar.updateProgress(elaborated,elab+"% Importing...");
|
||||||
}
|
}
|
||||||
if (elaborated == 1) progressBar.updateProgress(1, "completing...");
|
if (elaborated == 1) progressBar.updateProgress(1, "Completed");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,11 @@ package org.gcube.portlets.user.td.sdmximportwidget.client.progress;
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.TRId;
|
import org.gcube.portlets.user.td.gwtservice.shared.TRId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a listener for operation progress.
|
* Defines a listener for operation progress.
|
||||||
*
|
*
|
||||||
* @author "Giancarlo Panichi"
|
* @author "Giancarlo Panichi" <a
|
||||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface OperationProgressListener {
|
public interface OperationProgressListener {
|
||||||
|
@ -23,11 +21,12 @@ public interface OperationProgressListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when there is a progress for the operation.
|
* Called when there is a progress for the operation.
|
||||||
* @param elaborated the elaborated part.
|
*
|
||||||
|
* @param elaborated
|
||||||
|
* the elaborated part.
|
||||||
*/
|
*/
|
||||||
public void operationUpdate(float elaborated);
|
public void operationUpdate(float elaborated);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the operation is complete.
|
* Called when the operation is complete.
|
||||||
*/
|
*/
|
||||||
|
@ -35,8 +34,12 @@ public interface OperationProgressListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the operation is failed.
|
* Called when the operation is failed.
|
||||||
* @param caught the failure exception.
|
*
|
||||||
* @param reason the failure reason.
|
* @param caught
|
||||||
|
* the failure exception.
|
||||||
|
* @param reason
|
||||||
|
* the failure reason.
|
||||||
*/
|
*/
|
||||||
public void operationFailed(Throwable caught, String reason, String failureDetails);
|
public void operationFailed(Throwable caught, String reason,
|
||||||
|
String failureDetails);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,43 +9,46 @@ import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.TRId;
|
import org.gcube.portlets.user.td.gwtservice.shared.TRId;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportMonitor;
|
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportMonitor;
|
||||||
|
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
import com.google.gwt.user.client.Timer;
|
import com.google.gwt.user.client.Timer;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This {@link Timer} retrieves {@link OperationProgress} from the specified {@link OperationProgressSource} with the scheduled interval.
|
* This {@link Timer} retrieves {@link OperationProgress} from the specified
|
||||||
* The retrieved information are spread to the subscribed {@link OperationProgressListener}.
|
* {@link OperationProgressSource} with the scheduled interval. The retrieved
|
||||||
|
* information are spread to the subscribed {@link OperationProgressListener}.
|
||||||
*
|
*
|
||||||
* @author "Giancarlo Panichi"
|
* @author "Giancarlo Panichi" <a
|
||||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class OperationProgressUpdater extends Timer {
|
public class OperationProgressUpdater extends Timer {
|
||||||
|
|
||||||
protected ArrayList<OperationProgressListener> listeners = new ArrayList<OperationProgressListener>();
|
protected ArrayList<OperationProgressListener> listeners = new ArrayList<OperationProgressListener>();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Log.debug("requesting operation progress");
|
Log.debug("requesting operation progress");
|
||||||
TDGWTServiceAsync.INSTANCE.getSDMXImportMonitor(new AsyncCallback<SDMXImportMonitor>() {
|
TDGWTServiceAsync.INSTANCE
|
||||||
|
.getSDMXImportMonitor(new AsyncCallback<SDMXImportMonitor>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
cancel();
|
cancel();
|
||||||
Log.error("Error retrieving the operation state", caught);
|
Log.error("Error retrieving the operation state",
|
||||||
|
caught);
|
||||||
String message = getStack(caught);
|
String message = getStack(caught);
|
||||||
fireOperationFailed(caught, "Failed getting operation updates", message);
|
fireOperationFailed(caught,
|
||||||
|
"Failed getting operation updates", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(SDMXImportMonitor result) {
|
public void onSuccess(SDMXImportMonitor result) {
|
||||||
Log.info("retrieved ImportMonitor: "+result.getStatus());
|
Log.info("retrieved ImportMonitor: "
|
||||||
|
+ result.getStatus());
|
||||||
switch (result.getStatus()) {
|
switch (result.getStatus()) {
|
||||||
case INITIALIZING:
|
case INITIALIZING:
|
||||||
Log.info("Initializing...");
|
Log.info("Initializing...");
|
||||||
|
@ -57,11 +60,14 @@ public class OperationProgressUpdater extends Timer {
|
||||||
case FAILED:
|
case FAILED:
|
||||||
cancel();
|
cancel();
|
||||||
Log.info("Import SDMX Failed");
|
Log.info("Import SDMX Failed");
|
||||||
fireOperationFailed(result.getError(),"Failed Client Library Import", result.getStatusDescription());
|
fireOperationFailed(result.getError(),
|
||||||
|
"Failed Client Library Import",
|
||||||
|
result.getStatusDescription());
|
||||||
break;
|
break;
|
||||||
case SUCCEDED:
|
case SUCCEDED:
|
||||||
cancel();
|
cancel();
|
||||||
Log.info("Import fisnish TableId :"+result.getTrId());
|
Log.info("Import fisnish TableId :"
|
||||||
|
+ result.getTrId());
|
||||||
fireOperationComplete(result.getTrId());
|
fireOperationComplete(result.getTrId());
|
||||||
break;
|
break;
|
||||||
case ABORTED:
|
case ABORTED:
|
||||||
|
@ -74,59 +80,58 @@ public class OperationProgressUpdater extends Timer {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getStack(Throwable e)
|
protected String getStack(Throwable e) {
|
||||||
{
|
String message = e.getLocalizedMessage() + " -> <br>";
|
||||||
String message = e.getLocalizedMessage()+" -> <br>";
|
|
||||||
Throwable c = e.getCause();
|
Throwable c = e.getCause();
|
||||||
if (c!=null) message += getStack(c);
|
if (c != null)
|
||||||
|
message += getStack(c);
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fireOperationInitializing()
|
protected void fireOperationInitializing() {
|
||||||
{
|
for (OperationProgressListener listener : listeners)
|
||||||
for (OperationProgressListener listener:listeners) listener.operationInitializing();
|
listener.operationInitializing();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fireOperationUpdate(float elaborated)
|
protected void fireOperationUpdate(float elaborated) {
|
||||||
{
|
for (OperationProgressListener listener : listeners)
|
||||||
for (OperationProgressListener listener:listeners) listener.operationUpdate(elaborated);
|
listener.operationUpdate(elaborated);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fireOperationComplete(TRId trId)
|
protected void fireOperationComplete(TRId trId) {
|
||||||
{
|
for (OperationProgressListener listener : listeners)
|
||||||
for (OperationProgressListener listener:listeners) listener.operationComplete(trId);
|
listener.operationComplete(trId);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fireOperationFailed(Throwable caught, String failure, String failureDetails)
|
protected void fireOperationFailed(Throwable caught, String failure,
|
||||||
{
|
String failureDetails) {
|
||||||
for (OperationProgressListener listener:listeners) listener.operationFailed(caught, failure, failureDetails);
|
for (OperationProgressListener listener : listeners)
|
||||||
|
listener.operationFailed(caught, failure, failureDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new {@link OperationProgressListener} to this {@link OperationProgressUpdater}.
|
* Add a new {@link OperationProgressListener} to this
|
||||||
* @param listener the listener to add.
|
* {@link OperationProgressUpdater}.
|
||||||
|
*
|
||||||
|
* @param listener
|
||||||
|
* the listener to add.
|
||||||
*/
|
*/
|
||||||
public void addListener(OperationProgressListener listener)
|
public void addListener(OperationProgressListener listener) {
|
||||||
{
|
|
||||||
listeners.add(listener);
|
listeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the specified {@link OperationProgressListener} from this {@link OperationProgressUpdater}.
|
* Removes the specified {@link OperationProgressListener} from this
|
||||||
* @param listener the listener to remove.
|
* {@link OperationProgressUpdater}.
|
||||||
|
*
|
||||||
|
* @param listener
|
||||||
|
* the listener to remove.
|
||||||
*/
|
*/
|
||||||
public void removeListener(OperationProgressListener listener)
|
public void removeListener(OperationProgressListener listener) {
|
||||||
{
|
|
||||||
listeners.remove(listener);
|
listeners.remove(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue