Drop upload (not working)
authorVásáry Dániel <vasary@elgekko.net>
Tue, 20 Feb 2024 17:15:04 +0000 (18:15 +0100)
committerVásáry Dániel <vasary@elgekko.net>
Tue, 20 Feb 2024 17:15:04 +0000 (18:15 +0100)
24 files changed:
dropfile/src/main/java/net/elgekko/zkoss/Dropfile.java [new file with mode: 0644]
dropfile/src/main/java/net/elgekko/zkoss/Version.java [new file with mode: 0644]
dropfile/src/main/java/org/example/Dropfile.java [deleted file]
dropfile/src/main/java/org/example/Version.java [deleted file]
dropfile/src/main/resources/metainfo/zk/lang-addon.xml
dropfile/src/main/resources/web/js/dropfile/Dropfile.js
dropfile/src/main/resources/web/js/dropfile/css/dropfile.css.dsp
dropfile/src/main/resources/web/js/dropfile/less/dropfile.less [new file with mode: 0644]
dropfile/src/main/resources/web/js/dropfile/mold/dropfile.js
dropfile/src/main/resources/web/js/dropfile/zk.wpd
dropfile/src/test/java/test/ctrl/DemoWindowComposer.java [deleted file]
dropfile/src/test/webapp/META-INF/MANIFEST.MF [deleted file]
dropfile/src/test/webapp/WEB-INF/web.xml [deleted file]
dropfile/src/test/webapp/WEB-INF/zk.xml [deleted file]
dropfile/src/test/webapp/index.zul [deleted file]
dropfile/src/test/webapp/timeout.zul [deleted file]
lis-ui/src/main/java/hu/user/lis/ui/config/WebSecurityConfig.java
lis-ui/src/main/java/hu/user/lis/ui/view/IndexViewModel.java
lis-ui/src/main/java/hu/user/lis/ui/view/LoginViewModel.java
lis-ui/src/main/resources/web/editor/import-invoice-approve-editor.zul
lis-ui/src/main/resources/web/editor/import-invoice-assign-editor.zul
lis-ui/src/main/resources/web/form/invoice-form.zul
lis-ui/src/main/resources/web/index.zul
lis-ui/src/main/resources/web/login.zul

diff --git a/dropfile/src/main/java/net/elgekko/zkoss/Dropfile.java b/dropfile/src/main/java/net/elgekko/zkoss/Dropfile.java
new file mode 100644 (file)
index 0000000..38271a3
--- /dev/null
@@ -0,0 +1,268 @@
+package net.elgekko.zkoss;
+
+import org.zkoss.lang.Generics;
+import org.zkoss.lang.Objects;
+import org.zkoss.util.media.Media;
+import org.zkoss.zk.au.AuRequest;
+import org.zkoss.zk.ui.Component;
+import org.zkoss.zk.ui.Desktop;
+import org.zkoss.zk.ui.event.Events;
+import org.zkoss.zk.ui.event.UploadEvent;
+import org.zkoss.zk.ui.sys.ContentRenderer;
+import org.zkoss.zul.impl.XulElement;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+public class Dropfile extends XulElement {
+    private static final String DEFAULT_DETECTION = "browser";
+
+    static {
+        addClientEvent(Dropfile.class, "onUpload", 1);
+    }
+
+    private int _maxsize;
+    private String _viewerClass;
+
+
+    private String _detection = "browser";
+
+
+    private String _content;
+
+
+    private boolean _native;
+
+
+    private Component _anchor;
+
+
+    private static Media[] parseResult(List<Media> result) {
+        /* 245 */
+        if (result != null) {
+            /*     */
+            /* 247 */
+            for (Iterator<Media> it = result.iterator(); it.hasNext(); ) {
+                /* 248 */
+                Media media = it.next();
+                /* 249 */
+                if (media != null && media.inMemory() && media.isBinary()) {
+                    /* 250 */
+                    String nm = media.getName();
+                    /* 251 */
+                    if (nm == null || nm.length() == 0) {
+                        /* 252 */
+                        byte[] bs = media.getByteData();
+                        /* 253 */
+                        if (bs == null || bs.length == 0) {
+                            /* 254 */
+                            it.remove();
+                            /*     */
+                        }
+                        /*     */
+                    }
+                    /*     */
+                }
+                /*     */
+            }
+            /*     */
+            /* 260 */
+            if (!result.isEmpty())
+                /* 261 */ return result.toArray(new Media[result.size()]);
+            /*     */
+        }
+        /* 263 */
+        return null;
+        /*     */
+    }
+
+    public int getMaxsize() {
+        /*  95 */
+        return this._maxsize;
+        /*     */
+    }
+
+    public void setMaxsize(int value) {
+        /*  79 */
+        if (value < 0) {
+            /*  80 */
+            value = -1;
+            /*     */
+        }
+        /*     */
+        /*  83 */
+        if (this._maxsize != value) {
+            /*  84 */
+            this._maxsize = value;
+            /*  85 */
+            setAttribute("org.zkoss.zk.upload.maxsize", Integer.valueOf(value));
+            /*  86 */
+            smartUpdate("maxsize", this._maxsize);
+            /*     */
+        }
+        /*     */
+    }
+
+    public String getDetection() {
+        /* 122 */
+        return this._detection;
+        /*     */
+    }
+
+    public void setDetection(String value) {
+        /* 112 */
+        if (!this._detection.equals(value)) {
+            /* 113 */
+            this._detection = value;
+            /* 114 */
+            smartUpdate("detection", this._detection);
+            /*     */
+        }
+        /*     */
+    }
+
+    public String getViewerClass() {
+        /* 144 */
+        return this._viewerClass;
+        /*     */
+    }
+
+    public void setViewerClass(String value) {
+        /* 130 */
+        if (value != null && value.length() == 0) {
+            /* 131 */
+            value = null;
+            /*     */
+        }
+        /*     */
+        /* 134 */
+        if (!Objects.equals(this._viewerClass, value)) {
+            /* 135 */
+            this._viewerClass = value;
+            /* 136 */
+            smartUpdate("viewerClass", this._viewerClass);
+            /*     */
+        }
+        /*     */
+    }
+
+    public String getContent() {
+        /* 163 */
+        return this._content;
+        /*     */
+    }
+
+    public void setContent(String value) {
+        /* 153 */
+        if (value != null && !value.equals(this._content)) {
+            /* 154 */
+            this._content = value;
+            /* 155 */
+            smartUpdate("content", this._content);
+            /*     */
+        }
+        /*     */
+    }
+
+    public boolean isNative() {
+        /* 183 */
+        return this._native;
+        /*     */
+    }
+
+    public void setNative(boolean value) {
+        /* 172 */
+        if (value != this._native) {
+            /* 173 */
+            this._native = value;
+            /* 174 */
+            smartUpdate("native", this._native);
+            /*     */
+        }
+        /*     */
+    }
+
+    public Component getAnchor() {
+        /* 203 */
+        return this._anchor;
+        /*     */
+    }
+
+    public void setAnchor(Component anchor) {
+        /* 192 */
+        if (anchor != this._anchor) {
+            /* 193 */
+            this._anchor = anchor;
+            /* 194 */
+            smartUpdate("anchorUuid", (this._anchor != null) ? this._anchor.getUuid() : "");
+            /*     */
+        }
+        /*     */
+    }
+
+    protected void renderProperties(ContentRenderer renderer) throws IOException {
+
+        if (this._maxsize == 0) {
+            /* 210 */
+            this._maxsize = getDesktop().getWebApp().getConfiguration().getMaxUploadSize();
+            /*     */
+        }
+        /*     */
+        /* 213 */
+        super.renderProperties(renderer);
+        /* 214 */
+        if (!Objects.equals(this._detection, "browser")) {
+            /* 215 */
+            render(renderer, "detection", this._detection);
+            /*     */
+        }
+        /* 217 */
+        render(renderer, "maxsize", Integer.valueOf(this._maxsize));
+        /* 218 */
+        render(renderer, "viewerClass", this._viewerClass);
+        /* 219 */
+        render(renderer, "content", this._content);
+        /* 220 */
+        render(renderer, "native", this._native);
+        /* 221 */
+        if (this._anchor != null) {
+            /* 222 */
+            render(renderer, "anchorUuid", (this._anchor != null) ? this._anchor.getUuid() : "");
+            /*     */
+        }
+        /*     */
+    }
+
+    public void service(AuRequest request, boolean everError) {
+        /* 230 */
+        String cmd = request.getCommand();
+        /* 231 */
+        if ("onUpload".equals(cmd)) {
+            /* 232 */
+            Desktop desktop = getDesktop();
+            /* 233 */
+            List<Media> result = Generics.cast((List) desktop.getAttribute(getUuid()));
+            /* 234 */
+            desktop.removeAttribute(getUuid());
+            /* 235 */
+            UploadEvent uploadEvent = new UploadEvent("onUpload", desktop.getComponentByUuid(getUuid()), parseResult(result));
+            /*     */
+            /* 237 */
+            Events.postEvent(uploadEvent);
+            /*     */
+        } else {
+            /* 239 */
+            super.service(request, everError);
+            /*     */
+        }
+        /*     */
+    }
+    /*     */
+}
+
+
+/* Location:              C:\temp\zk\zkmax\!\org\zkoss\zkmax\zul\Dropupload.class
+ * Java compiler version: 5 (49.0)
+ * JD-Core Version:       1.1.3
+ */
\ No newline at end of file
diff --git a/dropfile/src/main/java/net/elgekko/zkoss/Version.java b/dropfile/src/main/java/net/elgekko/zkoss/Version.java
new file mode 100644 (file)
index 0000000..ae13c65
--- /dev/null
@@ -0,0 +1,8 @@
+package net.elgekko.zkoss;
+
+public class Version {
+    /**
+     * Returns the version UID.
+     */
+    public static final String UID = "0.0.1-SNAPSHOT";
+}
diff --git a/dropfile/src/main/java/org/example/Dropfile.java b/dropfile/src/main/java/org/example/Dropfile.java
deleted file mode 100644 (file)
index c5882c6..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.example;
-
-import org.zkoss.lang.Objects;
-import org.zkoss.zk.au.AuRequest;
-import org.zkoss.zk.ui.event.Event;
-import org.zkoss.zk.ui.event.Events;
-import org.zkoss.zul.impl.XulElement;
-
-import java.util.Map;
-
-public class Dropfile extends XulElement {
-
-    static {
-        addClientEvent(Dropfile.class, "onFoo", 0);
-    }
-
-    /* Here's a simple example for how to implements a member field */
-
-    private String _text;
-
-    public String getText() {
-        return _text;
-    }
-
-    public void setText(String text) {
-        if (!Objects.equals(_text, text)) {
-            _text = text;
-            smartUpdate("text", _text);
-        }
-    }
-
-
-    //super//
-    protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer)
-            throws java.io.IOException {
-        super.renderProperties(renderer);
-
-        render(renderer, "text", _text);
-    }
-
-    public void service(AuRequest request, boolean everError) {
-        final String cmd = request.getCommand();
-        final Map data = request.getData();
-
-        if (cmd.equals("onFoo")) {
-            final String foo = (String) data.get("foo");
-            System.out.println("do onFoo, data:" + foo);
-            Events.postEvent(Event.getEvent(request));
-        } else
-            super.service(request, everError);
-    }
-
-    /**
-     * The default zclass is "z-dropfile"
-     */
-    public String getZclass() {
-        return (this._zclass != null ? this._zclass : "z-dropfile");
-    }
-}
-
diff --git a/dropfile/src/main/java/org/example/Version.java b/dropfile/src/main/java/org/example/Version.java
deleted file mode 100644 (file)
index 8414022..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.example;
-
-public class Version {
-       /** Returns the version UID.
-        */
-       public static final String UID = "0.0.1-SNAPSHOT";
-}
index d5f89ad1dea540b735870c77a0f4b8f86c55ccd7..f901505a4a0a107f63e66c5655c065a8579f1d63 100644 (file)
@@ -1,32 +1,32 @@
 <language-addon>
     <addon-name>dropfile</addon-name>
-       <version>
-               <version-class>org.example.Version</version-class>
-               <version-uid>0.0.1-SNAPSHOT</version-uid>
-               <zk-version>9.6.0</zk-version><!-- or later -->
-       </version>
-    
-       <language-name>xul/html</language-name>
-       <component>
-               <component-name>dropfile</component-name> <!-- required -->
-               <component-class>org.example.Dropfile</component-class> <!-- required -->
-               <widget-class>dropfile.Dropfile</widget-class> <!-- required -->
-               <mold>
-                       <mold-name>default</mold-name>
-                       <mold-uri>mold/dropfile.js</mold-uri>
+    <version>
+        <version-class>net.elgekko.zkoss.Version</version-class>
+        <version-uid>0.0.1-SNAPSHOT</version-uid>
+        <zk-version>9.6.0</zk-version><!-- or later -->
+    </version>
 
-                       <!--
-                       == Tip in advance ==
-                               You don't have to specify a css.dsp if you need not ,
-                               but usually you need it.
+    <language-name>xul/html</language-name>
+    <component>
+        <component-name>dropfile</component-name> <!-- required -->
+        <component-class>net.elgekko.zkoss.Dropfile</component-class> <!-- required -->
+        <widget-class>dropfile.Dropfile</widget-class> <!-- required -->
+        <mold>
+            <mold-name>default</mold-name>
+            <mold-uri>mold/dropfile.js</mold-uri>
 
-                               You could assign a .css file ,too.
+            <!--
+            == Tip in advance ==
+                You don't have to specify a css.dsp if you need not ,
+                but usually you need it.
 
-                               The css.dsp is almost as same as CSS file ,
-                               but have more powerful enhancement.     (like EL support.)
-                       ====
-                       -->
-                       <css-uri>css/dropfile.css.dsp</css-uri>
-               </mold>
-       </component>
+                You could assign a .css file ,too.
+
+                The css.dsp is almost as same as CSS file ,
+                but have more powerful enhancement.    (like EL support.)
+            ====
+            -->
+            <css-uri>css/dropfile.css.dsp</css-uri>
+        </mold>
+    </component>
 </language-addon>
