Servoy Stuff - Home of all Servoy related stuff!
Beans
DnDFileBean
The DnDFileBean v1.1
v1.1
Added an accept property (use a list of extensions separated by ',' ';' or space)
v1.0.1
Bug fix for 3.5.x
v1.0
First public release
This bean was made by request, but is released as Open Source (LGPL License), it is compatible with Servoy developer, smart client but NOT web client.
It works in Servoy 4.1.x and Servoy 3.5.x for Windows, should work on Mac and Linux OSes (not tested).
The idea is that this bean, when visible, adds a "drop target" surface on your form, when not visible, it transforms the whole form's background surface (and disabled/non editable objects) into a drop target for files.
When visible, it is a JList of files and will have all the behavior you would expect from a JList: you can select multiple lines, and I have added the option to omit the selection (by right-click popupmenu or using the backspace, delete or "-" keys) .
You can attach 2 javascript callback methods to events:
- "onDrop" will be called when files are dropped to it and will return an array of java.io.File (conveniently the .toString() methods of a file returns the path),
- "onOmit" will be called when files are omitted (with a right-click from the mouse or one of the delete keys), it will return an array of 2 arrays of java.io.File (omitted files, and remaining files).
You can drop files from your Windows explorer or Mac finder, you can even drop them from Eclipse or some other explorer that holds a tree of files basically (not Outlook though, as someone asked me).
The "recurseFolders" flag also tells the bean to recursively retrieve all the files containers inside a folder (or folders) dropped on it.
If true, you will get all the files in a folder, if false, you will only get the folder itself.
Download packages:
- the signed bean jar (rename to dndfiles.jar if necessary then put in your Servoy/application_server/beans/ folder)
- a simple Servoy example solution for Servoy 4.1.x (unzip and import)
- a simple Servoy example solution for Servoy 3.5..x (unzip and import)
- the Eclipse project (the java sources of the plugin)
There is now a companion Google-Code project where you will be able to submit issues/feature requests and check out the code from SVN
KNOW BUGS/LIMITATIONS:
This bean is NOT web compatible. There is less hope that it will ever be, unless browser's javascript get a functional API to receive files dropped in a reliable (and multi browser/platform compatible) way.
I only tested this one on Servoy 4.1.3 and 3.5.9 on Windows, but it should work OK on Mac/Linux since it doesn't use anything else than pure Java and the compilation has been targeted for Java 1.4.
On windows, the shortcuts are not resolved, meaning that if you drop a shortcut it will be retrieved as a file with a .lnk extension.
There is a possible workaround for this, and I can implement it if there is sufficient need/vote for it.
On Mac/Linux, shortcut should be symlink so be already resolved, but I have no proof of it.
Please send contact if there you note a different behavior and you know a workaround.
The bean behaviour is a little bit odd when used in List mode: you first have to click on a record of the form containing the bean to be able to use it, but I would guess it's standard Servoy limitation.
I haven't been able to use it in Table mode.
Anyway, there is little sense in using it other than in record mode, so I would recommend to stick with record mode to get the best results.
If you like this bean, consider donating to help me make more cool stuff available!
You can send me a note with any comment, feature request, bug report, using the contact form.
