1324: Update logging framework to Sl4j/Log4j
Task-Url: https://support.d4science.org/issues/1324 Init git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@120382 82a268e6-3cf1-43bd-a215-b396298e98cf
|
@ -0,0 +1,49 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" output="target/statistical-algorithms-importer-0.0.1-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/statistical-algorithms-importer-0.0.1-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.dependency" value="/WEB-INF/lib"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/gwt-user.jar">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="javadoc_location" value="file:/home/giancarlo/gwt/gwt-2.6.1/doc/javadoc/"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/gwt-dev.jar">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="javadoc_location" value="file:/home/giancarlo/gwt/gwt-2.6.1/doc/javadoc/"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA.jar" sourcepath="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/>
|
||||||
|
<classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/>
|
||||||
|
<classpathentry kind="output" path="target/statistical-algorithms-importer-0.0.1-SNAPSHOT/WEB-INF/classes"/>
|
||||||
|
</classpath>
|
|
@ -0,0 +1,53 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>statistical-algorithms-importer</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.google.gwt.eclipse.core.gwtProjectValidator</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>
|
||||||
|
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
|
||||||
|
<nature>com.google.gwt.eclipse.core.gwtNature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Resource>
|
||||||
|
<ID></ID>
|
||||||
|
<Type>Service</Type>
|
||||||
|
<Profile>
|
||||||
|
<Description>statistical-algorithms-importer imports statistical algorithms</Description>
|
||||||
|
<Class>PortletsUser</Class>
|
||||||
|
<Name>statistical-algorithms-importer</Name>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
<Packages>
|
||||||
|
<Software>
|
||||||
|
<Description>statistical-algorithms-importer imports statistical algorithms</Description>
|
||||||
|
<Name>statistical-algorithms-importer</Name>
|
||||||
|
<Version>0.0.1-SNAPSHOT</Version>
|
||||||
|
<MavenCoordinates>
|
||||||
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
|
<artifactId>statistical-algorithms-importer</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
</MavenCoordinates>
|
||||||
|
<Type>webapplication</Type>
|
||||||
|
<Files>
|
||||||
|
<File>statistical-algorithms-importer-0.0.1-SNAPSHOT.war</File>
|
||||||
|
</Files>
|
||||||
|
</Software>
|
||||||
|
</Packages>
|
||||||
|
</Profile>
|
||||||
|
</Resource>
|
||||||
|
|
||||||
|
|
|
@ -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,50 @@
|
||||||
|
The gCube System - statistical-algorithms-importer
|
||||||
|
------------------------------------------------------------
|
||||||
|
|
||||||
|
This work has been partially supported by the following European projects: DILIGENT (FP6-2003-IST-2),
|
||||||
|
D4Science (FP7-INFRA-2007-1.2.2), D4Science-II (FP7-INFRA-2008-1.2.2), iMarine (FP7-INFRASTRUCTURES-2011-2),
|
||||||
|
and EUBrazilOpenBio (FP7-ICT-2011-EU-Brazil), Parthenos (H2020-INFRADEV-1-2014-1), BlueBridge (H2020-EINFRA-2015-1).
|
||||||
|
|
||||||
|
Authors
|
||||||
|
-------
|
||||||
|
|
||||||
|
Giancarlo Panichi (giancarlo.panichi@isti.cnr.it), CNR Pisa,
|
||||||
|
Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo"
|
||||||
|
|
||||||
|
|
||||||
|
Version and Release Date
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
v. 0.0.1-SNAPSHOT (2015-04-30)
|
||||||
|
|
||||||
|
|
||||||
|
Description
|
||||||
|
-----------
|
||||||
|
|
||||||
|
statistical-algorithms-importer imports statistical algorithms
|
||||||
|
|
||||||
|
|
||||||
|
Download information
|
||||||
|
--------------------
|
||||||
|
Source code is available from SVN:
|
||||||
|
https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer
|
||||||
|
|
||||||
|
Binaries can be downloaded from:
|
||||||
|
http://software.d4science.research-infrastructures.eu/
|
||||||
|
|
||||||
|
|
||||||
|
Documentation
|
||||||
|
-------------
|
||||||
|
|
||||||
|
statistical-algorithms-importer imports statistical algorithms
|
||||||
|
|
||||||
|
Documentation is available on-line from the Projects Documentation Wiki:
|
||||||
|
http://wiki.gcube-system.org/gcube/Statistical_Algorithms_Importer
|
||||||
|
|
||||||
|
|
||||||
|
Licensing
|
||||||
|
---------
|
||||||
|
|
||||||
|
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<ReleaseNotes>
|
||||||
|
<Changeset component="org.gcube.portlets.user.statistical-algorithms-importer.0-0-1" date="2015-09-01">
|
||||||
|
<Change>First Release</Change>
|
||||||
|
</Changeset>
|
||||||
|
</ReleaseNotes>
|
|
@ -0,0 +1 @@
|
||||||
|
https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer
|
|
@ -0,0 +1,449 @@
|
||||||
|
<?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>statistical-algorithms-importer</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<packaging>war</packaging>
|
||||||
|
|
||||||
|
|
||||||
|
<name>statistical-algorithms-importer</name>
|
||||||
|
<description>statistical-algorithms-importer imports statistical algorithms</description>
|
||||||
|
|
||||||
|
<scm>
|
||||||
|
<url>https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer</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>2015-04-30</release.date>
|
||||||
|
<wikiurl>http://wiki.gcube-system.org/gcube/Statistical_Algorithms_Importer</wikiurl>
|
||||||
|
<templatesDirectory>templates</templatesDirectory>
|
||||||
|
<distroDirectory>distro</distroDirectory>
|
||||||
|
<configDirectory>config</configDirectory>
|
||||||
|
|
||||||
|
<!-- GWT configuration -->
|
||||||
|
<gwtVersion>2.6.1</gwtVersion>
|
||||||
|
<gwtLogVersion>3.3.2</gwtLogVersion>
|
||||||
|
<gxtVersion>3.1.1</gxtVersion>
|
||||||
|
<!-- <gxt2Version>2.6.1</gxt2Version> -->
|
||||||
|
|
||||||
|
|
||||||
|
<KEYS>${env.KEYS}</KEYS>
|
||||||
|
|
||||||
|
<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>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>log4j</groupId>
|
||||||
|
<artifactId>log4j</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- GWT -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.gwt</groupId>
|
||||||
|
<artifactId>gwt-user</artifactId>
|
||||||
|
<version>${gwtVersion}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.gwt</groupId>
|
||||||
|
<artifactId>gwt-servlet</artifactId>
|
||||||
|
<version>${gwtVersion}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-dev</artifactId>
|
||||||
|
<version>${gwtVersion}</version> </dependency> -->
|
||||||
|
|
||||||
|
<!-- GXT 3 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sencha.gxt</groupId>
|
||||||
|
<artifactId>gxt</artifactId>
|
||||||
|
<version>${gxtVersion}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Accounting Manager Theme -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.portlets.admin</groupId>
|
||||||
|
<artifactId>accounting-manager-theme</artifactId>
|
||||||
|
<version>[0.0.1-SNAPSHOT,
|
||||||
|
2.0.0-SNAPSHOT)</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.google.gwt</groupId>
|
||||||
|
<artifactId>gwt-dev</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- GXT-Theme-Neptune -->
|
||||||
|
<!-- <dependency> <groupId>com.sencha.gxt</groupId> <artifactId>gxt-theme-neptune</artifactId>
|
||||||
|
<version>${gxtVersion}</version> </dependency> -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Portlet -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.portlet</groupId>
|
||||||
|
<artifactId>portlet-api</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- PORTAL -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.core</groupId>
|
||||||
|
<artifactId>common-scope-maps</artifactId>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.portal</groupId>
|
||||||
|
<artifactId>custom-portal-handler</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||||
|
<artifactId>aslcore</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||||
|
<artifactId>accesslogger</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Social -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.portal</groupId>
|
||||||
|
<artifactId>social-networking-library</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||||
|
<artifactId>aslsocial</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- GCube Widgets -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
|
<artifactId>gcube-widgets</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- WSLT dependencies <dependency> <groupId>org.gcube.portlets.widgets</groupId>
|
||||||
|
<artifactId>workspace-light-tree</artifactId> <version>[2.13.1-SNAPSHOT,
|
||||||
|
3.0.0-SNAPSHOT)</version> </dependency> <dependency> <groupId>org.gcube.common</groupId>
|
||||||
|
<artifactId>home-library</artifactId> <version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||||
|
<scope>provided</scope> </dependency> -->
|
||||||
|
|
||||||
|
<!-- Session Checker -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.portlets.widgets</groupId>
|
||||||
|
<artifactId>session-checker</artifactId>
|
||||||
|
<version>[0.2.0-SNAPSHOT,1.0.0-SNAPSHOT)</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Apache Common Library -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-fileupload</groupId>
|
||||||
|
<artifactId>commons-fileupload</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.googlecode.juniversalchardet</groupId>
|
||||||
|
<artifactId>juniversalchardet</artifactId>
|
||||||
|
<version>1.0.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Common Encryption <dependency> <groupId>org.gcube.core</groupId> <artifactId>common-encryption</artifactId>
|
||||||
|
<scope>provided</scope> </dependency> -->
|
||||||
|
|
||||||
|
<!-- LOGGING -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.allen-sauer.gwt.log</groupId>
|
||||||
|
<artifactId>gwt-log</artifactId>
|
||||||
|
<version>${gwtLogVersion}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>log4j</groupId>
|
||||||
|
<artifactId>log4j</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId>
|
||||||
|
<version>1.0.1</version> <scope>runtime</scope> </dependency> -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- JUnit TEST -->
|
||||||
|
<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>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**/*.*</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
|
||||||
|
<plugins>
|
||||||
|
<!-- GWT Maven Plugin -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>gwt-maven-plugin</artifactId>
|
||||||
|
<version>${gwtVersion}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<configuration>
|
||||||
|
<extraJvmArgs>-Xmx1024M -Xss1024k -Dgwt.compiler.localWorkers=1</extraJvmArgs>
|
||||||
|
|
||||||
|
</configuration>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
<goal>test</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<runTarget>StatAlgoImporter.html</runTarget>
|
||||||
|
<hostedWebapp>${webappDirectory}</hostedWebapp>
|
||||||
|
<module>org.gcube.portlets.user.statisticalalgorithmsimporter.statalgoimporter</module>
|
||||||
|
<!-- <compileSourcesArtifacts> <artifact>com.github.highcharts4gwt:highcharts</artifact>
|
||||||
|
</compileSourcesArtifacts> -->
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Copy static web files before executing gwt:run -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
|
<version>2.1.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<!--<goals> <goal>exploded</goal> </goals> -->
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<webappDirectory>${webappDirectory}</webappDirectory>
|
||||||
|
<warName>${project.build.finalName}</warName>
|
||||||
|
|
||||||
|
<!-- Include static jar into WEB-INF/lib -->
|
||||||
|
<!-- <webResources> <resource> <directory>lib</directory> <includes>
|
||||||
|
<include>*.jar</include> </includes> <targetPath>WEB-INF/lib</targetPath>
|
||||||
|
</resource> </webResources> -->
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Maven Surefire Plugin for Test -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.16</version>
|
||||||
|
<configuration>
|
||||||
|
<skipTests>false</skipTests>
|
||||||
|
</configuration>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.surefire</groupId>
|
||||||
|
<artifactId>surefire-junit47</artifactId>
|
||||||
|
<version>2.16</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Maven Resources Plugin -->
|
||||||
|
<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>
|
||||||
|
<finalName>${project.build.finalName}</finalName>
|
||||||
|
</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,179 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.dom.client.Element;
|
||||||
|
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||||
|
import com.google.gwt.user.client.Window;
|
||||||
|
import com.sencha.gxt.core.client.dom.XDOM;
|
||||||
|
import com.sencha.gxt.core.client.dom.XElement;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.Viewport.ViewportAppearance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class PortalViewport extends SimpleContainer {
|
||||||
|
|
||||||
|
protected int rightScrollBarSize = 17;
|
||||||
|
|
||||||
|
protected boolean enableScroll;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a viewport layout container with the default appearance.
|
||||||
|
*/
|
||||||
|
public PortalViewport() {
|
||||||
|
this(GWT.<ViewportAppearance> create(ViewportAppearance.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a viewport layout container with the specified appearance.
|
||||||
|
*
|
||||||
|
* @param appearance
|
||||||
|
* the appearance of the viewport layout container
|
||||||
|
*/
|
||||||
|
public PortalViewport(ViewportAppearance appearance) {
|
||||||
|
super(true);
|
||||||
|
try {
|
||||||
|
|
||||||
|
SafeHtmlBuilder sb = new SafeHtmlBuilder();
|
||||||
|
appearance.render(sb);
|
||||||
|
XElement element=XDOM.create(sb.toSafeHtml());
|
||||||
|
setElement((Element)element);
|
||||||
|
monitorWindowResize = true;
|
||||||
|
forceLayoutOnResize = true;
|
||||||
|
getFocusSupport().setIgnore(false);
|
||||||
|
resize();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("PortalViewport: constructor error "
|
||||||
|
+ e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if window scrolling is enabled.
|
||||||
|
*
|
||||||
|
* @return true if window scrolling is enabled
|
||||||
|
*/
|
||||||
|
public boolean isEnableScroll() {
|
||||||
|
return enableScroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether window scrolling is enabled.
|
||||||
|
*
|
||||||
|
* @param enableScroll
|
||||||
|
* true to enable window scrolling
|
||||||
|
*/
|
||||||
|
public void setEnableScroll(boolean enableScroll) {
|
||||||
|
this.enableScroll = enableScroll;
|
||||||
|
Window.enableScrolling(enableScroll);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the rightScrollBarSize
|
||||||
|
*/
|
||||||
|
public int getRightScrollBarSize() {
|
||||||
|
return rightScrollBarSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param rightScrollBarSize
|
||||||
|
* the rightScrollBarSize to set
|
||||||
|
*/
|
||||||
|
public void setRightScrollBarSize(int rightScrollBarSize) {
|
||||||
|
this.rightScrollBarSize = rightScrollBarSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onAttach() {
|
||||||
|
super.onAttach();
|
||||||
|
setEnableScroll(enableScroll);
|
||||||
|
resize();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void resize() {
|
||||||
|
int viewWidth;
|
||||||
|
if(enableScroll){
|
||||||
|
viewWidth= calculateWidth() - rightScrollBarSize;
|
||||||
|
} else {
|
||||||
|
viewWidth = calculateWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
int viewHeight = calculateHeight();
|
||||||
|
Log.info("AM resize viewWidth: " + viewWidth + " viewHeight: "
|
||||||
|
+ viewHeight + " clientWidth: " + Window.getClientWidth()
|
||||||
|
+ " clientHeight: " + Window.getClientHeight());
|
||||||
|
try {
|
||||||
|
setPixelSize(viewWidth, viewHeight);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("PortalViewport: error in resize() at setPixelSize "
|
||||||
|
+ e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void onWindowResize(int width, int height) {
|
||||||
|
int viewWidth = calculateWidth();
|
||||||
|
int viewHeight = calculateHeight();
|
||||||
|
Log.trace("AM onWindowResize viewWidth: " + viewWidth
|
||||||
|
+ " viewHeight: " + viewHeight + " clientWidth: "
|
||||||
|
+ Window.getClientWidth() + " clientHeight: "
|
||||||
|
+ Window.getClientHeight());
|
||||||
|
setPixelSize(viewWidth, viewHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update window size
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* public void resize(){
|
||||||
|
*
|
||||||
|
* RootPanel workspace = RootPanel.get("tdp");
|
||||||
|
*
|
||||||
|
* int topBorder = workspace.getAbsoluteTop();
|
||||||
|
*
|
||||||
|
* int leftBorder = workspace.getAbsoluteLeft();
|
||||||
|
*
|
||||||
|
* int footer = 85;
|
||||||
|
*
|
||||||
|
* int rootHeight = (Window.getClientHeight() - topBorder - 4 - footer);// -
|
||||||
|
* ((footer == null)?0:(footer.getOffsetHeight()-15));
|
||||||
|
*
|
||||||
|
* if (rootHeight < 550) rootHeight = 550;
|
||||||
|
*
|
||||||
|
* int rootWidth = Window.getClientWidth() - 2* leftBorder; //-
|
||||||
|
* rightScrollBar;
|
||||||
|
*
|
||||||
|
* System.out.println("New workspace dimension Height: "+rootHeight+" Width: "
|
||||||
|
* +rootWidth);
|
||||||
|
*
|
||||||
|
* this.setHeight(rootHeight); this.setWidth(rootWidth); }
|
||||||
|
*/
|
||||||
|
|
||||||
|
protected int calculateWidth() {
|
||||||
|
int leftBorder = getAbsoluteLeft();
|
||||||
|
Log.info("AM width: "
|
||||||
|
+ String.valueOf(Window.getClientWidth() - 2 * leftBorder));
|
||||||
|
return Window.getClientWidth() - 2 * leftBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int calculateHeight() {
|
||||||
|
int topBorder = getAbsoluteTop();
|
||||||
|
Log.info("AM height: "
|
||||||
|
+ String.valueOf(Window.getClientHeight() - topBorder - 34));
|
||||||
|
return Window.getClientHeight() - topBorder - 34;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,143 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.maindata.MainDataPanel;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource.StatAlgoImporterResources;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.ribbon.StatAlgoImporterRibbon;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterService;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterServiceAsync;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.core.client.EntryPoint;
|
||||||
|
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.shared.EventBus;
|
||||||
|
import com.google.gwt.user.client.ui.RootPanel;
|
||||||
|
import com.sencha.gxt.core.client.util.Margins;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.BorderLayoutData;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.MarginData;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.Viewport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class StatAlgoImporter implements EntryPoint {
|
||||||
|
|
||||||
|
private static final String JSP_TAG_ID = "StatisticalRunnerPortlet";
|
||||||
|
|
||||||
|
private static final int RIBBON_HEIGHT = 120;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private final StatAlgoImporterServiceAsync statRunnerService = GWT
|
||||||
|
.create(StatAlgoImporterService.class);
|
||||||
|
|
||||||
|
// Main Panel
|
||||||
|
private static BorderLayoutContainer mainPanelLayout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public void onModuleLoad() {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Install an UncaughtExceptionHandler which will produce
|
||||||
|
* <code>FATAL</code> log messages
|
||||||
|
*/
|
||||||
|
Log.setUncaughtExceptionHandler();
|
||||||
|
|
||||||
|
// use deferred command to catch initialization exceptions in
|
||||||
|
// onModuleLoad2
|
||||||
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||||
|
public void execute() {
|
||||||
|
loadMainPanel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void loadMainPanel() {
|
||||||
|
StatAlgoImporterResources.INSTANCE.srCSS().ensureInjected();
|
||||||
|
// ScriptInjector.fromString(AccountingManagerResources.INSTANCE.jqueryJs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
|
||||||
|
|
||||||
|
StatAlgoImporterController controller = new StatAlgoImporterController();
|
||||||
|
EventBus eventBus = controller.getEventBus();
|
||||||
|
|
||||||
|
// Layout
|
||||||
|
mainPanelLayout = new BorderLayoutContainer();
|
||||||
|
mainPanelLayout.setId("mainPanelLayout");
|
||||||
|
mainPanelLayout.setBorders(false);
|
||||||
|
mainPanelLayout.setResize(true);
|
||||||
|
// mainPanelLayout.getElement().getStyle().setBackgroundColor("rgb(3, 126, 207)");
|
||||||
|
|
||||||
|
// Main
|
||||||
|
final MainDataPanel mainDataPanel = new MainDataPanel(eventBus);
|
||||||
|
MarginData mainData = new MarginData(new Margins(2));
|
||||||
|
mainPanelLayout.setCenterWidget(mainDataPanel, mainData);
|
||||||
|
|
||||||
|
// Menu
|
||||||
|
StatAlgoImporterRibbon accountingManagerMenu = new StatAlgoImporterRibbon(
|
||||||
|
eventBus);
|
||||||
|
|
||||||
|
BorderLayoutData ribbonData = new BorderLayoutData(RIBBON_HEIGHT);
|
||||||
|
ribbonData.setMargins(new Margins(2));
|
||||||
|
ribbonData.setCollapsible(false);
|
||||||
|
ribbonData.setSplit(false);
|
||||||
|
|
||||||
|
mainPanelLayout.setNorthWidget(accountingManagerMenu.getContainer(),
|
||||||
|
ribbonData);
|
||||||
|
|
||||||
|
// Tools
|
||||||
|
/*
|
||||||
|
* CodeUploadPanel codeUploadPanel=new CodeUploadPanel(eventBus);
|
||||||
|
* BorderLayoutData westData = new BorderLayoutData(310);
|
||||||
|
* westData.setCollapsible(false); westData.setSplit(false);
|
||||||
|
* westData.setFloatable(false); westData.setCollapseMini(false);
|
||||||
|
* westData.setMargins(new Margins(2, 7, 2, 7));
|
||||||
|
* westData.setCollapseHidden(true); westData.setMaxSize(310);
|
||||||
|
* westData.setMinSize(310);
|
||||||
|
* mainPanelLayout.setWestWidget(codeUploadPanel, westData);
|
||||||
|
* codeUploadPanel.expand(); codeUploadPanel.enable();
|
||||||
|
*/
|
||||||
|
|
||||||
|
bind(mainPanelLayout);
|
||||||
|
controller.setMainPanelLayout(mainPanelLayout);
|
||||||
|
controller.restoreUISession();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void bind(BorderLayoutContainer mainWidget) {
|
||||||
|
try {
|
||||||
|
RootPanel root = RootPanel.get(JSP_TAG_ID);
|
||||||
|
Log.info("Root Panel: " + root);
|
||||||
|
if (root == null) {
|
||||||
|
Log.info("Div with id " + JSP_TAG_ID
|
||||||
|
+ " not found, starting in dev mode");
|
||||||
|
Viewport viewport = new Viewport();
|
||||||
|
viewport.setWidget(mainWidget);
|
||||||
|
viewport.onResize();
|
||||||
|
RootPanel.get().add(viewport);
|
||||||
|
} else {
|
||||||
|
Log.info("Application div with id " + JSP_TAG_ID
|
||||||
|
+ " found, starting in portal mode");
|
||||||
|
PortalViewport viewport = new PortalViewport();
|
||||||
|
Log.info("Created Viewport");
|
||||||
|
viewport.setEnableScroll(false);
|
||||||
|
viewport.setWidget(mainWidget);
|
||||||
|
Log.info("Set Widget");
|
||||||
|
Log.info("getOffsetWidth(): " + viewport.getOffsetWidth());
|
||||||
|
Log.info("getOffsetHeight(): " + viewport.getOffsetHeight());
|
||||||
|
viewport.onResize();
|
||||||
|
root.add(viewport);
|
||||||
|
Log.info("Added viewport to root");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Log.error("Error in attach viewport:" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,241 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ImportCodeEvent;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.SessionExpiredEvent;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ShowCodeEvent;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.StatAlgoImporterRibbonEvent;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.UIStateEvent;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterServiceAsync;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.SessionExpiredType;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.StatAlgoImporterRibbonType;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.UIStateType;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.upload.CodeUploadDialog;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.upload.ImportCodeDescription;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.utils.UtilsGXT3;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterSessionExpiredException;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session.UserInfo;
|
||||||
|
import org.gcube.portlets.widgets.sessionchecker.client.CheckSession;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.event.shared.EventBus;
|
||||||
|
import com.google.gwt.event.shared.SimpleEventBus;
|
||||||
|
import com.google.gwt.i18n.client.LocaleInfo;
|
||||||
|
import com.google.gwt.user.client.Cookies;
|
||||||
|
import com.google.gwt.user.client.Timer;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class StatAlgoImporterController {
|
||||||
|
|
||||||
|
private SimpleEventBus eventBus;
|
||||||
|
private UserInfo userInfo;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private BorderLayoutContainer mainPanel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public StatAlgoImporterController() {
|
||||||
|
eventBus = new SimpleEventBus();
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
callHello();
|
||||||
|
checkSession();
|
||||||
|
bindToEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkSession() {
|
||||||
|
// if you do not need to something when the session expire
|
||||||
|
CheckSession.getInstance().startPolling();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sessionExpiredShow() {
|
||||||
|
CheckSession.showLogoutDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the eventBus
|
||||||
|
*/
|
||||||
|
public EventBus getEventBus() {
|
||||||
|
return eventBus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMainPanelLayout(BorderLayoutContainer mainPanel) {
|
||||||
|
this.mainPanel = mainPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void callHello() {
|
||||||
|
StatAlgoImporterServiceAsync.INSTANCE.hello(new AsyncCallback<UserInfo>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
Log.info("No valid user found: " + caught.getMessage());
|
||||||
|
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
||||||
|
UtilsGXT3.alert("Error", "Expired Session");
|
||||||
|
sessionExpiredShowDelayed();
|
||||||
|
} else {
|
||||||
|
UtilsGXT3.alert("Error", "No user found: "+caught.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(UserInfo result) {
|
||||||
|
userInfo = result;
|
||||||
|
Log.info("Hello: " + userInfo.getUsername());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sessionExpiredShowDelayed() {
|
||||||
|
Timer timeoutTimer = new Timer() {
|
||||||
|
public void run() {
|
||||||
|
sessionExpiredShow();
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
int TIMEOUT = 3; // 3 second timeout
|
||||||
|
|
||||||
|
timeoutTimer.schedule(TIMEOUT * 1000); // timeout is in milliseconds
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void checkLocale() {
|
||||||
|
String[] locales = LocaleInfo.getAvailableLocaleNames();
|
||||||
|
|
||||||
|
for (String locale : locales) {
|
||||||
|
Log.debug("Locale avaible:" + locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
String currentLocaleCookie = Cookies.getCookie(LocaleInfo
|
||||||
|
.getLocaleCookieName());
|
||||||
|
Log.debug(Constants.STATRUNNER_LANG_COOKIE + ":" + currentLocaleCookie);
|
||||||
|
|
||||||
|
LocaleInfo currentLocaleInfo = LocaleInfo.getCurrentLocale();
|
||||||
|
Log.debug("Current Locale:" + currentLocaleInfo.getLocaleName());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void changeLanguage(String localeName) {
|
||||||
|
Date now = new Date();
|
||||||
|
long nowLong = now.getTime();
|
||||||
|
nowLong = nowLong + (1000 * 60 * 60 * 24 * 21);
|
||||||
|
now.setTime(nowLong);
|
||||||
|
String cookieLang = Cookies.getCookie(Constants.STATRUNNER_LANG_COOKIE);
|
||||||
|
if (cookieLang != null) {
|
||||||
|
Cookies.removeCookie(Constants.STATRUNNER_LANG_COOKIE);
|
||||||
|
}
|
||||||
|
Cookies.setCookie(Constants.STATRUNNER_LANG_COOKIE, localeName, now);
|
||||||
|
com.google.gwt.user.client.Window.Location.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
public void restoreUISession() {
|
||||||
|
checkLocale();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bind Controller to events on bus
|
||||||
|
private void bindToEvents() {
|
||||||
|
eventBus.addHandler(SessionExpiredEvent.TYPE,
|
||||||
|
new SessionExpiredEvent.SessionExpiredEventHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSessionExpired(SessionExpiredEvent event) {
|
||||||
|
Log.debug("Catch Event SessionExpiredEvent");
|
||||||
|
doSessionExpiredCommand(event);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
eventBus.addHandler(StatAlgoImporterRibbonEvent.TYPE,
|
||||||
|
new StatAlgoImporterRibbonEvent.StatRunnerRibbonEventHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelect(StatAlgoImporterRibbonEvent event) {
|
||||||
|
Log.debug("Catch StatRunnerRibbonEvent");
|
||||||
|
doMenuCommand(event);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
eventBus.addHandler(ImportCodeEvent.TYPE,
|
||||||
|
new ImportCodeEvent.ImportCodeEventHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onImportCode(ImportCodeEvent event) {
|
||||||
|
Log.debug("Catch ImportCodeEvent");
|
||||||
|
doImportCodeCommand(event);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
eventBus.fireEvent(new UIStateEvent(UIStateType.START));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doMenuCommand(StatAlgoImporterRibbonEvent event) {
|
||||||
|
StatAlgoImporterRibbonType eventType=event.getStatRunnerRibbonType();
|
||||||
|
if(eventType==null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(eventType){
|
||||||
|
case HELP:
|
||||||
|
break;
|
||||||
|
case CREATE_ALGORITHM:
|
||||||
|
break;
|
||||||
|
case UPLOAD_CODE:
|
||||||
|
showCodeUploadPanel();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doImportCodeCommand(ImportCodeEvent event) {
|
||||||
|
ImportCodeDescription importCodeDesc=event.getImportCodeDescription();
|
||||||
|
if(importCodeDesc!=null && importCodeDesc.getImportCodeType()!=null){
|
||||||
|
ShowCodeEvent showCodeEvent=new ShowCodeEvent(importCodeDesc);
|
||||||
|
eventBus.fireEvent(showCodeEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void showCodeUploadPanel() {
|
||||||
|
CodeUploadDialog codeUploadDialog=new CodeUploadDialog(eventBus);
|
||||||
|
codeUploadDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doSessionExpiredCommand(SessionExpiredEvent event) {
|
||||||
|
Log.debug("Session Expired Event: " + event.getSessionExpiredType());
|
||||||
|
sessionExpiredShow();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private void asyncCodeLoadingFailed(Throwable reason) {
|
||||||
|
Log.error("Async code loading failed", reason);
|
||||||
|
eventBus.fireEvent(new SessionExpiredEvent(
|
||||||
|
SessionExpiredType.EXPIREDONSERVER));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.upload.ImportCodeDescription;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.EventHandler;
|
||||||
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
|
import com.google.gwt.event.shared.HandlerRegistration;
|
||||||
|
import com.google.gwt.event.shared.HasHandlers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import Code Event
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ImportCodeEvent extends
|
||||||
|
GwtEvent<ImportCodeEvent.ImportCodeEventHandler> {
|
||||||
|
|
||||||
|
public static Type<ImportCodeEventHandler> TYPE = new Type<ImportCodeEventHandler>();
|
||||||
|
private ImportCodeDescription importCodeDescription;
|
||||||
|
|
||||||
|
public interface ImportCodeEventHandler extends EventHandler {
|
||||||
|
void onImportCode(ImportCodeEvent event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface HasImportCodeEventHandler extends HasHandlers {
|
||||||
|
public HandlerRegistration addImportCodeEventHandler(
|
||||||
|
ImportCodeEventHandler handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImportCodeEvent(ImportCodeDescription importCodeDescription) {
|
||||||
|
this.importCodeDescription = importCodeDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void dispatch(ImportCodeEventHandler handler) {
|
||||||
|
handler.onImportCode(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type<ImportCodeEventHandler> getAssociatedType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Type<ImportCodeEventHandler> getType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void fire(HasHandlers source,
|
||||||
|
ImportCodeEvent importCodeEvent) {
|
||||||
|
source.fireEvent(importCodeEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImportCodeDescription getImportCodeDescription() {
|
||||||
|
return importCodeDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ImportCodeEvent [importCodeDescription="
|
||||||
|
+ importCodeDescription + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event;
|
||||||
|
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.SessionExpiredType;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.EventHandler;
|
||||||
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
|
import com.google.gwt.event.shared.HandlerRegistration;
|
||||||
|
import com.google.gwt.event.shared.HasHandlers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SessionExpiredEvent extends GwtEvent<SessionExpiredEvent.SessionExpiredEventHandler> {
|
||||||
|
|
||||||
|
public static Type<SessionExpiredEventHandler> TYPE = new Type<SessionExpiredEventHandler>();
|
||||||
|
private SessionExpiredType sessionExpiredType;
|
||||||
|
|
||||||
|
public interface SessionExpiredEventHandler extends EventHandler {
|
||||||
|
void onSessionExpired(SessionExpiredEvent event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface HasSessionExpiredEventHandler extends HasHandlers{
|
||||||
|
public HandlerRegistration addSessionExpiredEventHandler(SessionExpiredEventHandler handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SessionExpiredEvent(SessionExpiredType sessionExpiredType) {
|
||||||
|
this.sessionExpiredType = sessionExpiredType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void dispatch(SessionExpiredEventHandler handler) {
|
||||||
|
handler.onSessionExpired(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type<SessionExpiredEventHandler> getAssociatedType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Type<SessionExpiredEventHandler> getType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void fire(HasHandlers source, SessionExpiredType sessionExpiredType) {
|
||||||
|
source.fireEvent(new SessionExpiredEvent(sessionExpiredType));
|
||||||
|
}
|
||||||
|
|
||||||
|
public SessionExpiredType getSessionExpiredType() {
|
||||||
|
return sessionExpiredType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "SessionExpiredEvent [sessionExpiredType=" + sessionExpiredType
|
||||||
|
+ "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.upload.ImportCodeDescription;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.EventHandler;
|
||||||
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
|
import com.google.gwt.event.shared.HandlerRegistration;
|
||||||
|
import com.google.gwt.event.shared.HasHandlers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show Code Event
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ShowCodeEvent extends
|
||||||
|
GwtEvent<ShowCodeEvent.ShowCodeEventHandler> {
|
||||||
|
|
||||||
|
public static Type<ShowCodeEventHandler> TYPE = new Type<ShowCodeEventHandler>();
|
||||||
|
private ImportCodeDescription importCodeDescription;
|
||||||
|
|
||||||
|
public interface ShowCodeEventHandler extends EventHandler {
|
||||||
|
void onShowCode(ShowCodeEvent event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface HasShowCodeEventHandler extends HasHandlers {
|
||||||
|
public HandlerRegistration addShowCodeEventHandler(
|
||||||
|
ShowCodeEventHandler handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShowCodeEvent(ImportCodeDescription importCodeDescription) {
|
||||||
|
this.importCodeDescription = importCodeDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void dispatch(ShowCodeEventHandler handler) {
|
||||||
|
handler.onShowCode(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type<ShowCodeEventHandler> getAssociatedType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Type<ShowCodeEventHandler> getType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void fire(HasHandlers source,
|
||||||
|
ShowCodeEvent importCodeEvent) {
|
||||||
|
source.fireEvent(importCodeEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImportCodeDescription getImportCodeDescription() {
|
||||||
|
return importCodeDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ShowCodeEvent [importCodeDescription=" + importCodeDescription
|
||||||
|
+ "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.StatAlgoImporterRibbonType;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.EventHandler;
|
||||||
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
|
import com.google.gwt.event.shared.HandlerRegistration;
|
||||||
|
import com.google.gwt.event.shared.HasHandlers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class StatAlgoImporterRibbonEvent extends
|
||||||
|
GwtEvent<StatAlgoImporterRibbonEvent.StatRunnerRibbonEventHandler> {
|
||||||
|
|
||||||
|
public static Type<StatRunnerRibbonEventHandler> TYPE = new Type<StatRunnerRibbonEventHandler>();
|
||||||
|
private StatAlgoImporterRibbonType statAlgoImporterRibbonType;
|
||||||
|
|
||||||
|
public interface StatRunnerRibbonEventHandler extends EventHandler {
|
||||||
|
void onSelect(StatAlgoImporterRibbonEvent event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface HasStatRunnerRibbonEventHandler extends HasHandlers {
|
||||||
|
public HandlerRegistration addStatRunnerRibbonEventHandler(
|
||||||
|
StatRunnerRibbonEventHandler handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StatAlgoImporterRibbonEvent(StatAlgoImporterRibbonType statRunnerRibbonType) {
|
||||||
|
this.statAlgoImporterRibbonType = statRunnerRibbonType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void dispatch(StatRunnerRibbonEventHandler handler) {
|
||||||
|
handler.onSelect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type<StatRunnerRibbonEventHandler> getAssociatedType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Type<StatRunnerRibbonEventHandler> getType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void fire(HasHandlers source,
|
||||||
|
StatAlgoImporterRibbonEvent statRunnerRibbonEvent) {
|
||||||
|
source.fireEvent(statRunnerRibbonEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StatAlgoImporterRibbonType getStatRunnerRibbonType() {
|
||||||
|
return statAlgoImporterRibbonType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "StatAlgoImporterRibbonEvent [statAlgoImporterRibbonType="
|
||||||
|
+ statAlgoImporterRibbonType + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event;
|
||||||
|
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.UIStateType;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.EventHandler;
|
||||||
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
|
import com.google.gwt.event.shared.HandlerRegistration;
|
||||||
|
import com.google.gwt.event.shared.HasHandlers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class UIStateEvent extends GwtEvent<UIStateEvent.UIStateHandler> {
|
||||||
|
|
||||||
|
public static Type<UIStateHandler> TYPE = new Type<UIStateHandler>();
|
||||||
|
private UIStateType uiStateType;
|
||||||
|
|
||||||
|
public interface UIStateHandler extends EventHandler {
|
||||||
|
void onUIState(UIStateEvent event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface HasUIStateHandler extends HasHandlers {
|
||||||
|
public HandlerRegistration addUIStateHandler(UIStateHandler handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UIStateEvent(UIStateType uiStateType) {
|
||||||
|
this.uiStateType = uiStateType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void dispatch(UIStateHandler handler) {
|
||||||
|
handler.onUIState(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type<UIStateHandler> getAssociatedType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Type<UIStateHandler> getType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void fire(HasHandlers source, UIStateEvent uiStateEvent) {
|
||||||
|
source.fireEvent(uiStateEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public UIStateType getUiStateType() {
|
||||||
|
return uiStateType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "UIStateEvent [uiStateType=" + uiStateType + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,493 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.maindata;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.SessionExpiredEvent;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.CodeDataProperties;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource.StatAlgoImporterResources;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterServiceAsync;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.SessionExpiredType;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.utils.UtilsGXT3;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.code.CodeData;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterSessionExpiredException;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.cell.client.AbstractCell;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.dom.client.Style.TextAlign;
|
||||||
|
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||||
|
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||||
|
import com.google.gwt.event.shared.EventBus;
|
||||||
|
import com.google.gwt.event.shared.HandlerRegistration;
|
||||||
|
import com.google.gwt.safecss.shared.SafeStylesBuilder;
|
||||||
|
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||||
|
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.util.Margins;
|
||||||
|
import com.sencha.gxt.data.shared.ListStore;
|
||||||
|
import com.sencha.gxt.dnd.core.client.DND.Operation;
|
||||||
|
import com.sencha.gxt.dnd.core.client.GridDragSource;
|
||||||
|
import com.sencha.gxt.dnd.core.client.GridDropTarget;
|
||||||
|
import com.sencha.gxt.widget.core.client.ContentPanel;
|
||||||
|
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.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.grid.RowNumberer;
|
||||||
|
import com.sencha.gxt.widget.core.client.menu.Item;
|
||||||
|
import com.sencha.gxt.widget.core.client.menu.Menu;
|
||||||
|
import com.sencha.gxt.widget.core.client.menu.MenuItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo email: <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CodeViewerPanel extends ContentPanel {
|
||||||
|
private static final String GRID_CODE_HEIGHT = "300px";
|
||||||
|
private static final String GRID_IO_HEIGHT = "100px";
|
||||||
|
private static final String SET_INPUT = "SetInput";
|
||||||
|
|
||||||
|
private EventBus eventBus;
|
||||||
|
|
||||||
|
private ListStore<CodeData> storeCode;
|
||||||
|
private Grid<CodeData> gridCode;
|
||||||
|
|
||||||
|
private ListStore<CodeData> storeInput;
|
||||||
|
private Grid<CodeData> gridInput;
|
||||||
|
|
||||||
|
private ListStore<CodeData> storeOutput;
|
||||||
|
private Grid<CodeData> gridOutput;
|
||||||
|
|
||||||
|
// private TextField fileNameField;
|
||||||
|
|
||||||
|
public CodeViewerPanel(EventBus eventBus) {
|
||||||
|
super();
|
||||||
|
Log.debug("CodeViewerPanel");
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
|
||||||
|
// msgs = GWT.create(ServiceCategoryMessages.class);
|
||||||
|
init();
|
||||||
|
create();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
forceLayoutOnResize = true;
|
||||||
|
setBodyBorder(false);
|
||||||
|
setBorders(false);
|
||||||
|
setHeaderVisible(false);
|
||||||
|
setResize(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void create() {
|
||||||
|
/*
|
||||||
|
* ToolBar toolBar = new ToolBar();
|
||||||
|
*
|
||||||
|
* toolBar.add(new LabelToolItem("File: ")); fileNameField=new
|
||||||
|
* TextField(); fileNameField.setWidth("250px");
|
||||||
|
* toolBar.add(fileNameField);
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* toolBar.add(new LabelToolItem("Search: ")); final TextField
|
||||||
|
* searchField = new TextField(); toolBar.add(searchField);
|
||||||
|
*
|
||||||
|
* TextButton btnReload = new TextButton(); //
|
||||||
|
* btnReload.setText("Reload");
|
||||||
|
* btnReload.setIcon(StatisticalRunnerResources.INSTANCE.reload24());
|
||||||
|
* btnReload.setToolTip("Reload"); toolBar.add(btnReload);
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
CodeDataProperties props = GWT.create(CodeDataProperties.class);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* storeCode.addFilter(new StoreFilter<CodeData>() {
|
||||||
|
*
|
||||||
|
* public boolean select(Store<CodeData> store, CodeData parent,
|
||||||
|
* CodeData item) { String searchTerm = searchField.getCurrentValue();
|
||||||
|
* if (searchTerm == null) return true; return
|
||||||
|
* CodeViewerPanel.this.select(item, searchTerm); } });
|
||||||
|
*
|
||||||
|
* storeCode.setEnableFilters(true);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// The row numberer for the first column
|
||||||
|
RowNumberer<CodeData> numbererColumn = new RowNumberer<CodeData>();
|
||||||
|
numbererColumn.setSortable(false);
|
||||||
|
numbererColumn.setHeader("N.");
|
||||||
|
numbererColumn.setWidth(80);
|
||||||
|
numbererColumn.setResizable(true);
|
||||||
|
|
||||||
|
// numbererColumn.setHorizontalAlignment(HorizontalAlignmentConstant.endOf(Direction.LTR));
|
||||||
|
// numbererColumn.setColumnStyle(ss.toSafeStyles());
|
||||||
|
|
||||||
|
SafeStylesBuilder ss = new SafeStylesBuilder()
|
||||||
|
.textAlign(TextAlign.CENTER);
|
||||||
|
ColumnConfig<CodeData, Integer> codeIdColumn = new ColumnConfig<CodeData, Integer>(
|
||||||
|
props.id(), 80, "N.");
|
||||||
|
codeIdColumn.setSortable(false);
|
||||||
|
codeIdColumn.setColumnStyle(ss.toSafeStyles());
|
||||||
|
|
||||||
|
ColumnConfig<CodeData, String> codeLineColumn = new ColumnConfig<CodeData, String>(
|
||||||
|
props.codeLine(), 100, "Code");
|
||||||
|
|
||||||
|
|
||||||
|
codeLineColumn.setCell(new AbstractCell<String>(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(Context context,
|
||||||
|
String value, SafeHtmlBuilder sb) {
|
||||||
|
Log.debug(value);
|
||||||
|
SafeHtmlBuilder shb=new SafeHtmlBuilder();
|
||||||
|
shb.appendEscaped(value);
|
||||||
|
sb.appendHtmlConstant("<pre>"+shb.toSafeHtml().asString()+"</pre>");
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
codeLineColumn.setSortable(false);
|
||||||
|
|
||||||
|
// Grid Code
|
||||||
|
List<ColumnConfig<CodeData, ?>> gridCodeColumns = new ArrayList<ColumnConfig<CodeData, ?>>();
|
||||||
|
gridCodeColumns.add(numbererColumn);
|
||||||
|
gridCodeColumns.add(codeLineColumn);
|
||||||
|
|
||||||
|
ColumnModel<CodeData> gridCodeColumnModel = new ColumnModel<CodeData>(
|
||||||
|
gridCodeColumns);
|
||||||
|
|
||||||
|
IdentityValueProvider<CodeData> identityCode = new IdentityValueProvider<CodeData>();
|
||||||
|
final CheckBoxSelectionModel<CodeData> smCode = new CheckBoxSelectionModel<CodeData>(
|
||||||
|
identityCode);
|
||||||
|
smCode.setSelectionMode(SelectionMode.SINGLE);
|
||||||
|
|
||||||
|
storeCode = new ListStore<CodeData>(props.code());
|
||||||
|
|
||||||
|
gridCode = new Grid<CodeData>(storeCode, gridCodeColumnModel) {
|
||||||
|
@Override
|
||||||
|
protected void onAfterFirstAttach() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
super.onAfterFirstAttach();
|
||||||
|
loadData();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
gridCode.setSelectionModel(smCode);
|
||||||
|
gridCode.getView().setStripeRows(true);
|
||||||
|
gridCode.getView().setColumnLines(true);
|
||||||
|
gridCode.getView().setAutoFill(true);
|
||||||
|
gridCode.setBorders(false);
|
||||||
|
gridCode.setLoadMask(true);
|
||||||
|
gridCode.setHeight(GRID_CODE_HEIGHT);
|
||||||
|
gridCode.setColumnReordering(false);
|
||||||
|
gridCode.setColumnResize(false);
|
||||||
|
// gridCode.getView().setAutoExpandColumn(codeLineColumn);
|
||||||
|
|
||||||
|
// Initialize the row numberer
|
||||||
|
numbererColumn.initPlugin(gridCode);
|
||||||
|
|
||||||
|
// GridFilters<CodeData> filtersSelectedRules = new
|
||||||
|
// GridFilters<CodeData>();
|
||||||
|
// filtersSelectedRules.initPlugin(gridInput);
|
||||||
|
// filtersSelectedRules.setLocal(true);
|
||||||
|
// filtersSelectedRules.addFilter(nameFilter);
|
||||||
|
// filtersSelectedRules.addFilter(descriptionFilter);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* grid.addRowDoubleClickHandler(new RowDoubleClickHandler() {
|
||||||
|
*
|
||||||
|
* @Override public void onRowDoubleClick(RowDoubleClickEvent event) {
|
||||||
|
* int rowIndex = event.getRowIndex(); requestOpen(rowIndex); }
|
||||||
|
*
|
||||||
|
* });
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* SelectHandler sh = new SelectHandler() { public void
|
||||||
|
* onSelect(SelectEvent event) { loadData(); } };
|
||||||
|
*
|
||||||
|
* btnReload.addSelectHandler(sh);
|
||||||
|
*/
|
||||||
|
|
||||||
|
createContextMenuGridCode();
|
||||||
|
|
||||||
|
// Grid Input
|
||||||
|
List<ColumnConfig<CodeData, ?>> gridInputColumns = new ArrayList<ColumnConfig<CodeData, ?>>();
|
||||||
|
gridInputColumns.add(codeIdColumn);
|
||||||
|
gridInputColumns.add(codeLineColumn);
|
||||||
|
|
||||||
|
ColumnModel<CodeData> gridInputColumnModel = new ColumnModel<CodeData>(
|
||||||
|
gridInputColumns);
|
||||||
|
|
||||||
|
IdentityValueProvider<CodeData> identityInput = new IdentityValueProvider<CodeData>();
|
||||||
|
final CheckBoxSelectionModel<CodeData> smInput = new CheckBoxSelectionModel<CodeData>(
|
||||||
|
identityInput);
|
||||||
|
smInput.setSelectionMode(SelectionMode.SINGLE);
|
||||||
|
|
||||||
|
storeInput = new ListStore<CodeData>(props.code());
|
||||||
|
|
||||||
|
gridInput = new Grid<CodeData>(storeInput, gridInputColumnModel);
|
||||||
|
|
||||||
|
gridInput.setSelectionModel(smInput);
|
||||||
|
gridInput.getView().setStripeRows(true);
|
||||||
|
gridInput.getView().setColumnLines(true);
|
||||||
|
gridInput.getView().setAutoFill(true);
|
||||||
|
gridInput.setBorders(false);
|
||||||
|
gridInput.setLoadMask(true);
|
||||||
|
gridInput.setHeight(GRID_IO_HEIGHT);
|
||||||
|
gridInput.setColumnReordering(false);
|
||||||
|
gridInput.setColumnResize(false);
|
||||||
|
gridInput.getView().setAutoExpandColumn(codeLineColumn);
|
||||||
|
|
||||||
|
createContextMenuGridInput();
|
||||||
|
|
||||||
|
// Output
|
||||||
|
List<ColumnConfig<CodeData, ?>> gridOutputColumns = new ArrayList<ColumnConfig<CodeData, ?>>();
|
||||||
|
gridOutputColumns.add(codeIdColumn);
|
||||||
|
gridOutputColumns.add(codeLineColumn);
|
||||||
|
|
||||||
|
ColumnModel<CodeData> gridOutputColumnModel = new ColumnModel<CodeData>(
|
||||||
|
gridOutputColumns);
|
||||||
|
|
||||||
|
IdentityValueProvider<CodeData> identityOutput = new IdentityValueProvider<CodeData>();
|
||||||
|
final CheckBoxSelectionModel<CodeData> smOutput = new CheckBoxSelectionModel<CodeData>(
|
||||||
|
identityOutput);
|
||||||
|
smOutput.setSelectionMode(SelectionMode.SINGLE);
|
||||||
|
|
||||||
|
storeOutput = new ListStore<CodeData>(props.code());
|
||||||
|
|
||||||
|
gridOutput = new Grid<CodeData>(storeOutput, gridOutputColumnModel);
|
||||||
|
|
||||||
|
gridOutput.setSelectionModel(smOutput);
|
||||||
|
gridOutput.getView().setStripeRows(true);
|
||||||
|
gridOutput.getView().setColumnLines(true);
|
||||||
|
gridOutput.getView().setAutoFill(true);
|
||||||
|
gridOutput.setBorders(false);
|
||||||
|
gridOutput.setLoadMask(true);
|
||||||
|
gridOutput.setHeight(GRID_IO_HEIGHT);
|
||||||
|
gridOutput.setColumnReordering(false);
|
||||||
|
gridOutput.setColumnResize(false);
|
||||||
|
gridOutput.getView().setAutoExpandColumn(codeLineColumn);
|
||||||
|
|
||||||
|
createContextMenuGridOutput();
|
||||||
|
|
||||||
|
// DND
|
||||||
|
GridDragSource<CodeData> sourceCode = new GridDragSource<CodeData>(
|
||||||
|
gridCode);
|
||||||
|
sourceCode.setGroup(SET_INPUT);
|
||||||
|
|
||||||
|
GridDropTarget<CodeData> targetInput = new GridDropTarget<CodeData>(
|
||||||
|
gridInput);
|
||||||
|
targetInput.setGroup(SET_INPUT);
|
||||||
|
targetInput.setOperation(Operation.COPY);
|
||||||
|
|
||||||
|
GridDropTarget<CodeData> targetOutput = new GridDropTarget<CodeData>(
|
||||||
|
gridOutput);
|
||||||
|
targetOutput.setGroup(SET_INPUT);
|
||||||
|
targetOutput.setOperation(Operation.COPY);
|
||||||
|
|
||||||
|
// Label
|
||||||
|
FieldLabel gridCodeLabel = new FieldLabel(gridCode, "Code");
|
||||||
|
gridCodeLabel.setLabelWidth(50);
|
||||||
|
FieldLabel gridInputLabel = new FieldLabel(gridInput, "Input");
|
||||||
|
gridInputLabel.setLabelWidth(50);
|
||||||
|
FieldLabel gridOutputLabel = new FieldLabel(gridOutput, "Output");
|
||||||
|
gridOutputLabel.setLabelWidth(50);
|
||||||
|
|
||||||
|
//
|
||||||
|
VerticalLayoutContainer con = new VerticalLayoutContainer();
|
||||||
|
// con.setAdjustForScroll(false);
|
||||||
|
// con.setScrollMode(ScrollMode.AUTO);
|
||||||
|
|
||||||
|
con.add(gridCodeLabel, new VerticalLayoutData(1, 1, new Margins(0)));
|
||||||
|
con.add(gridInputLabel, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||||
|
con.add(gridOutputLabel, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||||
|
|
||||||
|
add(con, new MarginData(new Margins(0)));
|
||||||
|
// add(gridCode, new MarginData(new Margins(0)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createContextMenuGridCode() {
|
||||||
|
Menu contextMenuGridCode = new Menu();
|
||||||
|
MenuItem inputItem = new MenuItem("Input");
|
||||||
|
inputItem.setId("InputStatement");
|
||||||
|
inputItem.setIcon(StatAlgoImporterResources.INSTANCE.input16());
|
||||||
|
inputItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelection(SelectionEvent<Item> event) {
|
||||||
|
if (gridCode != null) {
|
||||||
|
CodeData codeData = getGridCodeSelectedItem();
|
||||||
|
if (storeInput.findModel(codeData) == null) {
|
||||||
|
storeInput.add(new CodeData(codeData.getId(), codeData
|
||||||
|
.getCodeLine()));
|
||||||
|
storeInput.commitChanges();
|
||||||
|
}
|
||||||
|
// UtilsGXT3.info("Input", "Row " + codeData.getId()
|
||||||
|
// + " is set as input statement!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
contextMenuGridCode.add(inputItem);
|
||||||
|
|
||||||
|
MenuItem outputItem = new MenuItem("Output");
|
||||||
|
outputItem.setId("OutputStatement");
|
||||||
|
outputItem.setIcon(StatAlgoImporterResources.INSTANCE.output16());
|
||||||
|
outputItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelection(SelectionEvent<Item> event) {
|
||||||
|
if (gridCode != null) {
|
||||||
|
CodeData codeData = getGridCodeSelectedItem();
|
||||||
|
if (storeOutput.findModel(codeData) == null) {
|
||||||
|
storeOutput.add(new CodeData(codeData.getId(), codeData
|
||||||
|
.getCodeLine()));
|
||||||
|
storeOutput.commitChanges();
|
||||||
|
}
|
||||||
|
// UtilsGXT3.info("Output", "Row " + codeData.getId()
|
||||||
|
// + " is set as otuput statement!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
contextMenuGridCode.add(outputItem);
|
||||||
|
|
||||||
|
gridCode.setContextMenu(contextMenuGridCode);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createContextMenuGridInput() {
|
||||||
|
Menu contextMenuGridInput = new Menu();
|
||||||
|
MenuItem deleteItem = new MenuItem("Delete");
|
||||||
|
deleteItem.setId("Delete");
|
||||||
|
deleteItem.setIcon(StatAlgoImporterResources.INSTANCE.input16());
|
||||||
|
deleteItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelection(SelectionEvent<Item> event) {
|
||||||
|
if (gridInput != null) {
|
||||||
|
CodeData codeData = getGridInputSelectedItem();
|
||||||
|
storeInput.remove(codeData);
|
||||||
|
storeInput.commitChanges();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
contextMenuGridInput.add(deleteItem);
|
||||||
|
|
||||||
|
gridInput.setContextMenu(contextMenuGridInput);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createContextMenuGridOutput() {
|
||||||
|
Menu contextMenuGridOutput = new Menu();
|
||||||
|
MenuItem deleteItem = new MenuItem("Delete");
|
||||||
|
deleteItem.setId("Delete");
|
||||||
|
deleteItem.setIcon(StatAlgoImporterResources.INSTANCE.input16());
|
||||||
|
deleteItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelection(SelectionEvent<Item> event) {
|
||||||
|
if (gridOutput != null) {
|
||||||
|
CodeData codeData = getGridOutputSelectedItem();
|
||||||
|
storeOutput.remove(codeData);
|
||||||
|
storeOutput.commitChanges();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
contextMenuGridOutput.add(deleteItem);
|
||||||
|
|
||||||
|
gridOutput.setContextMenu(contextMenuGridOutput);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadData() {
|
||||||
|
StatAlgoImporterServiceAsync.INSTANCE
|
||||||
|
.getCode(new AsyncCallback<ArrayList<CodeData>>() {
|
||||||
|
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
||||||
|
eventBus.fireEvent(new SessionExpiredEvent(
|
||||||
|
SessionExpiredType.EXPIREDONSERVER));
|
||||||
|
} else {
|
||||||
|
Log.error("Error retrieving code: "
|
||||||
|
+ caught.getLocalizedMessage());
|
||||||
|
UtilsGXT3.alert("Error",
|
||||||
|
caught.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
caught.printStackTrace();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSuccess(ArrayList<CodeData> result) {
|
||||||
|
Log.debug("loaded " + result.size() + " code lines");
|
||||||
|
ArrayList<CodeData> availables = new ArrayList<CodeData>();
|
||||||
|
for (CodeData codeData : result) {
|
||||||
|
Log.debug("Read: " + codeData);
|
||||||
|
availables.add(codeData);
|
||||||
|
}
|
||||||
|
storeCode.clear();
|
||||||
|
storeCode.addAll(availables);
|
||||||
|
storeCode.commitChanges();
|
||||||
|
|
||||||
|
forceLayout();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* private boolean select(CodeData item, String searchTerm) { if
|
||||||
|
* (item.getCodeLine() != null && item.getCodeLine().toLowerCase()
|
||||||
|
* .contains(searchTerm.toLowerCase())) return true; return false; }
|
||||||
|
*/
|
||||||
|
|
||||||
|
public HandlerRegistration addSelectionHandler(
|
||||||
|
SelectionHandler<CodeData> handler) {
|
||||||
|
return gridCode.getSelectionModel().addSelectionHandler(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CodeData getGridCodeSelectedItem() {
|
||||||
|
return gridCode.getSelectionModel().getSelectedItem();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public CodeData getGridInputSelectedItem() {
|
||||||
|
return gridInput.getSelectionModel().getSelectedItem();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public CodeData getGridOutputSelectedItem() {
|
||||||
|
return gridOutput.getSelectionModel().getSelectedItem();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void gridReload() {
|
||||||
|
storeCode.clear();
|
||||||
|
storeCode.commitChanges();
|
||||||
|
storeInput.clear();
|
||||||
|
storeInput.commitChanges();
|
||||||
|
storeOutput.clear();
|
||||||
|
storeOutput.commitChanges();
|
||||||
|
gridCode.getSelectionModel().deselectAll();
|
||||||
|
gridInput.getSelectionModel().deselectAll();
|
||||||
|
gridOutput.getSelectionModel().deselectAll();
|
||||||
|
|
||||||
|
loadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.maindata;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ShowCodeEvent;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.event.shared.EventBus;
|
||||||
|
import com.sencha.gxt.core.client.util.Margins;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.MarginData;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo email: <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class MainDataPanel extends SimpleContainer {
|
||||||
|
|
||||||
|
private EventBus eventBus;
|
||||||
|
private CodeViewerPanel codeViewPanel;
|
||||||
|
|
||||||
|
public MainDataPanel(EventBus eventBus) {
|
||||||
|
super();
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
init();
|
||||||
|
create();
|
||||||
|
bindToEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void init() {
|
||||||
|
forceLayoutOnResize = true;
|
||||||
|
//setBodyBorder(false);
|
||||||
|
setBorders(false);
|
||||||
|
//setHeaderVisible(false);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void create() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bindToEvents() {
|
||||||
|
eventBus.addHandler(ShowCodeEvent.TYPE,
|
||||||
|
new ShowCodeEvent.ShowCodeEventHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onShowCode(ShowCodeEvent event) {
|
||||||
|
Log.debug("Catch ShowCodeEvent");
|
||||||
|
doShowCodeCommand(event);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doShowCodeCommand(ShowCodeEvent event) {
|
||||||
|
if (codeViewPanel == null) {
|
||||||
|
addCodeViewPanel();
|
||||||
|
} else {
|
||||||
|
codeViewPanel.gridReload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addCodeViewPanel() {
|
||||||
|
codeViewPanel = new CodeViewerPanel(eventBus);
|
||||||
|
add(codeViewPanel, new MarginData(new Margins(0)));
|
||||||
|
forceLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.monitor;
|
||||||
|
|
||||||
|
import com.google.gwt.safehtml.shared.SafeHtml;
|
||||||
|
import com.sencha.gxt.widget.core.client.box.AutoProgressMessageBox;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo email: <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class StatAlgoImporterMonitor extends AutoProgressMessageBox {
|
||||||
|
|
||||||
|
public StatAlgoImporterMonitor(){
|
||||||
|
super("Waiting", "Please wait...");
|
||||||
|
create();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public StatAlgoImporterMonitor(SafeHtml headingHtml, SafeHtml messageHtml) {
|
||||||
|
super(headingHtml, messageHtml);
|
||||||
|
create();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public StatAlgoImporterMonitor(SafeHtml headingHtml) {
|
||||||
|
super(headingHtml);
|
||||||
|
create();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public StatAlgoImporterMonitor(String headingHtml, String messageHtml) {
|
||||||
|
super(headingHtml, messageHtml);
|
||||||
|
create();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public StatAlgoImporterMonitor(String headingHtml) {
|
||||||
|
super(headingHtml);
|
||||||
|
create();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void create() {
|
||||||
|
setProgressText("Updating...");
|
||||||
|
auto();
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.code.CodeData;
|
||||||
|
|
||||||
|
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 CodeDataProperties extends PropertyAccess<CodeData> {
|
||||||
|
|
||||||
|
@Path("id")
|
||||||
|
ModelKeyProvider<CodeData> code();
|
||||||
|
|
||||||
|
ValueProvider<CodeData, Integer> id();
|
||||||
|
ValueProvider<CodeData, String> codeLine();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
@CHARSET "UTF-8";
|
||||||
|
|
||||||
|
|
||||||
|
.ribbon {
|
||||||
|
line-height: 13px;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource;
|
||||||
|
|
||||||
|
import com.google.gwt.resources.client.CssResource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface StatAlgoImporterCSS extends CssResource {
|
||||||
|
|
||||||
|
@ClassName("ribbon")
|
||||||
|
public String getRibbon();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource;
|
||||||
|
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.resources.client.ClientBundle;
|
||||||
|
import com.google.gwt.resources.client.ImageResource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface StatAlgoImporterResources extends ClientBundle {
|
||||||
|
|
||||||
|
public static final StatAlgoImporterResources INSTANCE = GWT
|
||||||
|
.create(StatAlgoImporterResources.class);
|
||||||
|
|
||||||
|
@Source("StatAlgoImporter.css")
|
||||||
|
StatAlgoImporterCSS srCSS();
|
||||||
|
|
||||||
|
@Source("help_32.png")
|
||||||
|
ImageResource help32();
|
||||||
|
|
||||||
|
@Source("download_32.png")
|
||||||
|
ImageResource download32();
|
||||||
|
|
||||||
|
@Source("upload_32.png")
|
||||||
|
ImageResource upload32();
|
||||||
|
|
||||||
|
@Source("job_32.png")
|
||||||
|
ImageResource job32();
|
||||||
|
|
||||||
|
@Source("reload_32.png")
|
||||||
|
ImageResource reload32();
|
||||||
|
|
||||||
|
@Source("reload_24.png")
|
||||||
|
ImageResource reload24();
|
||||||
|
|
||||||
|
@Source("input_16.png")
|
||||||
|
ImageResource input16();
|
||||||
|
|
||||||
|
@Source("output_16.png")
|
||||||
|
ImageResource output16();
|
||||||
|
|
||||||
|
@Source("cancel_32.png")
|
||||||
|
ImageResource cancel32();
|
||||||
|
|
||||||
|
@Source("algorithm_32.png")
|
||||||
|
ImageResource algorithm32();
|
||||||
|
|
||||||
|
}
|
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 615 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.3 KiB |
|
@ -0,0 +1,38 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.ribbon;
|
||||||
|
|
||||||
|
import com.sencha.gxt.widget.core.client.ContentPanel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo
|
||||||
|
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class EmptyPanel extends ContentPanel {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
public EmptyPanel(String id){
|
||||||
|
this.id=id;
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init(){
|
||||||
|
setId(id);
|
||||||
|
setWidth(0);
|
||||||
|
setHeight(0);
|
||||||
|
setBodyBorder(false);
|
||||||
|
setBorders(false);
|
||||||
|
setHeaderVisible(false);
|
||||||
|
setVisible(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,282 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.ribbon;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.StatAlgoImporterRibbonEvent;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.UIStateEvent;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource.StatAlgoImporterResources;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.StatAlgoImporterRibbonType;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.UIStateType;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.dom.client.Element;
|
||||||
|
import com.google.gwt.dom.client.NodeList;
|
||||||
|
import com.google.gwt.user.client.ui.FlexTable;
|
||||||
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
|
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonArrowAlign;
|
||||||
|
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonScale;
|
||||||
|
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
||||||
|
import com.sencha.gxt.core.client.dom.XElement;
|
||||||
|
import com.sencha.gxt.widget.core.client.button.ButtonGroup;
|
||||||
|
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||||
|
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.toolbar.ToolBar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class HomeToolBar {
|
||||||
|
private static final String GROUP_HEIGHT = "80px";
|
||||||
|
private HomeToolBarMessages msgs;
|
||||||
|
private EventBus eventBus;
|
||||||
|
private ToolBar toolBar;
|
||||||
|
|
||||||
|
//Home
|
||||||
|
private TextButton importButton;
|
||||||
|
|
||||||
|
//Algorithm
|
||||||
|
private TextButton createAlgorithmButton;
|
||||||
|
|
||||||
|
|
||||||
|
// Help
|
||||||
|
private TextButton helpButton;
|
||||||
|
|
||||||
|
|
||||||
|
// private TextButton languageButton;
|
||||||
|
// private TextButton logsButton;
|
||||||
|
// private TextButton testButton;
|
||||||
|
|
||||||
|
// Language Menu
|
||||||
|
/*
|
||||||
|
* private MenuItem enItem; private MenuItem itItem; private MenuItem
|
||||||
|
* esItem;
|
||||||
|
*/
|
||||||
|
|
||||||
|
public HomeToolBar(EventBus eventBus) {
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
msgs = GWT.create(HomeToolBarMessages.class);
|
||||||
|
build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ToolBar getToolBar() {
|
||||||
|
return toolBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void build() {
|
||||||
|
toolBar = new ToolBar();
|
||||||
|
toolBar.setSpacing(5);
|
||||||
|
toolBar.setEnableOverflow(false);
|
||||||
|
|
||||||
|
// Home
|
||||||
|
ButtonGroup homeGroup = new ButtonGroup();
|
||||||
|
homeGroup.setId("Home");
|
||||||
|
homeGroup.setHeadingText(msgs.fileGroupHeadingText());
|
||||||
|
homeGroup.setHeight(GROUP_HEIGHT);
|
||||||
|
toolBar.add(homeGroup);
|
||||||
|
|
||||||
|
FlexTable homeLayout = new FlexTable();
|
||||||
|
homeGroup.add(homeLayout);
|
||||||
|
|
||||||
|
importButton = new TextButton(msgs.importButton(),
|
||||||
|
StatAlgoImporterResources.INSTANCE.upload32());
|
||||||
|
importButton.setId("importButton");
|
||||||
|
importButton.setScale(ButtonScale.MEDIUM);
|
||||||
|
importButton.setIconAlign(IconAlign.LEFT);
|
||||||
|
importButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||||
|
importButton.setToolTip(msgs.importButtonToolTip());
|
||||||
|
|
||||||
|
importButton.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
eventBus.fireEvent(new StatAlgoImporterRibbonEvent(
|
||||||
|
StatAlgoImporterRibbonType.UPLOAD_CODE));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
homeLayout.setWidget(0, 0, importButton);
|
||||||
|
homeLayout.getFlexCellFormatter().setRowSpan(0, 0, 2);
|
||||||
|
|
||||||
|
// Algorithm
|
||||||
|
ButtonGroup algorithmGroup = new ButtonGroup();
|
||||||
|
algorithmGroup.setId("Algorithm");
|
||||||
|
algorithmGroup.setHeadingText(msgs.algorithmGroupHeadingText());
|
||||||
|
algorithmGroup.setHeight(GROUP_HEIGHT);
|
||||||
|
toolBar.add(algorithmGroup);
|
||||||
|
|
||||||
|
FlexTable algorithmLayout = new FlexTable();
|
||||||
|
algorithmGroup.add(algorithmLayout);
|
||||||
|
|
||||||
|
createAlgorithmButton = new TextButton(msgs.createAlgorithmButton(),
|
||||||
|
StatAlgoImporterResources.INSTANCE.algorithm32());
|
||||||
|
createAlgorithmButton.setId("createAlgorithmButton");
|
||||||
|
createAlgorithmButton.setScale(ButtonScale.MEDIUM);
|
||||||
|
createAlgorithmButton.setIconAlign(IconAlign.LEFT);
|
||||||
|
createAlgorithmButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||||
|
createAlgorithmButton.setToolTip(msgs.createAlgorithmButtonToolTip());
|
||||||
|
|
||||||
|
createAlgorithmButton.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
eventBus.fireEvent(new StatAlgoImporterRibbonEvent(
|
||||||
|
StatAlgoImporterRibbonType.CREATE_ALGORITHM));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
algorithmLayout.setWidget(0, 0, createAlgorithmButton);
|
||||||
|
algorithmLayout.getFlexCellFormatter().setRowSpan(0, 0, 2);
|
||||||
|
|
||||||
|
// Help
|
||||||
|
ButtonGroup helpGroup = new ButtonGroup();
|
||||||
|
helpGroup.setId("Help");
|
||||||
|
helpGroup.setHeight(GROUP_HEIGHT);
|
||||||
|
helpGroup.setHeadingText(msgs.helpGroupHeadingText());
|
||||||
|
toolBar.add(helpGroup);
|
||||||
|
|
||||||
|
FlexTable helpLayout = new FlexTable();
|
||||||
|
helpGroup.add(helpLayout);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* languageButton = new TextButton(msgs.languageButton(),
|
||||||
|
* TabularDataResources.INSTANCE.language32()); languageButton.enable();
|
||||||
|
* languageButton.setScale(ButtonScale.LARGE);
|
||||||
|
* languageButton.setIconAlign(IconAlign.TOP);
|
||||||
|
* languageButton.setToolTip(msgs.languageButtonToolTip());
|
||||||
|
* languageButton.setArrowAlign(ButtonArrowAlign.RIGHT);
|
||||||
|
* languageButton.setMenu(createLanguageMenu());
|
||||||
|
*
|
||||||
|
* helpLayout.setWidget(0, 0, languageButton);
|
||||||
|
* helpLayout.getFlexCellFormatter().setRowSpan(0, 0, 2);
|
||||||
|
*/
|
||||||
|
|
||||||
|
helpButton = new TextButton(msgs.helpButton(),
|
||||||
|
StatAlgoImporterResources.INSTANCE.help32());
|
||||||
|
helpButton.enable();
|
||||||
|
helpButton.setToolTip(msgs.helpButtonToolTip());
|
||||||
|
helpButton.setScale(ButtonScale.MEDIUM);
|
||||||
|
helpButton.setIconAlign(IconAlign.LEFT);
|
||||||
|
helpButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||||
|
helpButton.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
eventBus.fireEvent(new StatAlgoImporterRibbonEvent(
|
||||||
|
StatAlgoImporterRibbonType.HELP));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
helpLayout.setWidget(0, 1, helpButton);
|
||||||
|
helpLayout.getFlexCellFormatter().setRowSpan(0, 1, 2);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* logsButton = new TextButton("Logs",
|
||||||
|
* TabularDataResources.INSTANCE.logs32()); logsButton.enable();
|
||||||
|
* logsButton.setToolTip("Show Logs");
|
||||||
|
* logsButton.setScale(ButtonScale.LARGE);
|
||||||
|
* logsButton.setIconAlign(IconAlign.TOP);
|
||||||
|
* logsButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||||
|
* logsButton.addSelectHandler(new SelectHandler() {
|
||||||
|
*
|
||||||
|
* public void onSelect(SelectEvent event) { eventBus.fireEvent(new
|
||||||
|
* RibbonEvent(RibbonType.LOGS)); } });
|
||||||
|
*
|
||||||
|
* helpLayout.setWidget(0, 1, logsButton);
|
||||||
|
* helpLayout.getFlexCellFormatter().setRowSpan(0, 1, 2);
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* testButton = new TextButton("Test",
|
||||||
|
* TabularDataResources.INSTANCE.test32()); testButton.disable();
|
||||||
|
* testButton.setToolTip("Test");
|
||||||
|
* testButton.setScale(ButtonScale.LARGE);
|
||||||
|
* testButton.setIconAlign(IconAlign.TOP);
|
||||||
|
* testButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||||
|
* testButton.addSelectHandler(new SelectHandler() {
|
||||||
|
*
|
||||||
|
* public void onSelect(SelectEvent event) { eventBus.fireEvent(new
|
||||||
|
* RibbonEvent(RibbonType.TEST)); } });
|
||||||
|
*
|
||||||
|
* helpLayout.setWidget(0, 2, testButton);
|
||||||
|
* helpLayout.getFlexCellFormatter().setRowSpan(0, 2, 2);
|
||||||
|
*/
|
||||||
|
|
||||||
|
cleanCells(helpLayout.getElement());
|
||||||
|
|
||||||
|
eventBus.addHandler(UIStateEvent.TYPE,
|
||||||
|
new UIStateEvent.UIStateHandler() {
|
||||||
|
|
||||||
|
public void onUIState(UIStateEvent event) {
|
||||||
|
setUI(event);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cleanCells(Element elem) {
|
||||||
|
NodeList<Element> tds = elem.<XElement> cast().select("td");
|
||||||
|
for (int i = 0; i < tds.getLength(); i++) {
|
||||||
|
Element td = tds.getItem(i);
|
||||||
|
|
||||||
|
if (!td.hasChildNodes() && td.getClassName().equals("")) {
|
||||||
|
td.removeFromParent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* private Menu createLanguageMenu() { Menu menuReplace = new Menu(); enItem
|
||||||
|
* = new MenuItem(msgs.english(), TabularDataResources.INSTANCE.flagGB());
|
||||||
|
* itItem = new MenuItem(msgs.italian(),
|
||||||
|
* TabularDataResources.INSTANCE.flagIT()); esItem = new
|
||||||
|
* MenuItem(msgs.spanish(), TabularDataResources.INSTANCE.flagES());
|
||||||
|
*
|
||||||
|
* enItem .addSelectionHandler(new SelectionHandler<Item>() {
|
||||||
|
*
|
||||||
|
* @Override public void onSelection(SelectionEvent<Item> event) {
|
||||||
|
* eventBus.fireEvent(new RibbonEvent( RibbonType.LANGUAGE_EN));
|
||||||
|
*
|
||||||
|
* } });
|
||||||
|
*
|
||||||
|
* itItem .addSelectionHandler(new SelectionHandler<Item>() {
|
||||||
|
*
|
||||||
|
* @Override public void onSelection(SelectionEvent<Item> event) {
|
||||||
|
* eventBus.fireEvent(new RibbonEvent( RibbonType.LANGUAGE_IT));
|
||||||
|
*
|
||||||
|
* } });
|
||||||
|
*
|
||||||
|
* esItem .addSelectionHandler(new SelectionHandler<Item>() {
|
||||||
|
*
|
||||||
|
* @Override public void onSelection(SelectionEvent<Item> event) {
|
||||||
|
* eventBus.fireEvent(new RibbonEvent( RibbonType.LANGUAGE_ES));
|
||||||
|
*
|
||||||
|
* } });
|
||||||
|
*
|
||||||
|
* menuReplace.add(enItem); menuReplace.add(esItem);
|
||||||
|
* menuReplace.add(itItem); return menuReplace; }
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void setUI(UIStateEvent event) {
|
||||||
|
UIStateType uiStateType = event.getUiStateType();
|
||||||
|
try {
|
||||||
|
switch (uiStateType) {
|
||||||
|
case START:
|
||||||
|
importButton.enable();
|
||||||
|
createAlgorithmButton.enable();
|
||||||
|
helpButton.enable();
|
||||||
|
|
||||||
|
// testButton.disable();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("setUI Error : " + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.ribbon;
|
||||||
|
|
||||||
|
import com.google.gwt.i18n.client.Messages;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo
|
||||||
|
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface HomeToolBarMessages extends Messages {
|
||||||
|
|
||||||
|
//
|
||||||
|
@DefaultMessage("Code")
|
||||||
|
String fileGroupHeadingText();
|
||||||
|
|
||||||
|
@DefaultMessage("Import")
|
||||||
|
String importButton();
|
||||||
|
|
||||||
|
@DefaultMessage("Import Code")
|
||||||
|
String importButtonToolTip();
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
@DefaultMessage("Help")
|
||||||
|
String helpGroupHeadingText();
|
||||||
|
|
||||||
|
@DefaultMessage("Help")
|
||||||
|
String helpButton();
|
||||||
|
|
||||||
|
@DefaultMessage("Help")
|
||||||
|
String helpButtonToolTip();
|
||||||
|
|
||||||
|
//
|
||||||
|
@DefaultMessage("Algorithm")
|
||||||
|
String algorithmGroupHeadingText();
|
||||||
|
|
||||||
|
@DefaultMessage("Create")
|
||||||
|
String createAlgorithmButton();
|
||||||
|
|
||||||
|
@DefaultMessage("Create Algorithm")
|
||||||
|
String createAlgorithmButtonToolTip();
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
@DefaultMessage("Language")
|
||||||
|
String languageButton();
|
||||||
|
|
||||||
|
@DefaultMessage("Language")
|
||||||
|
String languageButtonToolTip();
|
||||||
|
|
||||||
|
//
|
||||||
|
@DefaultMessage("English")
|
||||||
|
String english();
|
||||||
|
|
||||||
|
@DefaultMessage("Italian")
|
||||||
|
String italian();
|
||||||
|
|
||||||
|
@DefaultMessage("Spanish")
|
||||||
|
String spanish();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.ribbon;
|
||||||
|
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.event.shared.EventBus;
|
||||||
|
import com.sencha.gxt.widget.core.client.TabPanel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo
|
||||||
|
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class StatAlgoImporterMenu extends TabPanel {
|
||||||
|
//private AccountingManagerMenuMessages msgs;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private EventBus eventBus;
|
||||||
|
|
||||||
|
|
||||||
|
public StatAlgoImporterMenu(EventBus eventBus) {
|
||||||
|
//super(GWT.<TabPanelAppearance>create(Css3BigTabPanelAppearance.class));
|
||||||
|
Log.debug("Create StatisticalRunnerMenu");
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
//this.msgs = GWT.create(AccountingManagerMenuMessages.class);
|
||||||
|
setBodyBorder(false);
|
||||||
|
setBorders(false);
|
||||||
|
setAnimScroll(false);
|
||||||
|
setTabScroll(false);
|
||||||
|
setCloseContextMenu(true);
|
||||||
|
addTabs();
|
||||||
|
setHeight(60);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addTabs() {
|
||||||
|
// TabItemConfig storageItemConf = new TabItemConfig("Storage", false);
|
||||||
|
// storageItemConf.setIcon(AccountingManagerResources.INSTANCE.accountingStorage48());
|
||||||
|
// EmptyPanel storageCategory=new EmptyPanel(AccountingType.STORAGE.name());
|
||||||
|
// add(storageCategory, storageItemConf);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// setActiveWidget(getWidget(0));
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// addSelectionHandler(new SelectionHandler<Widget>() {
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onSelection(SelectionEvent<Widget> event) {
|
||||||
|
// Widget widget = event.getSelectedItem();
|
||||||
|
// if (widget instanceof EmptyPanel) {
|
||||||
|
// EmptyPanel p=(EmptyPanel) widget;
|
||||||
|
// AccountingMenuEvent accountMenuEvent=new AccountingMenuEvent(AccountingType.valueOf(p.getId()));
|
||||||
|
// eventBus.fireEvent(accountMenuEvent);
|
||||||
|
// } else {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.ribbon;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
|
import com.sencha.gxt.widget.core.client.TabPanel;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class StatAlgoImporterRibbon {
|
||||||
|
|
||||||
|
private static final String RIBBON_HEIGHT = "90px";
|
||||||
|
|
||||||
|
private TabPanel ribbon;
|
||||||
|
|
||||||
|
|
||||||
|
private HomeToolBar homeToolBar;
|
||||||
|
|
||||||
|
public StatAlgoImporterRibbon(EventBus eventBus) {
|
||||||
|
try {
|
||||||
|
StatAlgoImporterRibbonMessages msgs = GWT.create(StatAlgoImporterRibbonMessages.class);
|
||||||
|
|
||||||
|
ribbon = new TabPanel();
|
||||||
|
ribbon.setId("Ribbon");
|
||||||
|
ribbon.setHeight(RIBBON_HEIGHT);
|
||||||
|
|
||||||
|
VerticalLayoutData vldata=new VerticalLayoutData(1, -1);
|
||||||
|
|
||||||
|
homeToolBar = new HomeToolBar(eventBus);
|
||||||
|
VerticalLayoutContainer con = new VerticalLayoutContainer();
|
||||||
|
con.add(homeToolBar.getToolBar(), vldata);
|
||||||
|
ribbon.add(con, msgs.home());
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Log.error("Ribbon error:" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the container
|
||||||
|
*/
|
||||||
|
public TabPanel getContainer() {
|
||||||
|
return ribbon;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.ribbon;
|
||||||
|
|
||||||
|
import com.google.gwt.i18n.client.Messages;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo
|
||||||
|
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface StatAlgoImporterRibbonMessages extends Messages {
|
||||||
|
|
||||||
|
@DefaultMessage("Home")
|
||||||
|
String home();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.code.CodeData;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadMonitor;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session.UserInfo;
|
||||||
|
|
||||||
|
import com.google.gwt.user.client.rpc.RemoteService;
|
||||||
|
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@RemoteServiceRelativePath("statalgoimporterservice")
|
||||||
|
public interface StatAlgoImporterService extends RemoteService {
|
||||||
|
/**
|
||||||
|
* Get informations on the current user
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @throws StatAlgoImporterServiceException
|
||||||
|
*/
|
||||||
|
public UserInfo hello() throws StatAlgoImporterServiceException;
|
||||||
|
|
||||||
|
// File Upload Monitor
|
||||||
|
/**
|
||||||
|
* Get File Upload Monitor during the file upload operation in Import CSV
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @throws StatAlgoImporterServiceException
|
||||||
|
*/
|
||||||
|
public FileUploadMonitor getFileUploadMonitor()
|
||||||
|
throws StatAlgoImporterServiceException;
|
||||||
|
|
||||||
|
// Code
|
||||||
|
public ArrayList<CodeData> getCode() throws StatAlgoImporterServiceException;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.code.CodeData;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadMonitor;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session.UserInfo;
|
||||||
|
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface StatAlgoImporterServiceAsync {
|
||||||
|
|
||||||
|
public static StatAlgoImporterServiceAsync INSTANCE = (StatAlgoImporterServiceAsync) GWT
|
||||||
|
.create(StatAlgoImporterService.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param callback
|
||||||
|
*/
|
||||||
|
void hello(AsyncCallback<UserInfo> callback);
|
||||||
|
|
||||||
|
void getFileUploadMonitor(AsyncCallback<FileUploadMonitor> callback);
|
||||||
|
|
||||||
|
void getCode(AsyncCallback<ArrayList<CodeData>> callback);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public enum ImportCodeType {
|
||||||
|
FILE,
|
||||||
|
WORKSPACE;
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public enum SessionExpiredType {
|
||||||
|
EXPIRED,
|
||||||
|
EXPIREDONSERVER;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public enum StatAlgoImporterRibbonType {
|
||||||
|
UPLOAD_CODE,
|
||||||
|
CREATE_ALGORITHM,
|
||||||
|
HELP;
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public enum UIStateType {
|
||||||
|
START,
|
||||||
|
WAITING;
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.upload;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.EventBus;
|
||||||
|
import com.sencha.gxt.widget.core.client.Window;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dialog for Code Upload
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CodeUploadDialog extends Window {
|
||||||
|
private static final String WIDTH = "650px";
|
||||||
|
private static final String HEIGHT = "200px";
|
||||||
|
|
||||||
|
public CodeUploadDialog(EventBus eventBus) {
|
||||||
|
initWindow();
|
||||||
|
CodeUploadPanel changeColumnTypePanel = new CodeUploadPanel(this, eventBus);
|
||||||
|
add(changeColumnTypePanel);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initWindow() {
|
||||||
|
setModal(true);
|
||||||
|
setWidth(WIDTH);
|
||||||
|
setHeight(HEIGHT);
|
||||||
|
setBodyBorder(false);
|
||||||
|
setResizable(false);
|
||||||
|
setHeadingText("Import");
|
||||||
|
//getHeader().setIcon(StatisticalRunnerResources.INSTANCE.upload16());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void initTools() {
|
||||||
|
super.initTools();
|
||||||
|
|
||||||
|
closeBtn.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
hide();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,240 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.upload;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ImportCodeEvent;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource.StatAlgoImporterResources;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.ImportCodeType;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.upload.progress.FileUploadProgressBarUpdater;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.upload.progress.FileUploadProgressListener;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.upload.progress.FileUploadProgressUpdater;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.utils.UtilsGXT3;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||||
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||||
|
import com.google.gwt.event.shared.EventBus;
|
||||||
|
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
||||||
|
import com.sencha.gxt.core.client.util.Margins;
|
||||||
|
import com.sencha.gxt.widget.core.client.ProgressBar;
|
||||||
|
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
||||||
|
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.event.SelectEvent;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||||
|
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.FileUploadField;
|
||||||
|
import com.sencha.gxt.widget.core.client.form.FormPanel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo email: <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CodeUploadPanel extends FormPanel {
|
||||||
|
|
||||||
|
private static final String UPLOAD_SERVLET = "LocalUploadServlet";
|
||||||
|
|
||||||
|
private static final int STATUS_POLLING_DELAY = 1000;
|
||||||
|
|
||||||
|
private EventBus eventBus;
|
||||||
|
private CodeUploadDialog parent;
|
||||||
|
private FileUploadField fileUploadField;
|
||||||
|
|
||||||
|
private TextButton uploadCodeBtn;
|
||||||
|
private TextButton cancelBtn;
|
||||||
|
|
||||||
|
//private FileUploadProgressUpdater progressUpdater;
|
||||||
|
|
||||||
|
private ProgressBar uploadProgressBar;
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
private FileUploadProgressUpdater progressUpdater;
|
||||||
|
|
||||||
|
public CodeUploadPanel(CodeUploadDialog parent, EventBus eventBus) {
|
||||||
|
super();
|
||||||
|
this.parent = parent;
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
init();
|
||||||
|
create();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void init() {
|
||||||
|
forceLayoutOnResize = true;
|
||||||
|
setBorders(false);
|
||||||
|
setResize(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void create() {
|
||||||
|
setId("CodeUploadPanel");
|
||||||
|
setAction(GWT.getModuleBaseURL() + UPLOAD_SERVLET);
|
||||||
|
setWidth("100%");
|
||||||
|
|
||||||
|
setEncoding(Encoding.MULTIPART);
|
||||||
|
setMethod(Method.POST);
|
||||||
|
|
||||||
|
uploadCodeBtn = new TextButton("Upload");
|
||||||
|
uploadCodeBtn.setIcon(StatAlgoImporterResources.INSTANCE.upload32());
|
||||||
|
uploadCodeBtn.setIconAlign(IconAlign.RIGHT);
|
||||||
|
uploadCodeBtn.setToolTip("Upload Code");
|
||||||
|
|
||||||
|
uploadCodeBtn.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
Log.info("request upload");
|
||||||
|
|
||||||
|
if (fileUploadField.getValue() == null
|
||||||
|
|| fileUploadField.getValue().equals("")) {
|
||||||
|
Log.info("fileUploadField is null or empty");
|
||||||
|
UtilsGXT3.alert("Code file missing",
|
||||||
|
"Please specify a Code file.");
|
||||||
|
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
Log.info("startUpload call");
|
||||||
|
startUpload();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
cancelBtn = new TextButton("Cancel");
|
||||||
|
cancelBtn.setIcon(StatAlgoImporterResources.INSTANCE.cancel32());
|
||||||
|
cancelBtn.setIconAlign(IconAlign.RIGHT);
|
||||||
|
cancelBtn.setEnabled(false);
|
||||||
|
|
||||||
|
fileUploadField = new FileUploadField();
|
||||||
|
fileUploadField.setName(Constants.FILE_UPLOADED_FIELD);
|
||||||
|
|
||||||
|
fileUploadField.addChangeHandler(new ChangeHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChange(ChangeEvent event) {
|
||||||
|
Log.debug("File Changed", "Selected " + fileUploadField.getValue());
|
||||||
|
String path = fileUploadField.getValue();
|
||||||
|
int punto = path.lastIndexOf(".");
|
||||||
|
if (punto < 0) {
|
||||||
|
punto = path.length();
|
||||||
|
}
|
||||||
|
int slash = path.lastIndexOf("/");
|
||||||
|
int backslash = path.lastIndexOf("\\");
|
||||||
|
String fname = "";
|
||||||
|
if (slash > backslash) {
|
||||||
|
if (slash != -1) {
|
||||||
|
fname = path.substring(slash + 1, punto);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (backslash != -1) {
|
||||||
|
fname = path.substring(backslash + 1, punto);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
fileName = fname;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
fileUploadField.setAllowBlank(false);
|
||||||
|
|
||||||
|
FieldLabel fileUploadFieldLabel = new FieldLabel(fileUploadField, "File");
|
||||||
|
|
||||||
|
|
||||||
|
uploadProgressBar = new ProgressBar();
|
||||||
|
//uploadProgressBar.setVisible(false);
|
||||||
|
//uploadProgressBar.getElement().setPadding(new Padding(3, 0, 5, 0));
|
||||||
|
|
||||||
|
|
||||||
|
progressUpdater = new FileUploadProgressUpdater();
|
||||||
|
progressUpdater.addListener(new FileUploadProgressBarUpdater(
|
||||||
|
uploadProgressBar));
|
||||||
|
|
||||||
|
progressUpdater.addListener(new FileUploadProgressListener() {
|
||||||
|
|
||||||
|
public void operationUpdate(float elaborated) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
public void operationInitializing() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void operationFailed(Throwable caught, String reason,
|
||||||
|
String failureDetails) {
|
||||||
|
UtilsGXT3.alert("Error uploading file", caught.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void operationComplete() {
|
||||||
|
ImportCodeDescription desc=new ImportCodeDescription(ImportCodeType.FILE, fileName);
|
||||||
|
ImportCodeEvent importEvent=new ImportCodeEvent(desc);
|
||||||
|
eventBus.fireEvent(importEvent);
|
||||||
|
parent.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
parent.addButton(uploadCodeBtn);
|
||||||
|
parent.addButton(cancelBtn);
|
||||||
|
parent.setButtonAlign(BoxLayoutPack.CENTER);
|
||||||
|
|
||||||
|
|
||||||
|
VerticalLayoutContainer vlc = new VerticalLayoutContainer();
|
||||||
|
vlc.add(fileUploadFieldLabel, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||||
|
vlc.add(uploadProgressBar, new VerticalLayoutData(1, -1, new Margins(5,0,0,0)));
|
||||||
|
uploadProgressBar.setVisible(false);
|
||||||
|
|
||||||
|
|
||||||
|
FieldSet fieldSet = new FieldSet();
|
||||||
|
fieldSet.setHeadingHtml("<b>Upload Code</b>");
|
||||||
|
fieldSet.setCollapsible(false);
|
||||||
|
fieldSet.add(vlc);
|
||||||
|
|
||||||
|
|
||||||
|
add(fieldSet, new MarginData(new Margins(5, 0, 0, 7)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void startUpload() {
|
||||||
|
disableUpload();
|
||||||
|
|
||||||
|
StringBuilder actionUrl = new StringBuilder();
|
||||||
|
actionUrl.append(GWT.getModuleBaseURL());
|
||||||
|
actionUrl.append(UPLOAD_SERVLET);
|
||||||
|
setAction(actionUrl.toString());
|
||||||
|
Log.info("Start Upload action Url " + actionUrl.toString());
|
||||||
|
submit();
|
||||||
|
|
||||||
|
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void disableUpload() {
|
||||||
|
fileUploadField.disable();
|
||||||
|
uploadCodeBtn.disable();
|
||||||
|
uploadProgressBar.setVisible(true);;
|
||||||
|
cancelBtn.setEnabled(true);
|
||||||
|
|
||||||
|
parent.forceLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*private void uploadCode() {
|
||||||
|
if (fileName != null && !fileName.isEmpty()) {
|
||||||
|
if (parent != null) {
|
||||||
|
parent.close();
|
||||||
|
}
|
||||||
|
ImportCodeDescription importDesc = new ImportCodeDescription(
|
||||||
|
ImportCodeType.FILE, fileName);
|
||||||
|
ImportCodeEvent importCodeEvent = new ImportCodeEvent(importDesc);
|
||||||
|
eventBus.fireEvent(importCodeEvent);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.upload;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.ImportCodeType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo email: <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ImportCodeDescription {
|
||||||
|
private ImportCodeType importCodeType;
|
||||||
|
private String file;
|
||||||
|
|
||||||
|
public ImportCodeDescription(ImportCodeType importCodeType, String file) {
|
||||||
|
super();
|
||||||
|
this.importCodeType = importCodeType;
|
||||||
|
this.file = file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImportCodeType getImportCodeType() {
|
||||||
|
return importCodeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImportCodeType(ImportCodeType importCodeType) {
|
||||||
|
this.importCodeType = importCodeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFile() {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFile(String file) {
|
||||||
|
this.file = file;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ImportCodeDescription [importCodeType=" + importCodeType
|
||||||
|
+ ", file=" + file + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.upload.progress;
|
||||||
|
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.sencha.gxt.widget.core.client.ProgressBar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a {@link ProgressBar} progress and text based on {@link CSVImportProgressListener} events.
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class FileUploadProgressBarUpdater implements FileUploadProgressListener {
|
||||||
|
|
||||||
|
protected ProgressBar progressBar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link ProgressBar} updater.
|
||||||
|
* @param progressBar the {@link ProgressBar} to update.
|
||||||
|
*/
|
||||||
|
public FileUploadProgressBarUpdater(ProgressBar progressBar) {
|
||||||
|
this.progressBar = progressBar;
|
||||||
|
this.progressBar.updateProgress(0, "Please Wait...");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public void operationComplete() {
|
||||||
|
Log.info("File upload complete");
|
||||||
|
progressBar.updateProgress(1, "File upload completed.");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public void operationFailed(Throwable caught, String reason, String failureDetails) {
|
||||||
|
Log.info("File upload failed");
|
||||||
|
progressBar.updateText("File upload failed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void operationInitializing() {
|
||||||
|
Log.info("File upload inizializing");
|
||||||
|
progressBar.updateProgress(0, "Initializing...");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void operationUpdate(float elaborated) {
|
||||||
|
Log.info("File upload elaborated: "+elaborated);
|
||||||
|
if (elaborated>=0 && elaborated<1) {
|
||||||
|
Log.trace("progress "+elaborated);
|
||||||
|
int elab=new Float(elaborated*100).intValue();
|
||||||
|
progressBar.updateProgress(elaborated,elab+"% Uploading...");
|
||||||
|
}
|
||||||
|
if (elaborated == 1) progressBar.updateProgress(1, "Completing...");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.upload.progress;
|
||||||
|
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class FileUploadProgressCardUpdater implements FileUploadProgressListener {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public FileUploadProgressCardUpdater() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void operationComplete() {
|
||||||
|
Log.info("File upload completed");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public void operationFailed(Throwable caught, String reason, String failureDetails) {
|
||||||
|
Log.info("File upload failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void operationInitializing() {
|
||||||
|
Log.info("File upload inizializing");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void operationUpdate(float elaborated) {
|
||||||
|
Log.info("File uploading: "+elaborated);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.upload.progress;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines a listener for operation progress.
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface FileUploadProgressListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the operation is starting.
|
||||||
|
*/
|
||||||
|
public void operationInitializing();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when there is a progress for the operation.
|
||||||
|
* @param elaborated the elaborated part.
|
||||||
|
*/
|
||||||
|
public void operationUpdate(float elaborated);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the operation is complete.
|
||||||
|
*/
|
||||||
|
public void operationComplete();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the operation is failed.
|
||||||
|
* @param caught the failure exception.
|
||||||
|
* @param reason the failure reason.
|
||||||
|
*/
|
||||||
|
public void operationFailed(Throwable caught, String reason, String failureDetails);
|
||||||
|
}
|
|
@ -0,0 +1,129 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.upload.progress;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterServiceAsync;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadMonitor;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.user.client.Timer;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This {@link Timer} retrieves {@link OperationProgress} from the specified {@link OperationProgressSource} with the scheduled interval.
|
||||||
|
* The retrieved information are spread to the subscribed {@link CSVImportProgressListener}.
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class FileUploadProgressUpdater extends Timer {
|
||||||
|
|
||||||
|
protected ArrayList<FileUploadProgressListener> listeners = new ArrayList<FileUploadProgressListener>();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Log.debug("requesting operation progress");
|
||||||
|
StatAlgoImporterServiceAsync.INSTANCE.getFileUploadMonitor(new AsyncCallback<FileUploadMonitor>() {
|
||||||
|
|
||||||
|
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
cancel();
|
||||||
|
Log.error("Error retrieving the operation state", caught);
|
||||||
|
String message = getStack(caught);
|
||||||
|
fireOperationFailed(caught, "Failed getting operation updates", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSuccess(FileUploadMonitor result) {
|
||||||
|
Log.info("retrieved FileUploadMonitor: "+result.getState());
|
||||||
|
switch (result.getState()) {
|
||||||
|
case STARTED:
|
||||||
|
Log.debug("File Upload Started");
|
||||||
|
break;
|
||||||
|
case INPROGRESS:
|
||||||
|
Log.debug("Progress: "+result.getElaboratedLenght()+" of "+result.getTotalLenght());
|
||||||
|
fireOperationUpdate(result.getPercentDone());
|
||||||
|
break;
|
||||||
|
case FAILED:
|
||||||
|
Log.debug("File Upload Failed");
|
||||||
|
cancel();
|
||||||
|
fireOperationFailed(new Throwable("File Upload Failed") ,result.getFailureReason(), result.getFailureDetails());
|
||||||
|
break;
|
||||||
|
case COMPLETED:
|
||||||
|
cancel();
|
||||||
|
Log.debug("File Upload Completed");
|
||||||
|
fireOperationComplete();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected String getStack(Throwable e)
|
||||||
|
{
|
||||||
|
String message = e.getLocalizedMessage()+" -> <br>";
|
||||||
|
Throwable c = e.getCause();
|
||||||
|
if (c!=null) message += getStack(c);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void fireOperationInitializing()
|
||||||
|
{
|
||||||
|
for (FileUploadProgressListener listener:listeners) listener.operationInitializing();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void fireOperationUpdate(float elaborated)
|
||||||
|
{
|
||||||
|
for (FileUploadProgressListener listener:listeners) listener.operationUpdate(elaborated);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void fireOperationComplete()
|
||||||
|
{
|
||||||
|
for (FileUploadProgressListener listener:listeners) listener.operationComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void fireOperationFailed(Throwable caught, String failure, String failureDetails)
|
||||||
|
{
|
||||||
|
for (FileUploadProgressListener listener:listeners) listener.operationFailed(caught, failure, failureDetails);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param listener
|
||||||
|
*/
|
||||||
|
public void addListener(FileUploadProgressListener listener)
|
||||||
|
{
|
||||||
|
listeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param listener
|
||||||
|
*/
|
||||||
|
public void removeListener(FileUploadProgressListener listener)
|
||||||
|
{
|
||||||
|
listeners.remove(listener);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Format {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a file size into a {@link String} representation adding the misure unit.
|
||||||
|
* @param size the file size.
|
||||||
|
* @return the textual representation.
|
||||||
|
*/
|
||||||
|
public static String fileSize(long size) {
|
||||||
|
StringBuilder text = new StringBuilder();
|
||||||
|
if (size < 1024) {
|
||||||
|
text.append(size);
|
||||||
|
text.append(" bytes");
|
||||||
|
} else if (size < 1048576) {
|
||||||
|
text.append(Math.round(((size * 10) / 1024)) / 10);
|
||||||
|
text.append(" KB");
|
||||||
|
} else if (size < 1073741824) {
|
||||||
|
text.append(Math.round(((size * 10) / 1048576)) / 10);
|
||||||
|
text.append(" MB");
|
||||||
|
} else {
|
||||||
|
text.append(Math.round(((size * 10) / 1073741824)) / 10);
|
||||||
|
text.append(" GB");
|
||||||
|
}
|
||||||
|
return text.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.utils;
|
||||||
|
|
||||||
|
import com.sencha.gxt.widget.core.client.box.MessageBox;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class InfoMessageBox extends MessageBox {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a message box with an info icon and the specified title and
|
||||||
|
* message.
|
||||||
|
*
|
||||||
|
* @param title
|
||||||
|
* the message box title
|
||||||
|
* @param message
|
||||||
|
* the message displayed in the message box
|
||||||
|
*/
|
||||||
|
public InfoMessageBox(String title, String message) {
|
||||||
|
super(title, message);
|
||||||
|
|
||||||
|
setIcon(ICONS.info());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.utils;
|
||||||
|
|
||||||
|
|
||||||
|
import com.google.gwt.core.client.Callback;
|
||||||
|
import com.google.gwt.dom.client.Element;
|
||||||
|
import com.sencha.gxt.core.client.dom.XElement;
|
||||||
|
import com.sencha.gxt.widget.core.client.Component;
|
||||||
|
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.HideEvent;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class UtilsGXT3 {
|
||||||
|
public static void mask(Element element) {
|
||||||
|
XElement el = element.<XElement> cast();
|
||||||
|
el.mask("Loading...");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void umask(Element element) {
|
||||||
|
element.<XElement> cast().unmask();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void alert(String title, String message) {
|
||||||
|
final AlertMessageBox d = new AlertMessageBox(title, message);
|
||||||
|
d.addHideHandler(new HideHandler() {
|
||||||
|
|
||||||
|
public void onHide(HideEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
d.show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void alert(String title, String message, final Callback<Component, Void> callback) {
|
||||||
|
final AlertMessageBox d = new AlertMessageBox(title, message);
|
||||||
|
d.addHideHandler(new HideHandler() {
|
||||||
|
|
||||||
|
public void onHide(HideEvent event) {
|
||||||
|
Component comp=event.getSource();
|
||||||
|
callback.onSuccess(comp);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
d.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void info(String title, String message) {
|
||||||
|
final InfoMessageBox d = new InfoMessageBox(title, message);
|
||||||
|
d.addHideHandler(new HideHandler() {
|
||||||
|
|
||||||
|
public void onHide(HideEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
d.show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void info(String title, String message, final Callback<Component, Void> callback) {
|
||||||
|
final InfoMessageBox d = new InfoMessageBox(title, message);
|
||||||
|
d.addHideHandler(new HideHandler() {
|
||||||
|
|
||||||
|
public void onHide(HideEvent event) {
|
||||||
|
Component comp=event.getSource();
|
||||||
|
callback.onSuccess(comp);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
d.show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,186 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.server;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.apache.commons.fileupload.FileItem;
|
||||||
|
import org.apache.commons.fileupload.FileItemFactory;
|
||||||
|
import org.apache.commons.fileupload.FileUploadException;
|
||||||
|
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||||
|
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.CodeFileUploadSession;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.FileUploadListener;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.FileUtil;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterSessionExpiredException;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadMonitor;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadState;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class LocalUploadServlet extends HttpServlet {
|
||||||
|
|
||||||
|
protected static Logger logger = LoggerFactory.getLogger(LocalUploadServlet.class);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -4197748678713054285L;
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
|
||||||
|
logger.trace("Post");
|
||||||
|
|
||||||
|
HttpSession session = request.getSession();
|
||||||
|
|
||||||
|
if(session==null){
|
||||||
|
logger.error("Error getting the upload session, no session valid found: "+session);
|
||||||
|
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "ERROR-Error getting the user session, no session found"+session);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
logger.info("Code Import session id: "+session.getId());
|
||||||
|
|
||||||
|
CodeFileUploadSession fileUploadSession=new CodeFileUploadSession();
|
||||||
|
FileUploadMonitor fileUploadMonitor=new FileUploadMonitor();
|
||||||
|
|
||||||
|
fileUploadSession.setId(session.getId());
|
||||||
|
fileUploadSession.setFileUploadState(FileUploadState.STARTED);
|
||||||
|
//fileUploadSession.setCsvImportMonitor(csvImportMonitor);
|
||||||
|
SessionUtil.setFileUploadMonitor(session, fileUploadMonitor);
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
SessionUtil.setCodeFileUploadSession(session,fileUploadSession);
|
||||||
|
} catch (StatAlgoImporterSessionExpiredException e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new ServletException(e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FileItemFactory factory = new DiskFileItemFactory();
|
||||||
|
ServletFileUpload upload = new ServletFileUpload(factory);
|
||||||
|
|
||||||
|
|
||||||
|
FileUploadListener uploadListener = new FileUploadListener(fileUploadMonitor);
|
||||||
|
upload.setProgressListener(uploadListener);
|
||||||
|
|
||||||
|
FileItem uploadItem = null;
|
||||||
|
Log.info("Start upload file ");
|
||||||
|
try {
|
||||||
|
List items = upload.parseRequest(request);
|
||||||
|
Iterator it = items.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
FileItem item = (FileItem) it.next();
|
||||||
|
if (!item.isFormField() && Constants.FILE_UPLOADED_FIELD.equals(item.getFieldName())) {
|
||||||
|
uploadItem = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (FileUploadException e) {
|
||||||
|
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
|
||||||
|
fum.setFailed("An error occured elaborating the HTTP request", FileUtil.exceptionDetailMessage(e));
|
||||||
|
SessionUtil.setFileUploadMonitor(session, fum);
|
||||||
|
fileUploadSession.setFileUploadState(FileUploadState.FAILED);
|
||||||
|
try {
|
||||||
|
SessionUtil.setCodeFileUploadSession(session, fileUploadSession);
|
||||||
|
} catch (StatAlgoImporterSessionExpiredException e1) {
|
||||||
|
logger.error(e1.getLocalizedMessage());
|
||||||
|
e1.printStackTrace();
|
||||||
|
throw new ServletException(e1.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
logger.error("Error processing request in upload servlet", e);
|
||||||
|
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "ERROR-Error during request processing: "+e.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uploadItem == null) {
|
||||||
|
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
|
||||||
|
fum.setFailed("An error occured elaborating the HTTP request: No file found", "Upload request without file");
|
||||||
|
SessionUtil.setFileUploadMonitor(session, fum);
|
||||||
|
fileUploadSession.setFileUploadState(FileUploadState.FAILED);
|
||||||
|
try {
|
||||||
|
SessionUtil.setCodeFileUploadSession(session, fileUploadSession);
|
||||||
|
} catch (StatAlgoImporterSessionExpiredException e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new ServletException(e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
logger.error("Error processing request in upload servlet: No file to upload");
|
||||||
|
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "No file to upload");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String contentType = uploadItem.getContentType();
|
||||||
|
|
||||||
|
logger.trace("ContentType: "+contentType);
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
FileUtil.setImportCodeFile(fileUploadSession, uploadItem.getInputStream(), uploadItem.getName(), contentType);
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
|
||||||
|
fum.setFailed("An error occured elaborating the file", FileUtil.exceptionDetailMessage(e));
|
||||||
|
SessionUtil.setFileUploadMonitor(session, fum);
|
||||||
|
fileUploadSession.setFileUploadState(FileUploadState.FAILED);
|
||||||
|
try {
|
||||||
|
SessionUtil.setCodeFileUploadSession(session, fileUploadSession);
|
||||||
|
} catch (StatAlgoImporterSessionExpiredException e1) {
|
||||||
|
logger.error(e1.getLocalizedMessage());
|
||||||
|
e1.printStackTrace();
|
||||||
|
throw new ServletException(e1.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
logger.error("Error elaborating the stream", e);
|
||||||
|
uploadItem.delete();
|
||||||
|
response.getWriter().write("ERROR-"+e.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uploadItem.delete();
|
||||||
|
|
||||||
|
logger.trace("changing state");
|
||||||
|
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
|
||||||
|
fum.setState(FileUploadState.COMPLETED);
|
||||||
|
SessionUtil.setFileUploadMonitor(session, fum);
|
||||||
|
try {
|
||||||
|
SessionUtil.setCodeFileUploadSession(session, fileUploadSession);
|
||||||
|
} catch (StatAlgoImporterSessionExpiredException e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new ServletException(e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
response.getWriter().write("OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,115 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.server;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.gcube.application.framework.core.session.ASLSession;
|
||||||
|
import org.gcube.application.framework.core.session.SessionManager;
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.CodeFileUploadSession;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterSessionExpiredException;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadMonitor;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session.SessionConstants;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SessionUtil {
|
||||||
|
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(SessionUtil.class);
|
||||||
|
|
||||||
|
public static ASLSession getAslSession(HttpSession httpSession)
|
||||||
|
throws StatAlgoImporterSessionExpiredException {
|
||||||
|
String username = (String) httpSession
|
||||||
|
.getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
|
||||||
|
ASLSession session;
|
||||||
|
if (username == null) {
|
||||||
|
logger.warn("no user found in session, use test user");
|
||||||
|
/*throw new AccountingManagerSessionExpiredException("Session Expired!");*/
|
||||||
|
|
||||||
|
|
||||||
|
// Remove comment for Test
|
||||||
|
username = Constants.DEFAULT_USER;
|
||||||
|
String scope = Constants.DEFAULT_SCOPE;
|
||||||
|
|
||||||
|
httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, username);
|
||||||
|
session = SessionManager.getInstance().getASLSession(
|
||||||
|
httpSession.getId(), username);
|
||||||
|
session.setScope(scope);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
session = SessionManager.getInstance().getASLSession(
|
||||||
|
httpSession.getId(), username);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info("SessionUtil: aslSession " + session.getUsername() + " "
|
||||||
|
+ session.getScope());
|
||||||
|
|
||||||
|
return session;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
public static FileUploadMonitor getFileUploadMonitor(HttpSession httpSession) {
|
||||||
|
FileUploadMonitor fileUploadMonitor = (FileUploadMonitor) httpSession
|
||||||
|
.getAttribute(SessionConstants.FILE_UPLOAD_MONITOR);
|
||||||
|
if (fileUploadMonitor != null) {
|
||||||
|
return fileUploadMonitor;
|
||||||
|
} else {
|
||||||
|
fileUploadMonitor = new FileUploadMonitor();
|
||||||
|
httpSession.setAttribute(SessionConstants.FILE_UPLOAD_MONITOR,
|
||||||
|
fileUploadMonitor);
|
||||||
|
return fileUploadMonitor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setFileUploadMonitor(HttpSession httpSession,
|
||||||
|
FileUploadMonitor fileUploadMonitor) {
|
||||||
|
FileUploadMonitor fum = (FileUploadMonitor) httpSession
|
||||||
|
.getAttribute(SessionConstants.FILE_UPLOAD_MONITOR);
|
||||||
|
if (fum != null) {
|
||||||
|
httpSession.removeAttribute(SessionConstants.FILE_UPLOAD_MONITOR);
|
||||||
|
}
|
||||||
|
httpSession.setAttribute(SessionConstants.FILE_UPLOAD_MONITOR,
|
||||||
|
fileUploadMonitor);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
public static void setCodeFileUploadSession(HttpSession httpSession,
|
||||||
|
CodeFileUploadSession s) throws StatAlgoImporterSessionExpiredException {
|
||||||
|
|
||||||
|
CodeFileUploadSession session = (CodeFileUploadSession) httpSession
|
||||||
|
.getAttribute(SessionConstants.IMPORT_CODE_FILE_UPLOAD_SESSION);
|
||||||
|
if (session != null)
|
||||||
|
httpSession
|
||||||
|
.removeAttribute(SessionConstants.IMPORT_CODE_FILE_UPLOAD_SESSION);
|
||||||
|
httpSession.setAttribute(
|
||||||
|
SessionConstants.IMPORT_CODE_FILE_UPLOAD_SESSION, s);
|
||||||
|
ASLSession aslSession = getAslSession(httpSession);
|
||||||
|
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CodeFileUploadSession getCodeFileUploadSession(
|
||||||
|
HttpSession httpSession) {
|
||||||
|
CodeFileUploadSession fileUploadSession = (CodeFileUploadSession) httpSession
|
||||||
|
.getAttribute(SessionConstants.IMPORT_CODE_FILE_UPLOAD_SESSION);
|
||||||
|
if (fileUploadSession == null) {
|
||||||
|
logger.error("CodeFileUploadSession was not acquired");
|
||||||
|
}
|
||||||
|
return fileUploadSession;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,120 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.server;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.gcube.application.framework.core.session.ASLSession;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterService;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.CodeFileReader;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.CodeFileUploadSession;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.code.CodeData;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadMonitor;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session.UserInfo;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The server side implementation of the RPC service.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
||||||
|
StatAlgoImporterService {
|
||||||
|
|
||||||
|
private static Logger logger = LoggerFactory
|
||||||
|
.getLogger(StatAlgoImporterServiceImpl.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() throws ServletException {
|
||||||
|
super.init();
|
||||||
|
System.out.println("Fix JAXP: jdk.xml.entityExpansionLimit=0");
|
||||||
|
System.setProperty("jdk.xml.entityExpansionLimit", "0");
|
||||||
|
|
||||||
|
System.out.println("initializing StatisticalRunner");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public UserInfo hello() throws StatAlgoImporterServiceException {
|
||||||
|
try {
|
||||||
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
|
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||||
|
UserInfo userInfo = new UserInfo(aslSession.getUsername(),
|
||||||
|
aslSession.getGroupId(), aslSession.getGroupName(),
|
||||||
|
aslSession.getScope(), aslSession.getScopeName(),
|
||||||
|
aslSession.getUserEmailAddress(),
|
||||||
|
aslSession.getUserFullName());
|
||||||
|
logger.debug("UserInfo: " + userInfo);
|
||||||
|
return userInfo;
|
||||||
|
} catch (StatAlgoImporterServiceException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw e;
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error("Hello(): " + e.getLocalizedMessage(), e);
|
||||||
|
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public FileUploadMonitor getFileUploadMonitor()
|
||||||
|
throws StatAlgoImporterServiceException {
|
||||||
|
|
||||||
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
|
if (session == null) {
|
||||||
|
throw new StatAlgoImporterServiceException(
|
||||||
|
"Error retrieving the session: null");
|
||||||
|
}
|
||||||
|
|
||||||
|
FileUploadMonitor fileUploadMonitor = SessionUtil
|
||||||
|
.getFileUploadMonitor(session);
|
||||||
|
if (fileUploadMonitor == null) {
|
||||||
|
throw new StatAlgoImporterServiceException(
|
||||||
|
"Error retrieving the fileUploadMonitor: null");
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug("FileUploadMonitor: " + fileUploadMonitor);
|
||||||
|
|
||||||
|
return fileUploadMonitor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<CodeData> getCode() throws StatAlgoImporterServiceException {
|
||||||
|
try {
|
||||||
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
|
SessionUtil.getAslSession(session);
|
||||||
|
logger.debug("getCode()");
|
||||||
|
CodeFileUploadSession codeFileUploadSession = SessionUtil
|
||||||
|
.getCodeFileUploadSession(session);
|
||||||
|
|
||||||
|
CodeFileReader codeFileReader = new CodeFileReader(
|
||||||
|
codeFileUploadSession);
|
||||||
|
ArrayList<CodeData> codeList = codeFileReader.getCodeList();
|
||||||
|
for (CodeData codeData : codeList) {
|
||||||
|
logger.debug("" + codeData.getId() + " "
|
||||||
|
+ codeData.getCodeLine());
|
||||||
|
}
|
||||||
|
return codeList;
|
||||||
|
} catch (StatAlgoImporterServiceException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw e;
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error("getCode(): " + e.getLocalizedMessage(), e);
|
||||||
|
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.file;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.code.CodeData;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CodeFileReader
|
||||||
|
*
|
||||||
|
* Read code and convert it in ArrayList
|
||||||
|
*
|
||||||
|
* @author giancarlo email: <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CodeFileReader {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(CodeFileReader.class);
|
||||||
|
private ArrayList<CodeData> codeList;
|
||||||
|
|
||||||
|
public CodeFileReader(CodeFileUploadSession codeFileUploadSession)
|
||||||
|
throws StatAlgoImporterServiceException {
|
||||||
|
|
||||||
|
try {
|
||||||
|
if(codeFileUploadSession==null|| codeFileUploadSession.getCodeFile()==null){
|
||||||
|
throw new StatAlgoImporterServiceException("CodeFileUploadSession is invalid");
|
||||||
|
}
|
||||||
|
|
||||||
|
codeList = new ArrayList<CodeData>();
|
||||||
|
FileInputStream fio=new FileInputStream(codeFileUploadSession.getCodeFile());
|
||||||
|
|
||||||
|
InputStreamReader isr = new InputStreamReader(fio);
|
||||||
|
|
||||||
|
BufferedReader br = new BufferedReader((Reader) isr );
|
||||||
|
|
||||||
|
String s;
|
||||||
|
int i = 1;
|
||||||
|
while ((s = br.readLine()) != null) {
|
||||||
|
CodeData codeData = new CodeData(i, s);
|
||||||
|
codeList.add(codeData);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
fio.close();
|
||||||
|
logger.trace("CodeList size: " + codeList.size());
|
||||||
|
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
logger.error("File Not Found: "+e.getLocalizedMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("IOException: "+e.getLocalizedMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<CodeData> getCodeList() {
|
||||||
|
return codeList;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.file;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CodeFileUploadSession implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -7906477664944910362L;
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private FileUploadState fileUploadState;
|
||||||
|
|
||||||
|
private File codeFile;
|
||||||
|
private String codeName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileUploadState getFileUploadState() {
|
||||||
|
return fileUploadState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileUploadState(FileUploadState fileUploadState) {
|
||||||
|
this.fileUploadState = fileUploadState;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public File getCodeFile() {
|
||||||
|
return codeFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCodeFile(File codeFile) {
|
||||||
|
this.codeFile = codeFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCodeName() {
|
||||||
|
return codeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCodeName(String codeName) {
|
||||||
|
this.codeName = codeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "CSVFileUploadSession [id=" + id + ", fileUploadState="
|
||||||
|
+ fileUploadState + ", csvFile=" + codeFile + ", csvName="
|
||||||
|
+ codeName + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.file;
|
||||||
|
|
||||||
|
import org.apache.commons.fileupload.ProgressListener;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadMonitor;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadState;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class FileUploadListener implements ProgressListener {
|
||||||
|
|
||||||
|
private Logger logger=LoggerFactory.getLogger(FileUploadListener.class);
|
||||||
|
|
||||||
|
private FileUploadMonitor fileUploadMonitor;
|
||||||
|
|
||||||
|
private long num100Ks = 0;
|
||||||
|
private long theBytesRead = 0;
|
||||||
|
private long theContentLength = -1;
|
||||||
|
private int whichItem = 0;
|
||||||
|
private int percentDone = 0;
|
||||||
|
private boolean contentLengthKnown = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public FileUploadListener(FileUploadMonitor fileUploadMonitor) {
|
||||||
|
logger.debug("FileUploadListener created");
|
||||||
|
this.fileUploadMonitor=fileUploadMonitor;
|
||||||
|
//this.session=session;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public void update(long bytesRead, long contentLength, int items) {
|
||||||
|
if (contentLength > -1) {
|
||||||
|
contentLengthKnown = true;
|
||||||
|
}
|
||||||
|
theBytesRead = bytesRead;
|
||||||
|
theContentLength = contentLength;
|
||||||
|
whichItem = items;
|
||||||
|
|
||||||
|
long nowNum100Ks = bytesRead / 100000;
|
||||||
|
// Only run this code once every 100K
|
||||||
|
if (nowNum100Ks > num100Ks) {
|
||||||
|
num100Ks = nowNum100Ks;
|
||||||
|
if (contentLengthKnown) {
|
||||||
|
percentDone = (int) Math.round(100.00 * bytesRead / contentLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fileUploadMonitor.setTotalLenght(contentLength);
|
||||||
|
fileUploadMonitor.setElaboratedLenght(bytesRead);
|
||||||
|
fileUploadMonitor.setPercentDone(Float.valueOf(percentDone)/100);
|
||||||
|
|
||||||
|
fileUploadMonitor.setState(FileUploadState.INPROGRESS);
|
||||||
|
//logger.debug("File Upload: "+fileUploadMonitor.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "FileUploadListener [fileUploadMonitor=" + fileUploadMonitor
|
||||||
|
+ ", num100Ks=" + num100Ks + ", theBytesRead=" + theBytesRead
|
||||||
|
+ ", theContentLength=" + theContentLength + ", whichItem="
|
||||||
|
+ whichItem + ", percentDone=" + percentDone
|
||||||
|
+ ", contentLengthKnown=" + contentLengthKnown + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,124 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.file;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class FileUtil {
|
||||||
|
|
||||||
|
protected static final Logger logger = LoggerFactory
|
||||||
|
.getLogger(FileUtil.class);
|
||||||
|
|
||||||
|
public static final String[] ZIP_MIMETYPES = new String[] {
|
||||||
|
"application/x-compress", "application/x-compressed",
|
||||||
|
"application/x-gzip", "application/x-winzip", "application/x-zip",
|
||||||
|
"application/zip", "multipart/x-zip" };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the content type is a zip type.
|
||||||
|
*
|
||||||
|
* @param contentType
|
||||||
|
* the content type to check.
|
||||||
|
* @return <code>true</code> if is a zip file, <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
public static boolean isZipContentType(String contentType) {
|
||||||
|
for (String zip_mimetype : ZIP_MIMETYPES)
|
||||||
|
if (zip_mimetype.equals(contentType))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unzip the specified stream
|
||||||
|
*
|
||||||
|
* @param is
|
||||||
|
* the zip stream.
|
||||||
|
* @param os
|
||||||
|
* the output stream.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static String unZip(InputStream is, OutputStream os)
|
||||||
|
throws Exception {
|
||||||
|
try {
|
||||||
|
ZipInputStream zis = new ZipInputStream(is);
|
||||||
|
ZipEntry entry;
|
||||||
|
|
||||||
|
while ((entry = zis.getNextEntry()) != null && !entry.isDirectory())
|
||||||
|
;
|
||||||
|
|
||||||
|
if (entry == null || entry.isDirectory()) {
|
||||||
|
zis.close();
|
||||||
|
os.close();
|
||||||
|
throw new Exception("Unzip error: No file entry found");
|
||||||
|
}
|
||||||
|
IOUtils.copy(zis, os);
|
||||||
|
zis.closeEntry();
|
||||||
|
zis.close();
|
||||||
|
os.close();
|
||||||
|
return entry.getName();
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new Exception("Unzip error: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String exceptionDetailMessage(Throwable t) {
|
||||||
|
StringWriter out = new StringWriter();
|
||||||
|
PrintWriter writer = new PrintWriter(out);
|
||||||
|
t.printStackTrace(writer);
|
||||||
|
|
||||||
|
StringBuilder message = new StringBuilder("Error message:\n");
|
||||||
|
message.append(out.toString());
|
||||||
|
|
||||||
|
return message.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setImportCodeFile(CodeFileUploadSession fileUploadSession,
|
||||||
|
InputStream is, String name, String mimeType) throws Exception {
|
||||||
|
|
||||||
|
File csvTmp = setImportFile(is, "import", ".code", name, mimeType);
|
||||||
|
|
||||||
|
fileUploadSession.setCodeName(name);
|
||||||
|
fileUploadSession.setCodeFile(csvTmp);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static File setImportFile(InputStream is, String tempName,
|
||||||
|
String extention, String name, String mimeType) throws Exception {
|
||||||
|
File fileTmp = File.createTempFile(tempName, extention);
|
||||||
|
|
||||||
|
fileTmp.deleteOnExit();
|
||||||
|
|
||||||
|
logger.debug("Import File mimeType: " + mimeType);
|
||||||
|
if (isZipContentType(mimeType)) {
|
||||||
|
// we need to unzip
|
||||||
|
logger.trace("is a zip file");
|
||||||
|
name = unZip(is, new FileOutputStream(fileTmp));
|
||||||
|
} else {
|
||||||
|
logger.trace("is a text file");
|
||||||
|
IOUtils.copy(is, new FileOutputStream(fileTmp));
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.trace("upload completed");
|
||||||
|
|
||||||
|
return fileTmp;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.portlet;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.portlet.GenericPortlet;
|
||||||
|
import javax.portlet.PortletException;
|
||||||
|
import javax.portlet.PortletRequestDispatcher;
|
||||||
|
import javax.portlet.RenderRequest;
|
||||||
|
import javax.portlet.RenderResponse;
|
||||||
|
|
||||||
|
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo
|
||||||
|
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class StatAlgoImporterPortlet extends GenericPortlet {
|
||||||
|
|
||||||
|
protected Logger logger = LoggerFactory.getLogger(StatAlgoImporterPortlet.class);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JSP folder name
|
||||||
|
*/
|
||||||
|
public static final String JSP_FOLDER = "/WEB-INF/jsp/";
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static final String VIEW_JSP = JSP_FOLDER + "StatAlgoImporterPortlet_view.jsp";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param request .
|
||||||
|
* @param response .
|
||||||
|
* @throws IOException .
|
||||||
|
* @throws PortletException .
|
||||||
|
*/
|
||||||
|
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
|
||||||
|
|
||||||
|
logger.trace("Loading from JSP: "+VIEW_JSP);
|
||||||
|
|
||||||
|
logger.trace("setting context using ScopeHelper");
|
||||||
|
ScopeHelper.setContext(request);
|
||||||
|
|
||||||
|
logger.trace("passing to the render");
|
||||||
|
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(VIEW_JSP);
|
||||||
|
logger.trace("Call: "+VIEW_JSP);
|
||||||
|
rd.include(request,response);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo
|
||||||
|
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Constants {
|
||||||
|
|
||||||
|
public static final String APPLICATION_ID = "org.gcube.portlets.user.statisticalrunner.server.portlet.StatisticalRunnerPortlet";
|
||||||
|
public static final String STATRUNNER_ID = "StatRunnerId";
|
||||||
|
public static final String STATRUNNER_LANG_COOKIE = "StatRunnerLangCookie";
|
||||||
|
public static final String STATRUNNER_LANG = "StatRunnerLang";
|
||||||
|
public final static String DEFAULT_USER = "test.user";
|
||||||
|
//public final static String DEFAULT_SCOPE = "/gcube/devNext";
|
||||||
|
public final static String DEFAULT_SCOPE = "/gcube/devsec/devVRE";
|
||||||
|
|
||||||
|
|
||||||
|
public static final String FILE_UPLOADED_FIELD = "fileUploadedField";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.code;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo email: <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CodeData implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 2507639790500338861L;
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
private String codeLine;
|
||||||
|
|
||||||
|
public CodeData(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CodeData(int id, String codeLine) {
|
||||||
|
super();
|
||||||
|
this.id = id;
|
||||||
|
this.codeLine = codeLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCodeLine() {
|
||||||
|
return codeLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCodeLine(String codeLine) {
|
||||||
|
this.codeLine = codeLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "CodeData [id=" + id + ", codeLine=" + codeLine + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class StatAlgoImporterServiceException extends Exception {
|
||||||
|
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -2255657546267656458L;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public StatAlgoImporterServiceException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
public StatAlgoImporterServiceException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public StatAlgoImporterServiceException(String message,Throwable t) {
|
||||||
|
super(message,t);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ASL Session Expired Exception
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class StatAlgoImporterSessionExpiredException extends StatAlgoImporterServiceException {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -4831171355042165166L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public StatAlgoImporterSessionExpiredException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
public StatAlgoImporterSessionExpiredException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* @param t
|
||||||
|
*/
|
||||||
|
public StatAlgoImporterSessionExpiredException(String message,Throwable t) {
|
||||||
|
super(message,t);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,123 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class FileUploadMonitor implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -1150111422206443617L;
|
||||||
|
|
||||||
|
protected long totalLenght;
|
||||||
|
protected long elaboratedLenght;
|
||||||
|
protected FileUploadState state;
|
||||||
|
protected String failureReason;
|
||||||
|
protected String failureDetails;
|
||||||
|
protected float percentDone;
|
||||||
|
|
||||||
|
public FileUploadMonitor(){
|
||||||
|
state = FileUploadState.INPROGRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileUploadMonitor(long totalLenght, long elaboratedLenght, FileUploadState state, String failureReason) {
|
||||||
|
this.totalLenght = totalLenght;
|
||||||
|
this.elaboratedLenght = elaboratedLenght;
|
||||||
|
this.state = state;
|
||||||
|
this.failureReason = failureReason;
|
||||||
|
this.percentDone=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the totalLenght
|
||||||
|
*/
|
||||||
|
public long getTotalLenght() {
|
||||||
|
return totalLenght;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the elaboratedLenght
|
||||||
|
*/
|
||||||
|
public long getElaboratedLenght() {
|
||||||
|
return elaboratedLenght;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public FileUploadState getState(){
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the failureDetails
|
||||||
|
*/
|
||||||
|
public String getFailureDetails() {
|
||||||
|
return failureDetails;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getPercentDone() {
|
||||||
|
return percentDone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPercentDone(float percentDone) {
|
||||||
|
this.percentDone = percentDone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFailureReason(String failureReason) {
|
||||||
|
this.failureReason = failureReason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFailureDetails(String failureDetails) {
|
||||||
|
this.failureDetails = failureDetails;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(FileUploadState state)
|
||||||
|
{
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the reason
|
||||||
|
*/
|
||||||
|
public String getFailureReason() {
|
||||||
|
return failureReason;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param totalLenght the totalLenght to set
|
||||||
|
*/
|
||||||
|
public void setTotalLenght(long totalLenght) {
|
||||||
|
this.totalLenght = totalLenght;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param elaboratedLenght the elaboratedLenght to set
|
||||||
|
*/
|
||||||
|
public void setElaboratedLenght(long elaboratedLenght) {
|
||||||
|
this.elaboratedLenght = elaboratedLenght;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param failed the failed to set
|
||||||
|
*/
|
||||||
|
public void setFailed(String failureReason, String failureDetails) {
|
||||||
|
this.state = FileUploadState.FAILED;
|
||||||
|
this.failureReason = failureReason;
|
||||||
|
this.failureDetails = failureDetails;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "FileUploadMonitor [totalLenght=" + totalLenght
|
||||||
|
+ ", elaboratedLenght=" + elaboratedLenght + ", state=" + state
|
||||||
|
+ ", failureReason=" + failureReason + ", failureDetails="
|
||||||
|
+ failureDetails + ", percentDone=" + percentDone + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Federico De Faveri defaveri@isti.cnr.it
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public enum FileUploadState {
|
||||||
|
|
||||||
|
STARTED,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The operation is in progress.
|
||||||
|
*/
|
||||||
|
INPROGRESS,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The operation is completed.
|
||||||
|
*/
|
||||||
|
COMPLETED,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The operation is failed.
|
||||||
|
*/
|
||||||
|
FAILED;
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo
|
||||||
|
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SessionConstants {
|
||||||
|
|
||||||
|
public static final String FILE_UPLOAD_MONITOR="FILE_UPLOAD_MONITOR";
|
||||||
|
public static final String IMPORT_CODE_FILE_UPLOAD_SESSION = "IMPORT_CODE_FILE_UPLOAD_SESSION";
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,114 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo
|
||||||
|
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class UserInfo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -2826549639677017234L;
|
||||||
|
|
||||||
|
private String username;
|
||||||
|
private long groupId;
|
||||||
|
private String groupName;
|
||||||
|
private String scope;
|
||||||
|
private String scopeName;
|
||||||
|
private String userEmailAddress;
|
||||||
|
private String userFullName;
|
||||||
|
|
||||||
|
public UserInfo() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param username
|
||||||
|
* @param groupId
|
||||||
|
* @param groupName
|
||||||
|
* @param scope
|
||||||
|
* @param scopeName
|
||||||
|
* @param userEmailAddress
|
||||||
|
* @param userFullName
|
||||||
|
*/
|
||||||
|
public UserInfo(String username, long groupId, String groupName,
|
||||||
|
String scope, String scopeName, String userEmailAddress,
|
||||||
|
String userFullName) {
|
||||||
|
super();
|
||||||
|
this.username = username;
|
||||||
|
this.groupId = groupId;
|
||||||
|
this.groupName = groupName;
|
||||||
|
this.scope = scope;
|
||||||
|
this.scopeName = scopeName;
|
||||||
|
this.userEmailAddress = userEmailAddress;
|
||||||
|
this.userFullName = userFullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getGroupId() {
|
||||||
|
return groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupId(long groupId) {
|
||||||
|
this.groupId = groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGroupName() {
|
||||||
|
return groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupName(String groupName) {
|
||||||
|
this.groupName = groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getScope() {
|
||||||
|
return scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScope(String scope) {
|
||||||
|
this.scope = scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getScopeName() {
|
||||||
|
return scopeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScopeName(String scopeName) {
|
||||||
|
this.scopeName = scopeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserEmailAddress() {
|
||||||
|
return userEmailAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserEmailAddress(String userEmailAddress) {
|
||||||
|
this.userEmailAddress = userEmailAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserFullName() {
|
||||||
|
return userFullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserFullName(String userFullName) {
|
||||||
|
this.userFullName = userFullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "UserInfo [username=" + username + ", groupId=" + groupId
|
||||||
|
+ ", groupName=" + groupName + ", scope=" + scope
|
||||||
|
+ ", scopeName=" + scopeName + ", userEmailAddress="
|
||||||
|
+ userEmailAddress + ", userFullName=" + userFullName + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module rename-to='statalgoimporter'>
|
||||||
|
|
||||||
|
<inherits name='com.google.gwt.user.User' />
|
||||||
|
<inherits name="com.google.gwt.http.HTTP" />
|
||||||
|
<!-- <inherits name="com.google.gwt.i18n.I18N" /> -->
|
||||||
|
|
||||||
|
<!-- <inherits name='com.extjs.gxt.ui.GXT' /> -->
|
||||||
|
<inherits name='com.sencha.gxt.ui.GXT' />
|
||||||
|
|
||||||
|
<!-- GXT Theme -->
|
||||||
|
<!-- <inherits name='com.sencha.gxt.theme.blue.Blue' /> -->
|
||||||
|
<!-- <inherits name='com.sencha.gxt.theme.gray.Gray' /> -->
|
||||||
|
<!-- Be sure to include Neptunes gxt-theme-neptune.jar in the classpath -->
|
||||||
|
<inherits name='com.sencha.gxt.theme.neptune.Theme' />
|
||||||
|
|
||||||
|
<!-- <inherits name="com.google.gwt.logging.Logging" /> -->
|
||||||
|
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
|
||||||
|
|
||||||
|
<inherits name="com.google.gwt.resources.Resources" />
|
||||||
|
|
||||||
|
|
||||||
|
<inherits name='org.gcube.portlets.widgets.sessionchecker.SessionChecker' />
|
||||||
|
|
||||||
|
<!-- Specify the app entry point class. -->
|
||||||
|
<entry-point class='org.gcube.portlets.user.statisticalalgorithmsimporter.client.StatAlgoImporter' />
|
||||||
|
|
||||||
|
<!-- <set-configuration-property name="locale.cookie" value="AMLangCookie"
|
||||||
|
/> <set-configuration-property name="locale.queryparam" value="AMLang" />
|
||||||
|
<set-configuration-property name="locale.usemeta" value="Y" /> <set-configuration-property
|
||||||
|
name="locale.useragent" value="Y" /> <set-configuration-property name="locale.searchorder"
|
||||||
|
value="cookie,queryparam,meta,useragent" /> <extend-property name="locale"
|
||||||
|
values="en" /> <extend-property name="locale" values="it" /> <extend-property
|
||||||
|
name="locale" values="es" /> <set-property name="locale" value="en, it, es"
|
||||||
|
/> <set-property-fallback name="locale" value="en" /> -->
|
||||||
|
|
||||||
|
<!-- <set-property name="log_DivLogger" value="ENABLED" /> <set-property
|
||||||
|
name="log_ConsoleLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
|
||||||
|
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
|
||||||
|
/> -->
|
||||||
|
|
||||||
|
|
||||||
|
<set-property name="log_DivLogger" value="DISABLED" />
|
||||||
|
<set-property name="log_ConsoleLogger" value="DISABLED" />
|
||||||
|
<set-property name="log_GWTLogger" value="DISABLED" />
|
||||||
|
<set-property name="log_SystemLogger" value="DISABLED" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Specify the paths for translatable code -->
|
||||||
|
<source path='client' />
|
||||||
|
<source path='shared' />
|
||||||
|
|
||||||
|
</module>
|
|
@ -0,0 +1,7 @@
|
||||||
|
@CHARSET "UTF-8";
|
||||||
|
|
||||||
|
|
||||||
|
.ribbon {
|
||||||
|
line-height: 13px;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 615 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.3 KiB |
|
@ -0,0 +1,4 @@
|
||||||
|
storage = Storage
|
||||||
|
job = Job
|
||||||
|
task = Task
|
||||||
|
service = Service
|
|
@ -0,0 +1,4 @@
|
||||||
|
storage = Storage
|
||||||
|
job = Job
|
||||||
|
task = Task
|
||||||
|
service = Service
|
|
@ -0,0 +1,4 @@
|
||||||
|
storage = Storage
|
||||||
|
job = Job
|
||||||
|
task = Task
|
||||||
|
service = Service
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module rename-to='statalgoimporter'>
|
||||||
|
|
||||||
|
<inherits name='com.google.gwt.user.User' />
|
||||||
|
<inherits name="com.google.gwt.http.HTTP" />
|
||||||
|
|
||||||
|
<inherits name="com.google.gwt.resources.Resources" />
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <inherits name="com.google.gwt.i18n.I18N" /> -->
|
||||||
|
|
||||||
|
<!-- <inherits name='com.extjs.gxt.ui.GXT' /> -->
|
||||||
|
<inherits name='com.sencha.gxt.ui.GXT' />
|
||||||
|
|
||||||
|
|
||||||
|
<!-- GXT Theme -->
|
||||||
|
<!-- <inherits name='com.sencha.gxt.theme.blue.Blue' /> -->
|
||||||
|
<!-- <inherits name='com.sencha.gxt.theme.gray.Gray' /> -->
|
||||||
|
<!-- Be sure to include Neptunes gxt-theme-neptune.jar in the classpath -->
|
||||||
|
<inherits name='com.sencha.gxt.theme.neptune.Theme' />
|
||||||
|
|
||||||
|
<!-- <inherits name="com.google.gwt.logging.Logging" /> -->
|
||||||
|
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
|
||||||
|
|
||||||
|
<!-- Debug CSS style -->
|
||||||
|
<set-configuration-property name="CssResource.style"
|
||||||
|
value="pretty" />
|
||||||
|
|
||||||
|
<inherits name='org.gcube.portlets.widgets.sessionchecker.SessionChecker' />
|
||||||
|
|
||||||
|
<!-- Specify the app entry point class. -->
|
||||||
|
<entry-point
|
||||||
|
class='org.gcube.portlets.user.statisticalalgorithmsimporter.client.StatAlgoImporter' />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <set-configuration-property name="locale.cookie" value="AMLangCookie"
|
||||||
|
/> <set-configuration-property name="locale.queryparam" value="AMLang" />
|
||||||
|
<set-configuration-property name="locale.usemeta" value="Y" /> <set-configuration-property
|
||||||
|
name="locale.useragent" value="Y" /> <set-configuration-property name="locale.searchorder"
|
||||||
|
value="cookie,queryparam,meta,useragent" /> <extend-property name="locale"
|
||||||
|
values="en" /> <extend-property name="locale" values="it" /> <extend-property
|
||||||
|
name="locale" values="es" /> <set-property name="locale" value="en, it, es"
|
||||||
|
/> <set-property-fallback name="locale" value="en" /> -->
|
||||||
|
|
||||||
|
|
||||||
|
<set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property
|
||||||
|
name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
|
||||||
|
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
|
||||||
|
/>
|
||||||
|
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="ENABLED"
|
||||||
|
/> -->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<set-property name="log_ConsoleLogger" value="DISABLED" />
|
||||||
|
<set-property name="log_DivLogger" value="DISABLED" />
|
||||||
|
<set-property name="log_GWTLogger" value="DISABLED" />
|
||||||
|
<set-property name="log_SystemLogger" value="DISABLED" /> -->
|
||||||
|
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="DISABLED"
|
||||||
|
/> -->
|
||||||
|
|
||||||
|
<!-- Specify the paths for translatable code -->
|
||||||
|
<source path='client' />
|
||||||
|
<source path='shared' />
|
||||||
|
|
||||||
|
</module>
|
|
@ -0,0 +1,7 @@
|
||||||
|
/** Add css rules here for your application. */
|
||||||
|
/*table {
|
||||||
|
border-spacing: 1px !important;
|
||||||
|
top: 0px !important;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
<!doctype html>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
|
|
||||||
|
<!-- -->
|
||||||
|
<!-- Consider inlining CSS to reduce the number of requested files -->
|
||||||
|
<!-- -->
|
||||||
|
<link rel="stylesheet" type="text/css"
|
||||||
|
href="statalgoimporter/reset.css" />
|
||||||
|
|
||||||
|
<!-- -->
|
||||||
|
<!-- Any title is fine -->
|
||||||
|
<!-- -->
|
||||||
|
<title>Statistical Algorithms Importer</title>
|
||||||
|
|
||||||
|
<!-- -->
|
||||||
|
<!-- This script loads your compiled module. -->
|
||||||
|
<!-- If you add any GWT meta tags, they must -->
|
||||||
|
<!-- be added before this line. -->
|
||||||
|
<!-- -->
|
||||||
|
<link rel="stylesheet" type="text/css" href="gxt/css/gxt-all.css" />
|
||||||
|
<link type="text/css" rel="stylesheet" href="StatAlgoImporter.css">
|
||||||
|
<script type="text/javascript"
|
||||||
|
src="statalgoimporter/statalgoimporter.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>
|
||||||
|
<!-- <div id="StatAlgoImporterPortlet" style="width: 100%; height: 100%">
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,19 @@
|
||||||
|
log4j.rootCategory=TRACE, FILE, CONSOLE
|
||||||
|
|
||||||
|
# Direct log messages to a log file
|
||||||
|
log4j.appender.FILE=org.apache.log4j.RollingFileAppender
|
||||||
|
#Redirect to Tomcat logs folder
|
||||||
|
#log4j.appender.FILE.File=C:\\logging.log
|
||||||
|
log4j.appender.FILE.File=${catalina.home}/webapps/statistical-runner/logs/StatisticalRunnerLog4j.log
|
||||||
|
log4j.appender.FILE.MaxFileSize=10MB
|
||||||
|
log4j.appender.FILE.MaxBackupIndex=10
|
||||||
|
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
|
||||||
|
log4j.appender.FILE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}:%L] %m%n
|
||||||
|
|
||||||
|
# Console log
|
||||||
|
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
|
||||||
|
log4j.appender.CONSOLE.Target=System.out
|
||||||
|
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
|
||||||
|
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}:%L] %m%n
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
|
||||||
|
<!-- Insert the current time formatted as "yyyyMMdd'T'HHmmss" under the
|
||||||
|
key "bySecond" into the logger context. This value will be available to all
|
||||||
|
subsequent configuration elements. -->
|
||||||
|
<timestamp key="byDay" datePattern="yyyyMMdd" />
|
||||||
|
|
||||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||||
|
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||||
|
</Pattern>
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||||
|
<file>${CATALINA_HOME}/webapps/statistical-runner/logs/StatisticalRunnerLogBack.log
|
||||||
|
</file>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- daily rollover -->
|
||||||
|
<fileNamePattern>StatisticalRunner.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
|
||||||
|
<!-- keep 30 days' worth of history -->
|
||||||
|
<maxHistory>30</maxHistory>
|
||||||
|
|
||||||
|
</rollingPolicy>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
|
||||||
|
<layout class="ch.qos.logback.classic.html.HTMLLayout">
|
||||||
|
<pattern>%d%thread%-5level%logger%msg</pattern>
|
||||||
|
</layout>
|
||||||
|
</encoder> -->
|
||||||
|
|
||||||
|
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d [%thread] %-5level %logger{35} - %msg%n
|
||||||
|
</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root level="TRACE">
|
||||||
|
<appender-ref ref="STDOUT" />
|
||||||
|
<appender-ref ref="FILE" />
|
||||||
|
</root>
|
||||||
|
</configuration>
|
|
@ -0,0 +1 @@
|
||||||
|
debug.com.sun.portal.level=WARNING
|
|
@ -0,0 +1,17 @@
|
||||||
|
<%@page contentType="text/html"%>
|
||||||
|
<%@page pageEncoding="UTF-8"%>
|
||||||
|
|
||||||
|
<!-- -->
|
||||||
|
<!-- The module reference below is the link -->
|
||||||
|
<!-- between html and your Web Toolkit module -->
|
||||||
|
<link rel="stylesheet" href="<%= request.getContextPath()%>/statalgoimporter/reset.css" type="text/css"/>
|
||||||
|
<!-- <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/gxt/css/gxt-all.css" /> -->
|
||||||
|
<link rel="stylesheet" href="<%= request.getContextPath()%>/StatAlgoImporter.css" type="text/css">
|
||||||
|
|
||||||
|
<script src='<%=request.getContextPath()%>/statalgoimporter/statalgoimporter.nocache.js'></script>
|
||||||
|
|
||||||
|
|
||||||
|
<div id="StatisticalRunnerPortlet" style="width: 100%; height: 100%">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<display>
|
||||||
|
<category name="gCube Applications">
|
||||||
|
<portlet id="StatisticalRunner" />
|
||||||
|
</category>
|
||||||
|
</display>
|
|
@ -0,0 +1,9 @@
|
||||||
|
name=StatisticalRunner
|
||||||
|
module-group-id=liferay
|
||||||
|
module-incremental-version=1
|
||||||
|
tags=
|
||||||
|
short-description=
|
||||||
|
change-log=
|
||||||
|
page-url=http://www.d4science.eu
|
||||||
|
author=D4Science EU
|
||||||
|
licenses=
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 5.2.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_5_2_0.dtd">
|
||||||
|
|
||||||
|
<liferay-portlet-app>
|
||||||
|
<portlet>
|
||||||
|
<portlet-name>StatisticalRunner</portlet-name>
|
||||||
|
<icon>/icon.png</icon>
|
||||||
|
<layout-cacheable>false</layout-cacheable>
|
||||||
|
<instanceable>false</instanceable>
|
||||||
|
<ajaxable>false</ajaxable>
|
||||||
|
</portlet>
|
||||||
|
</liferay-portlet-app>
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<portlet-app xmlns='http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd' version='2.0'>
|
||||||
|
<portlet>
|
||||||
|
<description>StatisticalRunner</description>
|
||||||
|
<portlet-name>StatisticalRunner</portlet-name>
|
||||||
|
<display-name>StatisticalRunner</display-name>
|
||||||
|
<portlet-class>org.gcube.portlets.user.statisticalrunner.server.portlet.StatisticalRunnerPortlet</portlet-class>
|
||||||
|
<expiration-cache>0</expiration-cache>
|
||||||
|
<supports>
|
||||||
|
<mime-type>text/html</mime-type>
|
||||||
|
<portlet-mode>view</portlet-mode>
|
||||||
|
</supports>
|
||||||
|
<portlet-info>
|
||||||
|
<title>StatisticalRunner</title>
|
||||||
|
<short-title>StatisticalRunner</short-title>
|
||||||
|
</portlet-info>
|
||||||
|
</portlet>
|
||||||
|
</portlet-app>
|
|
@ -0,0 +1,65 @@
|
||||||
|
<?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 -->
|
||||||
|
<!-- JUnit -->
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>jUnitHostImpl</servlet-name>
|
||||||
|
<servlet-class>com.google.gwt.junit.server.JUnitHostImpl</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Check Session Expired -->
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>checkServlet</servlet-name>
|
||||||
|
<servlet-class>org.gcube.portlets.widgets.sessionchecker.server.SessionCheckerServiceImpl</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
|
||||||
|
<!-- StatisticalAlgoImporterService -->
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>StatAlgoImporterService</servlet-name>
|
||||||
|
<servlet-class>org.gcube.portlets.user.statisticalalgorithmsimporter.server.StatAlgoImporterServiceImpl</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
|
||||||
|
<!-- LocalUploadServlet -->
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>LocalUploadServlet</servlet-name>
|
||||||
|
<servlet-class>org.gcube.portlets.user.statisticalalgorithmsimporter.server.LocalUploadServlet</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Servlets Mapping -->
|
||||||
|
<!-- JUnit -->
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>jUnitHostImpl</servlet-name>
|
||||||
|
<url-pattern>/statalgoimporter/junithost/*</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<!-- Check Session Expired -->
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>checkServlet</servlet-name>
|
||||||
|
<url-pattern>/statalgoimporter/checksession</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<!--StatAlgoImporterService -->
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>StatAlgoImporterService</servlet-name>
|
||||||
|
<url-pattern>/statalgoimporter/statalgoimporterservice</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<!--StatRunnerService -->
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>LocalUploadServlet</servlet-name>
|
||||||
|
<url-pattern>/statalgoimporter/LocalUploadServlet</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Default page to serve -->
|
||||||
|
<welcome-file-list>
|
||||||
|
<welcome-file>StatAlgoImporter.html</welcome-file>
|
||||||
|
</welcome-file-list>
|
||||||
|
</web-app>
|