\ No newline at end of file
index 2616c23a8500ae1c475f09a66ea1ce3a4e357f34..9db4d89d7931642625e4074586adf8f72a3dd362 100644 (file)
-/**
- *
- * Base naming rule:
- * The stuff start with "_" means private , end with "_" means protect ,
- * others mean public.
- *
- * All the member field should be private.
- *
- * Life cycle: (It's very important to know when we bind the event)
- * A widget will do this by order :
- * 1. $init
- * 2. set attributes (setters)
- * 3. rendering mold (@see mold/dropfile.js )
- * 4. call bind_ to bind the event to dom .
- *
- * this.deskop will be assigned after super bind_ is called,
- * so we use it to determine whether we need to update view
- * manually in setter or not.
- * If this.desktop exist , means it's after mold rendering.
- *
- */
-dropfile.Dropfile = zk.$extends(zul.Widget, {
-       _text:'', //default value for text attribute
-       
-       /**
-        * Don't use array/object as a member field, it's a restriction for ZK object,
-        * it will work like a static , share with all the same Widget class instance.
-        *
-        * if you really need this , assign it in bind_ method to prevent any trouble.
-        *
-        * TODO:check array or object , must be one of them ...I forgot. -_- by Tony
-        */
-       
-       $define: {
-               /**
-                * The member in $define means that it has its own setter/getter.
-                * (It's a coding sugar.)
-                *
-                * If you don't get this ,
-                * you could see the comment below for another way to do this.
-                *
-                * It's more clear.
-                *
-                */
-               text: function() { //this function will be called after setText() .
-               
-                       if(this.desktop) {
-                               //updated UI here.
-                       }
-               }
-       },
-       /**
-        * If you don't like the way in $define ,
-        * you could do the setter/getter by yourself here.
-        *
-        * Like the example below, they are the same as we mentioned in $define section.
-        */
-       /*
-       getText:function(){ return this._text; },
-       setText:function(val){
-               this._text = val;
-               if(this.desktop){
-               //update the UI here.
-               }
-       },
-       */
-       bind_: function () {
-               /**
-                * For widget lifecycle , the super bind_ should be called
-                * as FIRST STATEMENT in the function.
-                * DONT'T forget to call supers in bind_ , or you will get error.
-                */
-               this.$supers(dropfile.Dropfile,'bind_', arguments);
-       
-               //A example for domListen_ , REMEMBER to do domUnlisten in unbind_.
-               //this.domListen_(this.$n("cave"), "onClick", "_doItemsClick");
-       },
-       /*
-               A example for domListen_ listener.
-       */
-       /*
-       _doItemsClick: function (evt) {
-               alert("item click event fired");
-       },
-       */
-       unbind_: function () {
-       
-               // A example for domUnlisten_ , should be paired with bind_
-               // this.domUnlisten_(this.$n("cave"), "onClick", "_doItemsClick");
-               
-               /*
-               * For widget lifecycle , the super unbind_ should be called
-               * as LAST STATEMENT in the function.
-               */
-               this.$supers(dropfile.Dropfile,'unbind_', arguments);
-       },
-       /*
-               widget event, more detail 
-               please refer to http://books.zkoss.org/wiki/ZK%20Client-side%20Reference/Notifications
-        */
-       doClick_: function (evt) {
-               this.$super('doClick_', evt, true);//the super doClick_ should be called
-               this.fire('onFoo', {foo: 'myData'});
-       }
-});
\ No newline at end of file
+(function () {
+    var j = {};
+    function e(m) {
+        m.stop()
+    }
+    function f(m) {
+        m.originalEvent.dataTransfer.dropEffect = "copy"
+    }
+    function g(m) {
+        m.originalEvent.dataTransfer.dropEffect = "none"
+    }
+    function i(m) {
+        e(m);
+        f(m)
+    }
+    function h(m) {
+        e(m);
+        g(m)
+    }
+    function a() {
+        jq(document).bind("dragenter dragover", h)
+    }
+    function k() {
+        jq(document).unbind("dragenter dragover", h)
+    }
+    function d(m) {
+        jq(document).bind("dragenter dragover", m.proxy(m._dragShow)).bind("dragleave drop", m.proxy(m._dragHide))
+    }
+    function l(m) {
+        jq(document).unbind("dragenter dragover", m.proxy(m._dragShow)).unbind("dragleave drop", m.proxy(m._dragHide))
+    }
+    dropfile.Dropfile = zk.$extends(zul.Widget, {
+        _sid: 0,
+        _detection: "browser",
+        _content: "",
+        _native: false,
+        _anchorUuid: "",
+        $init: function () {
+            this.$supers("$init", arguments);
+            this._uploaders = {};
+            this._last = {};
+            this._error = true
+        },
+        setMaxsize: (function (m) {
+            return function (n) {
+                this[m] = n;
+                return this
+            }
+        })("_maxsize"),
+        getMaxsize: _zkf$ = function () {
+            return this._maxsize
+        },
+        isMaxsize: _zkf$,
+        setViewerClass: (function (m) {
+            return function (n) {
+                this[m] = n;
+                return this
+            }
+        })("_viewerClass"),
+        getViewerClass: _zkf$ = function () {
+            return this._viewerClass
+        },
+        isViewerClass: _zkf$,
+        setDetection: (function (m) {
+            return function (n) {
+                this[m] = n;
+                return this
+            }
+        })("_detection"),
+        getDetection: _zkf$ = function () {
+            return this._detection
+        },
+        isDetection: _zkf$,
+        setContent: (function (m, n) {
+            return function () {
+                this.__fname__ = m.substring(1);
+                this[m] = n.apply(this, arguments);
+                this.__fname__ = null;
+                return this
+            }
+        })("_content", (function (m) {
+                return m ? m : ""
+            })),
+        getContent: _zkf$ = function () {
+            return this._content
+        },
+        isContent: _zkf$,
+        setAnchorUuid: (function (m, n) {
+            return function (p, q) {
+                var r = this[m];
+                this[m] = p;
+                if (r !== p || (q && q.force)) {
+                    this.__fname__ = m.substring(1);
+                    n.apply(this, arguments);
+                    this.__fname__ = null
+                }
+                return this
+            }
+        })("_anchorUuid", (function (m) {
+                this._shallSyncSize = true
+            })),
+        getAnchorUuid: _zkf$ = function () {
+            return this._anchorUuid
+        },
+        isAnchorUuid: _zkf$,
+        setNative: function (m) {
+            this._native = m
+        },
+        isNative: function () {
+            return this._native
+        },
+        bind_: function (r, q, p) {
+            this.$supers("bind_", arguments);
+            var o = this.getDetection(),
+            m = jq(this.$n());
+            m.bind("drop", this.proxy(this._dropAction));
+            switch (o) {
+            case "self":
+                m.bind("dragenter dragover", this.proxy(this._showContent)).bind("dragleave", this.proxy(this._hideContent));
+                a();
+                this._setContentVisible(false);
+                break;
+            case "browser":
+                m.bind("dragenter dragover", f).bind("dragleave", g);
+                d(this);
+                this.hide();
+                break;
+            case "none":
+                m.bind("dragenter dragover", i);
+                a();
+                break;
+            default:
+                var n = this;
+                p.push(function () {
+                    var s = jq(n.$f(o));
+                    if (s.length) {
+                        m.bind("dragenter dragover", i);
+                        s.bind("dragenter dragover", n.proxy(n._showContentNoneDrop)).bind("dragleave", n.proxy(n._hideContent));
+                        a();
+                        n._setContentVisible(false)
+                    } else {
+                        m.bind("dragenter dragover", f).bind("dragleave", g);
+                        d(n);
+                        n.hide()
+                    }
+                })
+            }
+        },
+        unbind_: function () {
+            var n = this.getDetection(),
+            m = jq(this.$n()).unbind("drop", this.proxy(this._dropAction));
+            var o = jq(this.$f(n));
+            if (n == "self") {
+                m.unbind("dragenter dragover", this.proxy(this._showContent)).unbind("dragleave", this.proxy(this._hideContent));
+                k()
+            } else {
+                if (n == "none") {
+                    m.unbind("dragenter dragover", i);
+                    k()
+                } else {
+                    if (n == "browser" || !o.length) {
+                        m.unbind("dragenter dragover", f).unbind("dragleave", g);
+                        l(this)
+                    } else {
+                        m.unbind("dragenter dragover", i);
+                        o.unbind("dragenter dragover", this.proxy(this._showContentNoneDrop)).unbind("dragleave", this.proxy(this._hideContent));
+                        k()
+                    }
+                }
+            }
+            if (j[this.uuid]) {
+                delete j[this.uuid]
+            }
+            this.$supers("unbind_", arguments)
+        },
+        _showContent: function (m) {
+            i(m);
+            this._setContentVisible(true);
+            this._shallContentHide = false
+        },
+        _showContentNoneDrop: function (m) {
+            h(m);
+            this._setContentVisible(true);
+            this._shallContentHide = false
+        },
+        _hideContent: function (n) {
+            e(n);
+            if (!this._shallContentHide) {
+                var m = this;
+                setTimeout(function () {
+                    if (m && m.desktop && m._shallContentHide) {
+                        m._setContentVisible(false)
+                    }
+                }, 50)
+            }
+            this._shallContentHide = true
+        },
+        _setContentVisible: function (m) {
+            var n = jq(this.$n()).children();
+            m ? n.show() : n.hide()
+        },
+        _dragHide: function (n) {
+            e(n);
+            delete j[this.uuid];
+            if (!this._shallHide) {
+                var m = this;
+                setTimeout(function () {
+                    if (m && m.desktop && m._shallHide) {
+                        m.setVisible(false)
+                    }
+                }, 50)
+            }
+            this._shallHide = true
+        },
+        _dragShow: function (p) {
+            e(p);
+            if (p.originalEvent.dataTransfer.types.length) {
+                var o = p.originalEvent.dataTransfer.types[0];
+                if (o != "Files" && o != "public.file-url" && o != "application/x-moz-file") {
+                    a();
+                    return
+                }
+                k()
+            }
+            if (p.originalEvent.dataTransfer.dropEffect != "copy") {
+                g(p)
+            }
+            this._shallHide = false;
+            j[this.uuid] = this;
+            var z = this.$n(),
+            s = this._last,
+            x = this._anchorUuid,
+            w = 0,
+            F;
+            for (F in s) {
+                if (s[F]) {
+                    w++
+                }
+            }
+            var A = this._shallSyncSize;
+            if (z) {
+                if (x) {
+                    var v = this._lastAnchor || {};
+                    var u = jq(x, zk),
+                    D = jq(z),
+                    B = u.offset(),
+                    m = D.offset();
+                    var t = u.width(),
+                    C = u.height(),
+                    r = B.top,
+                    y = B.left;
+                    if (v.w != t || v.h != C || v.t != r || v.l != y) {
+                        A = true;
+                        v.w = t;
+                        v.h = C;
+                        v.t = r;
+                        v.l = y;
+                        this._lastAnchor = v
+                    }
+                    if (A) {
+                        z.style.position = "fixed";
+                        z.style.zIndex = "10000";
+                        if (w == 0) {
+                            var q = D.width(),
+                            E = D.height();
+                            s.w = q ? q + "px" : "";
+                            s.h = E ? E + "px" : "";
+                            s.t = m.top ? m.top + "px" : "";
+                            s.l = m.left ? m.left + "px" : ""
+                        }
+                        if (u.size() > 0) {
+                            z.style.width = t + "px";
+                            z.style.height = C + "px";
+                            z.style.top = r + "px";
+                            z.style.left = y + "px"
+                        }
+                    }
+                } else {
+                    if (A) {
+                        z.style.position = "static";
+                        z.style.zIndex = "auto";
+                        z.style.width = s.w || "100px";
+                        z.style.height = s.h || "100px";
+                        z.style.top = s.t || "auto";
+                        z.style.left = s.l || "auto";
+                        this._last = {}
+                    }
+                }
+                this._shallSyncSize = false
+            }
+            this.setVisible(true)
+        },
+        _dropAction: function (s) {
+            e(s);
+            for (var y in j) {
+                this._dragHide.call(j[y], s)
+            }
+            if (this.getDetection() == "self") {
+                this._setContentVisible(false)
+            }
+            var r = s.originalEvent.dataTransfer.files;
+            console.log("_dropAction", r);
+            var C = this._maxsize > 0 ? this._maxsize * 1024 : -1;
+            if (C != -1) {
+                var p = [];
+                for (var A = 0; A < r.length; A++) {
+                    var B = r[A],
+                    w = B.size,
+                    u = w / 1024,
+                    q = C / 1024,
+                    t = " " + msgzk.KBYTES,
+                    m = " " + msgzk.MBYTES,
+                    v = Math.round(u) + t,
+                    n = Math.round(q) + t;
+                    if (w > C) {
+                        p.push(B.name);
+                        p.push(zk.fmt.Text.format(msgzul.UPLOAD_ERROR_EXCEED_MAXSIZE, v, n, w, C, v, n, Math.round(u / 1024) + m, Math.round(q / 1024) + m))
+                    }
+                }
+                if (p.length > 0) {
+                    zk.load("zul.wnd,zul.wgt,zul.box", function () {
+                        var H = [];
+                        for (var E = 0; E < p.length; E += 2) {
+                            H.push(new zul.wgt.Label({
+                                    id: "msg" + E,
+                                    value: p[E],
+                                    style: "font-weight: bold"
+                                }));
+                            H.push(new zul.wgt.Label({
+                                    id: "msg" + E + 1,
+                                    value: p[E + 1]
+                                }));
+                            if (!(E == p.length - 2)) {
+                                H.push(new zul.wgt.Separator({
+                                        bar: true
+                                    }))
+                            }
+                        }
+                        var F = new zul.wnd.Window({
+                            id: "aualert",
+                            closable: true,
+                            width: "250pt",
+                            title: zk.appName,
+                            border: "normal",
+                            children: [new zul.box.Box({
+                                    mold: "horizontal",
+                                    children: [new zul.wgt.Div({
+                                            sclass: "z-messagebox-icon z-messagebox-error"
+                                        }), new zul.wgt.Div({
+                                            id: "content",
+                                            sclass: "z-messagebox",
+                                            width: "210pt",
+                                            style: "overflow:auto",
+                                            children: [new zul.box.Box({
+                                                    mold: "vertical",
+                                                    children: H
+                                                })]
+                                        })]
+                                }), new zul.wgt.Separator({
+                                    bar: true
+                                }), new zul.box.Box({
+                                    mold: "horizontal",
+                                    style: "margin-left:auto; margin-right:auto",
+                                    children: [new zul.wgt.Button({
+                                            label: "OK",
+                                            listeners: {
+                                                onClick: function (I) {
+                                                    this.$o().detach()
+                                                }
+                                            }
+                                        })]
+                                })],
+                            mode: "modal"
+                        });
+                        var G = zk.Desktop.$();
+                        if (G && (G = G.firstChild) && G.desktop) {
+                            G.appendChild(F)
+                        } else {
+                            jq(document.body).append(F)
+                        }
+                    });
+                    return
+                }
+            }
+            var x = s.originalEvent.dataTransfer.items;
+            for (var A = 0; A < r.length; A++) {
+                var D = false;
+                if (x) {
+                    var o = x[A];
+                    if (o.getAsEntry) {
+                        D = o.getAsEntry().isDirectory
+                    } else {
+                        if (o.webkitGetAsEntry) {
+                            D = o.webkitGetAsEntry().isDirectory
+                        }
+                    }
+                }
+                if (!D) {
+                    this._sid++;
+                    var z = new dropfile.DropUploader(this, this._genKey(), r[A]);
+                    this._uploaders[z.id] = z
+                }
+            }
+            this.checkFinish()
+        },
+        _genKey: function () {
+            return this.uuid + "_uplder_" + this._sid
+        },
+        cancel: function (m) {
+            delete this._uploaders[m];
+            this.checkFinish()
+        },
+        checkFinish: function () {
+            var m = false;
+            for (var o in this._uploaders) {
+                if (!(m = this._uploaders[o].isFinish())) {
+                    this._uploaders[o].start();
+                    break
+                }
+                var n = this._uploaders[o].xhr.responseText;
+                n.startsWith("error") ? jq.alert(n.substring(6), {
+                    icon: "ERROR"
+                }) : this._error = false;
+                delete this._uploaders[o]
+            }
+            if (m && !this._error) {
+                this.fire("onUpload");
+                this._error = true
+            }
+        },
+        domContent_: function () {
+            return '<div id="' + this.uuid + '-content">' + this.getContent() + "</div>"
+        }
+    });
+    function c(n) {
+        var m = dropfile.DropUploadViewer.fileManager;
+        if (!m || !m.desktop) {
+            if (m) {
+                m.detach()
+            }
+            dropfile.DropUploadViewer.fileManager = m = new dropfile.DropUploadManager();
+            n.getWidget().getPage().appendChild(m)
+        }
+        m.removeFile(n);
+        m.addFile(n)
+    }
+    function b(m) {
+        if (dropfile.DropUploadManager) {
+            return c(m)
+        }
+        zk.load("zul.wgt,zul.box", function () {
+            dropfile.DropUploadManager = zk.$extends(zul.wgt.Popup, {
+                $init: function () {
+                    this.$supers("$init", arguments);
+                    this._files = {};
+                    this.setSclass("z-fileupload-manager")
+                },
+                onFloatUp: function (n) {
+                    if (!this.isVisible()) {
+                        return
+                    }
+                    this.setTopmost()
+                },
+                getFileItem: function (n) {
+                    return this._files[n] || zk.Widget.$(n)
+                },
+                addFile: function (p) {
+                    var r = p.id,
+                    q = p.file.name,
+                    o = this.getFileItem(r);
+                    if (!o) {
+                        o = new zul.wgt.Div({
+                            uuid: r,
+                            children: [new zul.wgt.Label({
+                                    value: q + ":"
+                                }), new zul.box.Box({
+                                    mold: "horizontal",
+                                    children: [new dropfile.Dropuploadprogress({
+                                            id: r,
+                                            sclass: "z-fileupload-progress"
+                                        }), new zul.wgt.Div({
+                                            sclass: "z-fileupload-remove z-icon-times",
+                                            listeners: {
+                                                onClick: function () {
+                                                    p.cancel()
+                                                }
+                                            }
+                                        })]
+                                }), new zul.wgt.Label({
+                                    id: r + "_total"
+                                }), new zul.wgt.Separator()]
+                        });
+                        try {
+                            this.appendChild(o)
+                        } catch (n) {}
+                        this._files[r] = o
+                    }
+                    return o
+                },
+                updateFile: function (p, q, n) {
+                    var r = p.id,
+                    o = this.getFileItem(r);
+                    if (!o) {
+                        return
+                    }
+                    o.$f(r).setValue(q);
+                    o.$f(r + "_total").setValue(n)
+                },
+                removeFile: function (q) {
+                    var s = q.id,
+                    o = this.getFileItem(s);
+                    if (o) {
+                        o.detach()
+                    }
+                    delete this._files[s];
+                    var r = true;
+                    for (var n in this._files) {
+                        if (!(r = false)) {
+                            break
+                        }
+                    }
+                    if (r) {
+                        this.close()
+                    }
+                },
+                open: function (o, n) {
+                    this.$super("open", o, null, n || "after_start", {
+                        sendOnOpen: false,
+                        disableMask: true
+                    })
+                }
+            });
+            c(m)
+        })
+    }
+    dropfile.DropUploadViewer = zk.$extends(zk.Object, {
+        $init: function (n, m) {
+            this.uploader = n;
+            b(n)
+        },
+        update: function (m, n) {
+            var o = dropfile.DropUploadViewer.fileManager;
+            if (o) {
+                if (!o.isOpen()) {
+                    o.open(this.uploader.getWidget())
+                }
+                o.updateFile(this.uploader, m * 100 / n, msgzk.FILE_SIZE + Math.round(n / 1024) + msgzk.KBYTES)
+            }
+        },
+        destroy: function () {
+            var m = dropfile.DropUploadViewer.fileManager;
+            if (m) {
+                m.removeFile(this.uploader)
+            }
+        }
+    });
+    dropfile.DropUploader = zk.$extends(zk.Object, {
+        _status: 100,
+        $init: function (n, q, o) {
+            this.upload = n;
+            this.id = q;
+            this.file = o;
+            var p,
+            m = this;
+            if (n.getViewerClass()) {
+                zk.$import(n.getViewerClass(), function (r) {
+                    p = new r(m, o)
+                })
+            } else {
+                p = new dropfile.DropUploadViewer(this, o)
+            }
+            this.viewer = p;
+            this.xhr = new XMLHttpRequest();
+            this.xhr.upload.onprogress = this.progressFunc();
+            this.xhr.onload = this.completeFunc();
+            this.xhr.onerror = this.errorFunc()
+        },
+        getWidget: function () {
+            return this.upload
+        },
+        isFinish: function () {
+            return this._status == 300
+        },
+        start: function () {
+            if (this._status == 200) {
+                return
+            }
+            this._status = 200;
+            var o = new FormData();
+            o.append("file", this.file);
+            var m = this.upload;
+            var n = m.desktop;
+            var q = zk.ajaxURI("/dropupload", {
+                desktop: n,
+                au: true
+            }) + "?uuid=" + m.uuid + "&dtid=" + n.id + "&native=" + m._native;
+            var p = this.xhr;
+            p.open("POST", q, true);
+            p.send(o)
+        },
+        cancel: function () {
+            if (this.xhr) {
+                this.xhr.abort()
+            }
+            this.viewer.destroy();
+            this.upload.cancel(this.id)
+        },
+        progressFunc: function () {
+            var m = this.viewer;
+            return function (n) {
+                m.update(n.loaded, n.total)
+            }
+        },
+        completeFunc: function () {
+            var m = this;
+            return function (n) {
+                m._status = 300;
+                m.viewer.destroy();
+                m.upload.checkFinish()
+            }
+        },
+        errorFunc: function () {
+            var m = this;
+            return function (n) {
+                m.cancel()
+            }
+        }
+    });
+    dropfile.Dropuploadprogress = zk.$extends(zul.wgt.Progressmeter, {
+        _fixImgWidth: _zkf = function () {
+            var p = this.$n(),
+            m = this.$n("img");
+            if (m) {
+                if (zk(p).isRealVisible()) {
+                    var o = jq(m)
+                }
+                o.animate({
+                    width: Math.round((p.clientWidth * this._value) / 100) + "px"
+                }, o.zk.getAnimationSpeed(100))
+            }
+        }
+    })
+})();
index ae850e95cca4a742e795a13fa2d852f0026d0b48..c9895ac2a44166663377df7161baac876c879cdb 100644 (file)
@@ -1,8 +1 @@
-<%--
-       Here you could do any styling job you want , all CSS stuff.
---%>
-<%@ taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c" %>
-
-.z-dropfile{
-     color:black;
-}
\ No newline at end of file
+<%@ taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c" %><%@ taglib uri="http://www.zkoss.org/dsp/zk/core" prefix="z" %><%@ taglib uri="http://www.zkoss.org/dsp/web/theme" prefix="t" %>.z-dropfile{width:100px;height:100px;-webkit-border-radius:10px;-moz-border-radius:10px;-o-border-radius:10px;-ms-border-radius:10px;border-radius:10px;padding:2px;background:#e6e6e6}
\ No newline at end of file
diff --git a/dropfile/src/main/resources/web/js/dropfile/less/dropfile.less b/dropfile/src/main/resources/web/js/dropfile/less/dropfile.less
new file mode 100644 (file)
index 0000000..8d836d9
--- /dev/null
@@ -0,0 +1,8 @@
+@import "~./zul/less/_header.less";
+
+.z-dropfile {
+       .size(100px, 100px);
+       .borderRadius(10px);
+       padding: 2px;
+       background: #E6E6E6;
+}
\ No newline at end of file
index 42e8584824b8108fed8e392367dfa1656cca227f..27f13f81832699c9ef09c3189f4750e2826cfccc 100644 (file)
@@ -1,21 +1 @@
-/**
-* Here's the mold file , a mold means a HTML struct that the widget really presented.
-* yep, we build html in Javascript , that make it more clear and powerful.
-*/
-function (out) {
-
-       //Here you call the "this" means the widget instance. (@see Dropfile.js)
-
-       var zcls = this.getZclass(),
-               uuid = this.uuid;
-
-       //The this.domAttrs_() means it will prepare some dom attributes,
-       //like the pseudo code below
-       /*
-               class="${zcls} ${this.getSclass()}" id="${uuid}"
-       */
-       out.push('<span ', this.domAttrs_(), '>');
-       out.push(this._text);
-       out.push('</span>');
-
-}
\ No newline at end of file
+function(a){a.push("<div",this.domAttrs_()," >",this.domContent_(),"</div>")};
\ No newline at end of file
index 05ee18f1f128c34c2788c38c7c806e8573e18627..75a5316e41740b5c0caac7d24c211ba569e5fba9 100644 (file)
@@ -1,62 +1,4 @@
 <?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-       ZK Widget Package Definition
-
-       ZK will load javascript by WPD , (i.e. zk.wpd , zul.inp.wpd ...etc )
-       that means all the widget definition in the package will be packed into single file in runtime ,
-       and be loaded when the component is accessed.
-
-       == Tip in advance ==
-         To prevent too many client Javascript requests for speeding up the loading,
-         sometimes you will consider to merge multiple packages in lang-addon.xml .
-         (@see lang-addon.xml)
-
-         We are not promising anything about the merging config ,
-         you have to check the order and dependency carefully when you merge it,
-         especially the dependency for "zul.lang" , it couldn't be merged with any package.
-       ====
-
-
-       Options:
-
-       * depends
-
-               If you are developing your own package ,
-               and you need to access a existing widget (ex.zul.db.Datebox)  ,
-               which your widget inherit from or need to instance for ,
-
-               that means your package count on the package (ex. "zul.db") ,
-               then you have to specify the package as "depends".
-
-               i.e.
-               <package name="my.package.name" language="xul/html" depends="zul.db">
-                       <widget name="MyWidget" />
-               </package>
-
-               You might depend multiple packages , use comma to separate them.
-               i.e. depends="zk.fmt,zul.inp"
-
-               When ZK try to load the package , it will load the dependency first.
-
--->
 <package name="dropfile" language="xul/html" depends="zul" >
