ref 8033:Support for SDMX export from templates on tabman
https://support.d4science.org/issues/8033 Updated to support export of Dataset git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-sdmx-export-widget@146849 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d38abe2959
commit
27b1a7d826
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" output="target/tabular-data-sdmx-export-widget-1.8.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
<classpathentry kind="src" output="target/tabular-data-sdmx-export-widget-1.9.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry excluding="**" kind="src" output="target/tabular-data-sdmx-export-widget-1.8.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
<classpathentry excluding="**" kind="src" output="target/tabular-data-sdmx-export-widget-1.9.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
@ -45,5 +45,5 @@
|
||||||
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/tabular-data-sdmx-export-widget-1.8.0-SNAPSHOT/WEB-INF/classes"/>
|
<classpathentry kind="output" path="target/tabular-data-sdmx-export-widget-1.9.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
<ReleaseNotes>
|
<ReleaseNotes>
|
||||||
|
<Changeset component="${groupId}.${artifactId}.1-9-0" date="2017-04-01">
|
||||||
|
<Change>Added support for template export in SDMX [issue #8033]
|
||||||
|
</Change>
|
||||||
|
</Changeset>
|
||||||
<Changeset component="${groupId}.${artifactId}.1-8-0" date="2017-02-15">
|
<Changeset component="${groupId}.${artifactId}.1-8-0" date="2017-02-15">
|
||||||
<Change>Updated to support Dataset export [ticket #5870]</Change>
|
<Change>Updated to support Dataset export [ticket #5870]</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -13,7 +13,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
<artifactId>tabular-data-sdmx-export-widget</artifactId>
|
<artifactId>tabular-data-sdmx-export-widget</artifactId>
|
||||||
<version>1.8.0-SNAPSHOT</version>
|
<version>1.9.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
|
||||||
<name>tabular-data-sdmx-export-widget</name>
|
<name>tabular-data-sdmx-export-widget</name>
|
||||||
|
|
|
@ -23,7 +23,8 @@ public class MeasureColumnSelectionCard extends WizardCard {
|
||||||
private MeasureColumnSelectionCard thisCard;
|
private MeasureColumnSelectionCard thisCard;
|
||||||
private SDMXExportSession exportSession;
|
private SDMXExportSession exportSession;
|
||||||
private MeasureColumnSelectionPanel measureColumnSelectionPanel;
|
private MeasureColumnSelectionPanel measureColumnSelectionPanel;
|
||||||
//private Agencies agency;
|
|
||||||
|
// private Agencies agency;
|
||||||
|
|
||||||
public MeasureColumnSelectionCard(final SDMXExportSession exportSession) {
|
public MeasureColumnSelectionCard(final SDMXExportSession exportSession) {
|
||||||
super("Measure column selection", "");
|
super("Measure column selection", "");
|
||||||
|
@ -31,13 +32,15 @@ public class MeasureColumnSelectionCard extends WizardCard {
|
||||||
this.exportSession = exportSession;
|
this.exportSession = exportSession;
|
||||||
thisCard = this;
|
thisCard = this;
|
||||||
|
|
||||||
this.measureColumnSelectionPanel = new MeasureColumnSelectionPanel(thisCard,res, exportSession);
|
this.measureColumnSelectionPanel = new MeasureColumnSelectionPanel(
|
||||||
|
thisCard, res, exportSession);
|
||||||
|
|
||||||
measureColumnSelectionPanel
|
measureColumnSelectionPanel
|
||||||
.addSelectionHandler(new SelectionHandler<ColumnData>() {
|
.addSelectionHandler(new SelectionHandler<ColumnData>() {
|
||||||
|
|
||||||
public void onSelection(SelectionEvent<ColumnData> event) {
|
public void onSelection(SelectionEvent<ColumnData> event) {
|
||||||
exportSession.setObsValueColumn(measureColumnSelectionPanel
|
exportSession
|
||||||
|
.setObsValueColumn(measureColumnSelectionPanel
|
||||||
.getSelectedItem());
|
.getSelectedItem());
|
||||||
getWizardWindow().setEnableNextButton(true);
|
getWizardWindow().setEnableNextButton(true);
|
||||||
|
|
||||||
|
@ -81,12 +84,15 @@ public class MeasureColumnSelectionCard extends WizardCard {
|
||||||
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||||
// getWizardWindow().setEnableNextButton(false);
|
// getWizardWindow().setEnableNextButton(false);
|
||||||
|
|
||||||
setEnableNextButton(false);
|
|
||||||
|
|
||||||
setBackButtonVisible(true);
|
setBackButtonVisible(true);
|
||||||
setEnableBackButton(true);
|
setEnableBackButton(true);
|
||||||
|
|
||||||
|
if (measureColumnSelectionPanel == null
|
||||||
|
|| measureColumnSelectionPanel.getSelectedItem() == null) {
|
||||||
|
setEnableNextButton(false);
|
||||||
|
} else {
|
||||||
|
setEnableNextButton(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,11 +99,17 @@ public class SDMXAgenciesSelectionCard extends WizardCard {
|
||||||
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||||
// getWizardWindow().setEnableNextButton(false);
|
// getWizardWindow().setEnableNextButton(false);
|
||||||
|
|
||||||
setEnableNextButton(false);
|
|
||||||
|
|
||||||
setBackButtonVisible(true);
|
setBackButtonVisible(true);
|
||||||
setEnableBackButton(true);
|
setEnableBackButton(true);
|
||||||
|
|
||||||
|
if (agenciesSelectionPanel == null
|
||||||
|
|| agenciesSelectionPanel.getSelectedItem() == null) {
|
||||||
|
setEnableNextButton(false);
|
||||||
|
} else {
|
||||||
|
setEnableNextButton(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client.properties;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateColumnData;
|
||||||
|
|
||||||
|
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 TemplateColumnDataProperties extends
|
||||||
|
PropertyAccess<TemplateColumnData> {
|
||||||
|
|
||||||
|
@Path("id")
|
||||||
|
ModelKeyProvider<TemplateColumnData> id();
|
||||||
|
|
||||||
|
ValueProvider<TemplateColumnData,String> label();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client.properties;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData;
|
||||||
|
|
||||||
|
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
|
||||||
|
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface TemplateDataProperties extends PropertyAccess<TemplateData> {
|
||||||
|
|
||||||
|
@Path("id")
|
||||||
|
ModelKeyProvider<TemplateData> id();
|
||||||
|
|
||||||
|
ValueProvider<TemplateData, String> name();
|
||||||
|
ValueProvider<TemplateData, String> category();
|
||||||
|
ValueProvider<TemplateData, String> ownerLogin();
|
||||||
|
ValueProvider<TemplateData, String> agency();
|
||||||
|
ValueProvider<TemplateData, String> description();
|
||||||
|
ValueProvider<TemplateData, Date> creationDate();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client.template;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXTemplateExportSession;
|
||||||
|
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;
|
||||||
|
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||||
|
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||||
|
import com.google.gwt.user.client.Command;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SDMXTemplateExportAgenciesSelectionCard extends WizardCard {
|
||||||
|
|
||||||
|
private SDMXTemplateExportAgenciesSelectionCard thisCard;
|
||||||
|
private SDMXTemplateExportSession sdmxTemplateExportSession;
|
||||||
|
private SDMXTemplateExportAgenciesSelectionPanel agenciesSelectionPanel;
|
||||||
|
|
||||||
|
// private Agencies agency;
|
||||||
|
|
||||||
|
public SDMXTemplateExportAgenciesSelectionCard(
|
||||||
|
final SDMXTemplateExportSession sdmxTemplateExportSession) {
|
||||||
|
super("SDMX Agencies selection", "");
|
||||||
|
|
||||||
|
this.sdmxTemplateExportSession = sdmxTemplateExportSession;
|
||||||
|
thisCard = this;
|
||||||
|
|
||||||
|
this.agenciesSelectionPanel = new SDMXTemplateExportAgenciesSelectionPanel(
|
||||||
|
thisCard, res);
|
||||||
|
|
||||||
|
agenciesSelectionPanel
|
||||||
|
.addSelectionHandler(new SelectionHandler<Agencies>() {
|
||||||
|
|
||||||
|
public void onSelection(SelectionEvent<Agencies> event) {
|
||||||
|
if (agenciesSelectionPanel.getSelectedItem() == null) {
|
||||||
|
sdmxTemplateExportSession.setAgency(null);
|
||||||
|
getWizardWindow().setEnableNextButton(false);
|
||||||
|
} else {
|
||||||
|
sdmxTemplateExportSession
|
||||||
|
.setAgency(agenciesSelectionPanel
|
||||||
|
.getSelectedItem());
|
||||||
|
getWizardWindow().setEnableNextButton(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
setContent(agenciesSelectionPanel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
Command sayNextCard = new Command() {
|
||||||
|
|
||||||
|
public void execute() {
|
||||||
|
SDMXTemplateSelectionCard sdmxTemplateSelectionCard = new SDMXTemplateSelectionCard(
|
||||||
|
sdmxTemplateExportSession);
|
||||||
|
getWizardWindow().addCard(sdmxTemplateSelectionCard);
|
||||||
|
Log.info("NextCard SDMXTemplateExportTemplateSelectionCard");
|
||||||
|
getWizardWindow().nextCard();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setNextButtonCommand(sayNextCard);
|
||||||
|
|
||||||
|
Command sayPreviousCard = new Command() {
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
getWizardWindow().previousCard();
|
||||||
|
getWizardWindow().removeCard(thisCard);
|
||||||
|
Log.info("Remove SDMXTemplateExportAgenciesSelectionCard");
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||||
|
// getWizardWindow().setEnableNextButton(false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
setBackButtonVisible(true);
|
||||||
|
setEnableBackButton(true);
|
||||||
|
|
||||||
|
if (agenciesSelectionPanel == null
|
||||||
|
|| agenciesSelectionPanel.getSelectedItem() == null) {
|
||||||
|
setEnableNextButton(false);
|
||||||
|
} else {
|
||||||
|
setEnableNextButton(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,251 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client.template;
|
||||||
|
|
||||||
|
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.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;
|
||||||
|
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 SDMXTemplateExportAgenciesSelectionPanel extends ContentPanel implements
|
||||||
|
HasSelectionHandlers<Agencies> {
|
||||||
|
|
||||||
|
private static final AgenciesProperties properties = GWT
|
||||||
|
.create(AgenciesProperties.class);
|
||||||
|
|
||||||
|
protected static final ColumnConfig<Agencies, String> idColumn = new ColumnConfig<Agencies, String>(
|
||||||
|
properties.id(), 50, "Id");
|
||||||
|
protected static final ColumnConfig<Agencies, String> nameColumn = new ColumnConfig<Agencies, String>(
|
||||||
|
properties.name(), 50, "Name");
|
||||||
|
protected static final ColumnConfig<Agencies, String> descriptionColumn = new ColumnConfig<Agencies, String>(
|
||||||
|
properties.description(), 50, "Description");
|
||||||
|
|
||||||
|
protected Grid<Agencies> grid;
|
||||||
|
protected ResourceBundle res;
|
||||||
|
|
||||||
|
private WizardCard parent;
|
||||||
|
|
||||||
|
public SDMXTemplateExportAgenciesSelectionPanel(WizardCard parent, ResourceBundle res) {
|
||||||
|
this.parent = parent;
|
||||||
|
this.res = res;
|
||||||
|
setHeaderVisible(false);
|
||||||
|
//new Resizable(this, Dir.E, Dir.SE, Dir.S);
|
||||||
|
buildPanel(properties.key(), Arrays.<ColumnConfig<Agencies, ?>> asList(
|
||||||
|
idColumn, nameColumn, descriptionColumn), idColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void buildPanel(ModelKeyProvider<Agencies> keyProvider,
|
||||||
|
List<ColumnConfig<Agencies, ?>> columns,
|
||||||
|
ColumnConfig<Agencies, ?> 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<Agencies> identity = new IdentityValueProvider<Agencies>();
|
||||||
|
final CheckBoxSelectionModel<Agencies> sm = new CheckBoxSelectionModel<Agencies>(
|
||||||
|
identity);
|
||||||
|
|
||||||
|
ColumnModel<Agencies> cm = new ColumnModel<Agencies>(columns);
|
||||||
|
|
||||||
|
final ExtendedListStore<Agencies> store = new ExtendedListStore<Agencies>(
|
||||||
|
keyProvider);
|
||||||
|
|
||||||
|
searchField.addKeyUpHandler(new KeyUpHandler() {
|
||||||
|
|
||||||
|
public void onKeyUp(KeyUpEvent event) {
|
||||||
|
Log.trace("searchTerm: " + searchField.getCurrentValue());
|
||||||
|
store.applyFilters();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
store.addFilter(new StoreFilter<Agencies>() {
|
||||||
|
|
||||||
|
public boolean select(Store<Agencies> store, Agencies parent,
|
||||||
|
Agencies item) {
|
||||||
|
String searchTerm = searchField.getCurrentValue();
|
||||||
|
if (searchTerm == null)
|
||||||
|
return true;
|
||||||
|
return SDMXTemplateExportAgenciesSelectionPanel.this.select(item, searchTerm);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
store.setEnableFilters(true);
|
||||||
|
|
||||||
|
RpcProxy<ListLoadConfig, ListLoadResult<Agencies>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<Agencies>>() {
|
||||||
|
|
||||||
|
public void load(ListLoadConfig loadConfig,
|
||||||
|
final AsyncCallback<ListLoadResult<Agencies>> callback) {
|
||||||
|
loadData(loadConfig, callback);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
final ListLoader<ListLoadConfig, ListLoadResult<Agencies>> loader = new ListLoader<ListLoadConfig, ListLoadResult<Agencies>>(
|
||||||
|
proxy);
|
||||||
|
|
||||||
|
loader.setRemoteSort(false);
|
||||||
|
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, Agencies, ListLoadResult<Agencies>>(
|
||||||
|
store));
|
||||||
|
|
||||||
|
grid = new Grid<Agencies>(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(Agencies item, String searchTerm) {
|
||||||
|
if (item.getName() != null
|
||||||
|
&& item.getName().toLowerCase()
|
||||||
|
.contains(searchTerm.toLowerCase()))
|
||||||
|
return true;
|
||||||
|
if (item.getDescription() != null
|
||||||
|
&& item.getDescription().toLowerCase()
|
||||||
|
.contains(searchTerm.toLowerCase()))
|
||||||
|
return true;
|
||||||
|
if (item.getId() != null
|
||||||
|
&& item.getId().toLowerCase()
|
||||||
|
.contains(searchTerm.toLowerCase()))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void loadData(ListLoadConfig loadConfig,
|
||||||
|
final AsyncCallback<ListLoadResult<Agencies>> callback) {
|
||||||
|
TDGWTServiceAsync.INSTANCE
|
||||||
|
.getAgencies(new AsyncCallback<ArrayList<Agencies>>() {
|
||||||
|
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
if (caught instanceof TDGWTSessionExpiredException) {
|
||||||
|
parent.getEventBus()
|
||||||
|
.fireEvent(
|
||||||
|
new SessionExpiredEvent(
|
||||||
|
SessionExpiredType.EXPIREDONSERVER));
|
||||||
|
} else {
|
||||||
|
Log.error("No agencies retrieved");
|
||||||
|
}
|
||||||
|
callback.onFailure(caught);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSuccess(ArrayList<Agencies> result) {
|
||||||
|
Log.trace("loaded " + result.size() + " agencies");
|
||||||
|
callback.onSuccess(new ListLoadResultBean<Agencies>(
|
||||||
|
result));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerRegistration addSelectionHandler(
|
||||||
|
SelectionHandler<Agencies> handler) {
|
||||||
|
return grid.getSelectionModel().addSelectionHandler(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* public List<Agencies> getSelectedItems() { return
|
||||||
|
* grid.getSelectionModel().getSelectedItems(); }
|
||||||
|
*/
|
||||||
|
|
||||||
|
public Agencies 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,104 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client.template;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXTemplateExportSession;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateColumnData;
|
||||||
|
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||||
|
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||||
|
import com.google.gwt.user.client.Command;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SDMXTemplateExportMeasureColumnSelectionCard extends WizardCard {
|
||||||
|
|
||||||
|
private SDMXTemplateExportMeasureColumnSelectionCard thisCard;
|
||||||
|
private SDMXTemplateExportSession sdmxTemplateExportSession;
|
||||||
|
private SDMXTemplateExportMeasureColumnSelectionPanel measureColumnSelectionPanel;
|
||||||
|
|
||||||
|
public SDMXTemplateExportMeasureColumnSelectionCard(
|
||||||
|
final SDMXTemplateExportSession sdmxTemplateExportSession) {
|
||||||
|
super("Measure column selection", "");
|
||||||
|
|
||||||
|
this.sdmxTemplateExportSession = sdmxTemplateExportSession;
|
||||||
|
thisCard = this;
|
||||||
|
|
||||||
|
this.measureColumnSelectionPanel = new SDMXTemplateExportMeasureColumnSelectionPanel(
|
||||||
|
thisCard, res, sdmxTemplateExportSession);
|
||||||
|
|
||||||
|
measureColumnSelectionPanel
|
||||||
|
.addSelectionHandler(new SelectionHandler<TemplateColumnData>() {
|
||||||
|
|
||||||
|
public void onSelection(
|
||||||
|
SelectionEvent<TemplateColumnData> event) {
|
||||||
|
if (measureColumnSelectionPanel.getSelectedItem() == null) {
|
||||||
|
sdmxTemplateExportSession.setObsValueColumn(null);
|
||||||
|
getWizardWindow().setEnableNextButton(false);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
sdmxTemplateExportSession
|
||||||
|
.setObsValueColumn(measureColumnSelectionPanel
|
||||||
|
.getSelectedItem());
|
||||||
|
getWizardWindow().setEnableNextButton(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
setContent(measureColumnSelectionPanel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
Command sayNextCard = new Command() {
|
||||||
|
|
||||||
|
public void execute() {
|
||||||
|
SDMXTemplateExportTableDetailCard sdmxTableDetailCard = new SDMXTemplateExportTableDetailCard(
|
||||||
|
sdmxTemplateExportSession);
|
||||||
|
getWizardWindow().addCard(sdmxTableDetailCard);
|
||||||
|
Log.info("NextCard SDMXTemplateExportTableDetailCard");
|
||||||
|
getWizardWindow().nextCard();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setNextButtonCommand(sayNextCard);
|
||||||
|
|
||||||
|
Command sayPreviousCard = new Command() {
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
getWizardWindow().previousCard();
|
||||||
|
getWizardWindow().removeCard(thisCard);
|
||||||
|
Log.info("Remove measureColumnSelectionCard");
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||||
|
// getWizardWindow().setEnableNextButton(false);
|
||||||
|
|
||||||
|
setBackButtonVisible(true);
|
||||||
|
setEnableBackButton(true);
|
||||||
|
|
||||||
|
if (measureColumnSelectionPanel == null
|
||||||
|
|| measureColumnSelectionPanel.getSelectedItem() == null) {
|
||||||
|
setEnableNextButton(false);
|
||||||
|
} else {
|
||||||
|
setEnableNextButton(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,265 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client.template;
|
||||||
|
|
||||||
|
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.SDMXTemplateExportSession;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateColumnData;
|
||||||
|
import org.gcube.portlets.user.td.sdmxexportwidget.client.properties.TemplateColumnDataProperties;
|
||||||
|
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.ColumnTypeCode;
|
||||||
|
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 SDMXTemplateExportMeasureColumnSelectionPanel extends ContentPanel
|
||||||
|
implements HasSelectionHandlers<TemplateColumnData> {
|
||||||
|
|
||||||
|
private static final TemplateColumnDataProperties properties = GWT
|
||||||
|
.create(TemplateColumnDataProperties.class);
|
||||||
|
|
||||||
|
private static final ColumnConfig<TemplateColumnData, String> nameColumn = new ColumnConfig<TemplateColumnData, String>(
|
||||||
|
properties.label(), 50, "Name");
|
||||||
|
|
||||||
|
private Grid<TemplateColumnData> grid;
|
||||||
|
|
||||||
|
private WizardCard parent;
|
||||||
|
private ResourceBundle res;
|
||||||
|
private SDMXTemplateExportSession sdmxTemplateExportSession;
|
||||||
|
|
||||||
|
public SDMXTemplateExportMeasureColumnSelectionPanel(WizardCard parent,
|
||||||
|
ResourceBundle res,
|
||||||
|
SDMXTemplateExportSession sdmxTemplateExportSession) {
|
||||||
|
this.parent = parent;
|
||||||
|
this.res = res;
|
||||||
|
this.sdmxTemplateExportSession = sdmxTemplateExportSession;
|
||||||
|
|
||||||
|
setHeaderVisible(false);
|
||||||
|
buildPanel(
|
||||||
|
properties.id(),
|
||||||
|
Arrays.<ColumnConfig<TemplateColumnData, ?>> asList(nameColumn),
|
||||||
|
nameColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildPanel(ModelKeyProvider<TemplateColumnData> keyProvider,
|
||||||
|
List<ColumnConfig<TemplateColumnData, ?>> columns,
|
||||||
|
ColumnConfig<TemplateColumnData, ?> 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<TemplateColumnData> identity = new IdentityValueProvider<TemplateColumnData>();
|
||||||
|
final CheckBoxSelectionModel<TemplateColumnData> sm = new CheckBoxSelectionModel<TemplateColumnData>(
|
||||||
|
identity);
|
||||||
|
|
||||||
|
ColumnModel<TemplateColumnData> cm = new ColumnModel<TemplateColumnData>(
|
||||||
|
columns);
|
||||||
|
|
||||||
|
final ExtendedListStore<TemplateColumnData> store = new ExtendedListStore<TemplateColumnData>(
|
||||||
|
keyProvider);
|
||||||
|
|
||||||
|
searchField.addKeyUpHandler(new KeyUpHandler() {
|
||||||
|
|
||||||
|
public void onKeyUp(KeyUpEvent event) {
|
||||||
|
Log.trace("searchTerm: " + searchField.getCurrentValue());
|
||||||
|
store.applyFilters();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
store.addFilter(new StoreFilter<TemplateColumnData>() {
|
||||||
|
|
||||||
|
public boolean select(Store<TemplateColumnData> store,
|
||||||
|
TemplateColumnData parent, TemplateColumnData item) {
|
||||||
|
String searchTerm = searchField.getCurrentValue();
|
||||||
|
if (searchTerm == null)
|
||||||
|
return true;
|
||||||
|
return SDMXTemplateExportMeasureColumnSelectionPanel.this
|
||||||
|
.select(item, searchTerm);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
store.setEnableFilters(true);
|
||||||
|
|
||||||
|
RpcProxy<ListLoadConfig, ListLoadResult<TemplateColumnData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<TemplateColumnData>>() {
|
||||||
|
|
||||||
|
public void load(
|
||||||
|
ListLoadConfig loadConfig,
|
||||||
|
final AsyncCallback<ListLoadResult<TemplateColumnData>> callback) {
|
||||||
|
loadData(loadConfig, callback);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
final ListLoader<ListLoadConfig, ListLoadResult<TemplateColumnData>> loader = new ListLoader<ListLoadConfig, ListLoadResult<TemplateColumnData>>(
|
||||||
|
proxy);
|
||||||
|
|
||||||
|
loader.setRemoteSort(false);
|
||||||
|
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, TemplateColumnData, ListLoadResult<TemplateColumnData>>(
|
||||||
|
store));
|
||||||
|
|
||||||
|
grid = new Grid<TemplateColumnData>(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(TemplateColumnData 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<TemplateColumnData>> callback) {
|
||||||
|
|
||||||
|
String templateId=String.valueOf(sdmxTemplateExportSession
|
||||||
|
.getTemplateData().getId());
|
||||||
|
|
||||||
|
TDGWTServiceAsync.INSTANCE.getTemplateColumnsData(templateId,
|
||||||
|
new AsyncCallback<ArrayList<TemplateColumnData>>() {
|
||||||
|
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
if (caught instanceof TDGWTSessionExpiredException) {
|
||||||
|
parent.getEventBus()
|
||||||
|
.fireEvent(
|
||||||
|
new SessionExpiredEvent(
|
||||||
|
SessionExpiredType.EXPIREDONSERVER));
|
||||||
|
} else {
|
||||||
|
Log.error("No Template Columns Data retrieved");
|
||||||
|
}
|
||||||
|
callback.onFailure(caught);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSuccess(ArrayList<TemplateColumnData> result) {
|
||||||
|
Log.trace("loaded " + result.size() + " Template Columns Data");
|
||||||
|
List<TemplateColumnData> measureColumn = new ArrayList<>();
|
||||||
|
for (TemplateColumnData column : result) {
|
||||||
|
if (column != null
|
||||||
|
&& column.getTypeCode() != null
|
||||||
|
&& column.getTypeCode().compareTo(
|
||||||
|
ColumnTypeCode.MEASURE) == 0) {
|
||||||
|
measureColumn.add(column);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
callback.onSuccess(new ListLoadResultBean<TemplateColumnData>(
|
||||||
|
measureColumn));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerRegistration addSelectionHandler(
|
||||||
|
SelectionHandler<TemplateColumnData> handler) {
|
||||||
|
return grid.getSelectionModel().addSelectionHandler(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* public List<TemplateColumnData> getSelectedItems() { return
|
||||||
|
* grid.getSelectionModel().getSelectedItems(); }
|
||||||
|
*/
|
||||||
|
|
||||||
|
public TemplateColumnData 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,295 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client.template;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXTemplateExportSession;
|
||||||
|
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
|
||||||
|
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
|
||||||
|
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.OperationResult;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||||
|
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||||
|
import com.google.gwt.user.client.Command;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.google.gwt.user.client.ui.FlexTable;
|
||||||
|
import com.sencha.gxt.core.client.util.Margins;
|
||||||
|
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.MarginData;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer.VBoxLayoutAlign;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SDMXTemplateExportOperationInProgressCard extends WizardCard implements
|
||||||
|
MonitorDialogListener {
|
||||||
|
|
||||||
|
protected SDMXTemplateExportOperationInProgressCard thisCard;
|
||||||
|
protected SDMXTemplateExportSession sdmxTemplateExportSession;
|
||||||
|
protected TRId newTrId;
|
||||||
|
protected HtmlLayoutContainer resultField;
|
||||||
|
|
||||||
|
public SDMXTemplateExportOperationInProgressCard(final SDMXTemplateExportSession sdmxTemplateExportSession) {
|
||||||
|
super("Operation In Progress", "");
|
||||||
|
|
||||||
|
this.sdmxTemplateExportSession = sdmxTemplateExportSession;
|
||||||
|
thisCard = this;
|
||||||
|
String urlRegistry;
|
||||||
|
if (sdmxTemplateExportSession.getRegistryBaseUrl() == null
|
||||||
|
|| sdmxTemplateExportSession.getRegistryBaseUrl().isEmpty()) {
|
||||||
|
urlRegistry = "Internal";
|
||||||
|
} else {
|
||||||
|
urlRegistry = sdmxTemplateExportSession.getRegistryBaseUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
VBoxLayoutContainer operationInProgressPanel = new VBoxLayoutContainer();
|
||||||
|
operationInProgressPanel.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER);
|
||||||
|
|
||||||
|
final FlexTable description = new FlexTable();
|
||||||
|
// FlexCellFormatter cellFormatter = description.getFlexCellFormatter();
|
||||||
|
description.setCellSpacing(10);
|
||||||
|
description.setCellPadding(4);
|
||||||
|
description.setBorderWidth(0);
|
||||||
|
|
||||||
|
// display:block;vertical-align:text-top;
|
||||||
|
description.setHTML(0, 0,
|
||||||
|
"<span style=\"font-weight:bold;\";>Destination: </span>");
|
||||||
|
description.setText(0, 1, sdmxTemplateExportSession.getSource().getName());
|
||||||
|
|
||||||
|
description.setHTML(1, 0,
|
||||||
|
"<span style=\"font-weight:bold;\";>Id: </span>");
|
||||||
|
description.setText(1, 1, sdmxTemplateExportSession.getId());
|
||||||
|
|
||||||
|
description.setHTML(2, 0,
|
||||||
|
"<span style=\"font-weight:bold;\";>Agency Id: </span>");
|
||||||
|
description.setText(2, 1, sdmxTemplateExportSession.getAgencyId());
|
||||||
|
|
||||||
|
description.setHTML(3, 0,
|
||||||
|
"<span style=\"font-weight:bold;\";>Registry: </span>");
|
||||||
|
description.setText(3, 1, urlRegistry);
|
||||||
|
|
||||||
|
description.setHTML(4, 0,
|
||||||
|
"<span style=\"font-weight:bold;\";>Version: </span>");
|
||||||
|
description.setText(4, 1, sdmxTemplateExportSession.getVersion());
|
||||||
|
|
||||||
|
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)));
|
||||||
|
|
||||||
|
resultField = new HtmlLayoutContainer("<div></div>");
|
||||||
|
|
||||||
|
operationInProgressPanel.add(resultField, new BoxLayoutData(
|
||||||
|
new Margins(10, 5, 10, 5)));
|
||||||
|
|
||||||
|
setCenterWidget(operationInProgressPanel, new MarginData(0));
|
||||||
|
resultField.setVisible(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// columnToImportMask
|
||||||
|
|
||||||
|
public void exportSDMX() {
|
||||||
|
TDGWTServiceAsync.INSTANCE.startSDMXTemplateExport(sdmxTemplateExportSession,
|
||||||
|
new AsyncCallback<String>() {
|
||||||
|
|
||||||
|
public void onSuccess(String taskId) {
|
||||||
|
openMonitorDialog(taskId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
if (caught instanceof TDGWTSessionExpiredException) {
|
||||||
|
getEventBus()
|
||||||
|
.fireEvent(
|
||||||
|
new SessionExpiredEvent(
|
||||||
|
SessionExpiredType.EXPIREDONSERVER));
|
||||||
|
} else {
|
||||||
|
if (caught instanceof TDGWTIsLockedException) {
|
||||||
|
Log.error(caught.getLocalizedMessage());
|
||||||
|
showErrorAndHide("Error Locked",
|
||||||
|
caught.getLocalizedMessage(), "",
|
||||||
|
caught);
|
||||||
|
} else {
|
||||||
|
showErrorAndHide("Error in template export SDMX",
|
||||||
|
"An error occured in template export SDMX.",
|
||||||
|
caught.getLocalizedMessage(), caught);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
getWizardWindow().setEnableBackButton(false);
|
||||||
|
setBackButtonVisible(false);
|
||||||
|
getWizardWindow().setEnableNextButton(false);
|
||||||
|
getWizardWindow().setNextButtonToFinish();
|
||||||
|
exportSDMX();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
protected void openMonitorDialog(String taskId) {
|
||||||
|
MonitorDialog monitorDialog = new MonitorDialog(taskId, getEventBus());
|
||||||
|
monitorDialog.addProgressDialogListener(this);
|
||||||
|
monitorDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationComplete(OperationResult operationResult) {
|
||||||
|
newTrId = operationResult.getTrId();
|
||||||
|
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
||||||
|
safeHtmlBuilder
|
||||||
|
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold; color:#009900;'>Operation Completed</div>");
|
||||||
|
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
||||||
|
resultField.setVisible(true);
|
||||||
|
Command sayComplete = new Command() {
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
getWizardWindow().close(false);
|
||||||
|
Log.info("fire Complete: " + newTrId);
|
||||||
|
|
||||||
|
getWizardWindow().fireCompleted(newTrId);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("fire Complete :" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setNextButtonCommand(sayComplete);
|
||||||
|
|
||||||
|
setNextButtonVisible(true);
|
||||||
|
getWizardWindow().setEnableNextButton(true);
|
||||||
|
forceLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationFailed(Throwable caught, String reason, String details) {
|
||||||
|
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
||||||
|
safeHtmlBuilder
|
||||||
|
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color:red;'>Operation Failed</div>");
|
||||||
|
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
||||||
|
resultField.setVisible(true);
|
||||||
|
if (caught instanceof TDGWTSessionExpiredException) {
|
||||||
|
getEventBus()
|
||||||
|
.fireEvent(
|
||||||
|
new SessionExpiredEvent(
|
||||||
|
SessionExpiredType.EXPIREDONSERVER));
|
||||||
|
} else {
|
||||||
|
showErrorAndHide("Error in SDMX Export", reason, details, caught);
|
||||||
|
}
|
||||||
|
forceLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationStopped(OperationResult operationResult, String reason, String details) {
|
||||||
|
newTrId = operationResult.getTrId();
|
||||||
|
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
||||||
|
safeHtmlBuilder
|
||||||
|
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #FF9900;'>Problems in the Operation</div>");
|
||||||
|
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
||||||
|
resultField.setVisible(true);
|
||||||
|
|
||||||
|
Command sayComplete = new Command() {
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
getWizardWindow().close(false);
|
||||||
|
Log.info("fire Complete: tabular resource "
|
||||||
|
+ newTrId.getId());
|
||||||
|
Log.info("fire Complete: tableId " + newTrId.getTableId());
|
||||||
|
|
||||||
|
getWizardWindow().fireCompleted(newTrId);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("fire Complete :" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setNextButtonCommand(sayComplete);
|
||||||
|
|
||||||
|
setNextButtonVisible(true);
|
||||||
|
getWizardWindow().setEnableNextButton(true);
|
||||||
|
forceLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationAborted() {
|
||||||
|
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
||||||
|
safeHtmlBuilder
|
||||||
|
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #AA00AA;'>Operation Aborted</div>");
|
||||||
|
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
||||||
|
resultField.setVisible(true);
|
||||||
|
|
||||||
|
Command sayComplete = new Command() {
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
getWizardWindow().close(false);
|
||||||
|
Log.info("fire Aborted");
|
||||||
|
|
||||||
|
getWizardWindow().fireAborted();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("fire Aborted :" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setNextButtonCommand(sayComplete);
|
||||||
|
|
||||||
|
setNextButtonVisible(true);
|
||||||
|
getWizardWindow().setEnableNextButton(true);
|
||||||
|
forceLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationPutInBackground() {
|
||||||
|
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
||||||
|
safeHtmlBuilder
|
||||||
|
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #00AAAA;'>Operation in Background</div>");
|
||||||
|
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
||||||
|
resultField.setVisible(true);
|
||||||
|
|
||||||
|
Command sayComplete = new Command() {
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
getWizardWindow().close(false);
|
||||||
|
Log.info("fire Operation In Background");
|
||||||
|
|
||||||
|
getWizardWindow().firePutInBackground();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("fire Operation In Background :"
|
||||||
|
+ e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setNextButtonCommand(sayComplete);
|
||||||
|
|
||||||
|
setNextButtonVisible(true);
|
||||||
|
getWizardWindow().setEnableNextButton(true);
|
||||||
|
forceLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,223 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client.template;
|
||||||
|
|
||||||
|
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.SDMXTemplateExportSession;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
|
||||||
|
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;
|
||||||
|
|
||||||
|
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.MarginData;
|
||||||
|
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 SDMXTemplateExportRegistrySelectionCard extends WizardCard {
|
||||||
|
|
||||||
|
private SDMXTemplateExportSession sdmxTemplateExportSession;
|
||||||
|
private SDMXTemplateExportRegistrySelectionCard thisCard;
|
||||||
|
|
||||||
|
final TextField url = new TextField();
|
||||||
|
|
||||||
|
public SDMXTemplateExportRegistrySelectionCard(final SDMXTemplateExportSession sdmxTemplateExportSession) {
|
||||||
|
super("SDMX Registry selection", "");
|
||||||
|
thisCard = this;
|
||||||
|
SDMXRegistrySource sdmxRegistrySource=new SDMXRegistrySource();
|
||||||
|
sdmxTemplateExportSession.setSource(sdmxRegistrySource);
|
||||||
|
this.sdmxTemplateExportSession = sdmxTemplateExportSession;
|
||||||
|
|
||||||
|
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();
|
||||||
|
radioUrlRegistry.setVisible(false);
|
||||||
|
|
||||||
|
|
||||||
|
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>>() {
|
||||||
|
|
||||||
|
|
||||||
|
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) sdmxTemplateExportSession
|
||||||
|
.getSource());
|
||||||
|
r.setUrl(null);
|
||||||
|
Log.info("" + sdmxTemplateExportSession.getSource());
|
||||||
|
} else {
|
||||||
|
vcontainer.setVisible(false);
|
||||||
|
Log.info("SDMXRegistry Default");
|
||||||
|
SDMXRegistrySource r = ((SDMXRegistrySource) sdmxTemplateExportSession
|
||||||
|
.getSource());
|
||||||
|
r.setUrl(null);
|
||||||
|
Log.info("Input value: " + url.getCurrentValue());
|
||||||
|
Log.info("" + sdmxTemplateExportSession.getSource());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("ToggleGroup: onValueChange "
|
||||||
|
+ e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setCenterWidget(registrySelectionPanel, new MarginData(0));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
Command sayNextCard = new Command() {
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
Log.info("Input value: " + url.getCurrentValue());
|
||||||
|
if (sdmxTemplateExportSession.getSource() instanceof SDMXRegistrySource) {
|
||||||
|
((SDMXRegistrySource) sdmxTemplateExportSession.getSource())
|
||||||
|
.setUrl(url.getCurrentValue());
|
||||||
|
|
||||||
|
TDGWTServiceAsync.INSTANCE.setSDMXRegistrySource(
|
||||||
|
((SDMXRegistrySource)sdmxTemplateExportSession.getSource()), new AsyncCallback<Void>() {
|
||||||
|
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
if (caught instanceof TDGWTSessionExpiredException) {
|
||||||
|
getEventBus()
|
||||||
|
.fireEvent(
|
||||||
|
new SessionExpiredEvent(
|
||||||
|
SessionExpiredType.EXPIREDONSERVER));
|
||||||
|
} else {
|
||||||
|
Log.error("SDMXRegistrySource do not stored "
|
||||||
|
+ caught.getLocalizedMessage());
|
||||||
|
showErrorAndHide("Error", "SDMXRegistrySource do not stored."
|
||||||
|
,caught.getLocalizedMessage(), caught);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSuccess(Void result) {
|
||||||
|
Log.info("SDMXRegistrySource stored");
|
||||||
|
goNext();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Log.error("There is a problem in source selection.Expected SDMXRegistrySource, and found"
|
||||||
|
+ sdmxTemplateExportSession.getSource());
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("sayNextCard :" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setNextButtonCommand(sayNextCard);
|
||||||
|
|
||||||
|
|
||||||
|
Command sayPreviousCard = new Command() {
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
getWizardWindow().previousCard();
|
||||||
|
getWizardWindow().removeCard(thisCard);
|
||||||
|
Log.info("Remove SDMXTemplateRegistrySelectionCard");
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||||
|
|
||||||
|
setEnableBackButton(false);
|
||||||
|
setEnableNextButton(true);
|
||||||
|
setBackButtonVisible(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void goNext() {
|
||||||
|
try {
|
||||||
|
SDMXTemplateExportAgenciesSelectionCard sdmxAgencyTypeCard = new SDMXTemplateExportAgenciesSelectionCard(
|
||||||
|
sdmxTemplateExportSession);
|
||||||
|
getWizardWindow().addCard(sdmxAgencyTypeCard);
|
||||||
|
Log.info("NextCard SDMXTemplateExportAgenciesSelectionCard ");
|
||||||
|
getWizardWindow().nextCard();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("sayNextCard :" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,219 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client.template;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXTemplateExportSession;
|
||||||
|
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.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.container.VerticalLayoutContainer;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||||
|
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.TextField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SDMXTemplateExportTableDetailCard extends WizardCard {
|
||||||
|
|
||||||
|
private final String TABLEDETAILPANELWIDTH = "100%";
|
||||||
|
private final String TABLEDETAILPANELHEIGHT = "100%";
|
||||||
|
private final String FORMWIDTH = "838px";
|
||||||
|
|
||||||
|
private SDMXTemplateExportSession sdmxTemplateExportSession;
|
||||||
|
private SDMXTemplateExportTableDetailCard thisCard;
|
||||||
|
|
||||||
|
private VerticalLayoutContainer p = new VerticalLayoutContainer();
|
||||||
|
private VerticalPanel tableDetailPanel;
|
||||||
|
|
||||||
|
private TextField id;
|
||||||
|
private TextField agencyId;
|
||||||
|
private TextField registryBaseUrl;
|
||||||
|
private TextField version;
|
||||||
|
private TextField templateName;
|
||||||
|
private TextField measureColumn;
|
||||||
|
|
||||||
|
public SDMXTemplateExportTableDetailCard(final SDMXTemplateExportSession sdmxTemplateExportSession) {
|
||||||
|
super("SDMX Table Detail", "");
|
||||||
|
|
||||||
|
this.sdmxTemplateExportSession = sdmxTemplateExportSession;
|
||||||
|
thisCard = this;
|
||||||
|
|
||||||
|
tableDetailPanel = new VerticalPanel();
|
||||||
|
|
||||||
|
tableDetailPanel.setSpacing(4);
|
||||||
|
tableDetailPanel.setWidth(TABLEDETAILPANELWIDTH);
|
||||||
|
tableDetailPanel.setHeight(TABLEDETAILPANELHEIGHT);
|
||||||
|
|
||||||
|
FramedPanel form = new FramedPanel();
|
||||||
|
form.setHeadingText("Details");
|
||||||
|
form.setWidth(FORMWIDTH);
|
||||||
|
|
||||||
|
FieldSet fieldSet = new FieldSet();
|
||||||
|
fieldSet.setHeadingText("Information");
|
||||||
|
fieldSet.setCollapsible(false);
|
||||||
|
form.add(fieldSet);
|
||||||
|
|
||||||
|
templateViewConfig();
|
||||||
|
|
||||||
|
fieldSet.add(p);
|
||||||
|
|
||||||
|
tableDetailPanel.add(form);
|
||||||
|
setContent(tableDetailPanel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void templateViewConfig() {
|
||||||
|
id = new TextField();
|
||||||
|
id.setAllowBlank(false);
|
||||||
|
id.setEmptyText("Enter Id...");
|
||||||
|
id.setValue(Constants.SDMX_TEMPLATE_EXPORT_DEFAULT_ID);
|
||||||
|
p.add(new FieldLabel(id, "Id"), new VerticalLayoutData(1, -1));
|
||||||
|
|
||||||
|
agencyId = new TextField();
|
||||||
|
agencyId.setVisible(true);
|
||||||
|
agencyId.setEmptyText("Enter Agency Id...");
|
||||||
|
if (sdmxTemplateExportSession.getAgency().getId() == null
|
||||||
|
|| sdmxTemplateExportSession.getAgency().getId().isEmpty()) {
|
||||||
|
agencyId.setValue(Constants.SDMX_TEMPLATE_EXPORT_DEFAULT_AGENCY_ID);
|
||||||
|
} else {
|
||||||
|
agencyId.setValue(sdmxTemplateExportSession.getAgency().getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
FieldLabel agencyNameLabel = new FieldLabel(agencyId, "Agency Id");
|
||||||
|
p.add(agencyNameLabel, new VerticalLayoutData(1, -1));
|
||||||
|
|
||||||
|
registryBaseUrl = new TextField();
|
||||||
|
registryBaseUrl.setVisible(false);
|
||||||
|
registryBaseUrl.setEmptyText("Enter Registry URL...");
|
||||||
|
String urlRegistry = ((SDMXRegistrySource) sdmxTemplateExportSession.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_TEMPLATE_EXPORT_DEFAULT_VERSION);
|
||||||
|
p.add(new FieldLabel(version, "Version"), new VerticalLayoutData(1, -1));
|
||||||
|
|
||||||
|
|
||||||
|
templateName = new TextField();
|
||||||
|
templateName.setValue(sdmxTemplateExportSession.getTemplateData().getName());
|
||||||
|
templateName.setReadOnly(true);
|
||||||
|
p.add(new FieldLabel(templateName, "Template"),
|
||||||
|
new VerticalLayoutData(1, -1));
|
||||||
|
|
||||||
|
measureColumn = new TextField();
|
||||||
|
measureColumn.setValue(sdmxTemplateExportSession.getObsValueColumn().getLabel());
|
||||||
|
measureColumn.setReadOnly(true);
|
||||||
|
p.add(new FieldLabel(measureColumn, "Measure Column"),
|
||||||
|
new VerticalLayoutData(1, -1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
Command sayNextCard = new Command() {
|
||||||
|
|
||||||
|
public void execute() {
|
||||||
|
checkData();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setNextButtonCommand(sayNextCard);
|
||||||
|
|
||||||
|
Command sayPreviousCard = new Command() {
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
getWizardWindow().previousCard();
|
||||||
|
getWizardWindow().removeCard(thisCard);
|
||||||
|
Log.info("Remove SDMXTemplateExportTableDetailCard");
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||||
|
getWizardWindow().setEnableNextButton(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void checkData() {
|
||||||
|
getWizardWindow().setEnableNextButton(false);
|
||||||
|
getWizardWindow().setEnableBackButton(false);
|
||||||
|
AlertMessageBox d;
|
||||||
|
HideHandler hideHandler = new HideHandler() {
|
||||||
|
|
||||||
|
public void onHide(HideEvent event) {
|
||||||
|
getWizardWindow().setEnableNextButton(true);
|
||||||
|
getWizardWindow().setEnableBackButton(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
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");
|
||||||
|
d.addHideHandler(hideHandler);
|
||||||
|
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.addHideHandler(hideHandler);
|
||||||
|
d.show();
|
||||||
|
} else {
|
||||||
|
id.setReadOnly(true);
|
||||||
|
registryBaseUrl.setReadOnly(true);
|
||||||
|
version.setReadOnly(true);
|
||||||
|
agencyId.setReadOnly(true);
|
||||||
|
goNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void goNext() {
|
||||||
|
try {
|
||||||
|
sdmxTemplateExportSession.setId(id.getCurrentValue());
|
||||||
|
sdmxTemplateExportSession.setAgencyId(agencyId.getCurrentValue());
|
||||||
|
sdmxTemplateExportSession.setVersion(version.getCurrentValue());
|
||||||
|
sdmxTemplateExportSession.setRegistryBaseUrl(registryBaseUrl.getCurrentValue());
|
||||||
|
SDMXTemplateExportOperationInProgressCard sdmxOperationInProgressCard = new SDMXTemplateExportOperationInProgressCard(
|
||||||
|
sdmxTemplateExportSession);
|
||||||
|
getWizardWindow().addCard(sdmxOperationInProgressCard);
|
||||||
|
Log.info("NextCard SDMXTemplateExportOperationInProgressCard");
|
||||||
|
getWizardWindow().nextCard();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("sayNextCard :" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client.template;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXTemplateExportSession;
|
||||||
|
import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow;
|
||||||
|
|
||||||
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
* Entry point classes define <code>onModuleLoad()</code>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SDMXTemplateExportWizard extends WizardWindow {
|
||||||
|
|
||||||
|
private SDMXTemplateExportSession sdmxTemplateExportSession;
|
||||||
|
private static final String WIDTH = "850px";
|
||||||
|
private static final String HEIGHT = "530px";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The id of the {@link CSVTarget} to use.
|
||||||
|
*
|
||||||
|
* @param targetId
|
||||||
|
*/
|
||||||
|
|
||||||
|
public SDMXTemplateExportWizard(String title, final EventBus eventBus) {
|
||||||
|
super(title, eventBus);
|
||||||
|
setWidth(WIDTH);
|
||||||
|
setHeight(HEIGHT);
|
||||||
|
|
||||||
|
sdmxTemplateExportSession = new SDMXTemplateExportSession();
|
||||||
|
|
||||||
|
SDMXTemplateExportRegistrySelectionCard sdmxTemplateExportRegistrySelectionCard = new SDMXTemplateExportRegistrySelectionCard(
|
||||||
|
sdmxTemplateExportSession);
|
||||||
|
addCard(sdmxTemplateExportRegistrySelectionCard);
|
||||||
|
sdmxTemplateExportRegistrySelectionCard.setup();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,99 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client.template;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXTemplateExportSession;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData;
|
||||||
|
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||||
|
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||||
|
import com.google.gwt.user.client.Command;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SDMXTemplateSelectionCard extends WizardCard {
|
||||||
|
|
||||||
|
private SDMXTemplateSelectionCard thisCard;
|
||||||
|
private SDMXTemplateExportSession sdmxTemplateExportSession;
|
||||||
|
private SDMXTmplateExportTemplateSelectionPanel sdmxTemplateExportTemplateSelectionPanel;
|
||||||
|
|
||||||
|
public SDMXTemplateSelectionCard(
|
||||||
|
final SDMXTemplateExportSession sdmxTemplateExportSession) {
|
||||||
|
super("SDMX Template selection", "");
|
||||||
|
|
||||||
|
this.sdmxTemplateExportSession = sdmxTemplateExportSession;
|
||||||
|
thisCard = this;
|
||||||
|
|
||||||
|
this.sdmxTemplateExportTemplateSelectionPanel = new SDMXTmplateExportTemplateSelectionPanel(thisCard, res);
|
||||||
|
|
||||||
|
sdmxTemplateExportTemplateSelectionPanel
|
||||||
|
.addSelectionHandler(new SelectionHandler<TemplateData>() {
|
||||||
|
|
||||||
|
public void onSelection(SelectionEvent<TemplateData> event) {
|
||||||
|
if (sdmxTemplateExportTemplateSelectionPanel.getSelectedItem() != null) {
|
||||||
|
sdmxTemplateExportSession
|
||||||
|
.setTemplateData(sdmxTemplateExportTemplateSelectionPanel
|
||||||
|
.getSelectedItem());
|
||||||
|
getWizardWindow().setEnableNextButton(true);
|
||||||
|
} else {
|
||||||
|
sdmxTemplateExportSession
|
||||||
|
.setTemplateData(null);
|
||||||
|
getWizardWindow().setEnableNextButton(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
setContent(sdmxTemplateExportTemplateSelectionPanel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
Command sayNextCard = new Command() {
|
||||||
|
|
||||||
|
public void execute() {
|
||||||
|
SDMXTemplateExportMeasureColumnSelectionCard sdmxTemplateExportMeasureColumnSelectionCard = new SDMXTemplateExportMeasureColumnSelectionCard(
|
||||||
|
sdmxTemplateExportSession);
|
||||||
|
getWizardWindow().addCard(sdmxTemplateExportMeasureColumnSelectionCard);
|
||||||
|
Log.info("NextCard SDMXTemplateExportMeasureColumnSelectionCard");
|
||||||
|
getWizardWindow().nextCard();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setNextButtonCommand(sayNextCard);
|
||||||
|
|
||||||
|
Command sayPreviousCard = new Command() {
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
getWizardWindow().previousCard();
|
||||||
|
getWizardWindow().removeCard(thisCard);
|
||||||
|
Log.info("Remove SDMXTemplateExportTemplateSelectionCard");
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||||
|
|
||||||
|
|
||||||
|
if (sdmxTemplateExportTemplateSelectionPanel == null
|
||||||
|
|| sdmxTemplateExportTemplateSelectionPanel.getSelectedItem() == null) {
|
||||||
|
setEnableNextButton(false);
|
||||||
|
} else {
|
||||||
|
setEnableNextButton(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,268 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client.template;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
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.template.TemplateData;
|
||||||
|
import org.gcube.portlets.user.td.sdmxexportwidget.client.properties.TemplateDataProperties;
|
||||||
|
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;
|
||||||
|
import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.cell.client.DateCell;
|
||||||
|
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.i18n.client.DateTimeFormat;
|
||||||
|
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 SDMXTmplateExportTemplateSelectionPanel extends ContentPanel
|
||||||
|
implements HasSelectionHandlers<TemplateData> {
|
||||||
|
|
||||||
|
private static final DateTimeFormat sdf = DateTimeFormat
|
||||||
|
.getFormat("yyyy-MM-dd HH:mm");
|
||||||
|
|
||||||
|
private Grid<TemplateData> grid;
|
||||||
|
private ResourceBundle res;
|
||||||
|
|
||||||
|
private WizardCard parent;
|
||||||
|
|
||||||
|
public SDMXTmplateExportTemplateSelectionPanel(WizardCard parent,
|
||||||
|
ResourceBundle res) {
|
||||||
|
this.parent = parent;
|
||||||
|
this.res = res;
|
||||||
|
setHeaderVisible(false);
|
||||||
|
create();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void create() {
|
||||||
|
|
||||||
|
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<TemplateData> identity = new IdentityValueProvider<TemplateData>();
|
||||||
|
final CheckBoxSelectionModel<TemplateData> sm = new CheckBoxSelectionModel<TemplateData>(
|
||||||
|
identity);
|
||||||
|
|
||||||
|
TemplateDataProperties properties = GWT
|
||||||
|
.create(TemplateDataProperties.class);
|
||||||
|
|
||||||
|
ColumnConfig<TemplateData, String> nameColumn = new ColumnConfig<TemplateData, String>(
|
||||||
|
properties.name(), 50, "Name");
|
||||||
|
ColumnConfig<TemplateData, String> categoryColumn = new ColumnConfig<TemplateData, String>(
|
||||||
|
properties.category(), 50, "Category");
|
||||||
|
ColumnConfig<TemplateData, String> ownerLoginColumn = new ColumnConfig<TemplateData, String>(
|
||||||
|
properties.ownerLogin(), 50, "Owner");
|
||||||
|
ColumnConfig<TemplateData, String> agencyColumn = new ColumnConfig<TemplateData, String>(
|
||||||
|
properties.agency(), 50, "Agency");
|
||||||
|
ColumnConfig<TemplateData, String> descriptionColumn = new ColumnConfig<TemplateData, String>(
|
||||||
|
properties.description(), 50, "Description");
|
||||||
|
ColumnConfig<TemplateData, Date> creationDateColumn = new ColumnConfig<TemplateData, Date>(
|
||||||
|
properties.creationDate(), 50, "Creation Date");
|
||||||
|
creationDateColumn.setCell(new DateCell(sdf));
|
||||||
|
|
||||||
|
List<ColumnConfig<TemplateData, ?>> l = new ArrayList<ColumnConfig<TemplateData, ?>>();
|
||||||
|
l.add(nameColumn);
|
||||||
|
l.add(categoryColumn);
|
||||||
|
l.add(ownerLoginColumn);
|
||||||
|
l.add(agencyColumn);
|
||||||
|
l.add(descriptionColumn);
|
||||||
|
l.add(creationDateColumn);
|
||||||
|
|
||||||
|
ColumnModel<TemplateData> cm = new ColumnModel<TemplateData>(l);
|
||||||
|
|
||||||
|
final ExtendedListStore<TemplateData> store = new ExtendedListStore<TemplateData>(
|
||||||
|
properties.id());
|
||||||
|
|
||||||
|
searchField.addKeyUpHandler(new KeyUpHandler() {
|
||||||
|
|
||||||
|
public void onKeyUp(KeyUpEvent event) {
|
||||||
|
Log.trace("searchTerm: " + searchField.getCurrentValue());
|
||||||
|
store.applyFilters();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
store.addFilter(new StoreFilter<TemplateData>() {
|
||||||
|
|
||||||
|
public boolean select(Store<TemplateData> store,
|
||||||
|
TemplateData parent, TemplateData item) {
|
||||||
|
String searchTerm = searchField.getCurrentValue();
|
||||||
|
if (searchTerm == null)
|
||||||
|
return true;
|
||||||
|
return SDMXTmplateExportTemplateSelectionPanel.this.select(
|
||||||
|
item, searchTerm);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
store.setEnableFilters(true);
|
||||||
|
|
||||||
|
RpcProxy<ListLoadConfig, ListLoadResult<TemplateData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<TemplateData>>() {
|
||||||
|
|
||||||
|
public void load(ListLoadConfig loadConfig,
|
||||||
|
final AsyncCallback<ListLoadResult<TemplateData>> callback) {
|
||||||
|
loadData(loadConfig, callback);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
final ListLoader<ListLoadConfig, ListLoadResult<TemplateData>> loader = new ListLoader<ListLoadConfig, ListLoadResult<TemplateData>>(
|
||||||
|
proxy);
|
||||||
|
|
||||||
|
loader.setRemoteSort(false);
|
||||||
|
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, TemplateData, ListLoadResult<TemplateData>>(
|
||||||
|
store));
|
||||||
|
|
||||||
|
grid = new Grid<TemplateData>(store, cm) {
|
||||||
|
|
||||||
|
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(nameColumn);
|
||||||
|
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(TemplateData item, String searchTerm) {
|
||||||
|
if (item.getName() != null
|
||||||
|
&& item.getName().toLowerCase()
|
||||||
|
.contains(searchTerm.toLowerCase()))
|
||||||
|
return true;
|
||||||
|
if (item.getCategory() != null
|
||||||
|
&& item.getCategory().toLowerCase()
|
||||||
|
.contains(searchTerm.toLowerCase()))
|
||||||
|
return true;
|
||||||
|
if (item.getOwnerLogin() != null
|
||||||
|
&& item.getOwnerLogin().toLowerCase()
|
||||||
|
.contains(searchTerm.toLowerCase()))
|
||||||
|
return true;
|
||||||
|
if (item.getDescription() != null
|
||||||
|
&& item.getDescription().toLowerCase()
|
||||||
|
.contains(searchTerm.toLowerCase()))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void loadData(ListLoadConfig loadConfig,
|
||||||
|
final AsyncCallback<ListLoadResult<TemplateData>> callback) {
|
||||||
|
TDGWTServiceAsync.INSTANCE
|
||||||
|
.getTemplatesForDSDExport(new AsyncCallback<ArrayList<TemplateData>>() {
|
||||||
|
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
if (caught instanceof TDGWTSessionExpiredException) {
|
||||||
|
parent.getEventBus()
|
||||||
|
.fireEvent(
|
||||||
|
new SessionExpiredEvent(
|
||||||
|
SessionExpiredType.EXPIREDONSERVER));
|
||||||
|
} else {
|
||||||
|
Log.error("No templates retrieved");
|
||||||
|
}
|
||||||
|
callback.onFailure(caught);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSuccess(ArrayList<TemplateData> result) {
|
||||||
|
Log.trace("loaded " + result.size() + " templates");
|
||||||
|
callback.onSuccess(new ListLoadResultBean<TemplateData>(
|
||||||
|
result));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerRegistration addSelectionHandler(
|
||||||
|
SelectionHandler<TemplateData> handler) {
|
||||||
|
return grid.getSelectionModel().addSelectionHandler(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TemplateData 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue