Skip to content

Commit e7702e0

Browse files
committed
FileUploader Updates.
1 parent 1deb031 commit e7702e0

File tree

4 files changed

+64
-5
lines changed

4 files changed

+64
-5
lines changed

src/main/java/gwt/material/design/addins/client/fileuploader/MaterialFileUploader.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import gwt.material.design.client.ui.MaterialToast;
4646
import gwt.material.design.jquery.client.api.Functions;
4747
import gwt.material.design.jquery.client.api.JQueryElement;
48+
import gwt.material.design.jscore.client.api.media.MediaStream;
4849

4950
import java.util.ArrayList;
5051
import java.util.Date;
@@ -498,7 +499,7 @@ public void addFile(Object object) {
498499
/**
499500
* Manually enqueue file when option autoQueue is disabled
500501
*/
501-
public void enqueueFile(File file) {
502+
public void enqueueFile(Object file) {
502503
uploader.enqueueFile(file);
503504
}
504505

@@ -1163,6 +1164,18 @@ public void setHiddenInputContainer(Object hiddenInputContainer) {
11631164
options.hiddenInputContainer = hiddenInputContainer;
11641165
}
11651166

1167+
public void setAccept(Functions.Func2<Object, Object> accept) {
1168+
options.accept = accept;
1169+
}
1170+
1171+
public void setResizeFunction(Functions.FuncRet1<Object> function) {
1172+
options.resize = function;
1173+
}
1174+
1175+
public Functions.Func2<Object, Object> getAccept() {
1176+
return options.accept;
1177+
}
1178+
11661179
public Object getCapture() {
11671180
return options.capture;
11681181
}
@@ -1222,6 +1235,10 @@ public void setFileProvider(FileProvider fileProvider) {
12221235
this.fileProvider = fileProvider;
12231236
}
12241237

1238+
public void done() {
1239+
uploader.done();
1240+
}
1241+
12251242
@Override
12261243
public HandlerRegistration addAddedFileHandler(final AddedFileEvent.AddedFileHandler<UploadFile> handler) {
12271244
return addHandler((AddedFileEvent.AddedFileHandler<UploadFile>) event -> {

src/main/java/gwt/material/design/addins/client/fileuploader/js/Dropzone.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public class Dropzone extends JQueryElement {
3535
public Dropzone(Element e, JsFileUploaderOptions options) {
3636
}
3737

38+
@JsProperty
39+
public Object[] files;
40+
3841
@JsMethod
3942
public native void on(String events, Functions.Func1<Object> callback);
4043

@@ -69,7 +72,7 @@ public interface ProgressCallback {
6972
public native void removeAllFiles();
7073

7174
@JsMethod
72-
public native void enqueueFile(File file);
75+
public native void enqueueFile(Object file);
7376

7477
@JsMethod
7578
public native void destroy();
@@ -100,4 +103,7 @@ public interface ProgressCallback {
100103

101104
@JsMethod
102105
public native void enable();
106+
107+
@JsMethod
108+
public native void done();
103109
}

src/main/java/gwt/material/design/addins/client/fileuploader/js/JsFileUploaderOptions.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@
2222

2323

2424
import gwt.material.design.jquery.client.api.Functions;
25-
import jsinterop.annotations.JsMethod;
2625
import jsinterop.annotations.JsPackage;
2726
import jsinterop.annotations.JsProperty;
2827
import jsinterop.annotations.JsType;
2928

30-
import java.util.List;
31-
3229
/**
3330
* Options for file uploader component
3431
*
@@ -66,6 +63,12 @@ public class JsFileUploaderOptions {
6663
@JsProperty
6764
public String clickable;
6865

66+
@JsProperty
67+
public Functions.Func2<Object, Object> accept;
68+
69+
@JsProperty
70+
public Functions.FuncRet1<Object> resize;
71+
6972
@JsProperty
7073
public boolean withCredentials;
7174

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package gwt.material.design.addins.client.fileuploader.js;
2+
3+
import jsinterop.annotations.JsPackage;
4+
import jsinterop.annotations.JsProperty;
5+
import jsinterop.annotations.JsType;
6+
7+
@JsType(isNative = true, name = "Object", namespace = JsPackage.GLOBAL)
8+
public class ResizeInfo {
9+
10+
@JsProperty
11+
public int srcX;
12+
13+
@JsProperty
14+
public int srcY;
15+
16+
@JsProperty
17+
public int trgX;
18+
19+
@JsProperty
20+
public int trgY;
21+
22+
@JsProperty
23+
public int srcWidth;
24+
25+
@JsProperty
26+
public int srcHeight;
27+
28+
@JsProperty
29+
public int trgWidth;
30+
31+
@JsProperty
32+
public int trgHeight;
33+
}

0 commit comments

Comments
 (0)