mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-06 02:52:22 +00:00
bug4811: added elemental2.[core|dom|promise] in an "elemental2" project;
this to enable things such as access to FileList and File from FileUpload input elements
This commit is contained in:
1 parent
1b3c1cddf1
commit
3d89837122
16 files changed
+155
-1
No files matched your search
@@ -11,7 +11,8 @@ Require-Bundle: com.google.gwt.user;bundle-version="2.9.0";resolution:=optional,
|
||||
com.google.gwt.servlet;bundle-version="2.9.0",
|
||||
com.sap.sse.common,
|
||||
com.sap.sse.filestorage,
|
||||
com.sap.sse.security.common
|
||||
com.sap.sse.security.common,
|
||||
elemental2;bundle-version="1.1.0"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Web-ContextPath: /gwt-base
|
||||
Import-Package: com.sap.sse.security,
|
||||
|
||||
@@ -16,6 +16,12 @@
|
||||
<version>${project.version}</version>
|
||||
<classifier>sources</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sap.sailing</groupId>
|
||||
<artifactId>elemental2</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<classifier>sources</classifier>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
<module>
|
||||
<!-- required module to enable String Messages -->
|
||||
<inherits name="com.google.gwt.resources.Resources" />
|
||||
<inherits name="elemental2.core.Core" />
|
||||
<inherits name="elemental2.dom.Dom" />
|
||||
<inherits name="elemental2.promise.Promise" />
|
||||
|
||||
<inherits name="com.google.gwt.activity.Activity" />
|
||||
<inherits name="com.sap.sse.common.SSECommonSerializers" />
|
||||
|
||||
Executable
+58
@@ -0,0 +1,58 @@
|
||||
package com.sap.sse.gwt.client.fileupload;
|
||||
|
||||
import com.google.gwt.user.client.ui.FileUpload;
|
||||
|
||||
import elemental2.core.ArrayBuffer;
|
||||
import elemental2.core.Uint8Array;
|
||||
import elemental2.dom.File;
|
||||
import elemental2.dom.FileList;
|
||||
import elemental2.dom.HTMLInputElement;
|
||||
import elemental2.promise.Promise;
|
||||
|
||||
/**
|
||||
* A GWT component wrapping a {@link FileUpload} form {@code input} element of type {@code file} which grants access to
|
||||
* the contents of the files the user has selected for upload. The {@code input} element of type {@code file} has a
|
||||
* {@code files} property of type {@link FileList}, an array of {@code File} JavaScript objects, each of which having,
|
||||
* e.g., an {@code arrayBuffer()} method that delivers a {@code Promise} resolving with an {@code ArrayBuffer}. See
|
||||
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/Blob/arrayBuffer">here</a>. This wrapper around a
|
||||
* {@link FileUpload} input element grants access to the files currently selected.
|
||||
* <p>
|
||||
*
|
||||
* This can also be combined with adding a {@code change}
|
||||
* {@link FileUpload#addChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) handler} to the {@link FileUpload}
|
||||
* element which is triggered in particular as the user changes the file selection.
|
||||
* <p>
|
||||
*
|
||||
* @author Axel Uhl (D043530)
|
||||
*
|
||||
*/
|
||||
public class FileUploadWithLocalFileContent {
|
||||
private final FileUpload fileUpload;
|
||||
|
||||
public static interface FileContentCallback {
|
||||
void fileContentsRead(byte[] fileContents);
|
||||
}
|
||||
|
||||
public FileUploadWithLocalFileContent(FileUpload fileUpload) {
|
||||
super();
|
||||
this.fileUpload = fileUpload;
|
||||
}
|
||||
|
||||
public FileList getFileList() {
|
||||
return getFileUploadAsHtmlInputElement().files;
|
||||
}
|
||||
|
||||
public void getFileContents(int i, FileContentCallback callback) {
|
||||
final FileList fileList = getFileList();
|
||||
final File file = fileList.item((double) i);
|
||||
final Promise<ArrayBuffer> arrayBufferPromise = file.arrayBuffer();
|
||||
arrayBufferPromise.then(arrayBuffer->{
|
||||
callback.fileContentsRead((byte[]) (Object) new Uint8Array(arrayBuffer));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
private HTMLInputElement getFileUploadAsHtmlInputElement() {
|
||||
return (HTMLInputElement) (Object) fileUpload;
|
||||
}
|
||||
}
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="lib/base-1.0.0.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/elemental2-core-1.1.0.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/elemental2-dom-1.1.0.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/elemental2-promise-1.1.0.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>elemental2</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,8 @@
|
||||
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.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
@@ -0,0 +1,3 @@
|
||||
eclipse.preferences.version=1
|
||||
pluginProject.extensions=false
|
||||
resolve.requirebundle=false
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Elemental2
|
||||
Bundle-SymbolicName: elemental2
|
||||
Bundle-Version: 1.1.0.qualifier
|
||||
Automatic-Module-Name: elemental2
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Bundle-ClassPath: lib/elemental2-core-1.1.0.jar,
|
||||
lib/elemental2-dom-1.1.0.jar,
|
||||
lib/elemental2-promise-1.1.0.jar,
|
||||
.,
|
||||
lib/base-1.0.0.jar
|
||||
Export-Package: com.google.gwt.core.client,
|
||||
elemental2.core,
|
||||
elemental2.dom,
|
||||
elemental2.promise,
|
||||
jsinterop.base
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
lib/elemental2-core-1.1.0.jar,\
|
||||
lib/elemental2-dom-1.1.0.jar,\
|
||||
lib/elemental2-promise-1.1.0.jar,\
|
||||
lib/base-1.0.0.jar
|
||||
Executable
BIN
Binary file not shown.
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
BIN
Binary file not shown.
Executable
+13
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>root</artifactId>
|
||||
<groupId>com.sap.sailing</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>elemental2</artifactId>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
||||
@@ -77,6 +77,7 @@
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>elemental2</module>
|
||||
<module>com.sap.sse</module>
|
||||
<module>com.sap.sse.test</module>
|
||||
<module>com.sap.sse.landscape.common</module>
|
||||
|
||||
Reference in new issue
Block a user