Giancarlo Panichi 10 years ago committed by Giancarlo Panichi
parent e1b5dd5da1
commit a87f3713e9

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/tabular-data-json-export-widget-1.0.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-json-export-widget-1.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/tabular-data-json-export-widget-1.0.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>tabular-data-json-export-widget</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.google.gwt.eclipse.core.launch.gwtJUnit">
<stringAttribute key="com.google.gwt.eclipse.core.LOG_LEVEL" value="INFO"/>
<booleanAttribute key="com.google.gwt.eclipse.core.NOT_HEADLESS" value="false"/>
<stringAttribute key="com.google.gwt.eclipse.core.OUT_DIR" value="www-test"/>
<booleanAttribute key="com.google.gwt.eclipse.core.STANDARDS_MODE" value="false"/>
<stringAttribute key="com.google.gwt.eclipse.core.STYLE" value="OBFUSCATED"/>
<stringAttribute key="com.google.gwt.eclipse.core.WEB_MODE" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/tabular-data-json-export-widget/src/test/java/org/gcube/portlets/user/td/jsonexportwidget/client/GwtTestJSONExportWidgetTD.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gdt.eclipse.maven.mavenClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.gcube.portlets.user.td.jsonexportwidget.client.GwtTestJSONExportWidgetTD"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="tabular-data-json-export-widget"/>
</launchConfiguration>

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.google.gwt.eclipse.core.launch.gwtJUnit">
<stringAttribute key="com.google.gwt.eclipse.core.LOG_LEVEL" value="INFO"/>
<booleanAttribute key="com.google.gwt.eclipse.core.NOT_HEADLESS" value="false"/>
<stringAttribute key="com.google.gwt.eclipse.core.OUT_DIR" value="www-test"/>
<booleanAttribute key="com.google.gwt.eclipse.core.STANDARDS_MODE" value="false"/>
<stringAttribute key="com.google.gwt.eclipse.core.STYLE" value="OBFUSCATED"/>
<stringAttribute key="com.google.gwt.eclipse.core.WEB_MODE" value="true"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/tabular-data-json-export-widget/src/test/java/org/gcube/portlets/user/td/jsonexportwidget/client/GwtTestJSONExportWidgetTD.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gdt.eclipse.maven.mavenClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.gcube.portlets.user.td.jsonexportwidget.client.GwtTestJSONExportWidgetTD"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="tabular-data-json-export-widget"/>
</launchConfiguration>

@ -0,0 +1,328 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId>
<version>1.0.0</version>
<relativePath />
</parent>
<!-- POM file generated with GWT webAppCreator -->
<modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>tabular-data-json-export-widget</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>tabular-data-json-export-widget</name>
<description>tabular-data-json-export-widget allows json export inside file and workspace</description>
<scm>
<url>https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-json-export-widget</url>
</scm>
<developers>
<developer>
<name>Giancarlo Panichi</name>
<email>g.panichi@isti.cnr.it</email>
<organization>CNR Pisa, Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo"</organization>
<roles>
<role>architect</role>
<role>developer</role>
</roles>
</developer>
</developers>
<properties>
<distroDirectory>${project.basedir}/distro</distroDirectory>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<release.date>2014-09-12</release.date>
<templatesDirectory>templates</templatesDirectory>
<distroDirectory>distro</distroDirectory>
<configDirectory>config</configDirectory>
<!-- Convenience property to set the GWT version -->
<gwtVersion>2.5.1</gwtVersion>
<KEYS>${env.KEYS}</KEYS>
<!-- GWT needs at least java 1.5 -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<profiles>
<profile>
<id>localRun</id>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.1</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
<classifier>sources</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sencha.gxt</groupId>
<artifactId>gxt</artifactId>
<version>3.0.1</version>
</dependency>
<!-- tabular-data-gwt-service -->
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>tabular-data-gwt-service</artifactId>
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<!-- tabular-data-widget-common-event -->
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>tabular-data-widget-common-event</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<!-- tabular-data-monitor-widget -->
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>tabular-data-monitor-widget</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<!-- tabular-data-wizard-widget -->
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>tabular-data-wizard-widget</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<!-- WSLT dependencies -->
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>workspace-light-tree</artifactId>
<version>[2.13.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>gcube-widgets</artifactId>
<scope>provided</scope>
</dependency>
<!-- LOGGING -->
<dependency>
<groupId>com.allen-sauer.gwt.log</groupId>
<artifactId>gwt-log</artifactId>
<version>3.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<!-- JUnit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- Generate compiled stuff in the folder used for developing mode -->
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
<!-- TODO check if needed -->
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.16</version>
</dependency>
</dependencies>
</plugin>
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwtVersion}</version>
<executions>
<execution>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
<configuration>
<runTarget>JSONExportWidgetTD.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<module>org.gcube.portlets.user.td.jsonexportwidget.JSONExportWidgetTD</module>
</configuration>
</plugin>
<!-- Maven -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-profile</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${configDirectory}</outputDirectory>
<resources>
<resource>
<directory>${templatesDirectory}</directory>
<includes>
<include>profile.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-distro-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${distroDirectory}</outputDirectory>
<resources>
<resource>
<directory>${templatesDirectory}</directory>
<excludes>
<exclude>profile.xml</exclude>
<exclude>descriptor.xml</exclude>
</excludes>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<configuration>
<filesets>
<fileset>
<directory>${distroDirectory}</directory>
<includes>
<include>**</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
<fileset>
<directory>${configDirectory}</directory>
<includes>
<include>**</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration>
<descriptors>
<descriptor>${templatesDirectory}/descriptor.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>servicearchive</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>LATEST</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>

