[ADDED] Drag & drop support to WebFileDrop?

Request new features and improvements you want to see in WebLaF.
I will answer any request so don't hesitate and post it!

[ADDED] Drag & drop support to WebFileDrop?

Postby Endogen » Sat Feb 22, 2014 5:54 pm

What i mean is, is it possible to drag a file that is already inside the WebFileDrop out on the desktop?

Thanks,
Endo
Endogen
 
Posts: 14
Joined: Tue Jan 22, 2013 12:48 pm

Re: Is it possible to add drag & drop support to WebFileDrop

Postby mgarin » Thu Feb 27, 2014 6:34 pm

I am not sure whether or not this can be done easily, will have to check it first.

And it also depends on what you mean under "drag a file out on desktop" - WebFileDrop only contains a path to a physical file in your file system - you want to create a copy of that file in this case or..?
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg

Re: Is it possible to add drag & drop support to WebFileDrop

Postby Endogen » Fri Feb 28, 2014 1:00 am

Well yes you are absolutely right, there are only paths inside, sorry for that. What i'm doing right now is, i drop files into WebFileDrop and then save them (as blobs) in a database. But what i also want to do is the other direction: take a file that is displayed inside WebFileDrop and then drag it to a location - and there i want to copy the file from the database. But i'm not sure how to achieve this or if it is possible.

Intuitively i would expect WebFileDrop to go both ways - drop paths into it and also drop paths from it to another location. There could be a listener that will be triggered if the user drops the path somewhere. This listener could tell the user the dragged path and the drop location.

But maybe i can already do this somehow... Don't know.
Thanks for looking into that
Endogen
 
Posts: 14
Joined: Tue Jan 22, 2013 12:48 pm

Re: Is it possible to add drag & drop support to WebFileDrop

Postby mgarin » Fri Feb 28, 2014 1:15 pm

I got your point.

Still, there are two issues to do the thing you want:

1. WebFileDrop can contain only real file representation so far, so if you don't have a real file in your filesystem its plate will probably fail to show up in the selected files list. This might be improved later to allow custom non-existing files to be added, but there is another issue...

2. When you are dropping something into system (Java app [drag] -> System app) - for example into Windows Explorer or Mac OS X Finder - you will have to convert your dragged data into proper system format so that Explorer or Finder can understand what are dropping on them and decide what to do with that data. That leads to another issue - you will probably have to download your file from database before even dropping it somewhere as you won't be able to listen where something was dropped in the system. After that you will have to save that file somewhere locally and when you will perform drop - provide an appropriate file link so that Explorer or Filder will copy/move that file.

I am still not sure about the second part - there might be some tricky solution. I will investigate this issue and will say if i find something.
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg

Re: Is it possible to add drag & drop support to WebFileDrop

Postby mgarin » Fri Mar 07, 2014 11:48 am

Unfortunately i didn't find anything useful/working considering D&D back into filesystem. Theoretically it can be done by providing system-dependant Transferables on drag action, but i'm not sure about it.
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg

Re: Is it possible to add drag & drop support to WebFileDrop

Postby Endogen » Fri Mar 07, 2014 9:02 pm

Then i have to find some other mechanism to do this. But thanks a lot for looking into that!
Endogen
 
Posts: 14
Joined: Tue Jan 22, 2013 12:48 pm

Re: Is it possible to add drag & drop support to WebFileDrop

Postby mgarin » Tue Mar 11, 2014 2:55 pm

I was doing some more tests and found a pretty simple way to do the drag into the system.
It works without any issues on Windows, but i'm not sure about Mac OS X and Linux.

I will add some custom Transferable and TransferHandler classes into the next update.
Drag feature will also be available for separate WebFileDrop plates so you will be able to test it.
Still, you will have to enable this feature by calling webFileDrop.setFilesDragEnabled(true)
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg

Re: Is it possible to add drag & drop support to WebFileDrop

Postby mgarin » Tue Mar 11, 2014 4:52 pm

Here is a small example code that shows some of new WebFileDrop features:
Code: Select all
public class WebFileDropExample
{
    public static void main ( final String[] args )
    {
        WebLookAndFeel.install ();

        final WebFileDrop webFileDrop1 = new WebFileDrop ();
        webFileDrop1.setSelectedFiles ( Arrays.asList ( new File ( "C:\\test.xml" ) ) );
        webFileDrop1.setFilesDragEnabled ( true );
        webFileDrop1.setDragAction ( TransferHandler.COPY );

        final WebLabel copy = new WebLabel ( "COPY" );
        final GroupPanel group1 = new GroupPanel ( GroupingType.fillLast, 5, false, copy, new WebScrollPane ( webFileDrop1 ) );
        group1.setPreferredSize ( new Dimension ( 200, 400 ) );

        final WebFileDrop webFileDrop2 = new WebFileDrop ();
        webFileDrop2.setSelectedFiles ( Arrays.asList ( new File ( "C:\\test.mp3" ) ) );
        webFileDrop2.setFilesDragEnabled ( true );
        webFileDrop2.setDragAction ( TransferHandler.MOVE );

        final WebLabel move = new WebLabel ( "MOVE" );
        final GroupPanel group2 = new GroupPanel ( GroupingType.fillLast, 5, false, move, new WebScrollPane ( webFileDrop2 ) );
        group2.setPreferredSize ( new Dimension ( 200, 400 ) );

        TestFrame.show ( new GridPanel ( 1, 2, 10, group1, group2 ), 50 );
    }
}

The left WebFileDrop has COPY action and files dragged from it will be copied to other WebFileDrop components or copied within file system if you drop it on your system file manager. Right WebFileDrop has MOVE action and will perform file move actions to another WebFileDrop or within your file system.
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg

Re: Is it possible to add drag & drop support to WebFileDrop

Postby Endogen » Tue Mar 18, 2014 9:52 pm

Great! I will use that for sure. Will test this on linux as soon a 1.27 is out. Thanks a lot for the effort :D
Endogen
 
Posts: 14
Joined: Tue Jan 22, 2013 12:48 pm

Re: [ADDED] Drag & drop support to WebFileDrop?

Postby mgarin » Wed Jul 16, 2014 11:32 am

Mentioned features were added in v1.27 update.
A newer v1.28 update is already available though:
https://github.com/mgarin/weblaf/releases/tag/v1.28
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg


Return to Suggestions

Who is online

Users browsing this forum: No registered users and 2 guests

cron