refs 5870: TDM - adding new functionalities to portlets

Task-Url: https://support.d4science.org/issues/5870

Updated to support SDMX Dataset export

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-sdmx-export-widget@142036 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-02-01 17:54:41 +00:00 committed by Giancarlo Panichi
parent a3df91b41e
commit c7ffc4f87e
21 changed files with 567 additions and 88 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/tabular-data-sdmx-export-widget-1.7.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/tabular-data-sdmx-export-widget-1.8.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/tabular-data-sdmx-export-widget-1.7.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<classpathentry excluding="**" kind="src" output="target/tabular-data-sdmx-export-widget-1.8.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -45,5 +45,5 @@
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/tabular-data-sdmx-export-widget-1.7.0-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/tabular-data-sdmx-export-widget-1.8.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -0,0 +1,4 @@
eclipse.preferences.version=1
jarsExcludedFromWebInfLib=
warSrcDir=
warSrcDirIsOutput=true

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="tabular-data-sdmx-export-widget">
<wb-resource deploy-path="/" source-path="/src/main/java"/>
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
<wb-resource deploy-path="/" source-path="/src/test/java"/>
<wb-resource deploy-path="/" source-path="/src/test/resources"/>
</wb-module>
</project-modules>

View File

@ -45,14 +45,14 @@ Installation
--------------------------------------------------
Installation documentation is available on-line in the gCube Wiki:
https://gcube.wiki.gcube-system.org/gcube/index.php/Tabular_Data_Manager
${gcube.wikiRoot}/Tabular_Data_Manager
Documentation
--------------------------------------------------
Documentation is available on-line in the gCube Wiki:
https://gcube.wiki.gcube-system.org/gcube/index.php/Tabular_Data_Manager
${gcube.wikiRoot}/Tabular_Data_Manager
Support

View File