@ -0,0 +1,163 @@
/**
*
*/
package org.gcube.portlets.user.td.jsonexportwidget.client;
import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.destination.FileDestination;
import org.gcube.portlets.user.td.gwtservice.shared.destination.WorkspaceDestination;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.sencha.gxt.core.client.util.ToggleGroup;
import com.sencha.gxt.widget.core.client.form.Radio;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class DestinationSelectionCard extends WizardCard {
protected final JSONExportSession exportSession;
protected DestinationSelectionCard thisCard;
final FileDestination fileDestination = FileDestination.INSTANCE;
final WorkspaceDestination workspaceDestination = WorkspaceDestination.INSTANCE;
public DestinationSelectionCard(final JSONExportSession exportSession) {
super("JSON destination selection", "");
thisCard=this;
this.exportSession = exportSession;
// Default
exportSession.setDestination(workspaceDestination);
VerticalPanel destinationSelectionPanel = new VerticalPanel();
destinationSelectionPanel.setStylePrimaryName(res.wizardCSS()
.getImportSelectionSources());
Radio radioWorkspaceDestination = new Radio();
radioWorkspaceDestination.setBoxLabel("<p style='display:inline-table;'><b>"
+ workspaceDestination.getName() + "</b><br>"
+ workspaceDestination.getDescription() + "</p>");
radioWorkspaceDestination.setName(workspaceDestination.getName());
radioWorkspaceDestination.setStylePrimaryName(res.wizardCSS()
.getImportSelectionSource());
radioWorkspaceDestination.setValue(true);
Radio radioFileDestination = new Radio();
radioFileDestination.setBoxLabel("<p style='display:inline-table;'><b>"
+ fileDestination.getName() + "</b><br>"
+ fileDestination.getDescription() + "</p>");
radioFileDestination.setName(fileDestination.getName());
radioFileDestination.setStylePrimaryName(res.wizardCSS()
.getImportSelectionSource());
radioFileDestination.disable();
destinationSelectionPanel.add(radioWorkspaceDestination);
destinationSelectionPanel.add(radioFileDestination);
// we can set name on radios or use toggle group
ToggleGroup toggle = new ToggleGroup();
toggle.add(radioWorkspaceDestination);
toggle.add(radioFileDestination);
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("Source Selected:" + radio.getName());
if (radio.getName().compareTo(workspaceDestination.getName()) == 0) {
exportSession.setDestination(workspaceDestination);
} else {
if (radio.getName().compareTo(fileDestination.getName()) == 0) {
exportSession.setDestination(fileDestination);
} else {
}
}
} catch (Exception e) {
Log.error("ToggleGroup: onValueChange "
+ e.getLocalizedMessage());
}
}
});
setContent(destinationSelectionPanel);
}
@Override
public void setup() {
Log.debug("Setup Card");
Command sayNextCard = new Command() {
public void execute() {
try {
String destinationId = exportSession.getDestination().getId();
if (destinationId == null || destinationId.isEmpty()) {
Log.error("JSON Export Source Id: " + destinationId);
} else {
if (destinationId.compareTo("File") == 0) {
Log.info("NextCard JSONDownloadFileCard");
DownloadFileCard downloadFileCard = new DownloadFileCard(
exportSession);
getWizardWindow().addCard(downloadFileCard);
getWizardWindow().nextCard();
} else {
if (destinationId.compareTo("Workspace") == 0) {
Log.info("NextCard JSONWorkspaceSelectionCard");
JSONWorkSpaceSelectionCard jsonWorkspaceSelectionCard = new JSONWorkSpaceSelectionCard(
exportSession);
getWizardWindow().addCard(
jsonWorkspaceSelectionCard);
getWizardWindow().nextCard();
} else {
Log.debug("No destination selected and no card loaded");
}
}
}
} 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 DestinationSelectionCard");
} catch (Exception e) {
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
}
}
};
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
setEnableBackButton(true);
setEnableNextButton(true);
}
}

