ref 9056:TabMan - Improve resource management in TabMan

https://support.d4science.org/issues/9056

Added excel to Dataset

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-sdmx-export-widget@150557 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-06-27 10:36:44 +00:00 committed by Giancarlo Panichi
parent 890196705e
commit 19010a25a9
1 changed files with 51 additions and 21 deletions

View File

@ -9,8 +9,13 @@ import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard; import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
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.Command;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.VerticalPanel;
import com.sencha.gxt.core.client.util.ToggleGroup;
import com.sencha.gxt.widget.core.client.FramedPanel; import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.box.AlertMessageBox; import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
@ -19,6 +24,7 @@ import com.sencha.gxt.widget.core.client.event.HideEvent;
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler; import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
import com.sencha.gxt.widget.core.client.form.FieldLabel; 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.FieldSet;
import com.sencha.gxt.widget.core.client.form.Radio;
import com.sencha.gxt.widget.core.client.form.TextField; import com.sencha.gxt.widget.core.client.form.TextField;
/** /**
@ -44,6 +50,7 @@ public class SDMXTableDetailCard extends WizardCard {
private TextField registryBaseUrl; private TextField registryBaseUrl;
private TextField version; private TextField version;
private TextField measureColumn; private TextField measureColumn;
private Radio excelTrue;
public SDMXTableDetailCard(final SDMXExportSession exportSession) { public SDMXTableDetailCard(final SDMXExportSession exportSession) {
super("SDMX Table Detail", ""); super("SDMX Table Detail", "");
@ -97,8 +104,7 @@ public class SDMXTableDetailCard extends WizardCard {
agencyId = new TextField(); agencyId = new TextField();
agencyId.setVisible(true); agencyId.setVisible(true);
agencyId.setEmptyText("Enter Agency Id..."); agencyId.setEmptyText("Enter Agency Id...");
if (exportSession.getAgency().getId() == null if (exportSession.getAgency().getId() == null || exportSession.getAgency().getId().isEmpty()) {
|| exportSession.getAgency().getId().isEmpty()) {
agencyId.setValue(Constants.SDMX_DATASET_EXPORT_DEFAULT_AGENCY_ID); agencyId.setValue(Constants.SDMX_DATASET_EXPORT_DEFAULT_AGENCY_ID);
} else { } else {
agencyId.setValue(exportSession.getAgency().getId()); agencyId.setValue(exportSession.getAgency().getId());
@ -110,15 +116,13 @@ public class SDMXTableDetailCard extends WizardCard {
registryBaseUrl = new TextField(); registryBaseUrl = new TextField();
registryBaseUrl.setVisible(false); registryBaseUrl.setVisible(false);
registryBaseUrl.setEmptyText("Enter Registry URL..."); registryBaseUrl.setEmptyText("Enter Registry URL...");
String urlRegistry = ((SDMXRegistrySource) exportSession.getSource()) String urlRegistry = ((SDMXRegistrySource) exportSession.getSource()).getUrl();
.getUrl();
if (urlRegistry == null || urlRegistry.isEmpty()) { if (urlRegistry == null || urlRegistry.isEmpty()) {
registryBaseUrl.setValue(null); registryBaseUrl.setValue(null);
} else { } else {
registryBaseUrl.setValue(urlRegistry); registryBaseUrl.setValue(urlRegistry);
} }
FieldLabel registryBaseUrlLabel = new FieldLabel(registryBaseUrl, FieldLabel registryBaseUrlLabel = new FieldLabel(registryBaseUrl, "Registry URL");
"Registry URL");
registryBaseUrlLabel.setVisible(false); registryBaseUrlLabel.setVisible(false);
p.add(registryBaseUrlLabel, new VerticalLayoutData(1, -1)); p.add(registryBaseUrlLabel, new VerticalLayoutData(1, -1));
@ -131,8 +135,33 @@ public class SDMXTableDetailCard extends WizardCard {
measureColumn = new TextField(); measureColumn = new TextField();
measureColumn.setValue(exportSession.getObsValueColumn().getLabel()); measureColumn.setValue(exportSession.getObsValueColumn().getLabel());
measureColumn.setReadOnly(true); measureColumn.setReadOnly(true);
p.add(new FieldLabel(measureColumn, "Measure Column"), p.add(new FieldLabel(measureColumn, "Measure Column"), new VerticalLayoutData(1, -1));
new VerticalLayoutData(1, -1));
excelTrue = new Radio();
excelTrue.setBoxLabel("True");
excelTrue.setValue(true);
Radio excelFalse = new Radio();
excelFalse.setBoxLabel("False");
ToggleGroup excelToggle = new ToggleGroup();
excelToggle.add(excelTrue);
excelToggle.add(excelFalse);
excelToggle.addValueChangeHandler(new ValueChangeHandler<HasValue<Boolean>>() {
@Override
public void onValueChange(ValueChangeEvent<HasValue<Boolean>> event) {
}
});
HorizontalPanel hp = new HorizontalPanel();
hp.add(excelTrue);
hp.add(excelFalse);
p.add(new FieldLabel(hp, "Excel"), new VerticalLayoutData(-1, -1));
} }
private void codelistViewConfig() { private void codelistViewConfig() {
@ -145,8 +174,7 @@ public class SDMXTableDetailCard extends WizardCard {
agencyId = new TextField(); agencyId = new TextField();
agencyId.setVisible(true); agencyId.setVisible(true);
agencyId.setEmptyText("Enter Agency..."); agencyId.setEmptyText("Enter Agency...");
if (exportSession.getAgency().getId() == null if (exportSession.getAgency().getId() == null || exportSession.getAgency().getId().isEmpty()) {
|| exportSession.getAgency().getId().isEmpty()) {
agencyId.setValue(Constants.SDMX_CODELIST_EXPORT_DEFAULT_AGENCY_ID); agencyId.setValue(Constants.SDMX_CODELIST_EXPORT_DEFAULT_AGENCY_ID);
} else { } else {
agencyId.setValue(exportSession.getAgency().getId()); agencyId.setValue(exportSession.getAgency().getId());
@ -157,15 +185,13 @@ public class SDMXTableDetailCard extends WizardCard {
registryBaseUrl = new TextField(); registryBaseUrl = new TextField();
registryBaseUrl.setVisible(false); registryBaseUrl.setVisible(false);
registryBaseUrl.setEmptyText("Enter Registry URL..."); registryBaseUrl.setEmptyText("Enter Registry URL...");
String urlRegistry = ((SDMXRegistrySource) exportSession.getSource()) String urlRegistry = ((SDMXRegistrySource) exportSession.getSource()).getUrl();
.getUrl();
if (urlRegistry == null || urlRegistry.isEmpty()) { if (urlRegistry == null || urlRegistry.isEmpty()) {
registryBaseUrl.setValue(null); registryBaseUrl.setValue(null);
} else { } else {
registryBaseUrl.setValue(urlRegistry); registryBaseUrl.setValue(urlRegistry);
} }
FieldLabel registryBaseUrlLabel = new FieldLabel(registryBaseUrl, FieldLabel registryBaseUrlLabel = new FieldLabel(registryBaseUrl, "Registry URL");
"Registry URL");
registryBaseUrlLabel.setVisible(false); registryBaseUrlLabel.setVisible(false);
p.add(registryBaseUrlLabel, new VerticalLayoutData(1, -1)); p.add(registryBaseUrlLabel, new VerticalLayoutData(1, -1));
@ -174,6 +200,9 @@ public class SDMXTableDetailCard extends WizardCard {
version.setEmptyText("Enter Version..."); version.setEmptyText("Enter Version...");
version.setValue(Constants.SDMX_CODELIST_EXPORT_DEFAULT_VERSION); version.setValue(Constants.SDMX_CODELIST_EXPORT_DEFAULT_VERSION);
p.add(new FieldLabel(version, "Version"), new VerticalLayoutData(1, -1)); p.add(new FieldLabel(version, "Version"), new VerticalLayoutData(1, -1));
excelTrue=null;
} }
@Override @Override
@ -218,9 +247,8 @@ public class SDMXTableDetailCard extends WizardCard {
} }
}; };
if (id.getValue() == null || id.getValue().isEmpty() || !id.isValid() if (id.getValue() == null || id.getValue().isEmpty() || !id.isValid() || version.getValue() == null
|| version.getValue() == null || version.getValue().isEmpty() || version.getValue().isEmpty() || !version.isValid() || agencyId.getValue() == null
|| !version.isValid() || agencyId.getValue() == null
|| agencyId.getValue().isEmpty() || !agencyId.isValid()) { || agencyId.getValue().isEmpty() || !agencyId.isValid()) {
d = new AlertMessageBox("Attention!", "Fill in all fields"); d = new AlertMessageBox("Attention!", "Fill in all fields");
@ -228,8 +256,7 @@ public class SDMXTableDetailCard extends WizardCard {
d.show(); d.show();
} else { } else {
if (!version.getValue().matches("[0-9]+\\.[0-9]+")) { if (!version.getValue().matches("[0-9]+\\.[0-9]+")) {
d = new AlertMessageBox("Attention!", d = new AlertMessageBox("Attention!", "Version must match the regular expression [0-9]+\\.[0-9]+");
"Version must match the regular expression [0-9]+\\.[0-9]+");
d.addHideHandler(hideHandler); d.addHideHandler(hideHandler);
d.show(); d.show();
} else { } else {
@ -249,8 +276,11 @@ public class SDMXTableDetailCard extends WizardCard {
exportSession.setAgencyId(agencyId.getCurrentValue()); exportSession.setAgencyId(agencyId.getCurrentValue());
exportSession.setVersion(version.getCurrentValue()); exportSession.setVersion(version.getCurrentValue());
exportSession.setRegistryBaseUrl(registryBaseUrl.getCurrentValue()); exportSession.setRegistryBaseUrl(registryBaseUrl.getCurrentValue());
SDMXOperationInProgressCard sdmxOperationInProgressCard = new SDMXOperationInProgressCard( if (excelTrue != null) {
exportSession); exportSession.setExcel(excelTrue.getValue());
}
SDMXOperationInProgressCard sdmxOperationInProgressCard = new SDMXOperationInProgressCard(exportSession);
getWizardWindow().addCard(sdmxOperationInProgressCard); getWizardWindow().addCard(sdmxOperationInProgressCard);
Log.info("NextCard SDMXOperationInProgressCard"); Log.info("NextCard SDMXOperationInProgressCard");
getWizardWindow().nextCard(); getWizardWindow().nextCard();