From 19010a25a9cb6a4b82898c8f4214aad21b488da8 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Tue, 27 Jun 2017 10:36:44 +0000 Subject: [PATCH] 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 --- .../client/SDMXTableDetailCard.java | 72 +++++++++++++------ 1 file changed, 51 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/SDMXTableDetailCard.java b/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/SDMXTableDetailCard.java index 8a89790..3075878 100644 --- a/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/SDMXTableDetailCard.java +++ b/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/SDMXTableDetailCard.java @@ -9,8 +9,13 @@ 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.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.ui.HasValue; +import com.google.gwt.user.client.ui.HorizontalPanel; 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.box.AlertMessageBox; 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.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.TextField; /** @@ -44,6 +50,7 @@ public class SDMXTableDetailCard extends WizardCard { private TextField registryBaseUrl; private TextField version; private TextField measureColumn; + private Radio excelTrue; public SDMXTableDetailCard(final SDMXExportSession exportSession) { super("SDMX Table Detail", ""); @@ -97,8 +104,7 @@ public class SDMXTableDetailCard extends WizardCard { agencyId = new TextField(); agencyId.setVisible(true); agencyId.setEmptyText("Enter Agency Id..."); - if (exportSession.getAgency().getId() == null - || exportSession.getAgency().getId().isEmpty()) { + if (exportSession.getAgency().getId() == null || exportSession.getAgency().getId().isEmpty()) { agencyId.setValue(Constants.SDMX_DATASET_EXPORT_DEFAULT_AGENCY_ID); } else { agencyId.setValue(exportSession.getAgency().getId()); @@ -110,15 +116,13 @@ public class SDMXTableDetailCard extends WizardCard { registryBaseUrl = new TextField(); registryBaseUrl.setVisible(false); registryBaseUrl.setEmptyText("Enter Registry URL..."); - String urlRegistry = ((SDMXRegistrySource) exportSession.getSource()) - .getUrl(); + String urlRegistry = ((SDMXRegistrySource) exportSession.getSource()).getUrl(); if (urlRegistry == null || urlRegistry.isEmpty()) { registryBaseUrl.setValue(null); } else { registryBaseUrl.setValue(urlRegistry); } - FieldLabel registryBaseUrlLabel = new FieldLabel(registryBaseUrl, - "Registry URL"); + FieldLabel registryBaseUrlLabel = new FieldLabel(registryBaseUrl, "Registry URL"); registryBaseUrlLabel.setVisible(false); p.add(registryBaseUrlLabel, new VerticalLayoutData(1, -1)); @@ -131,8 +135,33 @@ public class SDMXTableDetailCard extends WizardCard { measureColumn = new TextField(); measureColumn.setValue(exportSession.getObsValueColumn().getLabel()); measureColumn.setReadOnly(true); - p.add(new FieldLabel(measureColumn, "Measure Column"), - new VerticalLayoutData(1, -1)); + p.add(new FieldLabel(measureColumn, "Measure Column"), 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>() { + + @Override + public void onValueChange(ValueChangeEvent> event) { + + } + + }); + + HorizontalPanel hp = new HorizontalPanel(); + hp.add(excelTrue); + hp.add(excelFalse); + + p.add(new FieldLabel(hp, "Excel"), new VerticalLayoutData(-1, -1)); + } private void codelistViewConfig() { @@ -145,8 +174,7 @@ public class SDMXTableDetailCard extends WizardCard { agencyId = new TextField(); agencyId.setVisible(true); agencyId.setEmptyText("Enter Agency..."); - if (exportSession.getAgency().getId() == null - || exportSession.getAgency().getId().isEmpty()) { + if (exportSession.getAgency().getId() == null || exportSession.getAgency().getId().isEmpty()) { agencyId.setValue(Constants.SDMX_CODELIST_EXPORT_DEFAULT_AGENCY_ID); } else { agencyId.setValue(exportSession.getAgency().getId()); @@ -157,15 +185,13 @@ public class SDMXTableDetailCard extends WizardCard { registryBaseUrl = new TextField(); registryBaseUrl.setVisible(false); registryBaseUrl.setEmptyText("Enter Registry URL..."); - String urlRegistry = ((SDMXRegistrySource) exportSession.getSource()) - .getUrl(); + String urlRegistry = ((SDMXRegistrySource) exportSession.getSource()).getUrl(); if (urlRegistry == null || urlRegistry.isEmpty()) { registryBaseUrl.setValue(null); } else { registryBaseUrl.setValue(urlRegistry); } - FieldLabel registryBaseUrlLabel = new FieldLabel(registryBaseUrl, - "Registry URL"); + FieldLabel registryBaseUrlLabel = new FieldLabel(registryBaseUrl, "Registry URL"); registryBaseUrlLabel.setVisible(false); p.add(registryBaseUrlLabel, new VerticalLayoutData(1, -1)); @@ -174,6 +200,9 @@ public class SDMXTableDetailCard extends WizardCard { version.setEmptyText("Enter Version..."); version.setValue(Constants.SDMX_CODELIST_EXPORT_DEFAULT_VERSION); p.add(new FieldLabel(version, "Version"), new VerticalLayoutData(1, -1)); + + excelTrue=null; + } @Override @@ -218,9 +247,8 @@ public class SDMXTableDetailCard extends WizardCard { } }; - if (id.getValue() == null || id.getValue().isEmpty() || !id.isValid() - || version.getValue() == null || version.getValue().isEmpty() - || !version.isValid() || agencyId.getValue() == null + if (id.getValue() == null || id.getValue().isEmpty() || !id.isValid() || version.getValue() == null + || version.getValue().isEmpty() || !version.isValid() || agencyId.getValue() == null || agencyId.getValue().isEmpty() || !agencyId.isValid()) { d = new AlertMessageBox("Attention!", "Fill in all fields"); @@ -228,8 +256,7 @@ public class SDMXTableDetailCard extends WizardCard { d.show(); } else { if (!version.getValue().matches("[0-9]+\\.[0-9]+")) { - d = new AlertMessageBox("Attention!", - "Version must match the regular expression [0-9]+\\.[0-9]+"); + d = new AlertMessageBox("Attention!", "Version must match the regular expression [0-9]+\\.[0-9]+"); d.addHideHandler(hideHandler); d.show(); } else { @@ -249,8 +276,11 @@ public class SDMXTableDetailCard extends WizardCard { exportSession.setAgencyId(agencyId.getCurrentValue()); exportSession.setVersion(version.getCurrentValue()); exportSession.setRegistryBaseUrl(registryBaseUrl.getCurrentValue()); - SDMXOperationInProgressCard sdmxOperationInProgressCard = new SDMXOperationInProgressCard( - exportSession); + if (excelTrue != null) { + exportSession.setExcel(excelTrue.getValue()); + } + + SDMXOperationInProgressCard sdmxOperationInProgressCard = new SDMXOperationInProgressCard(exportSession); getWizardWindow().addCard(sdmxOperationInProgressCard); Log.info("NextCard SDMXOperationInProgressCard"); getWizardWindow().nextCard();