-
-       <!--
-
-       == Tip in advance ==
-               You could also specify a general javascript file here,
-               it's not always required to be a widget definition.
-
-               For example , if you try to wrap some jQuery plug-in as a Widget ,
-               you might need to load some plug-in source code before you writing your widget.
-
-               Just place JS files in the package folder , and write the definition
-               <script src="js-file-a.js" />
-               <script src="js-file-b.js" />
-       ====
-
-       -->
-
        <widget name="Dropfile" />
 </package>
\ No newline at end of file
diff --git a/dropfile/src/test/java/test/ctrl/DemoWindowComposer.java b/dropfile/src/test/java/test/ctrl/DemoWindowComposer.java
deleted file mode 100644 (file)
index 63136b6..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-package test.ctrl;
-
-import org.example.Dropfile;
-
-import org.zkoss.zk.ui.Component;
-import org.zkoss.zk.ui.event.Event;
-import org.zkoss.zk.ui.event.ForwardEvent;
-import org.zkoss.zk.ui.select.SelectorComposer;
-import org.zkoss.zk.ui.select.annotation.Wire;
-
-public class DemoWindowComposer extends SelectorComposer {
-       
-       @Wire
-       private Dropfile myComp;
-       
-       public void doAfterCompose(Component comp) throws Exception {
-               super.doAfterCompose(comp);
-               myComp.setText("Hello ZK Component!! Please click me.");
-       }
-       
-       public void onFoo$myComp (ForwardEvent event) {
-               Event mouseEvent = (Event) event.getOrigin();
-               alert("You listen onFoo: " + mouseEvent.getTarget());
-       }
-}
\ No newline at end of file
diff --git a/dropfile/src/test/webapp/META-INF/MANIFEST.MF b/dropfile/src/test/webapp/META-INF/MANIFEST.MF
deleted file mode 100644 (file)
index 254272e..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Class-Path: 
-
diff --git a/dropfile/src/test/webapp/WEB-INF/web.xml b/dropfile/src/test/webapp/WEB-INF/web.xml
deleted file mode 100644 (file)
index 826f642..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
-       <display-name>dropfiledemo</display-name>
-       <listener>
-               <description>Used to cleanup when a session is destroyed</description>
-               <display-name>ZK Session cleaner</display-name>
-               <listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
-       </listener>
-       <servlet>
-               <description>The ZK loader for ZUML pages</description>
-               <servlet-name>zkLoader</servlet-name>
-               <servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class>
-               <init-param>
-                       <param-name>update-uri</param-name>
-                       <param-value>/zkau</param-value>
-               </init-param>
-               <load-on-startup>1</load-on-startup>
-       </servlet>
-       <servlet>
-               <description>The asynchronous update engine for ZK</description>
-               <servlet-name>auEngine</servlet-name>
-               <servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class>
-       </servlet>
-       <servlet-mapping>
-               <servlet-name>zkLoader</servlet-name>
-               <url-pattern>*.zul</url-pattern>
-       </servlet-mapping>
-       <servlet-mapping>
-               <servlet-name>zkLoader</servlet-name>
-               <url-pattern>*.zhtml</url-pattern>
-       </servlet-mapping>
-       <servlet-mapping>
-               <servlet-name>auEngine</servlet-name>
-               <url-pattern>/zkau/*</url-pattern>
-       </servlet-mapping>
-       <servlet>
-           <servlet-name>dspLoader</servlet-name>
-           <servlet-class>org.zkoss.web.servlet.dsp.InterpreterServlet</servlet-class>
-       </servlet>
-       <servlet-mapping>
-           <servlet-name>dspLoader</servlet-name>
-           <url-pattern>*.dsp</url-pattern>
-       </servlet-mapping>
-       <welcome-file-list>
-               <welcome-file>index.html</welcome-file>
-               <welcome-file>index.htm</welcome-file>
-               <welcome-file>index.jsp</welcome-file>
-               <welcome-file>default.html</welcome-file>
-               <welcome-file>default.htm</welcome-file>
-               <welcome-file>default.jsp</welcome-file>
-               <welcome-file>index.zul</welcome-file>
-       </welcome-file-list>
-</web-app>
\ No newline at end of file
diff --git a/dropfile/src/test/webapp/WEB-INF/zk.xml b/dropfile/src/test/webapp/WEB-INF/zk.xml
deleted file mode 100644 (file)
index b3ba275..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<zk>
-       <!-- Turn on if you want to debug JavaScript.
-               Once turned on, the uncompressed JavaScript files will be loaded.
-        -->
-       <client-config>
-               <debug-js>true</debug-js>
-       </client-config>
-       <device-config>
-               <device-type>ajax</device-type>
-               <timeout-uri>/timeout.zul</timeout-uri><!-- An empty URL can cause the browser to reload the same URL -->
-       </device-config>
-       <library-property>
-               <name>org.zkoss.zk.WPD.cache</name>
-               <value>false</value>
-       </library-property>
-       <library-property>
-               <name>org.zkoss.zk.WCS.cache</name>
-               <value>false</value>
-       </library-property>
-</zk>
diff --git a/dropfile/src/test/webapp/index.zul b/dropfile/src/test/webapp/index.zul
deleted file mode 100644 (file)
index ec0ad7b..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<zk>
-       <window title="Hello World!!" border="normal" width="300px"
-               apply="test.ctrl.DemoWindowComposer">
-               <dropfile id="myComp" />
-       </window>
-</zk>
\ No newline at end of file
diff --git a/dropfile/src/test/webapp/timeout.zul b/dropfile/src/test/webapp/timeout.zul
deleted file mode 100644 (file)
index 1516297..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<window width="80%" title="Session Timeout" border="normal">
-       <vbox>
-The page or component you request is no longer available.
-This is normally caused by timeout, opening too many Web pages, or rebooting
-the server.
-       </vbox>
-</window>
\ No newline at end of file
index 27916b9ded939896fc16530a2ab6024f54f89e10..7b3f8014fcde8d2997cc11e69f665645256c79f5 100644 (file)
@@ -22,7 +22,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
     public static final String REMOVE_DESKTOP_REGEX = "/zkau\\?dtid=.*&cmd_0=rmDesktop&.*";
 
 
-    public static final String[] ZK_RESOURCES = {"/zkau/web/**/js/**", "/zkau/web/**/zul/css/**", "/zkau/web/**/img/**", "/zkau/web/**/static/**"};
+    public static final String[] ZK_RESOURCES = {"/zkau/web/**/js/**", "/zkau/web/**/zul/css/**", "/zkau/web/**/zul/less/**", "/zkau/web/**/img/**", "/zkau/web/**/static/**"};
     @Autowired
     LocalAuthProvider localAuthProvider;
 
@@ -37,7 +37,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
         http.authorizeRequests()
                 .antMatchers(ZUL_FILES).denyAll() // block direct access to zul files
                 .antMatchers(HttpMethod.GET, ZK_RESOURCES).permitAll() // allow zk resources
-                .antMatchers(HttpMethod.POST, "/zkau/upload/**").permitAll() // allow zk resources
+                .antMatchers(HttpMethod.POST, "/zkau/upload/**", "/zkau/dropupload/**").permitAll() // allow zk resources
                 .regexMatchers(HttpMethod.GET, REMOVE_DESKTOP_REGEX).permitAll() // allow desktop cleanup
                 .requestMatchers(req -> "rmDesktop".equals(req.getParameter("cmd_0"))).permitAll() // allow desktop cleanup from ZATS
                 .mvcMatchers(Constants.NAV_ROOT, Constants.NAV_LOGIN, Constants.NAV_LOGOUT, Constants.NAV_API + "/**").permitAll()
index 5a6228aecd801c8fa65febae79de44dadeda5391..d7b66580b3f7448172f8c1e62befc39a74ae1219 100644 (file)
@@ -21,6 +21,7 @@ import org.zkoss.bind.annotation.Command;
 import org.zkoss.bind.annotation.Destroy;
 import org.zkoss.bind.annotation.Init;
 import org.zkoss.lang.Strings;
+import org.zkoss.util.media.Media;
 import org.zkoss.zk.ui.event.Event;
 import org.zkoss.zk.ui.event.EventListener;
 import org.zkoss.zk.ui.select.annotation.VariableResolver;
@@ -237,6 +238,16 @@ public class IndexViewModel implements EventListener<Event> {
         Editors.doShowEdit(Editors.POPUP_EDITOR, arg, modifiedEntity -> {
 
         });
+    }
+
 
+    @Command
+    public void doUploadFiles(@BindingParam("files") Media[] files) {
+        if (Objects.nonNull(files)) {
+            for (Media file : files) {
+                log.info(file.getName());
+            }
+        }
     }
+
 }
index c57966feab6ce8d61391c737008f3e6ed18e91e5..9c75c76c12de44caddf990f1995c0127e365d200 100644 (file)
@@ -44,4 +44,5 @@ public class LoginViewModel {
             message = Strings.EMPTY;
         }
     }
+
 }
index b785be5208179480404e920141d4432b0c208344..a40ddfe1cbd1250552ac66690ba1870867cead69 100644 (file)
                                     </vlayout>
                                     <vlayout>
                                         <label value="Nettó összeg"/>
-                                        <doublebox readonly="true"
+                                        <doublebox readonly="false"
                                                    value="@bind(vm.formDocument.netAmount) @validator(vm)"
                                                    format="#,###.##" locale="hu"
                                                    forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
                                     <vlayout>
                                         <label value="Bruttó összeg"/>
-                                        <doublebox readonly="true"
+                                        <doublebox readonly="false"
                                                    value="@bind(vm.formDocument.grossAmount) @validator(vm)"
                                                    format="#,###.##" locale="hu"
                                                    forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
                                     <vlayout>
                                         <label value="ÁFA"/>
-                                        <doublebox readonly="true"
+                                        <doublebox readonly="false"
                                                    value="@bind(vm.formDocument.vatAmount) @validator(vm)"
                                                    format="#,###.##" locale="hu"
                                                    forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                 <hlayout>
                                     <vlayout>
                                         <label value="Kiállítás dátuma"/>
-                                        <datebox readonly="true" format="yyyy. MM. dd."
+                                        <datebox readonly="false" format="yyyy. MM. dd."
                                                  value="@bind(vm.formDocument.createDate) @validator(vm)"
                                                  forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
                                     <vlayout>
                                         <label value="Teljesítés dátuma"/>
-                                        <datebox readonly="true" format="yyyy. MM. dd."
+                                        <datebox readonly="false" format="yyyy. MM. dd."
                                                  value="@bind(vm.formDocument.completionDate) @validator(vm)"
                                                  forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
                                     <vlayout>
                                         <label value="Fizetési határidő"/>
-                                        <datebox readonly="true" format="yyyy. MM. dd."
+                                        <datebox readonly="false" format="yyyy. MM. dd."
                                                  value="@bind(vm.formDocument.paymentDeadline) @validator(vm)"
                                                  forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
index 530fb3d5ad1e2b8217164bed68b7a23a1f6e2d6e..7b95ef88fa1ede6ad1c0eb65f7d3c7e01edded3f 100644 (file)
                                     </vlayout>
                                     <vlayout>
                                         <label value="Nettó összeg"/>
-                                        <doublebox readonly="true"
+                                        <doublebox readonly="false"
                                                    value="@bind(vm.formDocument.netAmount) @validator(vm)"
                                                    format="#,###.##" locale="hu"
                                                    forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
                                     <vlayout>
                                         <label value="Bruttó összeg"/>
-                                        <doublebox readonly="true"
+                                        <doublebox readonly="false"
                                                    value="@bind(vm.formDocument.grossAmount) @validator(vm)"
                                                    format="#,###.##" locale="hu"
                                                    forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
                                     <vlayout>
                                         <label value="ÁFA"/>
-                                        <doublebox readonly="true"
+                                        <doublebox readonly="false"
                                                    value="@bind(vm.formDocument.vatAmount) @validator(vm)"
                                                    format="#,###.##" locale="hu"
                                                    forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                 <hlayout>
                                     <vlayout>
                                         <label value="Kiállítás dátuma"/>
-                                        <datebox readonly="true" format="yyyy. MM. dd."
+                                        <datebox readonly="false" format="yyyy. MM. dd."
                                                  value="@bind(vm.formDocument.createDate) @validator(vm)"
                                                  forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
                                     <vlayout>
                                         <label value="Teljesítés dátuma"/>
-                                        <datebox readonly="true" format="yyyy. MM. dd."
+                                        <datebox readonly="false" format="yyyy. MM. dd."
                                                  value="@bind(vm.formDocument.completionDate) @validator(vm)"
                                                  forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
                                     <vlayout>
                                         <label value="Fizetési határidő"/>
-                                        <datebox readonly="true" format="yyyy. MM. dd."
+                                        <datebox readonly="false" format="yyyy. MM. dd."
                                                  value="@bind(vm.formDocument.paymentDeadline) @validator(vm)"
                                                  forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
index 19478f4b99c39e34a242521c1db29d6ea110d099..5a52302a05c62d525001699e415f0e3a63c9be55 100644 (file)
                                        format="#,###.##" locale="hu" instant="true"
                                        onChange="@command('onNetAmountChange')"
                                        forward="onOK=submit.onClick, onCancel=cancel.onClick"
+                                       disabled="@bind(vm.readonlyForm)"
                                        c:onPaste="preventPastingNonDigit(event)"/>
-                            <!--                                       disabled="@bind(vm.readonlyForm)"-->
                         </vlayout>
                         <vlayout>
                             <label value="Bruttó összeg"/>
                             <doublebox value="@bind(vm.formDocument.grossAmount) @validator(vm)"
                                        format="#,###.##" locale="hu" instant="true"
                                        forward="onOK=submit.onClick, onCancel=cancel.onClick"
+                                       disabled="@bind(vm.readonlyForm)"
                                        c:onPaste="preventPastingNonDigit(event)"/>
-                            <!--                                       disabled="@bind(vm.readonlyForm)"-->
                         </vlayout>
                         <vlayout>
                             <label value="ÁFA (HUF)"/>
                             <doublebox value="@bind(vm.formDocument.vatAmount) @validator(vm)"
                                        format="#,###.##" locale="hu" instant="true"
                                        forward="onOK=submit.onClick, onCancel=cancel.onClick"
+                                       disabled="@bind(vm.readonlyForm)"
                                        c:onPaste="preventPastingNonDigit(event)"/>
-                            <!--                                       disabled="@bind(vm.readonlyForm)"-->
                         </vlayout>
                     </hlayout>
                     <hlayout>
index 8ec38883ec97d743b71eb59389bced49c0ad6a9b..28abbca667d5cb377064dde561f2de2884ea8347 100644 (file)
                 </div>
 
             </div>
+            <window>
+                <zscript><![CDATA[
+public void showFileName(org.zkoss.zk.ui.event.UploadEvent event){
+       org.zkoss.util.media.Media[] medias = event.getMedias();
+       StringBuffer sb = new StringBuffer();
+       for (org.zkoss.util.media.Media m : medias) {
+               sb.append(m.getName()+"\n");
+       }
+       Messagebox.show(sb.toString());
+}
+]]></zscript>
+                <dropfile maxsize="5120" detection="none" onUpload="showFileName(event)"
+                          native="true">
+                    <attribute name="content">
+                        <![CDATA[
+                    <b>Drop Here</b><br/>
+                    size < 5MB
+                ]]>
+                    </attribute>
+                </dropfile>
+            </window>
+
         </caption>
 
         <borderlayout>
index 65e7f3d2fbcd82d20dcd7934ed3074251c9c7b4b..7d843776125c61867c082bed2a60687e39bfa534 100644 (file)
@@ -65,6 +65,7 @@
                 </rows>
             </grid>
 
+
         </window>
     </n:form>
 </zk>
\ No newline at end of file