@ -0,0 +1,62 @@
/**
*
*/
package org.gcube.portlets.user.td.jsonexportwidget.client;
import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.Command;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class DownloadFileCard extends WizardCard {
protected JSONExportSession exportSession;
protected DownloadFileCard thisCard;
public DownloadFileCard(final JSONExportSession exportSession) {
super("Download File", "");
this.thisCard = this;
this.exportSession = exportSession;
//setContent();
}
@Override
public void setup() {
Command sayNextCard = new Command() {
public void execute() {
}
};
getWizardWindow().setNextButtonCommand(sayNextCard);
Command sayPreviousCard = new Command() {
public void execute() {
try {
getWizardWindow().previousCard();
getWizardWindow().removeCard(thisCard);
Log.info("Remove DownloadFileCard");
} catch (Exception e) {
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
}
}
};
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
getWizardWindow().setEnableNextButton(false);
}
}

@ -0,0 +1,178 @@
package org.gcube.portlets.user.td.jsonexportwidget.client;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.jsonexportwidget.client.grid.ColumnDataGridPanel;
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;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.sencha.gxt.core.client.util.Padding;
import com.sencha.gxt.core.client.util.ToggleGroup;
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.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.FormPanel;
import com.sencha.gxt.widget.core.client.form.Radio;
import com.sencha.gxt.widget.core.client.tips.ToolTip;
import com.sencha.gxt.widget.core.client.tips.ToolTipConfig;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class JSONExportConfigCard extends WizardCard {
private static final int LABEL_WIDTH = 128;
private static final int LABEL_PAD_WIDTH = 2;
protected JSONExportSession exportSession;
private Radio viewColumnExportTrue;
private Radio viewColumnExportFalse;
protected ColumnDataGridPanel jsonColumnGridPanel;
public JSONExportConfigCard(final JSONExportSession exportSession) {
super("JSON configuration", "");
if (exportSession == null) {
Log.error("JSONExportSession is null");
}
this.exportSession = exportSession;
FormPanel panel = createPanel();
setContent(panel);
}
protected FormPanel createPanel() {
FormPanel panel = new FormPanel();
panel.setLabelWidth(90);
panel.getElement().setPadding(new Padding(5));
VerticalLayoutContainer content = new VerticalLayoutContainer();
panel.add(content);
// Export View Column
viewColumnExportTrue = new Radio();
viewColumnExportTrue.setBoxLabel("True");
viewColumnExportTrue.setValue(true);
viewColumnExportFalse = new Radio();
viewColumnExportFalse.setBoxLabel("False");
ToggleGroup exportViewColumnGroup = new ToggleGroup();
exportViewColumnGroup.add(viewColumnExportTrue);
exportViewColumnGroup.add(viewColumnExportFalse);
HorizontalPanel viewColumnExportPanel = new HorizontalPanel();
viewColumnExportPanel.add(viewColumnExportTrue);
viewColumnExportPanel.add(viewColumnExportFalse);
new ToolTip(viewColumnExportPanel, new ToolTipConfig(
"Export View Columns Too"));
FieldLabel fieldViewColumns=new FieldLabel(viewColumnExportPanel, "Export View Columns");
fieldViewColumns.setLabelWidth(LABEL_WIDTH);
fieldViewColumns.setLabelPad(LABEL_PAD_WIDTH);
content.add(fieldViewColumns);
// Column Selection Grid
jsonColumnGridPanel = new ColumnDataGridPanel(this);
jsonColumnGridPanel
.addSelectionHandler(new SelectionHandler<ColumnData>() {
public void onSelection(SelectionEvent<ColumnData> event) {
}
});
content.add(jsonColumnGridPanel);
return panel;
}
protected boolean getExportViewColumns() {
if(viewColumnExportTrue.getValue()){
return true;
} else {
return false;
}
}
@Override
public void setup() {
Log.debug("JSONExportConfigCard Setup");
Command sayNextCard = new Command() {
public void execute() {
Log.debug("JSONExportConfigCard Call sayNextCard");
checkData();
}
};
getWizardWindow().setNextButtonCommand(sayNextCard);
setEnableBackButton(false);
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);
}
};
ArrayList<ColumnData> columns = jsonColumnGridPanel.getSelectedItems();
if (columns.size() == 0) {
d = new AlertMessageBox("Attention", "No columns selected");
d.addHideHandler(hideHandler);
d.setModal(false);
d.show();
} else {
exportSession.setColumns(columns);
exportSession.setExportViewColumns(getExportViewColumns());
goNext();
}
}
protected void goNext() {
try {
DestinationSelectionCard destCard = new DestinationSelectionCard(
exportSession);
getWizardWindow().addCard(destCard);
getWizardWindow().nextCard();
} catch (Exception e) {
Log.error("sayNextCard :" + e.getLocalizedMessage());
}
}
@Override
public void dispose() {
}
}

@ -0,0 +1,43 @@
package org.gcube.portlets.user.td.jsonexportwidget.client;
import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession;
import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow;
import com.google.web.bindery.event.shared.EventBus;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class JSONExportWidgetTD extends WizardWindow {
protected JSONExportSession exportSession;
/**
*
* @param title
* @param eventBus
*/
public JSONExportWidgetTD(String title, EventBus eventBus) {
super(title,eventBus);
exportSession= new JSONExportSession();
JSONExportConfigCard jsonExportConfigCard=new JSONExportConfigCard(exportSession);
addCard(jsonExportConfigCard);
jsonExportConfigCard.setup();
}
}

@ -0,0 +1,15 @@
package org.gcube.portlets.user.td.jsonexportwidget.client;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.EntryPoint;
import com.google.web.bindery.event.shared.SimpleEventBus;
public class JSONExportWidgetTDEntry implements EntryPoint {
public void onModuleLoad() {
SimpleEventBus eventBus=new SimpleEventBus();
JSONExportWidgetTD exportWizard= new JSONExportWidgetTD("CSVExport",eventBus);
Log.info(exportWizard.getId());
}
}

@ -0,0 +1,283 @@
/**
*
*/
package org.gcube.portlets.user.td.jsonexportwidget.client;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession;
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.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.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.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 JSONOperationInProgressCard extends WizardCard implements
MonitorDialogListener {
protected JSONOperationInProgressCard thisCard;
protected JSONExportSession exportSession;
protected TRId newTrId;
protected HtmlLayoutContainer resultField;
public JSONOperationInProgressCard(final JSONExportSession exportSession) {
super("Operation In Progress", "");
this.exportSession = exportSession;
thisCard = this;
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, exportSession.getDestination().getName());
description.setHTML(1, 0,
"<span style=\"font-weight:bold;\";>File Name: </span>");
description.setText(1, 1, exportSession.getFileName());
description.setHTML(2, 0,
"<span style=\"font-weight:bold;\";>File Description: </span>");
description.setText(2, 1, exportSession.getFileDescription());
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)));
setContent(operationInProgressPanel);
resultField.setVisible(false);
}
public void exportCSV() {
TDGWTServiceAsync.INSTANCE.startJSONExport(exportSession,
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 export",
"An error occured in export: "
+ caught.getLocalizedMessage(),
caught);
}
}
}
});
}
@Override
public void setup() {
getWizardWindow().setEnableBackButton(false);
setBackButtonVisible(false);
setNextButtonVisible(false);
getWizardWindow().setEnableNextButton(false);
getWizardWindow().setNextButtonToFinish();
exportCSV();
}
//
protected void openMonitorDialog(String taskId) {
MonitorDialog monitorDialog = new MonitorDialog(taskId, getEventBus());
monitorDialog.addProgressDialogListener(this);
monitorDialog.setBackgroundBtnEnabled(false);
monitorDialog.show();
}
@Override
public void operationComplete(TRId trId) {
newTrId = trId;
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 Export",
reason,caught);
}
forceLayout();
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
newTrId = trId;
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,196 @@
/**
*
*/
package org.gcube.portlets.user.td.jsonexportwidget.client;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession;
import org.gcube.portlets.user.td.jsonexportwidget.client.workspace.WorkspacePanel;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import org.gcube.portlets.widgets.lighttree.client.Item;
import org.gcube.portlets.widgets.lighttree.client.ItemType;
import org.gcube.portlets.widgets.lighttree.client.event.ItemSelectionEvent;
import org.gcube.portlets.widgets.lighttree.client.event.ItemSelectionHandler;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.Command;
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.TextField;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class JSONWorkSpaceSelectionCard extends WizardCard {
protected JSONExportSession exportSession;
protected JSONWorkSpaceSelectionCard thisCard;
protected TextField fileName;
protected TextField fileDescription;
protected Item item;
protected VerticalLayoutContainer p;
protected WorkspacePanel wpanel;
/**
*
* @param exportSession
*/
public JSONWorkSpaceSelectionCard(final JSONExportSession exportSession) {
super("JSON Export in Workspace", "");
this.exportSession = exportSession;
thisCard = this;
FramedPanel formPanel = new FramedPanel();
formPanel.setHeaderVisible(false);
p = new VerticalLayoutContainer();
formPanel.setWidget(p);
fileName = new TextField();
fileName.setAllowBlank(false);
fileName.setWidth("410px");
fileName.setValue("filename.json");
p.add(new FieldLabel(fileName, "File Name"), new VerticalLayoutData(-1,
-1));
fileDescription = new TextField();
fileDescription.setAllowBlank(false);
fileDescription.setWidth("410px");
fileDescription.setValue("json");
p.add(new FieldLabel(fileDescription, "File Description"),
new VerticalLayoutData(-1, -1));
Log.debug("Set Workspace Panel");
wpanel = new WorkspacePanel();
wpanel.setSpWidth("410px");
wpanel.setSpHeight("330px");
List<ItemType> lItemType = new ArrayList<ItemType>();
lItemType.add(ItemType.ROOT);
lItemType.add(ItemType.FOLDER);
wpanel.setShowableTypes(lItemType);
wpanel.setSelectableTypes(lItemType);
wpanel.addSelectionHandler(new ItemSelectionHandler() {
public void onSelection(ItemSelectionEvent event) {
item = event.getSelectedItem();
Log.debug("Selected Item:" + item);
if (item.getType() == ItemType.FOLDER
|| item.getType() == ItemType.ROOT) {
thisCard.exportSession.setItemId(item.getId());
} else {
thisCard.exportSession.setItemId(null);
Log.debug("Item type:" + item.getType());
}
}
});
p.add(new FieldLabel(wpanel, "Folder"), new VerticalLayoutData(-1, -1));
wpanel.loadTree();
setContent(formPanel);
}
protected void checkExportData() {
Log.debug("File Name:" + fileName.getCurrentValue() + " Item id: "
+ exportSession.getItemId());
wpanel.disable();
fileName.disable();
getWizardWindow().setEnableNextButton(false);
getWizardWindow().setEnableBackButton(false);
AlertMessageBox d;
HideHandler hideHandler = new HideHandler() {
public void onHide(HideEvent event) {
wpanel.enable();
getWizardWindow().setEnableNextButton(true);
getWizardWindow().setEnableBackButton(true);
fileName.enable();
}
};
if (fileName.getCurrentValue() != null
&& !fileName.getCurrentValue().isEmpty() && fileName.validate()) {
if (fileDescription.getCurrentValue() != null
&& !fileDescription.getCurrentValue().isEmpty()
&& fileDescription.validate()) {
if (exportSession.getItemId() != null) {
exportSession.setFileName(fileName.getCurrentValue());
exportSession.setFileDescription(fileDescription.getCurrentValue());
goNext();
} else {
d = new AlertMessageBox("Attetion",
"No folder selected");
d.addHideHandler(hideHandler);
d.setModal(false);
d.show();
}
} else {
d = new AlertMessageBox("Attention",
"No valid file description");
d.addHideHandler(hideHandler);
d.setModal(false);
d.show();
}
} else {
d = new AlertMessageBox("Attention", "No valid file name");
d.addHideHandler(hideHandler);
d.setModal(false);
d.show();
}
}
@Override
public void setup() {
Log.debug("JSONWorkSpaceSelectionCard Call Setup ");
Command sayNextCard = new Command() {
public void execute() {
Log.debug("JSONWorkSpaceSelectionCard Call sayNextCard wpanel:"
+ wpanel);
checkExportData();
}
};
getWizardWindow().setNextButtonCommand(sayNextCard);
Command sayPreviousCard = new Command() {
public void execute() {
try {
getWizardWindow().previousCard();
getWizardWindow().removeCard(thisCard);
Log.debug("Remove JSONWorkSpaceSelectionCard");
} catch (Exception e) {
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
}
}
};
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
getWizardWindow().setEnableNextButton(true);
}
protected void goNext() {
JSONOperationInProgressCard jsonOperationInProgressCard = new JSONOperationInProgressCard(exportSession);
getWizardWindow().addCard(jsonOperationInProgressCard);
Log.info("NextCard CSVOperationInProgressCard");
getWizardWindow().nextCard();
}
}

@ -0,0 +1,179 @@
package org.gcube.portlets.user.td.jsonexportwidget.client.grid;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
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.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
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.core.client.dom.ScrollSupport.ScrollMode;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.data.client.loader.RpcProxy;
import com.sencha.gxt.data.shared.ListStore;
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.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
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;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ColumnDataGridPanel extends ContentPanel implements
HasSelectionHandlers<ColumnData> {
//private static final String GRID_WIDTH ="524px";
private static final String GRID_HEIGHT = "280px";
protected static final ColumnDataProperties props = GWT
.create(ColumnDataProperties.class);
protected final CheckBoxSelectionModel<ColumnData> sm;
protected final Grid<ColumnData> grid;
private WizardCard parent;
/**
*
* @param parent
*/
public ColumnDataGridPanel(WizardCard parent) {
this.parent=parent;
Log.debug("ColumnDataGridPanel");
setHeadingText("Columns");
ColumnConfig<ColumnData, String> labelCol = new ColumnConfig<ColumnData, String>(
props.label());
IdentityValueProvider<ColumnData> identity = new IdentityValueProvider<ColumnData>();
sm = new CheckBoxSelectionModel<ColumnData>(identity);
List<ColumnConfig<ColumnData, ?>> l = new ArrayList<ColumnConfig<ColumnData, ?>>();
l.add(sm.getColumn());
l.add(labelCol);
ColumnModel<ColumnData> cm = new ColumnModel<ColumnData>(l);
ListStore<ColumnData> store = new ListStore<ColumnData>(props.id());
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.MULTI);
grid.setLoader(loader);
grid.setSelectionModel(sm);
grid.setHeight(GRID_HEIGHT);
//grid.setWidth(GRID_WIDTH);
// grid.getView().setAutoExpandColumn(labelCol);
grid.getView().setStripeRows(true);
grid.getView().setColumnLines(true);
grid.getView().setAutoFill(true);
grid.setBorders(false);
grid.setLoadMask(true);
grid.setColumnReordering(false);
VerticalLayoutContainer con = new VerticalLayoutContainer();
con.setScrollMode(ScrollMode.AUTO);
con.add(grid, new VerticalLayoutData(-1, -1, new Margins(0)));
setWidget(con);
}
public Grid<ColumnData> getGrid() {
return grid;
}
protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
TDGWTServiceAsync.INSTANCE
.getColumns(new AsyncCallback<ArrayList<ColumnData>>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
parent.getEventBus()
.fireEvent(
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
parent.showErrorAndHide("Error Locked",
caught.getLocalizedMessage(), caught);
} else {
Log.error("No load columns: "
+ caught.getLocalizedMessage());
}
}
callback.onFailure(caught);
}
public void onSuccess(ArrayList<ColumnData> result) {
Log.trace("loaded " + result.size() + " columns");
callback.onSuccess(new ListLoadResultBean<ColumnData>(
result));
sm.selectAll();
forceLayout();
}
});
}
public ArrayList<ColumnData> getSelectedItems() {
return new ArrayList<ColumnData>(grid.getSelectionModel()
.getSelectedItems());
}
public HandlerRegistration addSelectionHandler(
SelectionHandler<ColumnData> handler) {
return grid.getSelectionModel().addSelectionHandler(handler);
}
}

@ -0,0 +1,29 @@
package org.gcube.portlets.user.td.jsonexportwidget.client.grid;
import org.gcube.portlets.user.td.gwtservice.shared.tr.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
* email: <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();
//ValueProvider<ColumnData, String> typeName();
//ValueProvider<ColumnData, String> typeCode();
}

@ -0,0 +1,53 @@
package org.gcube.portlets.user.td.jsonexportwidget.client.workspace;
import org.gcube.portlets.widgets.lighttree.client.WorkspaceLightTreePanel;
import com.allen_sauer.gwt.log.client.Log;
import com.sencha.gxt.widget.core.client.box.AutoProgressMessageBox;
import com.sencha.gxt.widget.core.client.event.DisableEvent;
import com.sencha.gxt.widget.core.client.event.EnableEvent;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class WorkspacePanel extends WorkspaceLightTreePanel {
AutoProgressMessageBox box;
public void setSpWidth(String w) {
sp.setWidth(w);
}
public void setSpHeight(String h) {
sp.setHeight(h);
}
public void disable() {
Log.debug("WorkspacePanel Disable");
fireEvent(new DisableEvent());
}
public void enable() {
Log.debug("WorkspacePanel Enable");
fireEvent(new EnableEvent());
}
public void startWaiting() {
box= new AutoProgressMessageBox("Loading",
"Retriving data from workspace, please wait...");
box.setProgressText("Loading...");
box.setModal(false);
box.auto();
box.show();
}
public void endWaiting() {
box.hide();
}
}

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='JSONExportWidgetTD'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<!-- We need the JUnit module in the main module, -->
<!-- otherwise eclipse complains (Google plugin bug?) -->
<inherits name='com.google.gwt.junit.JUnit' />
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.standard.Standard' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<inherits name='com.sencha.gxt.ui.GXT' />
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
<inherits name='org.gcube.portlets.user.td.gwtservice.TDGWTService' />
<inherits name='org.gcube.portlets.user.td.wizardwidget.Wizard' />
<inherits name='org.gcube.portlets.user.td.monitorwidget.MonitorWidgetTD' />
<!-- Specify the app entry point class. -->
<!-- <entry-point class='org.gcube.portlets.user.SDMXImportWizardTD.client.SDMXImportWizardTDEntry' /> -->
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
<!-- <source path='org.gcube.data.analysis.tabulardata.operation.worker'/> -->
</module>

