wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Drag and Drop to Tree Viewer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Drag and Drop to Tree Viewer" Watch "Drag and Drop to Tree Viewer" New topic
Author

Drag and Drop to Tree Viewer

LQ McDonald III
Greenhorn

Joined: Aug 01, 2012
Posts: 10

Hey there folks,

So I am having an issue with a bit of code that I am working with and I thought I would stop banging my head against the screen long enough to petition the brilliant minds here at the ranch for some guidance.

I have a TreeViewer that is set up and working nicely inside an RCP View. Everything is working fine with that. I also have another view that contains a ListViewer. Also working fine. I have the List in the ListViewer as the DragSource and the Tree in my TreeViewer as my Drop Target. I also have a Mouse Hover Listener on the tree to change the selection when a node of the tree is hovered over. This also works as intended. The issue I am having is that when I grab an item from the list and drag it to the tree the mouse hover even does not get handled. It is obvious to me that this is because the mouse button is held down and mouse events can't trigger if the mouse button is held down but I am wondering if anyone has a work around or potentially clever solution to the problem? What i want to happen is when I grab something from the list and drag it to the tree I want the tree to change to the node I am hovered over and drop the object there.

I have tried several different potential solutions including focus listeners, mouse events, etc to no avail. I thought I would get a fresh perspective before I throw my computer out the window. I appreciate the time and energy of your responses and if you need further clarification please ask. Thanks!
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
if it was Swing, you might be able to dispatchEvent(..) to the TreeViewer.
don't know if there's an equivalent in SWT (?)
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

I have no experience with it, but I think you should probably post some code snippet to show what you have done so far. That will increase your chances of getting an answer.


The quieter you are, the more you are able to hear.
LQ McDonald III
Greenhorn

Joined: Aug 01, 2012
Posts: 10

Michael Dunn wrote:if it was Swing, you might be able to dispatchEvent(..) to the TreeViewer.
don't know if there's an equivalent in SWT (?)


If it was Swing it would be much easier, of that much I am certain but the dev environment requires SWT/Jface api.

I am not sure how relevant a code snippet(s) is as the solution is not reliant on any particular implementation. I am simply asking if there is a reasonable way to detect mouse events even when the mouse button is held down. I have explained what I have done so far and I do not see the value in prancing out a bunch of code that does not address the root issue, namely the question about whether mouse hover events can be forced to be handled even if the mouse button is held down.
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

Sorry, I read the post to quickly and didn't notice you're looking just for an idea.
LQ McDonald III
Greenhorn

Joined: Aug 01, 2012
Posts: 10

Kemal Sokolovic wrote:Sorry, I read the post to quickly and didn't notice you're looking just for an idea.


No problem. I appreciate the post and advice anyway.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Drag and Drop to Tree Viewer
 
Similar Threads
onMouseUp in Safari
Drag and Drop from a tree view
Windows 7 seems to be worth it
Drag and drop of multiple items
making own InputStreamReader()