Updated Export SDMX
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-sdmx-export-widget@86536 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1de1a9a86c
commit
43eff8205a
2
pom.xml
2
pom.xml
|
@ -112,7 +112,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>tabular-data-gwt-service</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<!-- tabular-data-wizard-widget -->
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Agencies;
|
||||
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies;
|
||||
|
||||
import com.google.gwt.editor.client.Editor.Path;
|
||||
import com.sencha.gxt.core.client.ValueProvider;
|
||||
|
|
|
@ -8,7 +8,8 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Agencies;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies;
|
||||
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Codelist;
|
||||
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist;
|
||||
|
||||
import com.google.gwt.editor.client.Editor.Path;
|
||||
import com.sencha.gxt.core.client.ValueProvider;
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Codelist;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Dataset;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset;
|
||||
|
||||
import com.google.gwt.editor.client.Editor.Path;
|
||||
import com.sencha.gxt.core.client.ValueProvider;
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Dataset;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Agencies;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
|
||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||
|
@ -21,7 +21,7 @@ public class SDMXAgenciesSelectionCard extends WizardCard {
|
|||
protected SDMXAgenciesSelectionCard thisCard;
|
||||
protected SDMXExportSession exportSession;
|
||||
protected AgenciesSelectionPanel agenciesSelectionPanel;
|
||||
protected Agencies selectedAgencies=null;
|
||||
protected Agencies agency;
|
||||
|
||||
public SDMXAgenciesSelectionCard(final SDMXExportSession exportSession) {
|
||||
super("SDMX Agencies selection", "");
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Agencies;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
@ -37,8 +38,8 @@ public class SDMXAgencyTypeCard extends WizardCard {
|
|||
exportSession.setAgency(agency);
|
||||
|
||||
VerticalPanel selectionPanel = new VerticalPanel();
|
||||
selectionPanel.setStylePrimaryName(res.sdmxExportCss()
|
||||
.getExportSelectionSources());
|
||||
selectionPanel.setStylePrimaryName(res.wizardCSS()
|
||||
.getImportSelectionSource());
|
||||
|
||||
Radio radioSDMXAgencyPresent = new Radio();
|
||||
|
||||
|
@ -46,15 +47,15 @@ public class SDMXAgencyTypeCard extends WizardCard {
|
|||
.setBoxLabel("<p style='display:inline-table;'><b>Agencies Present</b><br>Select from the agencies already present in the registry</p>");
|
||||
radioSDMXAgencyPresent.setValue(true);
|
||||
radioSDMXAgencyPresent.setName("present");
|
||||
radioSDMXAgencyPresent.setStylePrimaryName(res.sdmxExportCss()
|
||||
.getExportSelectionSource());
|
||||
radioSDMXAgencyPresent.setStylePrimaryName(res.wizardCSS()
|
||||
.getImportSelectionSource());
|
||||
|
||||
Radio radioSDMXAgencyNew = new Radio();
|
||||
radioSDMXAgencyNew
|
||||
.setBoxLabel("<p style='display:inline-table;'><b>New Agencies</b><br>Creates a new agency in the registry</p>");
|
||||
radioSDMXAgencyNew.setName("new");
|
||||
radioSDMXAgencyNew.setStylePrimaryName(res.sdmxExportCss()
|
||||
.getExportSelectionSource());
|
||||
radioSDMXAgencyNew.setStylePrimaryName(res.wizardCSS()
|
||||
.getImportSelectionSource());
|
||||
|
||||
selectionPanel.add(radioSDMXAgencyPresent);
|
||||
selectionPanel.add(radioSDMXAgencyNew);
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Codelist;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
@ -21,13 +22,13 @@ import com.google.gwt.user.client.Command;
|
|||
public class SDMXCodelistSelectionCard extends WizardCard {
|
||||
|
||||
protected SDMXCodelistSelectionCard thisCard;
|
||||
protected SDMXExportSession importSession;
|
||||
protected SDMXExportSession exportSession;
|
||||
protected CodelistSelectionPanel codelistSelectionPanel;
|
||||
protected Codelist selectedCodelist=null;
|
||||
public SDMXCodelistSelectionCard(final SDMXExportSession importSession) {
|
||||
protected Codelist codelist;
|
||||
public SDMXCodelistSelectionCard(final SDMXExportSession exportSession) {
|
||||
super("SDMX Codelist selection", "");
|
||||
|
||||
this.importSession = importSession;
|
||||
this.exportSession = exportSession;
|
||||
thisCard=this;
|
||||
|
||||
this.codelistSelectionPanel=new CodelistSelectionPanel(res);
|
||||
|
@ -36,7 +37,7 @@ public class SDMXCodelistSelectionCard extends WizardCard {
|
|||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Codelist> event) {
|
||||
importSession.setSelectedCodelist(codelistSelectionPanel.getSelectedItem());
|
||||
//exportSession.setSelectedCodelist(codelistSelectionPanel.getSelectedItem());
|
||||
getWizardWindow().setEnableNextButton(true);
|
||||
}
|
||||
|
||||
|
@ -54,13 +55,13 @@ public class SDMXCodelistSelectionCard extends WizardCard {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
SDMXTableDetailCard sdmxTableDetailCard = new SDMXTableDetailCard(
|
||||
importSession);
|
||||
/*SDMXTableDetailCard sdmxTableDetailCard = new SDMXTableDetailCard(
|
||||
exportSession);
|
||||
getWizardWindow()
|
||||
.addCard(sdmxTableDetailCard);
|
||||
Log.info("NextCard SDMXTableDetailCard");
|
||||
getWizardWindow().nextCard();
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -18,7 +18,7 @@ import com.google.gwt.user.client.Command;
|
|||
public class SDMXDatasetSelectionCard extends WizardCard {
|
||||
|
||||
protected SDMXDatasetSelectionCard thisCard;
|
||||
protected SDMXExportSession importSession;
|
||||
protected SDMXExportSession exportSession;
|
||||
protected DatasetSelectionPanel datasetSelectionPanel;
|
||||
|
||||
public SDMXDatasetSelectionCard(final SDMXExportSession exportSession) {
|
||||
|
|
|
@ -3,8 +3,6 @@ package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
|
@ -23,7 +21,6 @@ public class SDMXExportWizardTD extends WizardWindow {
|
|||
* @param targetId
|
||||
*/
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public SDMXExportWizardTD(String title) {
|
||||
super(title);
|
||||
setWidth(550);
|
||||
|
@ -31,30 +28,11 @@ public class SDMXExportWizardTD extends WizardWindow {
|
|||
|
||||
exportSession= new SDMXExportSession();
|
||||
|
||||
SDMXExportWizardServiceAsync.INSTANCE.setSDMXSession(exportSession,new AsyncCallback() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Object result) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
SDMXAgencyTypeCard sdmxAgencyType= new SDMXAgencyTypeCard(exportSession);
|
||||
addCard(sdmxAgencyType);
|
||||
|
||||
SDMXAgenciesSelectionCard sdmxAgenciesSelection= new SDMXAgenciesSelectionCard(exportSession);
|
||||
addCard(sdmxAgenciesSelection);
|
||||
SDMXRegistrySelectionCard sdmxRegistrySelectionCard=new SDMXRegistrySelectionCard(exportSession);
|
||||
addCard(sdmxRegistrySelectionCard);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,13 +3,14 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||
|
||||
import org.gcube.portlets.user.td.sdmxexportwidget.client.progress.ImportProgressBarUpdater;
|
||||
import org.gcube.portlets.user.td.sdmxexportwidget.client.progress.OperationProgressListener;
|
||||
import org.gcube.portlets.user.td.sdmxexportwidget.client.progress.OperationProgressUpdater;
|
||||
|
||||
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.gwtservice.shared.sdmx.SDMXExportSession;
|
||||
import org.gcube.portlets.user.td.sdmxexportwidget.client.progress.SDMXExportProgressBarUpdater;
|
||||
import org.gcube.portlets.user.td.sdmxexportwidget.client.progress.SDMXExportProgressListener;
|
||||
import org.gcube.portlets.user.td.sdmxexportwidget.client.progress.SDMXExportProgressUpdater;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.TRId;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.user.client.Command;
|
||||
|
@ -22,139 +23,135 @@ import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutD
|
|||
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>
|
||||
*
|
||||
* @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 class SDMXOperationInProgressCard extends WizardCard implements
|
||||
SDMXExportProgressListener {
|
||||
|
||||
public static final int STATUS_POLLING_DELAY = 1000;
|
||||
protected SDMXOperationInProgressCard thisCard;
|
||||
protected SDMXExportSession exportSession;
|
||||
protected OperationProgressUpdater progressUpdater;
|
||||
protected SDMXExportProgressUpdater progressUpdater;
|
||||
|
||||
|
||||
|
||||
public SDMXOperationInProgressCard(final SDMXExportSession exportSession) {
|
||||
super("Operation In Progress", "");
|
||||
|
||||
|
||||
this.exportSession = exportSession;
|
||||
thisCard=this;
|
||||
thisCard = this;
|
||||
|
||||
VBoxLayoutContainer operationInProgressPanel = new VBoxLayoutContainer();
|
||||
operationInProgressPanel.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER);
|
||||
|
||||
final FlexTable description = new FlexTable();
|
||||
//FlexCellFormatter cellFormatter = description.getFlexCellFormatter();
|
||||
|
||||
final FlexTable description = new FlexTable();
|
||||
//FlexCellFormatter cellFormatter = description.getFlexCellFormatter();
|
||||
description.setCellSpacing(10);
|
||||
description.setCellPadding(4);
|
||||
description.setBorderWidth(0);
|
||||
|
||||
// display:block;vertical-align:text-top;
|
||||
description.setHTML(0, 0,
|
||||
"<span style=\"font-weight:bold;\";>Destination: </span>");
|
||||
description.setText(0, 1, exportSession.getSource().getName());
|
||||
description.setHTML(1, 0,
|
||||
"<span style=\"font-weight:bold;\";>Agency: </span>");
|
||||
description.setText(1, 1, exportSession.getAgency().getNameLabel());
|
||||
|
||||
description.setHTML(2, 0,
|
||||
"<span style=\"font-weight:bold;\";>Tabular Resource: </span>");
|
||||
description.setText(2, 1, exportSession.getTabResource().getName());
|
||||
|
||||
|
||||
|
||||
|
||||
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)));
|
||||
|
||||
FramedPanel summary = new FramedPanel();
|
||||
summary.setHeadingText("Export 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));
|
||||
|
||||
operationInProgressPanel.add(progressBar, new BoxLayoutData(
|
||||
new Margins(10, 5, 10, 5)));
|
||||
|
||||
progressUpdater = new SDMXExportProgressUpdater();
|
||||
progressUpdater.addListener(new SDMXExportProgressBarUpdater(progressBar));
|
||||
|
||||
progressUpdater.addListener(this);
|
||||
|
||||
|
||||
setContent(operationInProgressPanel);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void exportSDMX()
|
||||
{
|
||||
TDGWTServiceAsync.INSTANCE.exportSDMXClientLibraryRequest(exportSession, 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);
|
||||
}
|
||||
});
|
||||
//columnToImportMask
|
||||
|
||||
public void exportSDMX() {
|
||||
TDGWTServiceAsync.INSTANCE.startSDMXExport(exportSession, 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.getLocalizedMessage(), caught.getStackTrace().toString(), caught);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void setup(){
|
||||
getWizardWindow().setEnableBackButton(false);
|
||||
setBackButtonVisible(false);
|
||||
setNextButtonVisible(false);
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
getWizardWindow().setNextButtonToFinish();
|
||||
exportSDMX();
|
||||
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) {
|
||||
|
||||
public void operationComplete() {
|
||||
// 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);
|
||||
|
||||
Log.info("fire Complete: tableId");
|
||||
|
||||
getWizardWindow().fireCompleted(null);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.error("fire Complete :" + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
getWizardWindow().setNextButtonCommand(sayComplete);
|
||||
|
||||
};
|
||||
|
||||
getWizardWindow().setNextButtonCommand(sayComplete);
|
||||
|
||||
setNextButtonVisible(true);
|
||||
getWizardWindow().setEnableNextButton(true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void operationFailed(Throwable caught, String reason,
|
||||
String failureDetails) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,189 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.dom.client.Element;
|
||||
import com.google.gwt.dom.client.NodeList;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||
import com.google.gwt.user.client.Command;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.HasValue;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.sencha.gxt.core.client.util.ToggleGroup;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
||||
import com.sencha.gxt.widget.core.client.form.Radio;
|
||||
import com.sencha.gxt.widget.core.client.form.TextField;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class SDMXRegistrySelectionCard extends WizardCard {
|
||||
|
||||
protected SDMXExportSession exportSession;
|
||||
protected SDMXRegistrySelectionCard thisCard;
|
||||
|
||||
final TextField url = new TextField();
|
||||
|
||||
public SDMXRegistrySelectionCard(final SDMXExportSession exportSession) {
|
||||
super("SDMX Registry selection", "");
|
||||
|
||||
this.exportSession = exportSession;
|
||||
thisCard = this;
|
||||
|
||||
VerticalPanel registrySelectionPanel = new VerticalPanel();
|
||||
registrySelectionPanel.setStylePrimaryName(res.wizardCSS()
|
||||
.getImportSelectionSources());
|
||||
|
||||
Radio radioStandardRegistry = new Radio();
|
||||
|
||||
radioStandardRegistry
|
||||
.setBoxLabel("<p style='display:inline-table;'><b>Internal SDMX Registry</b>"
|
||||
+ "<br>Select this if you want use the Internal Registry</p>");
|
||||
radioStandardRegistry.setValue(true);
|
||||
radioStandardRegistry.setName("Default");
|
||||
radioStandardRegistry.setStylePrimaryName(res.wizardCSS()
|
||||
.getImportSelectionSource());
|
||||
|
||||
Radio radioUrlRegistry = new Radio();
|
||||
radioUrlRegistry
|
||||
.setBoxLabel("<p style='display:inline-table;'><b>Another SDMX Registry</b><br><SPAN id='SDMXRegistryUrl'></SPAN></p>");
|
||||
radioUrlRegistry.setName("Url");
|
||||
radioUrlRegistry.setStylePrimaryName(res.wizardCSS()
|
||||
.getImportSelectionSource());
|
||||
radioUrlRegistry.disable();
|
||||
|
||||
url.setName("sdmxRegistryUrlInpuntField");
|
||||
url.setId("sdmxRegistryUrlInputFieldId");
|
||||
url.setStylePrimaryName(res.wizardCSS()
|
||||
.getSDMXRegistryUrlInputStyle());
|
||||
|
||||
final VerticalLayoutContainer vcontainer = new VerticalLayoutContainer();
|
||||
vcontainer.add(new FieldLabel(url, "URL"), new VerticalLayoutData(-1,
|
||||
-1));
|
||||
vcontainer.setStylePrimaryName(res.wizardCSS()
|
||||
.getSDMXRegistryUrlStyle());
|
||||
vcontainer.setVisible(false);
|
||||
|
||||
NodeList<Element> nodel = radioUrlRegistry.getElement()
|
||||
.getElementsByTagName("SPAN");
|
||||
Element span = nodel.getItem(0);
|
||||
span.appendChild(vcontainer.getElement());
|
||||
|
||||
registrySelectionPanel.add(radioStandardRegistry);
|
||||
registrySelectionPanel.add(radioUrlRegistry);
|
||||
|
||||
// we can set name on radios or use toggle group
|
||||
ToggleGroup toggle = new ToggleGroup();
|
||||
toggle.add(radioStandardRegistry);
|
||||
toggle.add(radioUrlRegistry);
|
||||
|
||||
toggle.addValueChangeHandler(new ValueChangeHandler<HasValue<Boolean>>() {
|
||||
|
||||
@Override
|
||||
public void onValueChange(ValueChangeEvent<HasValue<Boolean>> event) {
|
||||
try {
|
||||
ToggleGroup group = (ToggleGroup) event.getSource();
|
||||
Radio radio = (Radio) group.getValue();
|
||||
Log.info("Registry Selected:" + radio.getName());
|
||||
if (radio.getName().compareTo("Url") == 0) {
|
||||
vcontainer.setVisible(true);
|
||||
NodeList<Element> nodel = radio.getElement()
|
||||
.getElementsByTagName("SPAN");
|
||||
Element span = nodel.getItem(0);
|
||||
span.appendChild(vcontainer.getElement());
|
||||
|
||||
Log.info("SDMXRegistry Url");
|
||||
Log.info("Input value: " + url.getCurrentValue());
|
||||
SDMXRegistrySource r = ((SDMXRegistrySource) exportSession
|
||||
.getSource());
|
||||
r.setUrl(null);
|
||||
Log.info("" + exportSession.getSource());
|
||||
} else {
|
||||
vcontainer.setVisible(false);
|
||||
Log.info("SDMXRegistry Default");
|
||||
SDMXRegistrySource r = ((SDMXRegistrySource) exportSession
|
||||
.getSource());
|
||||
r.setUrl(null);
|
||||
Log.info("Input value: " + url.getCurrentValue());
|
||||
Log.info("" + exportSession.getSource());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.error("ToggleGroup: onValueChange "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
setContent(registrySelectionPanel);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
Command sayNextCard = new Command() {
|
||||
public void execute() {
|
||||
try {
|
||||
Log.info("Input value: " + url.getCurrentValue());
|
||||
if (exportSession.getSource() instanceof SDMXRegistrySource) {
|
||||
((SDMXRegistrySource) exportSession.getSource())
|
||||
.setUrl(url.getCurrentValue());
|
||||
|
||||
TDGWTServiceAsync.INSTANCE.setSDMXRegistrySource(
|
||||
((SDMXRegistrySource)exportSession.getSource()), new AsyncCallback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Log.error("SDMXRegistrySource do not stored "
|
||||
+ caught.getLocalizedMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
Log.info("SDMXRegistrySource stored");
|
||||
goNext();
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Log.error("There is a problem in source selection.Expected SDMXRegistrySource, and found"
|
||||
+ exportSession.getSource());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.error("sayNextCard :" + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
getWizardWindow().setNextButtonCommand(sayNextCard);
|
||||
}
|
||||
|
||||
protected void goNext() {
|
||||
try {
|
||||
SDMXAgenciesSelectionCard sdmxAgencyTypeCard = new SDMXAgenciesSelectionCard(
|
||||
exportSession);
|
||||
getWizardWindow().addCard(sdmxAgencyTypeCard);
|
||||
Log.info("NextCard SDMXAgenciesSelectionCard ");
|
||||
getWizardWindow().nextCard();
|
||||
} catch (Exception e) {
|
||||
Log.error("sayNextCard :" + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,320 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Agencies;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.TabResource;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
|
||||
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||
import com.google.gwt.user.client.Command;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.HasValue;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
||||
import com.sencha.gxt.core.client.util.ToggleGroup;
|
||||
import com.sencha.gxt.data.client.loader.RpcProxy;
|
||||
import com.sencha.gxt.data.shared.LabelProvider;
|
||||
import com.sencha.gxt.data.shared.ListStore;
|
||||
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding;
|
||||
import com.sencha.gxt.data.shared.loader.PagingLoadConfig;
|
||||
import com.sencha.gxt.data.shared.loader.PagingLoadResult;
|
||||
import com.sencha.gxt.data.shared.loader.PagingLoadResultBean;
|
||||
import com.sencha.gxt.data.shared.loader.PagingLoader;
|
||||
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||
import com.sencha.gxt.widget.core.client.container.HorizontalLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||
import com.sencha.gxt.widget.core.client.form.ComboBox;
|
||||
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
||||
import com.sencha.gxt.widget.core.client.form.FieldSet;
|
||||
import com.sencha.gxt.widget.core.client.form.Radio;
|
||||
import com.sencha.gxt.widget.core.client.form.TextArea;
|
||||
import com.sencha.gxt.widget.core.client.form.TextField;
|
||||
import com.sencha.gxt.widget.core.client.info.Info;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class SDMXTableDetailCard extends WizardCard {
|
||||
|
||||
protected SDMXExportSession exportSession;
|
||||
protected SDMXTableDetailCard thisCard;
|
||||
|
||||
protected static final AgenciesProperties agenciesProperties = GWT.create(AgenciesProperties.class);
|
||||
protected VerticalLayoutContainer p = new VerticalLayoutContainer();
|
||||
//private final ComboBox<String> combo2;
|
||||
protected VerticalPanel tableDetailPanel;
|
||||
|
||||
//private static TextField agencyName=null;
|
||||
|
||||
protected TextField name;
|
||||
protected TextArea description;
|
||||
protected TextField right;
|
||||
protected ComboBox<Agencies> combo=null;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public SDMXTableDetailCard(final SDMXExportSession exportSession) {
|
||||
super("SDMX Table Detail", "");
|
||||
|
||||
this.exportSession = exportSession;
|
||||
thisCard=this;
|
||||
|
||||
|
||||
tableDetailPanel = new VerticalPanel();
|
||||
|
||||
tableDetailPanel.setSpacing(4);
|
||||
tableDetailPanel.setWidth("100%");
|
||||
tableDetailPanel.setHeight("100%");
|
||||
|
||||
|
||||
FramedPanel form2 = new FramedPanel();
|
||||
form2.setHeadingText("Details");
|
||||
//form2.setWidth(350);
|
||||
|
||||
FieldSet fieldSet = new FieldSet();
|
||||
fieldSet.setHeadingText("Information");
|
||||
fieldSet.setCollapsible(true);
|
||||
form2.add(fieldSet);
|
||||
|
||||
//VerticalLayoutContainer p = new VerticalLayoutContainer();
|
||||
fieldSet.add(p);
|
||||
|
||||
name = new TextField();
|
||||
name.setAllowBlank(false);
|
||||
name.setEmptyText("Enter a name...");
|
||||
name.setValue(exportSession.getSelectedCodelist().getName());
|
||||
p.add(new FieldLabel(name, "Name"), new VerticalLayoutData(1, -1));
|
||||
|
||||
|
||||
description = new TextArea();
|
||||
description.setAllowBlank(false);
|
||||
description.setEmptyText("Enter a description...");
|
||||
description.setValue(exportSession.getSelectedCodelist().getDescription());
|
||||
p.add(new FieldLabel(description, "Description"), new VerticalLayoutData(1, -1));
|
||||
|
||||
right = new TextField();
|
||||
right.setEmptyText("Enter right...");
|
||||
right.setAllowBlank(false);
|
||||
p.add(new FieldLabel(right, "Right"), new VerticalLayoutData(1, -1));
|
||||
|
||||
|
||||
ListStore<Agencies> agenciesStore = new ListStore<Agencies>(agenciesProperties.key());
|
||||
|
||||
RpcProxy<PagingLoadConfig, PagingLoadResult<Agencies>> proxy = new RpcProxy<PagingLoadConfig, PagingLoadResult<Agencies>>() {
|
||||
|
||||
|
||||
public void load(PagingLoadConfig loadConfig, final AsyncCallback<PagingLoadResult<Agencies>> callback) {
|
||||
loadData(loadConfig, callback);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
final PagingLoader<PagingLoadConfig, PagingLoadResult<Agencies>> loader = new PagingLoader<PagingLoadConfig, PagingLoadResult<Agencies>>(proxy);
|
||||
|
||||
loader.setRemoteSort(false);
|
||||
loader.addLoadHandler(new LoadResultListStoreBinding<PagingLoadConfig, Agencies, PagingLoadResult<Agencies>>(agenciesStore));
|
||||
|
||||
//agenciesStore.addAll(TestData.getStates());
|
||||
|
||||
combo = new ComboBox<Agencies>(agenciesStore, agenciesProperties.nameLabel());
|
||||
addHandlersForEventObservation(combo, agenciesProperties.nameLabel());
|
||||
|
||||
combo.setLoader(loader);
|
||||
combo.setEmptyText("Enter Agency...");
|
||||
combo.setTriggerAction(TriggerAction.ALL);
|
||||
combo.setAllowBlank(false);
|
||||
combo.setForceSelection(true);
|
||||
combo.setVisible(true);
|
||||
|
||||
|
||||
|
||||
//HorizontalLayoutContainer agenciesSelect= selectAgencies();
|
||||
p.add(new FieldLabel(combo, "Agencies"), new VerticalLayoutData(1, -1));
|
||||
|
||||
/*FieldLabel comboLabel=new FieldLabel(combo, "");
|
||||
comboLabel.setLabelSeparator("");
|
||||
p.add(comboLabel, new VerticalLayoutData(1, -1));
|
||||
|
||||
|
||||
agencyName = new TextField();
|
||||
agencyName.setVisible(false);
|
||||
agencyName.setEmptyText("Enter Agency...");
|
||||
FieldLabel agencyNameLabel=new FieldLabel(agencyName, "");
|
||||
agencyNameLabel.setLabelSeparator("");
|
||||
p.add(agencyNameLabel, new VerticalLayoutData(1, -1));
|
||||
*/
|
||||
tableDetailPanel.add(form2);
|
||||
|
||||
setContent(tableDetailPanel);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void loadData(PagingLoadConfig loadConfig, final AsyncCallback<PagingLoadResult<Agencies>> callback) {
|
||||
TDGWTServiceAsync.INSTANCE.getAgencies(new AsyncCallback<ArrayList<Agencies>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
callback.onFailure(caught);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ArrayList<Agencies> result) {
|
||||
Log.trace("loaded "+result.size()+" agencies");
|
||||
for(int i=0; i<result.size(); i++){
|
||||
Agencies ag=result.get(i);
|
||||
//if(ag.getId().compareTo())
|
||||
}
|
||||
|
||||
callback.onSuccess(new PagingLoadResultBean<Agencies>(result, result.size(), 0));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to add handlers to observe events that occur on each combobox
|
||||
*/
|
||||
private <T> void addHandlersForEventObservation(final ComboBox<T> combo, final LabelProvider<T> labelProvider) {
|
||||
combo.addValueChangeHandler(new ValueChangeHandler<T>() {
|
||||
@Override
|
||||
public void onValueChange(ValueChangeEvent<T> event) {
|
||||
|
||||
Info.display("Value Changed", "New value: "
|
||||
+ (event.getValue() == null ? combo.getValue() : labelProvider.getLabel(event.getValue()) + "!"));
|
||||
}
|
||||
});
|
||||
combo.addSelectionHandler(new SelectionHandler<T>() {
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<T> event) {
|
||||
Info.display("Agency Selected", "You selected "
|
||||
+ (event.getSelectedItem() == null ? combo.getValue() : labelProvider.getLabel(event.getSelectedItem()) + "!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup(){
|
||||
Command sayNextCard = new Command() {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
TabResource detail=new TabResource();
|
||||
detail.setName(name.getCurrentValue());
|
||||
detail.setAgency(combo.getSelectedText());
|
||||
detail.setDescription(description.getCurrentValue());
|
||||
detail.setRight(right.getCurrentValue());
|
||||
|
||||
exportSession.setTabResource(detail);
|
||||
SDMXOperationInProgressCard sdmxOperationInProgressCard = new SDMXOperationInProgressCard(
|
||||
exportSession);
|
||||
getWizardWindow()
|
||||
.addCard(sdmxOperationInProgressCard);
|
||||
Log.info("NextCard SDMXOperationInProgressCard");
|
||||
getWizardWindow().nextCard();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
getWizardWindow().setNextButtonCommand(sayNextCard);
|
||||
|
||||
|
||||
Command sayPreviousCard = new Command() {
|
||||
public void execute() {
|
||||
try {
|
||||
getWizardWindow().previousCard();
|
||||
getWizardWindow().removeCard(thisCard);
|
||||
Log.info("Remove SDMXTableDetailCard");
|
||||
} catch (Exception e) {
|
||||
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||
getWizardWindow().setEnableNextButton(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private HorizontalLayoutContainer selectAgencies(){
|
||||
|
||||
|
||||
|
||||
HorizontalLayoutContainer documentSelectionPanel = new HorizontalLayoutContainer();
|
||||
|
||||
Radio radioAgenciesAlready = new Radio();
|
||||
|
||||
radioAgenciesAlready.setBoxLabel("Present");
|
||||
radioAgenciesAlready.setValue(true);
|
||||
radioAgenciesAlready.setName("Agencies");
|
||||
|
||||
Radio radioAgencyNew = new Radio();
|
||||
radioAgencyNew.setBoxLabel("New");
|
||||
radioAgencyNew.setName("AgencyNew");
|
||||
|
||||
|
||||
documentSelectionPanel.add(radioAgenciesAlready);
|
||||
documentSelectionPanel.add(radioAgencyNew);
|
||||
|
||||
|
||||
// we can set name on radios or use toggle group
|
||||
ToggleGroup toggle = new ToggleGroup();
|
||||
toggle.add(radioAgenciesAlready);
|
||||
toggle.add(radioAgencyNew);
|
||||
|
||||
toggle.addValueChangeHandler(new ValueChangeHandler<HasValue<Boolean>>() {
|
||||
|
||||
@Override
|
||||
public void onValueChange(ValueChangeEvent<HasValue<Boolean>> event) {
|
||||
try {
|
||||
ToggleGroup group = (ToggleGroup) event.getSource();
|
||||
Radio radio = (Radio) group.getValue();
|
||||
Log.info("Document Selected:" + radio.getName());
|
||||
if (radio.getName().compareTo("AgencyNew") == 0) {
|
||||
/*agencyName.setVisible(true);
|
||||
combo.setVisible(false);
|
||||
*/
|
||||
} else {
|
||||
if (radio.getName().compareTo("Agency") == 0) {
|
||||
/*agencyName.setVisible(false);
|
||||
combo.setVisible(true);
|
||||
*/
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.error("ToggleGroup: onValueChange " + e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return documentSelectionPanel;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.sdmxexportwidget.client.progress;
|
||||
|
||||
|
||||
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.TRId;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.sencha.gxt.widget.core.client.ProgressBar;
|
||||
|
||||
/**
|
||||
* Updates a {@link ProgressBar} progress and text based on {@link OperationProgressListener} events.
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ImportProgressBarUpdater implements OperationProgressListener {
|
||||
|
||||
protected ProgressBar progressBar;
|
||||
//protected FramedPanel operationResult;
|
||||
//protected WizardWindow wizardWindow;
|
||||
/**
|
||||
* Creates a new {@link ProgressBar} updater.
|
||||
* @param progressBar the {@link ProgressBar} to update.
|
||||
*/
|
||||
public ImportProgressBarUpdater(ProgressBar progressBar) {
|
||||
this.progressBar = progressBar;
|
||||
//this.wizardWindow = w;
|
||||
//this.operationResult = operationResult;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void operationComplete(String url) {// TODO Auto-generated method stub
|
||||
Log.info("Import completed");
|
||||
progressBar.updateProgress(1, "Import completed.");
|
||||
/*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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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...");
|
||||
if (elaborated>0 && elaborated<1) {
|
||||
Log.trace("progress "+elaborated);
|
||||
int elab=new Float(elaborated*100).intValue();
|
||||
progressBar.updateProgress(elaborated,elab+"% importing...");
|
||||
}
|
||||
if (elaborated == 1) progressBar.updateProgress(1, "completing...");
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.sdmxexportwidget.client.progress;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Defines a listener for operation progress.
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface OperationProgressListener {
|
||||
|
||||
/**
|
||||
* Called when the operation is starting.
|
||||
*/
|
||||
public void operationInitializing();
|
||||
|
||||
/**
|
||||
* Called when there is a progress for the operation.
|
||||
* @param elaborated the elaborated part.
|
||||
*/
|
||||
public void operationUpdate(float elaborated);
|
||||
|
||||
|
||||
/**
|
||||
* Called when the operation is complete.
|
||||
*/
|
||||
public void operationComplete(String url);
|
||||
|
||||
/**
|
||||
* Called when the operation is failed.
|
||||
* @param caught the failure exception.
|
||||
* @param reason the failure reason.
|
||||
*/
|
||||
public void operationFailed(Throwable caught, String reason, String failureDetails);
|
||||
}
|
|
@ -1,131 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.sdmxexportwidget.client.progress;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
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.sdmx.SDMXExportMonitor;
|
||||
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
/**
|
||||
* This {@link Timer} retrieves {@link OperationProgress} from the specified {@link OperationProgressSource} with the scheduled interval.
|
||||
* The retrieved information are spread to the subscribed {@link OperationProgressListener}.
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class OperationProgressUpdater extends Timer {
|
||||
|
||||
protected ArrayList<OperationProgressListener> listeners = new ArrayList<OperationProgressListener>();
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
Log.debug("requesting operation progress");
|
||||
TDGWTServiceAsync.INSTANCE.getSDMXExportMonitor(new AsyncCallback<SDMXExportMonitor>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
cancel();
|
||||
Log.error("Error retrieving the operation state", caught);
|
||||
String message = getStack(caught);
|
||||
fireOperationFailed(caught, "Failed getting operation updates", message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(SDMXExportMonitor result) {
|
||||
Log.info("retrieved ImportMonitor: "+result.getStatus());
|
||||
switch (result.getStatus()) {
|
||||
case WAITING:
|
||||
break;
|
||||
case INITIALIZING:
|
||||
fireOperationInitializing();
|
||||
break;
|
||||
case IN_PROGRESS:
|
||||
fireOperationUpdate(result.getProgress());
|
||||
break;
|
||||
case FAILED:
|
||||
cancel();
|
||||
fireOperationFailed(result.getError(),"Failed Client Library Import", result.getStatusDescription());
|
||||
break;
|
||||
case SUCCEDED:
|
||||
cancel();
|
||||
Log.info("Import fisnish TableId :"+result.getUrl());
|
||||
fireOperationComplete(result.getUrl());
|
||||
break;
|
||||
case ABORTED:
|
||||
cancel();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected String getStack(Throwable e)
|
||||
{
|
||||
String message = e.getLocalizedMessage()+" -> <br>";
|
||||
Throwable c = e.getCause();
|
||||
if (c!=null) message += getStack(c);
|
||||
return message;
|
||||
}
|
||||
|
||||
protected void fireOperationInitializing()
|
||||
{
|
||||
for (OperationProgressListener listener:listeners) listener.operationInitializing();
|
||||
}
|
||||
|
||||
protected void fireOperationUpdate(float elaborated)
|
||||
{
|
||||
for (OperationProgressListener listener:listeners) listener.operationUpdate(elaborated);
|
||||
}
|
||||
|
||||
protected void fireOperationComplete(String url)
|
||||
{
|
||||
for (OperationProgressListener listener:listeners) listener.operationComplete(url);
|
||||
}
|
||||
|
||||
protected void fireOperationFailed(Throwable caught, String failure, String failureDetails)
|
||||
{
|
||||
for (OperationProgressListener listener:listeners) listener.operationFailed(caught, failure, failureDetails);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new {@link OperationProgressListener} to this {@link OperationProgressUpdater}.
|
||||
* @param listener the listener to add.
|
||||
*/
|
||||
public void addListener(OperationProgressListener listener)
|
||||
{
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified {@link OperationProgressListener} from this {@link OperationProgressUpdater}.
|
||||
* @param listener the listener to remove.
|
||||
*/
|
||||
public void removeListener(OperationProgressListener listener)
|
||||
{
|
||||
listeners.remove(listener);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue