master
Massimiliano Assante 2 years ago
commit 32728cd641

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" output="target/fileupload-progress-bar-2.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="resources/|java/" including="**/*.java" kind="src" path="src/test"/>
<classpathentry excluding="**" kind="src" output="target/fileupload-progress-bar-2.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<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"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<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"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/fileupload-progress-bar-2.0.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

1
.gitignore vendored

@ -0,0 +1 @@
/target/

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>fileupload-progress-bar</name>
<comment>fileupload-progress-bar project</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</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.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</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,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/webapp" />
<classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER" />
<classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true" />
</attributes>
</classpathentry>
<classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary" />
<classpathentry kind="output" path="" />
</classpath>

@ -0,0 +1,3 @@
#Thu Jun 16 10:18:26 CEST 2011
eclipse.preferences.version=1
filesCopiedToWebInfLib=

@ -0,0 +1,5 @@
eclipse.preferences.version=1
jarsExcludedFromWebInfLib=
lastWarOutDir=/home/costantino/workspace/fileupload-progress-bar/target/fileupload-progress-bar-1.3.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

@ -0,0 +1,5 @@
#Thu Jun 16 11:14:17 CEST 2011
eclipse.preferences.version=1
entryPointModules=
filesCopiedToWebInfLib=gwt-servlet.jar
gwtCompileSettings=PGd3dC1jb21waWxlLXNldHRpbmdzPjxsb2ctbGV2ZWw+SU5GTzwvbG9nLWxldmVsPjxvdXRwdXQtc3R5bGU+T0JGVVNDQVRFRDwvb3V0cHV0LXN0eWxlPjxleHRyYS1hcmdzPjwhW0NEQVRBWy13YXIgc3JjL21haW4vd2ViYXBwXV0+PC9leHRyYS1hcmdzPjx2bS1hcmdzPjwhW0NEQVRBWy1YbXg1MTJtXV0+PC92bS1hcmdzPjxlbnRyeS1wb2ludC1tb2R1bGU+Y29tLmNvbXBhbnkuU29tZU1vZHVsZTwvZW50cnktcG9pbnQtbW9kdWxlPjwvZ3d0LWNvbXBpbGUtc2V0dGluZ3M+

@ -0,0 +1,6 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8

@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8

@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="${module}">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="fileupload-progress-bar"/>
</wb-module>
</project-modules>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="jst.web" version="2.3"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="java" version="1.7"/>
</faceted-project>

@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.baseBrowserLibrary

@ -0,0 +1,2 @@
disabled=06target
eclipse.preferences.version=1

@ -0,0 +1,9 @@
#Thu Sep 02 10:42:12 CEST 2010
activeProfiles=
eclipse.preferences.version=1
fullBuildGoals=process-test-resources
includeModules=false
resolveWorkspaceProjects=true
resourceFilterGoals=process-resources resources\\:testResources
skipCompilerPlugin=true
version=1

@ -0,0 +1,27 @@
# Changelog for File Upload Progress bar widget
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v2.0.0-SNAPSHOT] - 2022-06-15
- Ported to git
- Ported to GWT 2.9
## [v1.4.1] - 2016-01-27
- added support to drag and drop mechanism in share-updates
## [v1.2.0] - 014-07-17"
- Fixed upload File fails if file name contains chars like (à ù ò)
## [v1.1.0] - 2014-04-22
- Fixed gets stuck after 4/5 uploads in a row bug
- Fixed gets stuck if file size greater than 2GB
## [v1.0.0] - 2014-01-30
- First release