@ -0,0 +1,34 @@
/** Add css rules here for your application. */
/** Example rules used by the template application (remove for your app) */
h1 {
font-size: 2em;
font-weight: bold;
color: #777777;
margin: 40px 0px 70px;
text-align: center;
}
.sendButton {
display: block;
font-size: 16pt;
}
/** Most GWT widgets already have a style name defined */
.gwt-DialogBox {
width: 400px;
}
.dialogVPanel {
margin: 5px;
}
.serverResponseLabelError {
color: red;
}
/** Set ids using widget.getElement().setId("idOfElement") */
#closeButton {
margin: 15px 6px 6px;
}

@ -0,0 +1,63 @@
<!doctype html>
<!-- The DOCTYPE declaration above will set the -->
<!-- browser's rendering engine into -->
<!-- "Standards Mode". Replacing this declaration -->
<!-- with a "Quirks Mode" doctype may lead to some -->
<!-- differences in layout. -->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- -->
<!-- Consider inlining CSS to reduce the number of requested files -->
<!-- -->
<link type="text/css" rel="stylesheet" href="JSONExportWidgetTD.css">
<!-- -->
<!-- Any title is fine -->
<!-- -->
<title>Web Application Starter Project</title>
<!-- -->
<!-- This script loads your compiled module. -->
<!-- If you add any GWT meta tags, they must -->
<!-- be added before this line. -->
<!-- -->
<script type="text/javascript" src="JSONExportWidgetTD/JSONExportWidgetTD.nocache.js"></script>
</head>
<!-- -->
<!-- The body can have arbitrary html, or -->
<!-- you can leave the body empty if you want -->
<!-- to create a completely dynamic UI. -->
<!-- -->
<body>
<!-- OPTIONAL: include this if you want history support -->
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
<!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
<noscript>
<div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
Your web browser must have JavaScript enabled
in order for this application to display correctly.
</div>
</noscript>
<h1>Web Application Starter Project</h1>
<table>
<tr>
<td colspan="2" style="font-weight:bold;">Please enter your name:</td>
</tr>
<tr>
<td id="nameFieldContainer"></td>
<td id="sendButtonContainer"></td>
</tr>
<tr>
<td colspan="2" style="color:red;" id="errorLabelContainer"></td>
</tr>
</table>
</body>
</html>

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<!-- Servlets -->
<servlet>
<servlet-name>TDGWTService</servlet-name>
<servlet-class>org.gcube.portlets.user.td.gwtservice.server.TDGWTServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>jUnitHostImpl</servlet-name>
<servlet-class>com.google.gwt.junit.server.JUnitHostImpl</servlet-class>
</servlet>
<!-- Servlets Mapping -->
<servlet-mapping>
<servlet-name>TDGWTService</servlet-name>
<url-pattern>tdgwtservice/TDGWTService</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>jUnitHostImpl</servlet-name>
<url-pattern>JSONExportWidget/junithost/*</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>JSONExportWidgetTD.html</welcome-file>
</welcome-file-list>
</web-app>

@ -0,0 +1,83 @@
package org.gcube.portlets.user.td.jsonexportwidget.client;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTService;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import com.google.gwt.core.client.GWT;
import com.google.gwt.junit.client.GWTTestCase;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
/**
* GWT JUnit <b>integration</b> tests must extend GWTTestCase.
* Using <code>"GwtTest*"</code> naming pattern exclude them from running with
* surefire during the test phase.
*
* If you run the tests using the Maven command line, you will have to
* navigate with your browser to a specific url given by Maven.
* See http://mojo.codehaus.org/gwt-maven-plugin/user-guide/testing.html
* for details.
*/
public class GwtTestJSONExportWidgetTD extends GWTTestCase {
/**
* Must refer to a valid module that sources this class.
*/
public String getModuleName() {
return "org.gcube.portlets.user.jsonexportwidget.JSONExportWidgetTDJUnit";
}
/**
* This test will send a request to the server
*/
public void testResource() {
// Create the service that we will test.
TDGWTServiceAsync tdGWTService = GWT.create(TDGWTService.class);
ServiceDefTarget target = (ServiceDefTarget) tdGWTService;
System.out.println(GWT.getModuleBaseURL() + "TDGWTService");
target.setServiceEntryPoint(GWT.getModuleBaseURL() + "TDGWTService");
// Since RPC calls are asynchronous, we will need to wait for a response
// after this test method returns. This line tells the test runner to wait
// up to 7 seconds before timing out.
delayTestFinish(7000);
// Send a request to the server.
tdGWTService.getTabularResources(new AsyncCallback<ArrayList<TabResource>>() {
public void onFailure(Throwable caught) {
// The request resulted in an unexpected error.
fail("Request failure: " + caught.getMessage());
}
public void onSuccess(ArrayList<TabResource> result) {
// Shows the first three resources.
int i=0;
for(TabResource tr:result){
i++;
System.out.println(tr.toString());
if(i>3){
break;
}
}
assertTrue(result.size()>0);
// Now that we have received a response, we need to tell the test runner
// that the test is complete. You must call finishTest() after an
// asynchronous test finishes successfully, or the test will time out.
finishTest();
}
});
}
}

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to="JSONExportWizardTDJUnit">
<!-- Inherit our applications main module. -->
<inherits name='org.gcube.portlets.user.td.gwtservice.TDGWTService' />
<!-- Specify the path to any remote services. -->
<servlet path="/TDGWTService"
class="org.gcube.portlets.user.td.gwtservice.server.TDGWTServiceImpl" />
<!-- Specify the paths for translatable code -->
<source path='client' />
</module>

