Dnd Problems on a Tree [message #455958] |
Tue, 24 May 2005 08:44 |
Eclipse User |
|
|
|
Originally posted by: ssc.acentic.net
Hi
I have a tree with drag and drop which works fine so far.
I created a object "Book" which I attach to the treeItem with setData.
This also works fine.
The problem appears when I drag and drop a treeitem, I am not able to
transfer the object to the new treeitem. Getting the name is not a
problem, but the object is.
I use this to get the name :
public void drop (DropTargetEvent event) {
if (event.data == null) {
event.detail = DND.DROP_NONE;
return;
}
String text = (String) event.data;
}
which works ok, but how would I get the object. I assumed to do someting
like this :
Book mybook = (Book) event.data;
System.out.println(mybook.gettitle());
But that gave me a CastException.
Book mybook = (Book) event.item;
System.out.println(mybook.gettitle());
This works fine on the other hand, but unfortunately that gives me the
data of the drop target and not the source.
Hope anyone can help me out here.
Thanks,
Sebastian
|
|
|
Re: Dnd Problems on a Tree [message #455960 is a reply to message #455958] |
Tue, 24 May 2005 09:13 |
Eclipse User |
|
|
|
Originally posted by: ssc.acentic.net
Hi
actually I did a "workaround" if you can call it, just taking the class
defined
private Item dragSourceItem;
and this :
TreeItem tmpItem = (TreeItem)dragSourceItem;
Book mybook = (Book) tmpItem.getdata();
System.out.println(mybook.gettitle());
Now is that a good way to do this or any other suggestions ?
-Sebastian
|
|
|
|
Powered by
FUDForum. Page generated in 0.03726 seconds