@ -0,0 +1,26 @@
# Acknowledgments
The projects leading to this software have received funding from a series of European Union programmes including:
- the Sixth Framework Programme for Research and Technological Development
- [DILIGENT](https://cordis.europa.eu/project/id/004260) (grant no. 004260).
- the Seventh Framework Programme for research, technological development and demonstration
- [D4Science](https://cordis.europa.eu/project/id/212488) (grant no. 212488);
- [D4Science-II](https://cordis.europa.eu/project/id/239019) (grant no.239019);
- [ENVRI](https://cordis.europa.eu/project/id/283465) (grant no. 283465);
- [iMarine](https://cordis.europa.eu/project/id/283644) (grant no. 283644);
- [EUBrazilOpenBio](https://cordis.europa.eu/project/id/288754) (grant no. 288754).
- the H2020 research and innovation programme
- [SoBigData](https://cordis.europa.eu/project/id/654024) (grant no. 654024);
- [PARTHENOS](https://cordis.europa.eu/project/id/654119) (grant no. 654119);
- [EGI-Engage](https://cordis.europa.eu/project/id/654142) (grant no. 654142);
- [ENVRI PLUS](https://cordis.europa.eu/project/id/654182) (grant no. 654182);
- [BlueBRIDGE](https://cordis.europa.eu/project/id/675680) (grant no. 675680);
- [PerformFISH](https://cordis.europa.eu/project/id/727610) (grant no. 727610);
- [AGINFRA PLUS](https://cordis.europa.eu/project/id/731001) (grant no. 731001);
- [DESIRA](https://cordis.europa.eu/project/id/818194) (grant no. 818194);
- [ARIADNEplus](https://cordis.europa.eu/project/id/823914) (grant no. 823914);
- [RISIS 2](https://cordis.europa.eu/project/id/824091) (grant no. 824091);
- [EOSC-Pillar](https://cordis.europa.eu/project/id/857650) (grant no. 857650);
- [Blue Cloud](https://cordis.europa.eu/project/id/862409) (grant no. 862409);
- [SoBigData-PlusPlus](https://cordis.europa.eu/project/id/871042) (grant no. 871042);

@ -0,0 +1,311 @@
#European Union Public Licence V.1.1
##*EUPL © the European Community 2007*
This **European Union Public Licence** (the **“EUPL”**) applies to the Work or Software
(as defined below) which is provided under the terms of this Licence. Any use of
the Work, other than as authorised under this Licence is prohibited (to the
extent such use is covered by a right of the copyright holder of the Work).
The Original Work is provided under the terms of this Licence when the Licensor
(as defined below) has placed the following notice immediately following the
copyright notice for the Original Work:
**Licensed under the EUPL V.1.1**
or has expressed by any other mean his willingness to license under the EUPL.
##1. Definitions
In this Licence, the following terms have the following meaning:
- The Licence: this Licence.
- The Original Work or the Software: the software distributed and/or
communicated by the Licensor under this Licence, available as Source Code and
also as Executable Code as the case may be.
- Derivative Works: the works or software that could be created by the Licensee,
based upon the Original Work or modifications thereof. This Licence does not
define the extent of modification or dependence on the Original Work required
in order to classify a work as a Derivative Work; this extent is determined by
copyright law applicable in the country mentioned in Article 15.
- The Work: the Original Work and/or its Derivative Works.
- The Source Code: the human-readable form of the Work which is the most
convenient for people to study and modify.
- The Executable Code: any code which has generally been compiled and which is
meant to be interpreted by a computer as a program.
- The Licensor: the natural or legal person that distributes and/or communicates
the Work under the Licence.
- Contributor(s): any natural or legal person who modifies the Work under the
Licence, or otherwise contributes to the creation of a Derivative Work.
- The Licensee or “You”: any natural or legal person who makes any usage of the
Software under the terms of the Licence.
- Distribution and/or Communication: any act of selling, giving, lending,
renting, distributing, communicating, transmitting, or otherwise making
available, on-line or off-line, copies of the Work or providing access to its
essential functionalities at the disposal of any other natural or legal
person.
##2. Scope of the rights granted by the Licence
The Licensor hereby grants You a world-wide, royalty-free, non-exclusive,
sub-licensable licence to do the following, for the duration of copyright vested
in the Original Work:
- use the Work in any circumstance and for all usage, reproduce the Work, modify
- the Original Work, and make Derivative Works based upon the Work, communicate
- to the public, including the right to make available or display the Work or
- copies thereof to the public and perform publicly, as the case may be, the
- Work, distribute the Work or copies thereof, lend and rent the Work or copies
- thereof, sub-license rights in the Work or copies thereof.
Those rights can be exercised on any media, supports and formats, whether now
known or later invented, as far as the applicable law permits so.
In the countries where moral rights apply, the Licensor waives his right to
exercise his moral right to the extent allowed by law in order to make effective
the licence of the economic rights here above listed.
The Licensor grants to the Licensee royalty-free, non exclusive usage rights to
any patents held by the Licensor, to the extent necessary to make use of the
rights granted on the Work under this Licence.
##3. Communication of the Source Code
The Licensor may provide the Work either in its Source Code form, or as
Executable Code. If the Work is provided as Executable Code, the Licensor
provides in addition a machine-readable copy of the Source Code of the Work
along with each copy of the Work that the Licensor distributes or indicates, in
a notice following the copyright notice attached to the Work, a repository where
the Source Code is easily and freely accessible for as long as the Licensor
continues to distribute and/or communicate the Work.
##4. Limitations on copyright
Nothing in this Licence is intended to deprive the Licensee of the benefits from
any exception or limitation to the exclusive rights of the rights owners in the
Original Work or Software, of the exhaustion of those rights or of other
applicable limitations thereto.
##5. Obligations of the Licensee
The grant of the rights mentioned above is subject to some restrictions and
obligations imposed on the Licensee. Those obligations are the following:
Attribution right: the Licensee shall keep intact all copyright, patent or
trademarks notices and all notices that refer to the Licence and to the
disclaimer of warranties. The Licensee must include a copy of such notices and a
copy of the Licence with every copy of the Work he/she distributes and/or
communicates. The Licensee must cause any Derivative Work to carry prominent
notices stating that the Work has been modified and the date of modification.
Copyleft clause: If the Licensee distributes and/or communicates copies of the
Original Works or Derivative Works based upon the Original Work, this
Distribution and/or Communication will be done under the terms of this Licence
or of a later version of this Licence unless the Original Work is expressly
distributed only under this version of the Licence. The Licensee (becoming
Licensor) cannot offer or impose any additional terms or conditions on the Work
or Derivative Work that alter or restrict the terms of the Licence.
Compatibility clause: If the Licensee Distributes and/or Communicates Derivative
Works or copies thereof based upon both the Original Work and another work
licensed under a Compatible Licence, this Distribution and/or Communication can
be done under the terms of this Compatible Licence. For the sake of this clause,
“Compatible Licence” refers to the licences listed in the appendix attached to
this Licence. Should the Licensees obligations under the Compatible Licence
conflict with his/her obligations under this Licence, the obligations of the
Compatible Licence shall prevail.
Provision of Source Code: When distributing and/or communicating copies of the
Work, the Licensee will provide a machine-readable copy of the Source Code or
indicate a repository where this Source will be easily and freely available for
as long as the Licensee continues to distribute and/or communicate the Work.
Legal Protection: This Licence does not grant permission to use the trade names,
trademarks, service marks, or names of the Licensor, except as required for
reasonable and customary use in describing the origin of the Work and
reproducing the content of the copyright notice.
##6. Chain of Authorship
The original Licensor warrants that the copyright in the Original Work granted
hereunder is owned by him/her or licensed to him/her and that he/she has the
power and authority to grant the Licence.
Each Contributor warrants that the copyright in the modifications he/she brings
to the Work are owned by him/her or licensed to him/her and that he/she has the
power and authority to grant the Licence.
Each time You accept the Licence, the original Licensor and subsequent
Contributors grant You a licence to their contributions to the Work, under the
terms of this Licence.
##7. Disclaimer of Warranty
The Work is a work in progress, which is continuously improved by numerous
contributors. It is not a finished work and may therefore contain defects or
“bugs” inherent to this type of software development.
For the above reason, the Work is provided under the Licence on an “as is” basis
and without warranties of any kind concerning the Work, including without
limitation merchantability, fitness for a particular purpose, absence of defects
or errors, accuracy, non-infringement of intellectual property rights other than
copyright as stated in Article 6 of this Licence.
This disclaimer of warranty is an essential part of the Licence and a condition
for the grant of any rights to the Work.
##8. Disclaimer of Liability
Except in the cases of wilful misconduct or damages directly caused to natural
persons, the Licensor will in no event be liable for any direct or indirect,
material or moral, damages of any kind, arising out of the Licence or of the use
of the Work, including without limitation, damages for loss of goodwill, work
stoppage, computer failure or malfunction, loss of data or any commercial
damage, even if the Licensor has been advised of the possibility of such
damage. However, the Licensor will be liable under statutory product liability
laws as far such laws apply to the Work.
##9. Additional agreements
While distributing the Original Work or Derivative Works, You may choose to
conclude an additional agreement to offer, and charge a fee for, acceptance of
support, warranty, indemnity, or other liability obligations and/or services
consistent with this Licence. However, in accepting such obligations, You may
act only on your own behalf and on your sole responsibility, not on behalf of
the original Licensor or any other Contributor, and only if You agree to
indemnify, defend, and hold each Contributor harmless for any liability incurred
by, or claims asserted against such Contributor by the fact You have accepted
any such warranty or additional liability.
##10. Acceptance of the Licence
The provisions of this Licence can be accepted by clicking on an icon “I agree”
placed under the bottom of a window displaying the text of this Licence or by
affirming consent in any other similar way, in accordance with the rules of
applicable law. Clicking on that icon indicates your clear and irrevocable
acceptance of this Licence and all of its terms and conditions.
Similarly, you irrevocably accept this Licence and all of its terms and
conditions by exercising any rights granted to You by Article 2 of this Licence,
such as the use of the Work, the creation by You of a Derivative Work or the
Distribution and/or Communication by You of the Work or copies thereof.
##11. Information to the public
In case of any Distribution and/or Communication of the Work by means of
electronic communication by You (for example, by offering to download the Work
from a remote location) the distribution channel or media (for example, a
website) must at least provide to the public the information requested by the
applicable law regarding the Licensor, the Licence and the way it may be
accessible, concluded, stored and reproduced by the Licensee.
##12. Termination of the Licence
The Licence and the rights granted hereunder will terminate automatically upon
any breach by the Licensee of the terms of the Licence.
Such a termination will not terminate the licences of any person who has
received the Work from the Licensee under the Licence, provided such persons
remain in full compliance with the Licence.
##13. Miscellaneous
Without prejudice of Article 9 above, the Licence represents the complete
agreement between the Parties as to the Work licensed hereunder.
If any provision of the Licence is invalid or unenforceable under applicable
law, this will not affect the validity or enforceability of the Licence as a
whole. Such provision will be construed and/or reformed so as necessary to make
it valid and enforceable.
The European Commission may publish other linguistic versions and/or new
versions of this Licence, so far this is required and reasonable, without
reducing the scope of the rights granted by the Licence. New versions of the
Licence will be published with a unique version number.
All linguistic versions of this Licence, approved by the European Commission,
have identical value. Parties can take advantage of the linguistic version of
their choice.
##14. Jurisdiction
Any litigation resulting from the interpretation of this License, arising
between the European Commission, as a Licensor, and any Licensee, will be
subject to the jurisdiction of the Court of Justice of the European Communities,
as laid down in article 238 of the Treaty establishing the European Community.
Any litigation arising between Parties, other than the European Commission, and
resulting from the interpretation of this License, will be subject to the
exclusive jurisdiction of the competent court where the Licensor resides or
conducts its primary business.
##15. Applicable Law
This Licence shall be governed by the law of the European Union country where
the Licensor resides or has his registered office.
This licence shall be governed by the Belgian law if:
- a litigation arises between the European Commission, as a Licensor, and any
- Licensee; the Licensor, other than the European Commission, has no residence
- or registered office inside a European Union country.
---
##Appendix
**“Compatible Licences”** according to article 5 EUPL are:
- GNU General Public License (GNU GPL) v. 2
- Open Software License (OSL) v. 2.1, v. 3.0
- Common Public License v. 1.0
- Eclipse Public License v. 1.0
- Cecill v. 2.0

@ -0,0 +1,146 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId>
<version>1.1.0</version>
<relativePath />
</parent>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>fileupload-progress-bar</artifactId>
<packaging>jar</packaging>
<version>2.0.0-SNAPSHOT</version>
<name>gCube File Upload Progress Bar Widget</name>
<description>
gCube File Upload Progress Bar Widget
</description>
<scm>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection>
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</developerConnection>
<url>https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</url>
</scm>
<properties>
<!-- Convenience property to set the GWT version -->
<gwtVersion>2.9.0</gwtVersion>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>3.6.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwtVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwtVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>${gwtVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>gcube-widgets</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<scope>compile</scope>
</dependency>
<!-- Liferay Deps -->
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>
<build>
<!-- Generate compiled stuff in the folder used for developing mode -->
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
<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>
<goals>
<goal>compile</goal>
<!-- <goal>test</goal> -->
</goals>
</execution>
</executions>
<!-- Plugin configuration. There are many available options, see gwt-maven-plugin
documentation at codehaus.org -->
<configuration>
<runTarget>FileUpload.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='FileUpload'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<!-- inherits GCUBE Widgets -->
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' />
<!-- To Comment out -->
<!-- <set-property name="user.agent" value="safari,gecko1_8,ie9" /> -->
<!-- Specify the app entry point class. -->
<entry-point class='org.gcube.portlets.widgets.fileupload.client.FileUpload' />
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
</module>

@ -0,0 +1,96 @@
package org.gcube.portlets.widgets.fileupload.client;
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadCompleteEvent;
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadCompleteEventHandler;
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadSelectedEvent;
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadSelectedEventHandler;
import org.gcube.portlets.widgets.fileupload.client.view.UploadProgressDialog;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;
/**
*
* @author Massimiliano Assante, ISTI-CNR
*
* Use this widget to display a dialog containing the possibility to upload a file on server with an actual progress of the current uploaded file in percentage;
* uncomment //showSample() in the onModuleLoad() to see it working
*
* To get to know which file was uploaded listen for the {@link FileUploadCompleteEvent} on the {@link HandlerManager} instance you pass to this widget.
*
*/
public class FileUpload implements EntryPoint {
@Override
public void onModuleLoad() {
// Button showDlg = new Button("Open Dialog");
// showDlg.addClickHandler(new ClickHandler() {
// @Override
// public void onClick(ClickEvent event) {
// showSample();
// }
// });
// RootPanel.get().add(showDlg);
}
private void showSample() {
HandlerManager eventBus = new HandlerManager(null);
final UploadProgressDialog dlg = new UploadProgressDialog("Share File", eventBus, true);
dlg.center();
dlg.show();
eventBus.addHandler(FileUploadSelectedEvent.TYPE, new FileUploadSelectedEventHandler() {
@Override
public void onFileSelected(FileUploadSelectedEvent event) {
String fileName = event.getSelectedFileName();
GWT.log("selected file name: " + fileName);
//pretend you do sth with the uploaded file, wait 3 seconds
Timer t = new Timer() {
@Override
public void run() {
try {
dlg.submitForm();
} catch (Exception e) {
e.printStackTrace();
}
}
};
t.schedule(1000);
}
});
/**
* get the uploaded file result
*/
eventBus.addHandler(FileUploadCompleteEvent.TYPE, new FileUploadCompleteEventHandler() {
@Override
public void onUploadComplete(FileUploadCompleteEvent event) {
//the filename and its path on server are returned to the client
String fileName = event.getUploadedFileInfo().getFilename();
String absolutePathOnServer = event.getUploadedFileInfo().getAbsolutePath();
GWT.log(fileName + " uploaded on Server here: " + absolutePathOnServer);
//pretend you do sth with the uploaded file, wait 3 seconds
Timer t = new Timer() {
@Override
public void run() {
dlg.showRegisteringResult(true); //or false if an error occurred
}
};
t.schedule(3000);
}
});
}
}

@ -0,0 +1,16 @@
package org.gcube.portlets.widgets.fileupload.client;
import java.util.List;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import org.gcube.portlets.widgets.fileupload.shared.event.*;
import org.gcube.portlets.widgets.fileupload.shared.dto.*;
@RemoteServiceRelativePath("uploadprogress")
public interface UploadProgressService extends RemoteService {
void initialise();
List<Event> getEvents();
}

@ -0,0 +1,12 @@
package org.gcube.portlets.widgets.fileupload.client;
import java.util.List;
import org.gcube.portlets.widgets.fileupload.shared.event.Event;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface UploadProgressServiceAsync {
void initialise(AsyncCallback<Void> asyncCallback);
void getEvents(AsyncCallback<List<Event>> asyncCallback);
}

@ -0,0 +1,95 @@
@external progressContainer, progressBarContainer, FileSubmit, bar-container, progress, blue, myBackground;
.progressContainer {
text-align: center;
width: 100%;
margin: 0px;
}
.progressBarContainer {
text-align: center;
width: 100%;
margin: 10px 0 0 -3px;
}
.FileSubmit input {
font-family: 'Lucida Grande', Verdana, 'Bitstream Vera Sans', Arial,
sans-serif;
font-size: 13px;
color: #464646;
border: 1px solid #BBB;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
background-color: #F2F2F2;
cursor: pointer;
cursor: hand;
margin-top: 10px;
padding: 10px 15px;
width: 350px;
}
/* Progress Bar Styles */
.bar-container {
font: 13px/20px 'Lucida Grande', Tahoma, Verdana, sans-serif;
color: #404040;
margin: 0px auto;
width: 382px;
}
.bar-container > div {
margin: 2px;
}
.progress {
height: 25px;
border-radius: 6px;
}
.progress > span {
position: relative;
float: left;
margin: 0 -1px;
min-width: 30px;
height: 18px;
line-height: 16px;
text-align: right;
background-color: #DDD;
border: 1px solid;
border-color: #FFF;
border-radius: 6px;
}
.progress>span>span {
padding: 0 8px;
font-size: 11px;
font-weight: bold;
color: #404040;
color: rgba(0, 0, 0, 0.7);
text-shadow: 0 1px rgba(255, 255, 255, 0.4);
}
@sprite .myBackground>span:before {
gwt-image: "progressTexture";
other: repeat-x;
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 1;
height: 18px;
border-radius: 6px;
}
.progress .blue {
background: #5aaadb;
border-color: #7bbbe2;
background-image: -webkit-linear-gradient(top, #aed5ed, #7bbbe2 70%, #5aaadb);
background-image: -moz-linear-gradient(top, #aed5ed, #7bbbe2 70%, #5aaadb);
background-image: -o-linear-gradient(top, #aed5ed, #7bbbe2 70%, #5aaadb);
background-image: linear-gradient(to bottom, #aed5ed, #7bbbe2 70%, #5aaadb);
}

@ -0,0 +1,95 @@
@external progressContainer, progressBarContainer, FileSubmit, bar-container, progress, blue, myBackground;
.progressContainer {
text-align: center;
width: 100%;
margin: 0px;
}
.progressBarContainer {
text-align: center;
width: 100%;
margin: 10px 0 0 -3px;
}
.FileSubmit input {
font-family: 'Lucida Grande', Verdana, 'Bitstream Vera Sans', Arial,
sans-serif;
font-size: 13px;
color: #464646;
border: 1px solid #BBB;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
background-color: #F2F2F2;
cursor: pointer;
cursor: hand;
margin-top: 10px;
padding: 10px 15px;
width: 565px;
}
/* Progress Bar Styles */
.bar-container {
font: 13px/20px 'Lucida Grande', Tahoma, Verdana, sans-serif;
color: #404040;
margin: 1px;
width: 100%;
}
.bar-container > div {
margin: 2px;
}
.progress {
height: 25px;
border-radius: 6px;
}
.progress > span {
position: relative;
float: left;
margin: 0 -1px;
min-width: 30px;
height: 18px;
line-height: 16px;
text-align: right;
background-color: #DDD;
border: 1px solid;
border-color: #FFF;
border-radius: 6px;
}
.progress>span>span {
padding: 0 8px;
font-size: 11px;
font-weight: bold;
color: #404040;
color: rgba(0, 0, 0, 0.7);
text-shadow: 0 1px rgba(255, 255, 255, 0.4);
}
@sprite .myBackground>span:before {
gwt-image: "progressTexture";
other: repeat-x;
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 1;
height: 18px;
border-radius: 6px;
}
.progress .blue {
background: #5aaadb;
border-color: #7bbbe2;
background-image: -webkit-linear-gradient(top, #aed5ed, #7bbbe2 70%, #5aaadb);
background-image: -moz-linear-gradient(top, #aed5ed, #7bbbe2 70%, #5aaadb);
background-image: -o-linear-gradient(top, #aed5ed, #7bbbe2 70%, #5aaadb);
background-image: linear-gradient(to bottom, #aed5ed, #7bbbe2 70%, #5aaadb);
}

@ -0,0 +1,36 @@
package org.gcube.portlets.widgets.fileupload.client.bundle;
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.resources.client.ImageResource.ImageOptions;
import com.google.gwt.resources.client.ImageResource.RepeatStyle;
public interface ProgressBarCssAndImages extends ClientBundle {
public static final ProgressBarCssAndImages INSTANCE = GWT.create(ProgressBarCssAndImages.class);
@Source("FileUpload.css")
public CssResource css();
@Source("PanelFileUpload.css")
public CssResource panelCss();
@Source("spinning.gif")
ImageResource spinner();
@Source("error.png")
ImageResource error();
@Source("ok.png")
ImageResource ok();
@ImageOptions(repeatStyle = RepeatStyle.Horizontal)
@Source("progress.png")
ImageResource progressTexture();
interface MyCssResource extends CssResource {
String myBackground();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

@ -0,0 +1,94 @@
package org.gcube.portlets.widgets.fileupload.client.controller;
import java.util.List;
import org.gcube.portlets.widgets.fileupload.client.UploadProgressService;
import org.gcube.portlets.widgets.fileupload.client.UploadProgressServiceAsync;
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadCompleteEvent;
import org.gcube.portlets.widgets.fileupload.client.state.UploadProgressState;
import org.gcube.portlets.widgets.fileupload.shared.event.Event;
import org.gcube.portlets.widgets.fileupload.shared.event.UploadProgressChangeEvent;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.rpc.AsyncCallback;
public final class ProgressController {
protected static final UploadProgressServiceAsync SERVICE = GWT.create(UploadProgressService.class);
private static ProgressController singleton;
private static HandlerManager eventBus;
public static ProgressController start(HandlerManager handlerManager) {
eventBus = handlerManager;
if (singleton == null) {
singleton = new ProgressController();
singleton.initialize(handlerManager);
}
return singleton;
}
private ProgressController() { }
private void getEvents() {
SERVICE.getEvents(new AsyncCallback<List<Event>>() {
@Override
public void onFailure(final Throwable t) {
GWT.log("error get events", t);
}
@Override
public void onSuccess(final List<Event> events) {
for (Event event : events) {
handleEvent(event);
}
SERVICE.getEvents(this);
}
private void handleEvent(final Event event) {
if (event instanceof UploadProgressChangeEvent) {
UploadProgressChangeEvent uploadPercentChangeEvent = (UploadProgressChangeEvent) event;
String fileName = uploadPercentChangeEvent.getFilename();
Integer percentage = uploadPercentChangeEvent.getPercentage();
UploadProgressState.INSTANCE.setUploadProgress(fileName, percentage);
if (percentage == 100) {
uploadCompleted(uploadPercentChangeEvent);
}
}
}
});
}
private void initialize(HandlerManager eventBus) {
SERVICE.initialise(new AsyncCallback<Void>() {
@Override
public void onFailure(final Throwable t) {
GWT.log("error initialise", t);
}
@Override
public void onSuccess(final Void result) {
getEvents();
}
});
}
/**
* here we fire the finished uploadedFile event
* @param uploadedFile
*/
private void uploadCompleted(UploadProgressChangeEvent uploadedFile) {
GWT.log("Finito");
eventBus.fireEvent(new FileUploadCompleteEvent(uploadedFile));
}
}

@ -0,0 +1,22 @@
package org.gcube.portlets.widgets.fileupload.client.events;
import com.google.gwt.event.shared.GwtEvent;
/**
* Event thrown when the user tries to upload a too large file.
* @author Costantino Perciante at ISTI-CNR
* (costantino.perciante@isti.cnr.it)
*/
public class FileTooLargeEvent extends GwtEvent<FileTooLargeEventHandler> {
public static Type<FileTooLargeEventHandler> TYPE = new Type<FileTooLargeEventHandler>();
@Override
public Type<FileTooLargeEventHandler> getAssociatedType() {
return TYPE;
}
@Override
protected void dispatch(FileTooLargeEventHandler handler) {
handler.onFileTooLargeEvent(this);
}
}

@ -0,0 +1,12 @@
package org.gcube.portlets.widgets.fileupload.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* Handler linked to @{FileTooLargeEvent} event class.
* @author Costantino Perciante at ISTI-CNR
* (costantino.perciante@isti.cnr.it)
*/
public interface FileTooLargeEventHandler extends EventHandler{
void onFileTooLargeEvent(FileTooLargeEvent fileTooLargeEvent);
}

@ -0,0 +1,32 @@
package org.gcube.portlets.widgets.fileupload.client.events;
import org.gcube.portlets.widgets.fileupload.shared.event.UploadProgressChangeEvent;
import com.google.gwt.event.shared.GwtEvent;
public class FileUploadCompleteEvent extends GwtEvent<FileUploadCompleteEventHandler> {
public static Type<FileUploadCompleteEventHandler> TYPE = new Type<FileUploadCompleteEventHandler>();
private UploadProgressChangeEvent uploadedFile;
public UploadProgressChangeEvent getUploadedFileInfo() {
return uploadedFile;
}
public FileUploadCompleteEvent(UploadProgressChangeEvent uploadedFile) {
this.uploadedFile = uploadedFile;
}
@Override
public Type<FileUploadCompleteEventHandler> getAssociatedType() {
return TYPE;
}
@Override
protected void dispatch(FileUploadCompleteEventHandler handler) {
handler.onUploadComplete(this);
}
}

@ -0,0 +1,7 @@
package org.gcube.portlets.widgets.fileupload.client.events;
import com.google.gwt.event.shared.EventHandler;
public interface FileUploadCompleteEventHandler extends EventHandler {
void onUploadComplete(FileUploadCompleteEvent event);
}

@ -0,0 +1,30 @@
package org.gcube.portlets.widgets.fileupload.client.events;
import com.google.gwt.event.shared.GwtEvent;
public class FileUploadSelectedEvent extends GwtEvent<FileUploadSelectedEventHandler> {
public static Type<FileUploadSelectedEventHandler> TYPE = new Type<FileUploadSelectedEventHandler>();
private String filename;
public String getSelectedFileName() {
return filename;
}
public FileUploadSelectedEvent(String filename) {
this.filename = filename;
}
@Override
public Type<FileUploadSelectedEventHandler> getAssociatedType() {
return TYPE;
}
@Override
protected void dispatch(FileUploadSelectedEventHandler handler) {
handler.onFileSelected(this);
}
}

@ -0,0 +1,7 @@
package org.gcube.portlets.widgets.fileupload.client.events;
import com.google.gwt.event.shared.EventHandler;
public interface FileUploadSelectedEventHandler extends EventHandler {
void onFileSelected(FileUploadSelectedEvent event);
}

@ -0,0 +1,37 @@
package org.gcube.portlets.widgets.fileupload.client.state;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
public abstract class AbstractState implements State {
private transient PropertyChangeSupport changes = new PropertyChangeSupport(this);
@Override
public final void addPropertyChangeListener(final PropertyChangeListener l) {
changes.addPropertyChangeListener(l);
}
@Override
public final void addPropertyChangeListener(final String propertyName,
final PropertyChangeListener l) {
changes.addPropertyChangeListener(propertyName, l);
}
@Override
public final void firePropertyChange(final String propertyName,
final Object oldValue, final Object newValue) {
changes.firePropertyChange(propertyName, oldValue, newValue);
}
@Override
public final void removePropertyChangeListener(final PropertyChangeListener l) {
changes.removePropertyChangeListener(l);
}
@Override
public final void removePropertyChangeListener(final String propertyName,
final PropertyChangeListener l) {
changes.removePropertyChangeListener(propertyName, l);
}
}

@ -0,0 +1,17 @@
package org.gcube.portlets.widgets.fileupload.client.state;
import java.beans.PropertyChangeListener;
interface State {
void addPropertyChangeListener(PropertyChangeListener l);
void addPropertyChangeListener(String propertyName, PropertyChangeListener l);
void firePropertyChange(String propertyName, Object oldValue, Object newValue);
void removePropertyChangeListener(PropertyChangeListener l);
void removePropertyChangeListener(String propertyName,
PropertyChangeListener l);
}

@ -0,0 +1,24 @@
package org.gcube.portlets.widgets.fileupload.client.state;
import java.util.HashMap;
import java.util.Map;
public final class UploadProgressState extends AbstractState {
public static final UploadProgressState INSTANCE = new UploadProgressState();
private Map<String, Integer> uploadProgress;
private UploadProgressState() {
uploadProgress = new HashMap<String, Integer>();
}
public Integer getUploadProgress(final String filename) {
return uploadProgress.get(filename);
}
public void setUploadProgress(final String filename, final Integer percentage) {
Integer old = this.uploadProgress.get(filename);
uploadProgress.put(filename, percentage);
firePropertyChange("uploadProgress", old, uploadProgress);
}
}

@ -0,0 +1,176 @@
package org.gcube.portlets.widgets.fileupload.client.view;
import org.gcube.portlets.widgets.fileupload.client.bundle.ProgressBarCssAndImages;
import org.gcube.portlets.widgets.fileupload.client.controller.ProgressController;
import org.gcube.portlets.widgets.fileupload.client.events.FileTooLargeEvent;
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadSelectedEvent;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FileUpload;
import com.google.gwt.user.client.ui.FormPanel;
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.SimplePanel;
/**
*
* @author Massimiliano Assante, ISTI-CNR
*
*/
public final class FileSubmit extends Composite {
/**
* VERY IMPORTANT, must be the same in web.xml
*/
public static final String URL = GWT.getModuleBaseURL()+"../FileUpload/upload";
ProgressBarCssAndImages images = GWT.create(ProgressBarCssAndImages.class);
// maximum size of a file that can be attached in MB
public static final int MAX_SIZE_ATTACHED_FILE_MB = 50;
// too large file selected
private static final String TOO_LARGE_FILE_ERROR = "The chosen file can't be uploaded since it is too large! Sorry...";
private HTML registeringLabel = new HTML("<span style=\"font-size: 15px; height: 20px; padding-top: 10px; display:inline-block; vertical-align:middle: 5px;\">"
+ "Applying required operations, please wait ... </span><img style=\"margin: 0; padding-left: 10px; vertical-align: middle; \" src='" + images.spinner().getSafeUri().asString() + "'>");
private FileUpload fileUpload;
private FormPanel form;
private Panel uploadPanel = new SimplePanel();
private UploadProgressDialog dlg;
private HandlerRegistration submitHandler;
private HandlerManager eventBus;
/**
* Constructor
* @param eventBus
* @param isDND if the file has to be loaded through DND
*/
public FileSubmit(HandlerManager eventBus, boolean isDND) {
// save the event bus
this.eventBus = eventBus;
if(!isDND){
ProgressController.start(eventBus);
fileUpload = new FileUpload();
fileUpload.setName("fileUpload");
fileUpload.setTitle("select a file to upload");
uploadPanel.setStyleName("FileSubmit");
uploadPanel.add(fileUpload);
form = new FormPanel();
form.setEncoding(FormPanel.ENCODING_MULTIPART);
form.setMethod(FormPanel.METHOD_POST);
form.getElement().setAttribute("acceptcharset", "UTF-8");
form.setAction(URL);
form.setWidget(uploadPanel);
this.initWidget(form);
//triggered on selected file form user
submitHandler = fileUpload.addChangeHandler(new FormSubmitChangeHandler());
form.addSubmitCompleteHandler(new FormSubmitCompleteHandler());
}else{
ProgressController.start(eventBus);
initWidget(new SimplePanel());
}
}
public FileSubmit(UploadProgressDialog dlg, final HandlerManager eventBus) {
this(eventBus, false);
this.dlg = dlg;
if (dlg.isFormSubmitHandled()) {
submitHandler.removeHandler();
fileUpload.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
eventBus.fireEvent(new FileUploadSelectedEvent(fileUpload.getFilename()));
}
});
}
}
protected void showRegisteringResult(boolean success, String customLabel) {
if (customLabel == null || customLabel.compareTo("") == 0) {
customLabel = success ? "Operation Completed Successfully" : "Sorry, an error occurred in the Server";
}
uploadPanel.clear();
if (success)
uploadPanel.add( new HTML("<span style=\"font-size: 15px; height: 20px; padding-top: 10px; display:inline-block; vertical-align:middle : 5px;\">"
+ customLabel + " </span><img style=\"margin: 0; padding-left: 10px; vertical-align: middle; \" src='" + images.ok().getSafeUri().asString() + "'>"));
else
uploadPanel.add( new HTML("<span style=\"font-size: 15px; height: 20px; padding-top: 10px; display:inline-block; vertical-align:middle : 5px;\">"
+ customLabel + " </span><img style=\"margin: 0; padding-left: 10px; vertical-align: middle; \" src='" + images.error().getSafeUri().asString() + "'>"));
if (dlg != null) //if dialog mode
dlg.showFinalCloseButton();
}
private class FormSubmitCompleteHandler implements SubmitCompleteHandler {
@Override
public void onSubmitComplete(final SubmitCompleteEvent event) {
//form.reset();
uploadPanel.remove(fileUpload);
if (dlg != null) { //if dialog mode
uploadPanel.add(registeringLabel);
dlg.hideCloseButton();
}
}
}
private class FormSubmitChangeHandler implements ChangeHandler {
@Override
public void onChange(ChangeEvent event) {
// check the size of the chosen file
GWT.log("SIZE is " + getChosenFileSize(fileUpload.getElement()));
if(getChosenFileSize(fileUpload.getElement()) > MAX_SIZE_ATTACHED_FILE_MB){
// signal the error
Window.alert(TOO_LARGE_FILE_ERROR);
// throw the event
eventBus.fireEvent(new FileTooLargeEvent());
return;
}
form.submit();
}
}
protected FileUpload getFileUpload() {
return fileUpload;
}
protected void submitForm() {
form.submit();
}
private static native int getChosenFileSize(final Element data) /*-{
// convert from bytes to MB
return (data.files[0].size / 1024 / 1024);
}-*/;
}

@ -0,0 +1,37 @@
package org.gcube.portlets.widgets.fileupload.client.view;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
public class ProgressBar extends Composite {
private static final double COMPLETE_PERECENTAGE = 100d;
private static final double START_PERECENTAGE = 0d;
private static ProgressBarUiBinder uiBinder = GWT
.create(ProgressBarUiBinder.class);
interface ProgressBarUiBinder extends UiBinder<Widget, ProgressBar> { }
@UiField HTML progressBarContainer;
public ProgressBar() {
initWidget(uiBinder.createAndBindUi(this));
}
public void update(int percentage) {
if (percentage > 100)
percentage = 100;
if (percentage < START_PERECENTAGE || percentage > COMPLETE_PERECENTAGE) {
throw new IllegalArgumentException("invalid value for percentage " + percentage);
} else { //cannot use DOM getElemById cus the second time you open the popup it fails
progressBarContainer.getElement().setAttribute("style", "width: "+percentage+"%");
progressBarContainer.getElement().getFirstChildElement().getFirstChildElement().setInnerText(percentage+"%");
}
}
}

@ -0,0 +1,13 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:HTMLPanel>
<div class="bar-container">
<g:HTML styleName="progress myBackground" ui:field='progressBarContainer' >
<span class="blue" style="width: 100%;">
<span id="upload-percent-number">0%</span>
</span>
</g:HTML>
</div>
</g:HTMLPanel>
</ui:UiBinder>

@ -0,0 +1,65 @@
package org.gcube.portlets.widgets.fileupload.client.view;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Map;
import org.gcube.portlets.widgets.fileupload.client.state.UploadProgressState;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.VerticalPanel;
public final class UploadProgress extends Composite {
private Panel panel;
private ProgressBar bar = new ProgressBar();
/**
*
*/
public UploadProgress() {
panel = new VerticalPanel();
panel.setStyleName("progressBarContainer");
this.initWidget(panel);
UploadProgressState.INSTANCE.addPropertyChangeListener("uploadProgress", new UploadProgressListener());
}
private final class UploadProgressListener implements PropertyChangeListener {
private static final int COMPLETE_PERECENTAGE = 100;
private static final int REMOVE_DELAY = 3000;
@Override
public void propertyChange(final PropertyChangeEvent event) {
Map<String, Integer> uploadPercentage = (Map<String, Integer>) event.getNewValue();
for (Map.Entry<String, Integer> entry : uploadPercentage.entrySet()) {
String file = entry.getKey();
Integer percentage = entry.getValue();
panel.add(bar);
bar.update(percentage);
if (percentage == COMPLETE_PERECENTAGE) {
Timer timer = new Timer() {
@Override
public void run() {
panel.remove(bar);
}
};
//timer.schedule(REMOVE_DELAY);
}
}
}
}
}

@ -0,0 +1,129 @@
package org.gcube.portlets.widgets.fileupload.client.view;
import org.gcube.portlets.user.gcubewidgets.client.popup.GCubeDialog;
import org.gcube.portlets.widgets.fileupload.client.bundle.ProgressBarCssAndImages;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CellPanel;
import com.google.gwt.user.client.ui.HasAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
/**
* @author Massimiliano Assante, ISTI-CNR
*
*/
public class UploadProgressDialog extends GCubeDialog {
private static final int WIDTH = 400;
static {
ProgressBarCssAndImages.INSTANCE.css().ensureInjected();
}
private CellPanel mainPanel = new VerticalPanel();
private HorizontalPanel bottomPanel = new HorizontalPanel();
private UploadProgressView uploadView ;
private boolean handleFormSubmit = false;
/**
* regular constructor
*
* @param headerText
* @param eventBus
*/
public UploadProgressDialog(String headerText, HandlerManager eventBus) {
setText(headerText);
this.uploadView = new UploadProgressView(this, eventBus);
mainPanel.setPixelSize(WIDTH, 80);
bottomPanel.setPixelSize(WIDTH, 25);
mainPanel.add(uploadView);
mainPanel.add(bottomPanel);
bottomPanel.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT);
Button close = new Button("Cancel");
bottomPanel.add(close);
close.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
hide();
}
});
mainPanel.setCellHeight(bottomPanel, "25px");
setWidget(mainPanel);
}
/**
* to be used if you want to handle form submit
*
* @param headerText
* @param eventBus
* @param handleFormSubmit
*/
public UploadProgressDialog(String headerText, HandlerManager eventBus, boolean handleFormSubmit) {
setText(headerText);
this.handleFormSubmit = handleFormSubmit;
this.uploadView = new UploadProgressView(this, eventBus);
mainPanel.setPixelSize(WIDTH, 80);
bottomPanel.setPixelSize(WIDTH, 25);
mainPanel.add(uploadView);
mainPanel.add(bottomPanel);
bottomPanel.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT);
Button close = new Button("Cancel");
bottomPanel.add(close);
close.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
hide();
}
});
mainPanel.setCellHeight(bottomPanel, "25px");
setWidget(mainPanel);
}
public void showRegisteringResult(boolean result) {
uploadView.showRegisteringResult(result, null);
}
public void showRegisteringResult(boolean result, String customFeedback) {
uploadView.showRegisteringResult(result, customFeedback);
}
/**
* to call when handle
* @throws Exception
*/
public void submitForm() throws Exception {
if (handleFormSubmit)
uploadView.submitForm();
else
throw new Exception("You must set this widget to handleFormSubmit");
}
protected void hideCloseButton() {
bottomPanel.clear();
}
protected boolean isFormSubmitHandled() {
return handleFormSubmit;
}
protected void showFinalCloseButton() {
bottomPanel.clear();
Button close = new Button("Close");
bottomPanel.add(close);
close.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
hide();
}
});
}
}

@ -0,0 +1,71 @@
package org.gcube.portlets.widgets.fileupload.client.view;
import org.gcube.portlets.widgets.fileupload.client.bundle.ProgressBarCssAndImages;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FileUpload;
import com.google.gwt.user.client.ui.VerticalPanel;
/**
*
* @author Massimiliano Assante, ISTI-CNR
*
*/
public final class UploadProgressPanel extends Composite {
static {
ProgressBarCssAndImages.INSTANCE.panelCss().ensureInjected();
}
private HandlerManager eventBus;
private FileSubmit fileSubmit;
private VerticalPanel mainPanel = new VerticalPanel();
/**
* as a Panel
* @param eventBus
*/
public UploadProgressPanel(HandlerManager eventBus) {
this.eventBus = eventBus;
mainPanel.setStyleName("progressContainer");
initWidget(mainPanel);
}
/**
* Used when attaching files via button
* @return
*/
public FileUpload initialize() {
mainPanel.clear();
fileSubmit = new FileSubmit(eventBus, false);
mainPanel.add(fileSubmit);
mainPanel.add(new UploadProgress());
//return the fileupload so that you cane set it hidden
return fileSubmit.getFileUpload();
}
/**
* Used when attaching files via dnd
* @return
*/
public void initializeDND(){
mainPanel.clear();
fileSubmit = new FileSubmit(eventBus, true);
mainPanel.add(fileSubmit);
mainPanel.add(new UploadProgress());
}
public void showRegisteringResult(boolean result) {
fileSubmit.showRegisteringResult(result, null);
}
public void showRegisteringResult(boolean result, String customFeedback) {
fileSubmit.showRegisteringResult(result, customFeedback);
}
public FileUpload getFileUpload() {
return fileSubmit.getFileUpload();
}
}

@ -0,0 +1,43 @@
package org.gcube.portlets.widgets.fileupload.client.view;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiFactory;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
public final class UploadProgressView extends Composite {
interface UploadProgressViewUiBinder extends UiBinder<Widget, UploadProgressView> {
}
private static UploadProgressViewUiBinder uiBinder = GWT.create(UploadProgressViewUiBinder.class);
private HandlerManager eventBus;
@UiField
FileSubmit fileSubmit;
@UiField
UploadProgress uploadProgress;
UploadProgressDialog dlg;
protected UploadProgressView(UploadProgressDialog dlg, HandlerManager eventBus) {
this.eventBus = eventBus;
this.dlg = dlg;
initWidget(uiBinder.createAndBindUi(this));
}
/** Used by UiBinder to instantiate FileSubmit */
@UiFactory
FileSubmit makeFileSubmit() {
return new FileSubmit(dlg, eventBus);
}
protected void showRegisteringResult(boolean result, String customFeedback) {
fileSubmit.showRegisteringResult(result, customFeedback);
}
protected void submitForm() {
fileSubmit.submitForm();
}
}

@ -0,0 +1,10 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g='urn:import:com.google.gwt.user.client.ui' xmlns:view='urn:import:org.gcube.portlets.widgets.fileupload.client.view'>
<g:HTMLPanel>
<div class="progressContainer">
<view:FileSubmit ui:field='fileSubmit' />
<view:UploadProgress ui:field='uploadProgress' />
</div>
</g:HTMLPanel>
</ui:UiBinder>

@ -0,0 +1,42 @@
package org.gcube.portlets.widgets.fileupload.server;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.gcube.portlets.widgets.fileupload.shared.event.*;
public final class UploadProgress {
private static final String SESSION_KEY = "uploadProgress";
private List<Event> events = new ArrayList<Event>();
private UploadProgress() {
}
public List<Event> getEvents() {
return events;
}
public void add(final Event event) {
events.add(event);
}
public void clear() {
events = new ArrayList<Event>();
}
public boolean isEmpty() {
return events.isEmpty();
}
public static UploadProgress getUploadProgress(final HttpSession session) {
Object attribute = session.getAttribute(SESSION_KEY);
if (null == attribute) {
attribute = new UploadProgress();
session.setAttribute(SESSION_KEY, attribute);
}
return null == attribute ? null : (UploadProgress) attribute;
}
}

@ -0,0 +1,69 @@
package org.gcube.portlets.widgets.fileupload.server;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.fileupload.ProgressListener;
public final class UploadProgressInputStream extends FilterInputStream {
private List<ProgressListener> listeners;
private long bytesRead = 0;
private long totalBytes = 0;
public UploadProgressInputStream(final InputStream in, final long totalBytes) {
super(in);
this.totalBytes = totalBytes;
listeners = new ArrayList<ProgressListener>();
}
public void addListener(final ProgressListener listener) {
listeners.add(listener);
}
@Override
public int read() throws IOException {
int b = super.read();
this.bytesRead++;
updateListeners(bytesRead, totalBytes);
return b;
}
@Override
public int read(final byte b[]) throws IOException {
return read(b, 0, b.length);
}
@Override
public int read(final byte b[], final int off, final int len) throws IOException {
int bytesRead = in.read(b, off, len);
this.bytesRead = this.bytesRead + bytesRead;
updateListeners(this.bytesRead, totalBytes);
return bytesRead;
}
@Override
public void close() throws IOException {
super.close();
updateListeners(totalBytes, totalBytes);
}
private void updateListeners(final long bytesRead, final long totalBytes) {
for (ProgressListener listener : listeners) {
listener.update(bytesRead, totalBytes, listeners.size());
}
}
}

@ -0,0 +1,42 @@
package org.gcube.portlets.widgets.fileupload.server;
import org.apache.commons.fileupload.ProgressListener;
import org.gcube.portlets.widgets.fileupload.shared.event.UploadProgressChangeEvent;
public final class UploadProgressListener implements ProgressListener {
private static final double COMPLETE_PERECENTAGE = 100d;
private int percentage = -1;
private String fileName;
private String absolutePath;
private UploadProgress uploadProgress;
public UploadProgressListener(final String fileName, final UploadProgress uploadProgress, final String absolutePath) {
this.fileName = fileName;
this.uploadProgress = uploadProgress;
this.absolutePath = absolutePath;
}
@Override
public void update(final long bytesRead, final long totalBytes, final int items) {
int percentage = (int) Math.floor(((double) bytesRead / (double) totalBytes) * COMPLETE_PERECENTAGE);
if (this.percentage == percentage) {
return;
}
this.percentage = percentage;
UploadProgressChangeEvent event = new UploadProgressChangeEvent();
event.setFilename(this.fileName);
event.setPercentage(percentage);
event.setAbsolutePath(this.absolutePath);
synchronized (this.uploadProgress) {
this.uploadProgress.add(event);
this.uploadProgress.notifyAll();
}
}
}

@ -0,0 +1,51 @@
package org.gcube.portlets.widgets.fileupload.server;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.gcube.portlets.widgets.fileupload.client.UploadProgressService;
import org.gcube.portlets.widgets.fileupload.shared.event.Event;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
@SuppressWarnings("serial")
public final class UploadProgressServlet extends RemoteServiceServlet implements UploadProgressService {
private static final int EVENT_WAIT = 30 * 1000;
private static final Logger _log = LoggerFactory.getLogger(UploadProgressServlet.class);
@Override
public void initialise() {
getThreadLocalRequest().getSession(true);
}
@Override
public List<Event> getEvents() {
HttpSession session = getThreadLocalRequest().getSession();
UploadProgress uploadProgress = UploadProgress.getUploadProgress(session);
List<Event> events = null;
if (null != uploadProgress) {
if (uploadProgress.isEmpty()) {
try {
synchronized (uploadProgress) {
_log.debug("waiting...");
uploadProgress.wait(EVENT_WAIT);
}
} catch (final InterruptedException ie) {
_log.debug("interrupted...");
}
}
synchronized (uploadProgress) {
events = uploadProgress.getEvents();
uploadProgress.clear();
}
}
return events;
}
}

@ -0,0 +1,98 @@
package org.gcube.portlets.widgets.fileupload.server;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.Normalizer;
import java.util.UUID;
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.FileItemFactory;
import org.apache.commons.fileupload.FileItemIterator;
import org.apache.commons.fileupload.FileItemStream;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.util.Streams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Massimiliano Assante, ISTI-CNR
*
*/
@SuppressWarnings("serial")
public final class UploadServlet extends HttpServlet {
private static final Logger _log = LoggerFactory.getLogger(UploadServlet.class);
/**
* use tomcat temp as base upload folder
*/
private static String UPLOAD_LOCATION = System.getProperty("java.io.tmpdir");
public void init() {
if (System.getenv("CATALINA_TMPDIR") != null && System.getenv("CATALINA_TMPDIR").compareTo("") != 0) {
UPLOAD_LOCATION = System.getenv("CATALINA_TMPDIR");
}
}
@Override
protected void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
try {
uploadFile(request);
} catch (FileUploadException fue) {
throw new ServletException(fue);
}
}
private void uploadFile(final HttpServletRequest request) throws FileUploadException, IOException {
if (!ServletFileUpload.isMultipartContent(request)) {
throw new FileUploadException("ERROR: multipart request not found");
}
FileItemFactory fileItemFactory = new DiskFileItemFactory();
ServletFileUpload servletFileUpload = new ServletFileUpload(fileItemFactory);
FileItemIterator fileItemIterator = servletFileUpload.getItemIterator(request);
HttpSession session = request.getSession();
UploadProgress uploadProgress = UploadProgress.getUploadProgress(session);
while (fileItemIterator.hasNext()) {
FileItemStream fileItemStream = fileItemIterator.next();
String filePath = fileItemStream.getName();
String fileName = filePath.substring(filePath.lastIndexOf(File.separator) + 1);
String normalizedString = Normalizer.normalize(fileName, Normalizer.Form.NFD);
String sanitizedFileName = normalizedString.replaceAll("[^\\x00-\\x7F]", "");
//generate the random dir
File theRandomDir = new File(UPLOAD_LOCATION + File.separator + UUID.randomUUID().toString());
theRandomDir.mkdir();
_log.debug("Created temp upload directory in: " + theRandomDir);
//create the file
File file = new File(theRandomDir, sanitizedFileName);
Long size = Long.parseLong(request.getHeader("Content-Length"));
_log.debug("size: " + size + " bytes sanitized File name="+sanitizedFileName);
_log.debug("path: " + file.getAbsolutePath());
//instanciate the progress listener
UploadProgressListener uploadProgressListener = new UploadProgressListener(sanitizedFileName, uploadProgress, file.getAbsolutePath());
UploadProgressInputStream inputStream = new UploadProgressInputStream(fileItemStream.openStream(), size);
inputStream.addListener(uploadProgressListener);
//actually copying
Streams.copy(inputStream, new FileOutputStream(file), true);
//finished
_log.info("uploaded file " + file.getAbsolutePath());
}
}
}

@ -0,0 +1,42 @@
package org.gcube.portlets.widgets.fileupload.shared;
/**
* <p>
* FieldVerifier validates that the name the user enters is valid.
* </p>
* <p>
* This class is in the <code>shared</code> packing because we use it in both
* the client code and on the server. On the client, we verify that the name is
* valid before sending an RPC request so the user doesn't have to wait for a
* network round trip to get feedback. On the server, we verify that the name is
* correct to ensure that the input is correct regardless of where the RPC
* originates.
* </p>
* <p>
* When creating a class that is used on both the client and the server, be sure
* that all code is translatable and does not use native JavaScript. Code that
* is note translatable (such as code that interacts with a database or the file
* system) cannot be compiled into client side JavaScript. Code that uses native
* JavaScript (such as Widgets) cannot be run on the server.
* </p>
*/
public class FieldVerifier {
/**
* Verifies that the specified name is valid for our service.
*
* In this example, we only require that the name is at least four
* characters. In your application, you can use more complex checks to ensure
* that usernames, passwords, email addresses, URLs, and other fields have the
* proper syntax.
*
* @param name the name to validate
* @return true if valid, false if invalid
*/
public static boolean isValidName(String name) {
if (name == null) {
return false;
}
return name.length() > 3;
}
}

@ -0,0 +1,60 @@
package org.gcube.portlets.widgets.fileupload.shared.dto;
import java.io.Serializable;
import java.util.Date;
public final class FileDto implements Serializable {
private String filename;
private Date dateUploaded;
public FileDto() {
}
public Date getDateUploaded() {
return dateUploaded;
}
public void setDateUploaded(final Date dateUploaded) {
this.dateUploaded = dateUploaded;
}
public String getFilename() {
return filename;
}
public void setFilename(final String filename) {
this.filename = filename;
}
@Override
public String toString() {
return filename + " - " + dateUploaded;
}
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final FileDto other = (FileDto) obj;
if ((this.filename == null) ? (other.filename != null) : !this.filename.equals(other.filename)) {
return false;
}
if (this.dateUploaded != other.dateUploaded && (this.dateUploaded == null || !this.dateUploaded.equals(other.dateUploaded))) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 5;
hash = 67 * hash + (this.filename != null ? this.filename.hashCode() : 0);
hash = 67 * hash + (this.dateUploaded != null ? this.dateUploaded.hashCode() : 0);
return hash;
}
}

@ -0,0 +1,4 @@
package org.gcube.portlets.widgets.fileupload.shared.event;
public interface Event {
}

@ -0,0 +1,51 @@
package org.gcube.portlets.widgets.fileupload.shared.event;
import java.io.Serializable;
@SuppressWarnings("serial")
public final class UploadProgressChangeEvent implements Event, Serializable {
/**
* the file name
*/
private String filename;
/**
* the path of the uploaded file
*/
private String absolutePath;
/**
* the current percentage
*/
private Integer percentage;
public UploadProgressChangeEvent() {
}
public String getFilename() {
return filename;
}
public void setFilename(final String filename) {
this.filename = filename;
}
public Integer getPercentage() {
return percentage;
}
public void setPercentage(final Integer percentage) {
this.percentage = percentage;
}
public String getAbsolutePath() {
return absolutePath;
}
public void setAbsolutePath(String absolutePath) {
this.absolutePath = absolutePath;
}
@Override
public String toString() {
return filename + " - " + percentage + " path="+absolutePath;
}
}

@ -0,0 +1,17 @@
log4j.rootLogger=DEBUG, A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
# Print the date in ISO 8601 format
log4j.appender.A1.layout.ConversionPattern=%d %-5p %c - %m%n
# Print only messages of level TRACE or above in the package org.gcube
log4j.logger.org.gcube=TRACE
log4j.logger.org.gcube.application.framework.core.session=INFO
log4j.logger.org.gcube.contentmanager=ERROR
log4j.logger.org.gcube.common.scope=ERROR
log4j.logger.org.gcube.contentmanagement=ERROR
log4j.logger.org.gcube.resources.discovery.icclient=ERROR
log4j.logger.org.gcube.common.clients=ERROR
log4j.logger.org.gcube.common.homelibrary.jcr=ERROR
log4j.logger.org.gcube.application.framework.accesslogger=ERROR

@ -0,0 +1,41 @@
<!doctype html>
<!-- The DOCTYPE declaration above will set the -->
<!-- browser's rendering engine into -->
<!-- "Standards Mode". Replacing this declaration -->
<!-- with a "Quirks Mode" doctype may lead to some -->
<!-- differences in layout. -->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- -->
<!-- Consider inlining CSS to reduce the number of requested files -->
<!-- -->
<!-- -->
<!-- Any title is fine -->
<!-- -->
<title>File Upload Widget</title>
<!-- -->
<!-- This script loads your compiled module. -->
<!-- If you add any GWT meta tags, they must -->
<!-- be added before this line. -->
<!-- -->
<script type="text/javascript" language="javascript" src="FileUpload/FileUpload.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>
</body>
</html>

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<!-- Servlets -->
<servlet>
<servlet-name>uploadprogress</servlet-name>
<servlet-class>org.gcube.portlets.widgets.fileupload.server.UploadProgressServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>uploadprogress</servlet-name>
<url-pattern>/FileUpload/uploadprogress</url-pattern>
</servlet-mapping>
<!-- DO NOT CHANGE -->
<servlet>
<servlet-name>upload</servlet-name>
<servlet-class>org.gcube.portlets.widgets.fileupload.server.UploadServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>upload</servlet-name>
<url-pattern>/FileUpload/upload</url-pattern>
</servlet-mapping>
<!-- END DO NOT CHANGE -->
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>FileUpload.html</welcome-file>
</welcome-file-list>
</web-app>

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module>
<!-- Inherit our applications main module. -->
<inherits name='org.gcube.portlets.widgets.fileupload.FileUpload' />
<!-- Specify the path to any remote services. -->
<servlet path="/FileUpload/greet" class="org.gcube.portlets.widgets.fileupload.server.GreetingServiceImpl" />
</module>
Loading…
Cancel
Save