162 lines
4.7 KiB
Java
162 lines
4.7 KiB
Java
/**
|
|
*
|
|
*/
|
|
package org.gcube.portlets.user.sdmxexportwizardtd.client;
|
|
|
|
import org.gcube.portlets.user.sdmxexportwizardtd.client.general.WizardCard;
|
|
import org.gcube.portlets.user.sdmxexportwizardtd.client.progress.ImportProgressBarUpdater;
|
|
import org.gcube.portlets.user.sdmxexportwizardtd.client.progress.OperationProgressListener;
|
|
import org.gcube.portlets.user.sdmxexportwizardtd.client.progress.OperationProgressUpdater;
|
|
import org.gcube.portlets.user.sdmxexportwizardtd.client.rpc.SDMXExportWizardServiceAsync;
|
|
import org.gcube.portlets.user.sdmxexportwizardtd.client.source.SDMXRegistrySource;
|
|
import org.gcube.portlets.user.sdmxexportwizardtd.shared.SDMXExportSession;
|
|
import org.gcube.portlets.user.td.gxtservice.shared.TRId;
|
|
|
|
|
|
import com.allen_sauer.gwt.log.client.Log;
|
|
import com.google.gwt.user.client.Command;
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
import com.google.gwt.user.client.ui.FlexTable;
|
|
import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
|
|
import com.google.gwt.user.client.ui.HasVerticalAlignment;
|
|
import com.sencha.gxt.core.client.util.Margins;
|
|
import com.sencha.gxt.widget.core.client.FramedPanel;
|
|
import com.sencha.gxt.widget.core.client.ProgressBar;
|
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
|
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer;
|
|
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer.VBoxLayoutAlign;
|
|
|
|
//import com.allen_sauer.gwt.log.client.Log;
|
|
//import com.google.gwt.user.client.Command;
|
|
|
|
/**
|
|
*
|
|
* @author "Giancarlo Panichi"
|
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
*
|
|
*/
|
|
public class SDMXOperationInProgressCard extends WizardCard
|
|
implements OperationProgressListener {
|
|
|
|
public static final int STATUS_POLLING_DELAY = 1000;
|
|
protected SDMXOperationInProgressCard thisCard;
|
|
protected SDMXExportSession importSession;
|
|
protected OperationProgressUpdater progressUpdater;
|
|
|
|
|
|
|
|
public SDMXOperationInProgressCard(final SDMXExportSession importSession) {
|
|
super("Operation In Progress", "");
|
|
|
|
this.importSession = importSession;
|
|
thisCard=this;
|
|
|
|
VBoxLayoutContainer operationInProgressPanel = new VBoxLayoutContainer();
|
|
operationInProgressPanel.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER);
|
|
|
|
final FlexTable description = new FlexTable();
|
|
FlexCellFormatter cellFormatter = description.getFlexCellFormatter();
|
|
description.setCellSpacing(10);
|
|
description.setCellPadding(4);
|
|
description.setBorderWidth(0);
|
|
|
|
|
|
|
|
FramedPanel summary = new FramedPanel();
|
|
summary.setHeadingText("Import Summary");
|
|
summary.setWidth(400);
|
|
summary.add(description);
|
|
operationInProgressPanel.add(summary, new BoxLayoutData(new Margins(20,5,10,5)));
|
|
|
|
ProgressBar progressBar = new ProgressBar();
|
|
operationInProgressPanel.add(progressBar, new BoxLayoutData(new Margins(10,5,10,5)));
|
|
|
|
progressUpdater = new OperationProgressUpdater();
|
|
progressUpdater.addListener(new ImportProgressBarUpdater(progressBar));
|
|
|
|
progressUpdater.addListener(this);
|
|
|
|
setContent(operationInProgressPanel);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void exportSDMX()
|
|
{
|
|
SDMXExportWizardServiceAsync.INSTANCE.exportSDMXClientLibraryRequest(importSession, new AsyncCallback<Void>() {
|
|
|
|
@Override
|
|
public void onSuccess(Void result) {
|
|
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
showErrorAndHide("Error in exportSDMX", "An error occured in exportSDMX", "", caught);
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
@Override
|
|
public void setup(){
|
|
getWizardWindow().setEnableBackButton(false);
|
|
setBackButtonVisible(false);
|
|
setNextButtonVisible(false);
|
|
getWizardWindow().setEnableNextButton(false);
|
|
getWizardWindow().setNextButtonToFinish();
|
|
exportSDMX();
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
public void operationInitializing() {
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
public void operationUpdate(float elaborated) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void operationComplete(final TRId trId){
|
|
// 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);
|
|
}
|
|
|
|
|
|
@Override
|
|
public void operationFailed(Throwable caught, String reason,
|
|
String failureDetails) {
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|