Updated on stop of the tasks

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-csv-export-widget@92504 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-02-28 15:22:22 +00:00
parent 37fa122874
commit 97366a24aa
5 changed files with 85 additions and 16 deletions

View File

@ -13,7 +13,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>tabular-data-csv-export-widget</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.1-SNAPSHOT</version>
<name>tabular-data-csv-export-widget</name>
<description>tabular-data-csv-export-widget allows csv export inside file and workspace</description>

View File

@ -8,6 +8,7 @@ import org.gcube.portlets.user.td.csvexportwidget.client.progress.CSVExportProgr
import org.gcube.portlets.user.td.csvexportwidget.client.progress.CSVExportProgressUpdater;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import com.allen_sauer.gwt.log.client.Log;
@ -24,8 +25,6 @@ import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer.VBoxLayou
import com.sencha.gxt.widget.core.client.event.HideEvent;
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
/**
*
* @author "Giancarlo Panichi" <a
@ -33,7 +32,7 @@ import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
*
*/
public class CSVOperationInProgressCard extends WizardCard implements
CSVExportProgressListener {
CSVExportProgressListener {
public static final int STATUS_POLLING_DELAY = 1000;
protected CSVOperationInProgressCard thisCard;
@ -50,7 +49,7 @@ CSVExportProgressListener {
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);
@ -67,7 +66,6 @@ CSVExportProgressListener {
"<span style=\"font-weight:bold;\";>File Description: </span>");
description.setText(2, 1, exportSession.getFileDescription());
FramedPanel summary = new FramedPanel();
summary.setHeadingText("Export Summary");
summary.setWidth(400);
@ -80,26 +78,31 @@ CSVExportProgressListener {
new Margins(10, 5, 10, 5)));
progressUpdater = new CSVExportProgressUpdater();
progressUpdater.addListener(new CSVExportProgressBarUpdater(progressBar));
progressUpdater
.addListener(new CSVExportProgressBarUpdater(progressBar));
progressUpdater.addListener(this);
setContent(operationInProgressPanel);
}
//columnToImportMask
// columnToImportMask
public void exportCSV() {
TDGWTServiceAsync.INSTANCE.startCSVExport(exportSession, new AsyncCallback<Void>() {
TDGWTServiceAsync.INSTANCE.startCSVExport(exportSession,
new AsyncCallback<Void>() {
public void onSuccess(Void result) {
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
}
public void onFailure(Throwable caught) {
showErrorAndHide("Error in exportCSV",
"An error occured in exportCSV: "+caught.getLocalizedMessage(), caught.getStackTrace().toString(), caught);
showErrorAndHide(
"Error in exportCSV",
"An error occured in exportCSV: "
+ caught.getLocalizedMessage(), caught
.getStackTrace().toString(), caught);
}
});
}
@ -155,4 +158,29 @@ CSVExportProgressListener {
d.show();
}
@Override
public void operationStopped(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: tableId");
getWizardWindow().fireCompleted(null);
} catch (Exception e) {
Log.error("fire Complete :" + e.getLocalizedMessage());
}
}
};
getWizardWindow().setNextButtonCommand(sayComplete);
setNextButtonVisible(true);
getWizardWindow().setEnableNextButton(true);
}
}

View File

@ -6,6 +6,8 @@ package org.gcube.portlets.user.td.csvexportwidget.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;
@ -64,5 +66,12 @@ public class CSVExportProgressBarUpdater implements CSVExportProgressListener {
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");
}
}

View File

@ -3,6 +3,8 @@
*/
package org.gcube.portlets.user.td.csvexportwidget.client.progress;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
@ -38,4 +40,15 @@ public interface CSVExportProgressListener {
* @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);
}

View File

@ -7,13 +7,11 @@ import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportMonitor;
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;
/**
*
@ -69,7 +67,7 @@ public class CSVExportProgressUpdater extends Timer {
break;
case STOPPED:
cancel();
errorMessage(result);
stopMessage(result);
break;
case SUCCEDED:
cancel();
@ -105,6 +103,22 @@ public class CSVExportProgressUpdater extends Timer {
fireOperationFailed(th, failure, details);
}
protected void stopMessage(CSVExportMonitor result) {
Log.info("CSV Export Stopped");
String failure = null;
String details = null;
if (result.getError() != null) {
failure = "Stopped export csv";
details = result.getError().getLocalizedMessage();
} else {
failure = "Stopped export csv";
details = "Stopped export csv";
}
fireOperationStopped(result.getTrId(),failure, details);
}
protected String getStack(Throwable e) {
String message = e.getLocalizedMessage() + " -> <br>";
@ -134,6 +148,11 @@ public class CSVExportProgressUpdater extends Timer {
for (CSVExportProgressListener listener : listeners)
listener.operationFailed(caught, failure, failureDetails);
}
protected void fireOperationStopped(TRId trId, String reason, String details) {
for (CSVExportProgressListener listener : listeners)
listener.operationStopped(trId,reason, details);
}
/**
* Add a new {@link CSVExportProgressListener} to this