@ -1,4 +1,7 @@
<ReleaseNotes>
<Changeset component="${groupId}.${artifactId}.1-8-0" date="2017-02-15">
<Change>Updated to support Dataset export [ticket #5870]</Change>
</Changeset>
<Changeset component="${groupId}.${artifactId}.1-7-0" date="2015-07-03">
<Change>Updated Dependencies</Change>
</Changeset>

View File

@ -13,7 +13,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>tabular-data-sdmx-export-widget</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.8.0-SNAPSHOT</version>
<name>tabular-data-sdmx-export-widget</name>

View File

@ -10,6 +10,7 @@ import java.util.List;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies;
import org.gcube.portlets.user.td.sdmxexportwidget.client.properties.AgenciesProperties;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;

View File

@ -10,6 +10,7 @@ import java.util.List;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist;
import org.gcube.portlets.user.td.sdmxexportwidget.client.properties.CodelistProperties;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;

View File

@ -10,6 +10,7 @@ import java.util.List;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset;
import org.gcube.portlets.user.td.sdmxexportwidget.client.properties.DatasetProperties;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;

View File

@ -14,61 +14,76 @@ import com.google.gwt.event.logical.shared.SelectionHandler;
/**
*
* @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 SDMXAgenciesSelectionCard extends WizardCard {
protected SDMXAgenciesSelectionCard thisCard;
protected SDMXExportSession exportSession;
protected AgenciesSelectionPanel agenciesSelectionPanel;
protected Agencies agency;
private SDMXAgenciesSelectionCard thisCard;
private SDMXExportSession exportSession;
private AgenciesSelectionPanel agenciesSelectionPanel;
// private Agencies agency;
public SDMXAgenciesSelectionCard(final SDMXExportSession exportSession) {
super("SDMX Agencies selection", "");
this.exportSession = exportSession;
thisCard=this;
this.agenciesSelectionPanel=new AgenciesSelectionPanel(thisCard,res);
agenciesSelectionPanel.addSelectionHandler(new SelectionHandler<Agencies>(){
public void onSelection(SelectionEvent<Agencies> event) {
exportSession.setAgency(agenciesSelectionPanel.getSelectedItem());
getWizardWindow().setEnableNextButton(true);
}
});
this.exportSession = exportSession;
thisCard = this;
this.agenciesSelectionPanel = new AgenciesSelectionPanel(thisCard, res);
agenciesSelectionPanel
.addSelectionHandler(new SelectionHandler<Agencies>() {
public void onSelection(SelectionEvent<Agencies> event) {
exportSession.setAgency(agenciesSelectionPanel
.getSelectedItem());
getWizardWindow().setEnableNextButton(true);
}
});
setContent(agenciesSelectionPanel);
}
@Override
public void setup(){
public void setup() {
Command sayNextCard = new Command() {
public void execute() {
SDMXTableDetailCard sdmxTableDetailCard = new SDMXTableDetailCard(
exportSession);
getWizardWindow()
.addCard(sdmxTableDetailCard);
Log.info("NextCard SDMXTableDetailCard");
getWizardWindow().nextCard();
switch (exportSession.getExportType()) {
case CODELIST:
SDMXTableDetailCard sdmxTableDetailCard = new SDMXTableDetailCard(
exportSession);
getWizardWindow().addCard(sdmxTableDetailCard);
Log.info("NextCard SDMXTableDetailCard");
getWizardWindow().nextCard();
break;
case DATASET:
ViewColumnSelectionCard viewColumnSelectionCard = new ViewColumnSelectionCard(
exportSession);
getWizardWindow().addCard(viewColumnSelectionCard);
Log.info("NextCard ViewColumnSelectionCard");
getWizardWindow().nextCard();
break;
case GENERIC:
default:
Log.error("Only the tabular resources with type Codelist and Dataset"
+ " are exportable in SDMX!");
break;
}
}
};
getWizardWindow().setNextButtonCommand(sayNextCard);
getWizardWindow().setNextButtonCommand(sayNextCard);
Command sayPreviousCard = new Command() {
public void execute() {
try {
@ -79,11 +94,16 @@ public class SDMXAgenciesSelectionCard extends WizardCard {
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
}
}
};
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
getWizardWindow().setEnableNextButton(false);
};
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
// getWizardWindow().setEnableNextButton(false);
setEnableNextButton(false);
setBackButtonVisible(true);
setEnableBackButton(true);
}
}

View File

@ -21,10 +21,13 @@ import com.google.gwt.user.client.Command;
*/
public class SDMXCodelistSelectionCard extends WizardCard {
protected SDMXCodelistSelectionCard thisCard;
protected SDMXExportSession exportSession;
protected CodelistSelectionPanel codelistSelectionPanel;
protected Codelist codelist;
private SDMXCodelistSelectionCard thisCard;
@SuppressWarnings("unused")
private SDMXExportSession exportSession;
private CodelistSelectionPanel codelistSelectionPanel;
@SuppressWarnings("unused")
private Codelist codelist;
public SDMXCodelistSelectionCard(final SDMXExportSession exportSession) {
super("SDMX Codelist selection", "");

View File

@ -17,9 +17,10 @@ import com.google.gwt.user.client.Command;
*/
public class SDMXDatasetSelectionCard extends WizardCard {
protected SDMXDatasetSelectionCard thisCard;
protected SDMXExportSession exportSession;
protected DatasetSelectionPanel datasetSelectionPanel;
private SDMXDatasetSelectionCard thisCard;
@SuppressWarnings("unused")
private SDMXExportSession exportSession;
private DatasetSelectionPanel datasetSelectionPanel;
public SDMXDatasetSelectionCard(final SDMXExportSession exportSession) {
super("SDMX Dataset selection", "");

View File

@ -7,6 +7,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.TableType;
import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow;
import com.allen_sauer.gwt.log.client.Log;
@ -73,6 +74,9 @@ public class SDMXExportWizardTD extends WizardWindow {
public void onSuccess(TabResource result) {
Log.debug("Tabular Resource Information retrived");
exportSession.setTabResource(result);
exportSession.setExportType(TableType
.getColumnDataTypeFromId(result
.getTableTypeName()));
box.hide();
}
@ -84,5 +88,4 @@ public class SDMXExportWizardTD extends WizardWindow {
sdmxRegistrySelectionCard.setup();
}
}

View File

@ -69,6 +69,8 @@ public class SDMXRegistrySelectionCard extends WizardCard {
radioUrlRegistry.setStylePrimaryName(res.wizardCSS()
.getImportSelectionSource());
radioUrlRegistry.disable();
radioUrlRegistry.setVisible(false);
url.setName("sdmxRegistryUrlInpuntField");
url.setId("sdmxRegistryUrlInputFieldId");
@ -183,6 +185,7 @@ public class SDMXRegistrySelectionCard extends WizardCard {
getWizardWindow().setNextButtonCommand(sayNextCard);
Command sayPreviousCard = new Command() {
public void execute() {
try {
@ -199,6 +202,7 @@ public class SDMXRegistrySelectionCard extends WizardCard {
setEnableBackButton(false);
setEnableNextButton(true);
setBackButtonVisible(false);
}

View File

@ -3,17 +3,16 @@
*/
package org.gcube.portlets.user.td.sdmxexportwidget.client;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
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.core.client.GWT;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
import com.sencha.gxt.widget.core.client.button.TextButton;
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.event.HideEvent;
@ -30,24 +29,21 @@ import com.sencha.gxt.widget.core.client.form.TextField;
*/
public class SDMXTableDetailCard extends WizardCard {
protected final String TABLEDETAILPANELWIDTH = "100%";
protected final String TABLEDETAILPANELHEIGHT = "100%";
protected final String FORMWIDTH = "538px";
private final String TABLEDETAILPANELWIDTH = "100%";
private final String TABLEDETAILPANELHEIGHT = "100%";
private final String FORMWIDTH = "538px";
protected SDMXExportSession exportSession;
protected SDMXTableDetailCard thisCard;
private SDMXExportSession exportSession;
private SDMXTableDetailCard thisCard;
protected static final AgenciesProperties agenciesProperties = GWT
.create(AgenciesProperties.class);
protected VerticalLayoutContainer p = new VerticalLayoutContainer();
protected VerticalPanel tableDetailPanel;
private VerticalLayoutContainer p = new VerticalLayoutContainer();
private VerticalPanel tableDetailPanel;
protected TextField id;
protected TextField agencyName;
protected TextField registryBaseUrl;
protected TextField version;
protected TextButton checkButton;
private TextField id;
private TextField agencyName;
private TextField registryBaseUrl;
private TextField version;
private TextField viewColumn;
public SDMXTableDetailCard(final SDMXExportSession exportSession) {
super("SDMX Table Detail", "");
@ -70,18 +66,44 @@ public class SDMXTableDetailCard extends WizardCard {
fieldSet.setCollapsible(false);
form.add(fieldSet);
switch (exportSession.getExportType()) {
case DATASET:
datasetViewConfig();
break;
case CODELIST:
codelistViewConfig();
break;
case GENERIC:
break;
default:
break;
}
fieldSet.add(p);
tableDetailPanel.add(form);
setContent(tableDetailPanel);
}
private void datasetViewConfig() {
id = new TextField();
id.setAllowBlank(false);
id.setEmptyText("Enter Id...");
id.setValue(exportSession.getTabResource().getName());
id.setValue(Constants.SDMX_DATASET_EXPORT_DEFAULT_ID);
p.add(new FieldLabel(id, "Id"), new VerticalLayoutData(1, -1));
agencyName = new TextField();
agencyName.setVisible(true);
agencyName.setEmptyText("Enter Agency...");
agencyName.setValue(exportSession.getAgency().getName());
if (exportSession.getAgency().getName() == null
|| exportSession.getAgency().getName().isEmpty()) {
agencyName.setValue(Constants.SDMX_DATASET_EXPORT_DEFAULT_AGENCY);
} else {
agencyName.setValue(exportSession.getAgency().getName());
}
FieldLabel agencyNameLabel = new FieldLabel(agencyName, "Agency");
p.add(agencyNameLabel, new VerticalLayoutData(1, -1));
@ -103,12 +125,55 @@ public class SDMXTableDetailCard extends WizardCard {
version = new TextField();
version.setAllowBlank(false);
version.setEmptyText("Enter Version...");
version.setValue("");
version.setValue(Constants.SDMX_DATASET_EXPORT_DEFAULT_ID);
p.add(new FieldLabel(version, "Version"), new VerticalLayoutData(1, -1));
tableDetailPanel.add(form);
setContent(tableDetailPanel);
viewColumn = new TextField();
viewColumn.setValue(exportSession.getObsValueColumn().getLabel());
viewColumn.setReadOnly(true);
p.add(new FieldLabel(viewColumn, "Codelist Column"),
new VerticalLayoutData(1, -1));
}
private void codelistViewConfig() {
id = new TextField();
id.setAllowBlank(false);
id.setEmptyText("Enter Id...");
id.setValue(Constants.SDMX_CODELIST_EXPORT_DEFAULT_ID);
p.add(new FieldLabel(id, "Id"), new VerticalLayoutData(1, -1));
agencyName = new TextField();
agencyName.setVisible(true);
agencyName.setEmptyText("Enter Agency...");
if (exportSession.getAgency().getName() == null
|| exportSession.getAgency().getName().isEmpty()) {
agencyName.setValue(Constants.SDMX_CODELIST_EXPORT_DEFAULT_AGENCY);
} else {
agencyName.setValue(exportSession.getAgency().getName());
}
FieldLabel agencyNameLabel = new FieldLabel(agencyName, "Agency");
p.add(agencyNameLabel, new VerticalLayoutData(1, -1));
registryBaseUrl = new TextField();
registryBaseUrl.setVisible(false);
registryBaseUrl.setEmptyText("Enter Registry URL...");
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");
registryBaseUrlLabel.setVisible(false);
p.add(registryBaseUrlLabel, new VerticalLayoutData(1, -1));
version = new TextField();
version.setAllowBlank(false);
version.setEmptyText("Enter Version...");
version.setValue(Constants.SDMX_CODELIST_EXPORT_DEFAULT_ID);
p.add(new FieldLabel(version, "Version"), new VerticalLayoutData(1, -1));
}
@Override
@ -163,7 +228,8 @@ 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 {

View File

@ -0,0 +1,92 @@
/**
*
*/
package org.gcube.portlets.user.td.sdmxexportwidget.client;
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnData;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.Command;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ViewColumnSelectionCard extends WizardCard {
private ViewColumnSelectionCard thisCard;
private SDMXExportSession exportSession;
private ViewColumnSelectionPanel viewColumnSelectionPanel;
//private Agencies agency;
public ViewColumnSelectionCard(final SDMXExportSession exportSession) {
super("Codelist column selection", "");
this.exportSession = exportSession;
thisCard = this;
this.viewColumnSelectionPanel = new ViewColumnSelectionPanel(thisCard,res, exportSession);
viewColumnSelectionPanel
.addSelectionHandler(new SelectionHandler<ColumnData>() {
public void onSelection(SelectionEvent<ColumnData> event) {
exportSession.setObsValueColumn(viewColumnSelectionPanel
.getSelectedItem());
getWizardWindow().setEnableNextButton(true);
}
});
setContent(viewColumnSelectionPanel);
}
@Override
public void setup() {
Command sayNextCard = new Command() {
public void execute() {
SDMXTableDetailCard sdmxTableDetailCard = new SDMXTableDetailCard(
exportSession);
getWizardWindow().addCard(sdmxTableDetailCard);
Log.info("NextCard SDMXTableDetailCard");
getWizardWindow().nextCard();
}
};
getWizardWindow().setNextButtonCommand(sayNextCard);
Command sayPreviousCard = new Command() {
public void execute() {
try {
getWizardWindow().previousCard();
getWizardWindow().removeCard(thisCard);
Log.info("Remove viewColumnSelectionCard");
} catch (Exception e) {
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
}
}
};
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
// getWizardWindow().setEnableNextButton(false);
setEnableNextButton(false);
setBackButtonVisible(true);
setEnableBackButton(true);
}
}

View File

@ -0,0 +1,254 @@
/**
*
*/
package org.gcube.portlets.user.td.sdmxexportwidget.client;
import java.util.ArrayList;
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.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
import org.gcube.portlets.user.td.sdmxexportwidget.client.properties.ColumnDataProperties;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnData;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.event.logical.shared.HasSelectionHandlers;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.sencha.gxt.core.client.IdentityValueProvider;
import com.sencha.gxt.core.client.Style.SelectionMode;
import com.sencha.gxt.data.client.loader.RpcProxy;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.data.shared.ModelKeyProvider;
import com.sencha.gxt.data.shared.Store;
import com.sencha.gxt.data.shared.Store.StoreFilter;
import com.sencha.gxt.data.shared.loader.ListLoadConfig;
import com.sencha.gxt.data.shared.loader.ListLoadResult;
import com.sencha.gxt.data.shared.loader.ListLoadResultBean;
import com.sencha.gxt.data.shared.loader.ListLoader;
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding;
import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.button.TextButton;
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.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
import com.sencha.gxt.widget.core.client.form.TextField;
import com.sencha.gxt.widget.core.client.grid.CheckBoxSelectionModel;
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid;
import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem;
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ViewColumnSelectionPanel extends ContentPanel implements
HasSelectionHandlers<ColumnData> {
private static final ColumnDataProperties properties = GWT
.create(ColumnDataProperties.class);
private static final ColumnConfig<ColumnData, String> nameColumn = new ColumnConfig<ColumnData, String>(
properties.label(), 50, "Name");
private Grid<ColumnData> grid;
private WizardCard parent;
private ResourceBundle res;
private SDMXExportSession sdmxExportSession;
public ViewColumnSelectionPanel(WizardCard parent, ResourceBundle res,
SDMXExportSession sdmxExportSession) {
this.parent=parent;
this.res = res;
this.sdmxExportSession = sdmxExportSession;
setHeaderVisible(false);
buildPanel(properties.id(),
Arrays.<ColumnConfig<ColumnData, ?>> asList(nameColumn),
nameColumn);
}
private void buildPanel(ModelKeyProvider<ColumnData> keyProvider,
List<ColumnConfig<ColumnData, ?>> columns,
ColumnConfig<ColumnData, ?> autoexpandColumn) {
ToolBar toolBar = new ToolBar();
toolBar.add(new LabelToolItem("Search: "));
final TextField searchField = new TextField();
toolBar.add(searchField);
TextButton btnReload = new TextButton();
// btnReload.setText("Reload");
btnReload.setIcon(res.refresh16());
btnReload.setToolTip("Reload");
toolBar.add(btnReload);
IdentityValueProvider<ColumnData> identity = new IdentityValueProvider<ColumnData>();
final CheckBoxSelectionModel<ColumnData> sm = new CheckBoxSelectionModel<ColumnData>(
identity);
ColumnModel<ColumnData> cm = new ColumnModel<ColumnData>(columns);
final ExtendedListStore<ColumnData> store = new ExtendedListStore<ColumnData>(
keyProvider);
searchField.addKeyUpHandler(new KeyUpHandler() {
public void onKeyUp(KeyUpEvent event) {
Log.trace("searchTerm: " + searchField.getCurrentValue());
store.applyFilters();
}
});
store.addFilter(new StoreFilter<ColumnData>() {
public boolean select(Store<ColumnData> store, ColumnData parent,
ColumnData item) {
String searchTerm = searchField.getCurrentValue();
if (searchTerm == null)
return true;
return ViewColumnSelectionPanel.this.select(item, searchTerm);
}
});
store.setEnableFilters(true);
RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>>() {
public void load(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
loadData(loadConfig, callback);
}
};
final ListLoader<ListLoadConfig, ListLoadResult<ColumnData>> loader = new ListLoader<ListLoadConfig, ListLoadResult<ColumnData>>(
proxy);
loader.setRemoteSort(false);
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, ColumnData, ListLoadResult<ColumnData>>(
store));
grid = new Grid<ColumnData>(store, cm) {
@Override
protected void onAfterFirstAttach() {
super.onAfterFirstAttach();
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
loader.load();
}
});
}
};
sm.setSelectionMode(SelectionMode.SINGLE);
grid.setLoader(loader);
grid.setSelectionModel(sm);
grid.getView().setAutoExpandColumn(autoexpandColumn);
grid.getView().setStripeRows(true);
grid.getView().setColumnLines(true);
grid.getView().setAutoFill(true);
grid.setBorders(false);
grid.setLoadMask(true);
grid.setColumnReordering(true);
SelectHandler sh = new SelectHandler() {
public void onSelect(SelectEvent event) {
loader.load();
}
};
btnReload.addSelectHandler(sh);
VerticalLayoutContainer con = new VerticalLayoutContainer();
con.add(toolBar, new VerticalLayoutData(1, -1));
con.add(grid, new VerticalLayoutData(1, 1));
setWidget(con);
}
protected boolean select(ColumnData item, String searchTerm) {
if (item.getLabel() != null
&& item.getLabel().toLowerCase()
.contains(searchTerm.toLowerCase()))
return true;
return false;
}
protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
TDGWTServiceAsync.INSTANCE.getColumnWithViewColumnIncluded(
sdmxExportSession.getTabResource().getTrId(),
new AsyncCallback<ArrayList<ColumnData>>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
parent.getEventBus()
.fireEvent(
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("No ColumnData retrieved");
}
callback.onFailure(caught);
}
public void onSuccess(ArrayList<ColumnData> result) {
Log.trace("loaded " + result.size() + " ColumnData");
List<ColumnData> viewColumn=new ArrayList<>();
for(ColumnData column:result){
if(column!=null&& column.isViewColumn()){
viewColumn.add(column);
}
}
callback.onSuccess(new ListLoadResultBean<ColumnData>(
viewColumn));
}
});
}
public HandlerRegistration addSelectionHandler(
SelectionHandler<ColumnData> handler) {
return grid.getSelectionModel().addSelectionHandler(handler);
}
/*
* public List<ColumnData> getSelectedItems() { return
* grid.getSelectionModel().getSelectedItems(); }
*/
public ColumnData getSelectedItem() {
return grid.getSelectionModel().getSelectedItem();
}
protected class ExtendedListStore<M> extends ListStore<M> {
public ExtendedListStore(ModelKeyProvider<? super M> keyProvider) {
super(keyProvider);
}
public void applyFilters() {
super.applyFilters();
}
}
}

View File

@ -1,7 +1,7 @@
/**
*
*/
package org.gcube.portlets.user.td.sdmxexportwidget.client;
package org.gcube.portlets.user.td.sdmxexportwidget.client.properties;

View File

@ -1,7 +1,7 @@
/**
*
*/
package org.gcube.portlets.user.td.sdmxexportwidget.client;
package org.gcube.portlets.user.td.sdmxexportwidget.client.properties;

View File

@ -0,0 +1,25 @@
package org.gcube.portlets.user.td.sdmxexportwidget.client.properties;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnData;
import com.google.gwt.editor.client.Editor.Path;
import com.sencha.gxt.core.client.ValueProvider;
import com.sencha.gxt.data.shared.ModelKeyProvider;
import com.sencha.gxt.data.shared.PropertyAccess;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface ColumnDataProperties extends
PropertyAccess<ColumnData> {
@Path("id")
ModelKeyProvider<ColumnData> id();
ValueProvider<ColumnData,String> label();
}

View File

@ -1,7 +1,7 @@
/**
*
*/
package org.gcube.portlets.user.td.sdmxexportwidget.client;
package org.gcube.portlets.user.td.sdmxexportwidget.client.properties;
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset;