Updated on stop of the tasks
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-csv-import-widget@92511 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
6660c42fd3
commit
033abe9f58
2
pom.xml
2
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>tabular-data-csv-import-widget</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
|
||||
<name>tabular-data-csv-import-widget</name>
|
||||
<description>tabular-data-csv-import-widget allows csv import from file and workspace</description>
|
||||
|
|
|
@ -35,7 +35,7 @@ import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
|||
*
|
||||
*/
|
||||
public class CSVOperationInProgressCard extends WizardCard implements
|
||||
CSVImportProgressListener {
|
||||
CSVImportProgressListener {
|
||||
|
||||
public static final int STATUS_POLLING_DELAY = 1000;
|
||||
protected CSVOperationInProgressCard thisCard;
|
||||
|
@ -52,7 +52,7 @@ CSVImportProgressListener {
|
|||
operationInProgressPanel.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER);
|
||||
|
||||
final FlexTable description = new FlexTable();
|
||||
//FlexCellFormatter cellFormatter = description.getFlexCellFormatter();
|
||||
// FlexCellFormatter cellFormatter = description.getFlexCellFormatter();
|
||||
description.setCellSpacing(10);
|
||||
description.setCellPadding(4);
|
||||
description.setBorderWidth(0);
|
||||
|
@ -69,7 +69,6 @@ CSVImportProgressListener {
|
|||
"<span style=\"font-weight:bold;\";>File: </span>");
|
||||
description.setText(2, 1, importSession.getTabResource().getName());
|
||||
|
||||
|
||||
FramedPanel summary = new FramedPanel();
|
||||
summary.setHeadingText("Import Summary");
|
||||
summary.setWidth(400);
|
||||
|
@ -82,26 +81,31 @@ CSVImportProgressListener {
|
|||
new Margins(10, 5, 10, 5)));
|
||||
|
||||
progressUpdater = new CSVImportProgressUpdater();
|
||||
progressUpdater.addListener(new CSVImportProgressBarUpdater(progressBar));
|
||||
progressUpdater
|
||||
.addListener(new CSVImportProgressBarUpdater(progressBar));
|
||||
|
||||
progressUpdater.addListener(this);
|
||||
|
||||
setContent(operationInProgressPanel);
|
||||
|
||||
}
|
||||
//columnToImportMask
|
||||
|
||||
// columnToImportMask
|
||||
|
||||
public void importCSV() {
|
||||
TDGWTServiceAsync.INSTANCE.startCSVImport(importSession, new AsyncCallback<Void>() {
|
||||
|
||||
TDGWTServiceAsync.INSTANCE.startCSVImport(importSession,
|
||||
new AsyncCallback<Void>() {
|
||||
|
||||
public void onSuccess(Void result) {
|
||||
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
|
||||
}
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
showErrorAndHide("Error in importCSV",
|
||||
"An error occured in importCSV: "+caught.getLocalizedMessage(), caught.getStackTrace().toString(), caught);
|
||||
showErrorAndHide(
|
||||
"Error in importCSV",
|
||||
"An error occured in importCSV: "
|
||||
+ caught.getLocalizedMessage(), caught
|
||||
.getStackTrace().toString(), caught);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -116,7 +120,6 @@ CSVImportProgressListener {
|
|||
importCSV();
|
||||
}
|
||||
|
||||
|
||||
public void operationInitializing() {
|
||||
|
||||
}
|
||||
|
@ -149,7 +152,6 @@ CSVImportProgressListener {
|
|||
getWizardWindow().setEnableNextButton(true);
|
||||
}
|
||||
|
||||
|
||||
public void operationFailed(Throwable caught, String reason,
|
||||
String failureDetails) {
|
||||
AlertMessageBox d = new AlertMessageBox("Error in CSV Import", reason);
|
||||
|
@ -160,4 +162,30 @@ CSVImportProgressListener {
|
|||
d.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operationStopped(final TRId trId, String reason, String details) {
|
||||
// final String tableId,final String tableResourceId) {
|
||||
|
||||
Command sayComplete = new Command() {
|
||||
public void execute() {
|
||||
try {
|
||||
getWizardWindow().close(false);
|
||||
Log.info("fire Complete: tabular resource " + trId.getId());
|
||||
Log.info("fire Complete: tableId " + trId.getTableId());
|
||||
|
||||
getWizardWindow().fireCompleted(trId);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.error("fire Complete :" + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
getWizardWindow().setNextButtonCommand(sayComplete);
|
||||
|
||||
setNextButtonVisible(true);
|
||||
getWizardWindow().setEnableNextButton(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ public class CSVImportProgressBarUpdater implements CSVImportProgressListener {
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void operationComplete(TRId trId) {
|
||||
Log.info("Import completed");
|
||||
progressBar.updateProgress(1, "Import completed.");
|
||||
|
@ -44,16 +45,19 @@ public class CSVImportProgressBarUpdater implements CSVImportProgressListener {
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void operationFailed(Throwable caught, String reason, String failureDetails) {
|
||||
Log.info("Import failed");
|
||||
progressBar.updateText("Import failed.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operationInitializing() {
|
||||
Log.info("Inport Inizializing");
|
||||
progressBar.updateProgress(0, "Initializing...");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operationUpdate(float elaborated) {
|
||||
Log.info("Import elaborated: "+elaborated);
|
||||
if (elaborated == 0) progressBar.updateProgress(0, "Initializing...");
|
||||
|
@ -66,4 +70,12 @@ public class CSVImportProgressBarUpdater implements CSVImportProgressListener {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operationStopped(TRId trId,String reason, String details) {
|
||||
Log.debug("Operation Stopped: ["+trId.toString()+", "+reason+", "+details+"]");
|
||||
progressBar.updateText("Stopped");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -39,4 +39,14 @@ public interface CSVImportProgressListener {
|
|||
* @param reason the failure reason.
|
||||
*/
|
||||
public void operationFailed(Throwable caught, String reason, String failureDetails);
|
||||
|
||||
/**
|
||||
* Called when the operation is stopped
|
||||
*
|
||||
* @param trId
|
||||
* @param reason
|
||||
* @param details
|
||||
*/
|
||||
public void operationStopped(TRId trId, String reason, String details);
|
||||
|
||||
}
|
||||
|
|
|
@ -12,9 +12,6 @@ import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
|||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
|
||||
import com.sencha.gxt.widget.core.client.event.HideEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
||||
|
||||
/**
|
||||
* This {@link Timer} retrieves {@link OperationProgress} from the specified
|
||||
|
@ -68,7 +65,7 @@ public class CSVImportProgressUpdater extends Timer {
|
|||
break;
|
||||
case STOPPED:
|
||||
cancel();
|
||||
errorMessage(result);
|
||||
stopMessage(result);
|
||||
break;
|
||||
case FAILED:
|
||||
cancel();
|
||||
|
@ -109,6 +106,21 @@ public class CSVImportProgressUpdater extends Timer {
|
|||
|
||||
}
|
||||
|
||||
protected void stopMessage(CSVImportMonitor result) {
|
||||
Log.info("CSV Import Stopped");
|
||||
String failure = null;
|
||||
String details = null;
|
||||
if (result.getError() != null) {
|
||||
failure = "Stopped";
|
||||
details = result.getError().getLocalizedMessage();
|
||||
} else {
|
||||
failure = "Stopped";
|
||||
details = "Stopped import CSV";
|
||||
}
|
||||
|
||||
fireOperationStopped(result.getTrId(),failure, details);
|
||||
}
|
||||
|
||||
protected String getStack(Throwable e) {
|
||||
String message = e.getLocalizedMessage() + " -> <br>";
|
||||
Throwable c = e.getCause();
|
||||
|
@ -138,6 +150,11 @@ public class CSVImportProgressUpdater extends Timer {
|
|||
listener.operationFailed(caught, failure, failureDetails);
|
||||
}
|
||||
|
||||
protected void fireOperationStopped(TRId trId, String reason, String details) {
|
||||
for (CSVImportProgressListener listener : listeners)
|
||||
listener.operationStopped(trId,reason, details);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new {@link CSVImportProgressListener} to this
|
||||
* {@link CSVImportProgressUpdater}.
|
||||
|
|
Loading…
Reference in New Issue