@ -0,0 +1,6 @@
gCube System - License
------------------------------------------------------------
The gCube/gCore software is licensed as Free Open Source software conveying to the EUPL (http://ec.europa.eu/idabc/eupl).
The software and documentation is provided by its authors/distributors "as is" and no expressed or
implied warranty is given for its use, quality or fitness for a particular case.

@ -0,0 +1 @@
Giancarlo Panichi (giancarlo.panichi@isti.cnr.it), CNR Pisa, Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo"

@ -0,0 +1,40 @@
The gCube System - ${name}
------------------------------------------------------------
This work has been supported by the following European projects: iMarine (FP7-INFRASTRUCTURES-2011-2)
Authors
-------
Giancarlo Panichi (giancarlo.panichi@isti.cnr.it), CNR Pisa,
Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo"
Version and Release Date
------------------------
v. ${version} (${release.date})
Description
-----------
${project.description}
Download information
--------------------
Source code URL: ${scm.url}
Documentation
-------------
${project.description}
Licensing
---------
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.

@ -0,0 +1,6 @@
<ReleaseNotes>
<Changeset component="${groupId}.${artifactId}.1-0-0"
date="2014-02-01">
<Change>First Release</Change>
</Changeset>
</ReleaseNotes>

@ -0,0 +1,39 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>servicearchive</id>
<formats>
<format>tar.gz</format>
</formats>
<baseDirectory>/</baseDirectory>
<fileSets>
<fileSet>
<directory>${distroDirectory}</directory>
<outputDirectory>/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<includes>
<include>README</include>
<include>LICENSE</include>
<include>INSTALL</include>
<include>MAINTAINERS</include>
<include>changelog.xml</include>
</includes>
<fileMode>755</fileMode>
</fileSet>
</fileSets>
<files>
<file>
<source>${distroDirectory}/svnpath.txt</source>
<outputDirectory>/${artifactId}</outputDirectory>
</file>
<file>
<source>${configDirectory}/profile.xml</source>
<outputDirectory>/</outputDirectory>
</file>
<file>
<source>target/${build.finalName}.${packaging}</source>
<outputDirectory>/${artifactId}</outputDirectory>
</file>
</files>
</assembly>

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<Resource>
<ID></ID>
<Type>Service</Type>
<Profile>
<Description>${project.description}</Description>
<Class>PortletsUser</Class>
<Name>${project.name}</Name>
<Version>${version}</Version>
<Packages>
<Software>
<Description>${project.description}</Description>
<Name>${project.name}</Name>
<Version>${version}</Version>
<MavenCoordinates>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
</MavenCoordinates>
<Type>library</Type>
<Files>
<File>${project.build.finalName}.${project.packaging}</File>
</Files>
</Software>
</Packages>
</Profile>
</Resource>

@ -0,0 +1 @@
${scm.url}
Loading…
Cancel
Save