Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » DND, multiple Transfer classes
DND, multiple Transfer classes [message #432812] Sat, 27 March 2004 19:46 Go to next message
Jochen Kressin is currently offline Jochen KressinFriend
Messages: 9
Registered: July 2009
Junior Member
Hi,

I am using Eclipse 3.0M7 on WinXP.
I am a little bit confused about Transfer classes: I have a tree
displaying several different kinds of objects(videos, clips, categories
etc.). I added DND-support for the first kind of object, called Clip, by
writing my own Transfer class. Everything was fine. Now, I added support
for another type, called Category. I wrote a transfer class for this
type as well, and added it:

Transfer[] transfers = new Transfer[] {ClipTransfer.getInstance(),
CategoryTransfer.getInstance()};
source.setTransfer(transfers);

In my DragSource#dragStart method I set the dataType field of the
DragSourceEvent to one of the TransferData, like this:

event.dataType=ClipTransfer.getInstance().getSupportedTypes( )[0];
or
event.dataType=CategoryTransfer.getInstance().getSupportedTy pes()[0];

However, it seems that only the first Transfer object in my array of
transfer objects is being used, regardless to what I set the dataType
to. If e.g. I add another Transfer as the first element of the Array of
transfer objects, say FileTransfer, then none of my transfer classes is
invoked at all. This causes a lot of ClassCasts and Nullpointers.

I thought that depending on the dataType field of the DragSource event,
the correct Transfer class is being used, but it seems that I really
misunderstood the use of transfer classes. However, I could not find any
good article about it. I read the articles about DND in JFace and
Eclipse, as found on eclipse.org, but they are rather short on Transfer
classes, especially on multiple transfer classes like in my example.
Could someone enlighten my stupid brain or point me to an article
explaining the proper use of Transfers?

Thanks you very much,

Jochen
Re: DND, multiple Transfer classes [message #432817 is a reply to message #432812] Sun, 28 March 2004 19:29 Go to previous messageGo to next message
Jochen Kressin is currently offline Jochen KressinFriend
Messages: 9
Registered: July 2009
Junior Member
Hi,

I think I figured out what I was missing. The point is that you do not
define one transfer class per object type you want to support. Neither
do you set the dataType on the event by yourself. The transfer class(es)
you use must be able to serialize/deserialize every object you want to dnd.
Now, if you define more than one transfer class on a
dragSource/dropTarget, then dnd is only possible if both the source and
the target have at least one transfer class which have 'compatible',
i.e. matching types.

If I am wrong that feel free to correct me ;)

Thanks,

Jochen

Jochen Kressin wrote:
> Hi,
>
> I am using Eclipse 3.0M7 on WinXP.
> I am a little bit confused about Transfer classes: I have a tree
> displaying several different kinds of objects(videos, clips, categories
> etc.). I added DND-support for the first kind of object, called Clip, by
> writing my own Transfer class. Everything was fine. Now, I added support
> for another type, called Category. I wrote a transfer class for this
> type as well, and added it:
>
> Transfer[] transfers = new Transfer[] {ClipTransfer.getInstance(),
> CategoryTransfer.getInstance()};
> source.setTransfer(transfers);
>
> In my DragSource#dragStart method I set the dataType field of the
> DragSourceEvent to one of the TransferData, like this:
>
> event.dataType=ClipTransfer.getInstance().getSupportedTypes( )[0];
> or
> event.dataType=CategoryTransfer.getInstance().getSupportedTy pes()[0];
>
> However, it seems that only the first Transfer object in my array of
> transfer objects is being used, regardless to what I set the dataType
> to. If e.g. I add another Transfer as the first element of the Array of
> transfer objects, say FileTransfer, then none of my transfer classes is
> invoked at all. This causes a lot of ClassCasts and Nullpointers.
>
> I thought that depending on the dataType field of the DragSource event,
> the correct Transfer class is being used, but it seems that I really
> misunderstood the use of transfer classes. However, I could not find any
> good article about it. I read the articles about DND in JFace and
> Eclipse, as found on eclipse.org, but they are rather short on Transfer
> classes, especially on multiple transfer classes like in my example.
> Could someone enlighten my stupid brain or point me to an article
> explaining the proper use of Transfers?
>
> Thanks you very much,
>
> Jochen
Re: DND, multiple Transfer classes [message #1623483 is a reply to message #432817] Thu, 19 February 2015 05:46 Go to previous message
Priyanka Ummanna is currently offline Priyanka UmmannaFriend
Messages: 1
Registered: February 2015
Junior Member
Hi Jochen,

I am facing same problem as you was faced.
In Transfer[] transferTypes I have 3 different Class Instances , where in both addDragSupport and addDropSupport I am using it.
Through transfer types are same in both addDragSupport and addDropSupport, Only first type is calling irrespective of what drag is.

can you please tell what we have to do to solve the problem.

thanks in advance.

Previous Topic:SWT Tree hides first item when header gets visible
Next Topic:How to trigger a redraw of all widgets of my application ?
Goto Forum:
  


Current Time: Fri Mar 29 09:38:27 GMT 2024

Powered by FUDForum. Page generated in 0.03826 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top