Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Problem with DND
Problem with DND [message #450535] Tue, 15 February 2005 09:41 Go to next message
Nicole is currently offline NicoleFriend
Messages: 26
Registered: July 2009
Junior Member
Hi,

I have a view which contains multiple types of objects. From this view, I
wish to drag any of these object types in a single TreeViewer in the
editor. I am using the addDropSupport API of the Treeviewer to pass in a
ViewerDropAdapter with the respective TransferTypes, say :

Transfer[] inputInventoryTransfer = new Transfer[] {
InventoryTransfer
.getInstance(), EntityTypeTransfer.getInstance() };
inputInventoryTreeViewer.addDropSupport(ops,
inputInventoryTransfer,
new InputInventoryDropAdapter(inputInventoryTreeViewer,
page) {
public boolean performDrop(Object data) {
// TODO Auto-generated method stub
boolean flag = super.performDrop(data);
if (flag) {
inputInventoryTreeViewer.refresh();
inputInventorySPart.markDirty();
((ModelTypeFormEditor) page.getEditor())
.markDirty(true);
}
return flag;
}
});

InventoryTransfer takes charge of the Inventory object and
EntityTypeTransfer takes care of the EntityType object. However when I try
to drop an EntityType object on the TreeViewer, it always seem to mistake
it for a Inventory object and therefore result in an exception. I
understand somewhere in my DropAdapter I need to set the
event.currentDatatype to the correct Transfer type. May I know where
exactly can i do this and how can I know the exact type of data I am
trying to transfer? Because I tried to do this using the event.data, but
this is not set until later during the actual drop.

Please advise. Thanks.

Regards,
Nicole
Re: Problem with DND [message #450599 is a reply to message #450535] Tue, 15 February 2005 22:54 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
See:

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet185.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup

"Nicole" <nicole_kidding@yahoo.com> wrote in message
news:cusg3p$f9n$1@www.eclipse.org...
> Hi,
>
> I have a view which contains multiple types of objects. From this view, I
> wish to drag any of these object types in a single TreeViewer in the
> editor. I am using the addDropSupport API of the Treeviewer to pass in a
> ViewerDropAdapter with the respective TransferTypes, say :
>
> Transfer[] inputInventoryTransfer = new Transfer[] {
> InventoryTransfer
> .getInstance(), EntityTypeTransfer.getInstance() };
> inputInventoryTreeViewer.addDropSupport(ops,
> inputInventoryTransfer,
> new InputInventoryDropAdapter(inputInventoryTreeViewer,
> page) {
> public boolean performDrop(Object data) {
> // TODO Auto-generated method stub
> boolean flag = super.performDrop(data);
> if (flag) {
> inputInventoryTreeViewer.refresh();
> inputInventorySPart.markDirty();
> ((ModelTypeFormEditor) page.getEditor())
> .markDirty(true);
> }
> return flag;
> }
> });
>
> InventoryTransfer takes charge of the Inventory object and
> EntityTypeTransfer takes care of the EntityType object. However when I try
> to drop an EntityType object on the TreeViewer, it always seem to mistake
> it for a Inventory object and therefore result in an exception. I
> understand somewhere in my DropAdapter I need to set the
> event.currentDatatype to the correct Transfer type. May I know where
> exactly can i do this and how can I know the exact type of data I am
> trying to transfer? Because I tried to do this using the event.data, but
> this is not set until later during the actual drop.
>
> Please advise. Thanks.
>
> Regards,
> Nicole
>
Re: Problem with DND [message #450609 is a reply to message #450599] Wed, 16 February 2005 08:55 Go to previous messageGo to next message
Nicole is currently offline NicoleFriend
Messages: 26
Registered: July 2009
Junior Member
Hi,

First of all, thanks for the reply. This matter has been bugging me for a
long time now and I really appreciate the help.

Next, I read thru the snipplet code. The target uses the respective
TableItems to determine which type of transfer to use. However for my
case, my target is a Tree which does not use any mechanism to distinguish
between the different types of drop items. I can pull in a Entity and drop
it anywhere within the Tree or I can pull in an Inventory and drop it
anywhere within the Tree. There is no apparent feature in the Tree which I
can reference to in order to know what item I am trying to drop.

Is there no other way of doing this? Just out of curiosity, in the
DragEvent, I believe there is a field which records the type of item we
are trying to drag. Why is it that this information cannot be duplicated
in the DropEvent?

Anyhow, thanks again.

Regards,
Nicole


Veronika Irvine wrote:

> See:

>
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet185.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup

> "Nicole" <nicole_kidding@yahoo.com> wrote in message
> news:cusg3p$f9n$1@www.eclipse.org...
>> Hi,
>>
>> I have a view which contains multiple types of objects. From this view, I
>> wish to drag any of these object types in a single TreeViewer in the
>> editor. I am using the addDropSupport API of the Treeviewer to pass in a
>> ViewerDropAdapter with the respective TransferTypes, say :
>>
>> Transfer[] inputInventoryTransfer = new Transfer[] {
>> InventoryTransfer
>> .getInstance(), EntityTypeTransfer.getInstance() };
>> inputInventoryTreeViewer.addDropSupport(ops,
>> inputInventoryTransfer,
>> new InputInventoryDropAdapter(inputInventoryTreeViewer,
>> page) {
>> public boolean performDrop(Object data) {
>> // TODO Auto-generated method stub
>> boolean flag = super.performDrop(data);
>> if (flag) {
>> inputInventoryTreeViewer.refresh();
>> inputInventorySPart.markDirty();
>> ((ModelTypeFormEditor) page.getEditor())
>> .markDirty(true);
>> }
>> return flag;
>> }
>> });
>>
>> InventoryTransfer takes charge of the Inventory object and
>> EntityTypeTransfer takes care of the EntityType object. However when I try
>> to drop an EntityType object on the TreeViewer, it always seem to mistake
>> it for a Inventory object and therefore result in an exception. I
>> understand somewhere in my DropAdapter I need to set the
>> event.currentDatatype to the correct Transfer type. May I know where
>> exactly can i do this and how can I know the exact type of data I am
>> trying to transfer? Because I tried to do this using the event.data, but
>> this is not set until later during the actual drop.
>>
>> Please advise. Thanks.
>>
>> Regards,
>> Nicole
>>
Re: Problem with DND [message #450654 is a reply to message #450609] Wed, 16 February 2005 16:33 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
Not quite sure I understand the problem. In any of the callbacks for the
DragSourceListener, the event.currentDataType contains the type of data that
will be dropped. This field can be updated (in all but the actual drop
callback) to change the type of data that will be dropped. You must choose
one of the types specified in the event.dataTypes field. How you choose
which type to accept is up to the application. For more information see:

http://www.eclipse.org/articles/Article-SWT-DND/DND-in-SWT.h tml

Perhaps what you want is not just the type of the data but the data itself
in the Drag Over event. This is only supported on Windows. The article
above describes how to do this.


"Nicole" <nicole_kidding@yahoo.com> wrote in message
news:cuv1pn$jrc$1@www.eclipse.org...
> Hi,
>
> First of all, thanks for the reply. This matter has been bugging me for a
> long time now and I really appreciate the help.
>
> Next, I read thru the snipplet code. The target uses the respective
> TableItems to determine which type of transfer to use. However for my
> case, my target is a Tree which does not use any mechanism to distinguish
> between the different types of drop items. I can pull in a Entity and drop
> it anywhere within the Tree or I can pull in an Inventory and drop it
> anywhere within the Tree. There is no apparent feature in the Tree which I
> can reference to in order to know what item I am trying to drop.
>
> Is there no other way of doing this? Just out of curiosity, in the
> DragEvent, I believe there is a field which records the type of item we
> are trying to drag. Why is it that this information cannot be duplicated
> in the DropEvent?
>
> Anyhow, thanks again.
>
> Regards,
> Nicole
>
>
> Veronika Irvine wrote:
>
>> See:
>
>>
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet185.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup
>
>> "Nicole" <nicole_kidding@yahoo.com> wrote in message
>> news:cusg3p$f9n$1@www.eclipse.org...
>>> Hi,
>>>
>>> I have a view which contains multiple types of objects. From this view,
>>> I wish to drag any of these object types in a single TreeViewer in the
>>> editor. I am using the addDropSupport API of the Treeviewer to pass in a
>>> ViewerDropAdapter with the respective TransferTypes, say :
>>>
>>> Transfer[] inputInventoryTransfer = new Transfer[] {
>>> InventoryTransfer
>>> .getInstance(), EntityTypeTransfer.getInstance() };
>>> inputInventoryTreeViewer.addDropSupport(ops,
>>> inputInventoryTransfer,
>>> new InputInventoryDropAdapter(inputInventoryTreeViewer,
>>> page) {
>>> public boolean performDrop(Object data) {
>>> // TODO Auto-generated method stub
>>> boolean flag = super.performDrop(data);
>>> if (flag) {
>>> inputInventoryTreeViewer.refresh();
>>> inputInventorySPart.markDirty();
>>> ((ModelTypeFormEditor) page.getEditor())
>>> .markDirty(true);
>>> }
>>> return flag;
>>> }
>>> });
>>>
>>> InventoryTransfer takes charge of the Inventory object and
>>> EntityTypeTransfer takes care of the EntityType object. However when I
>>> try to drop an EntityType object on the TreeViewer, it always seem to
>>> mistake it for a Inventory object and therefore result in an exception.
>>> I understand somewhere in my DropAdapter I need to set the
>>> event.currentDatatype to the correct Transfer type. May I know where
>>> exactly can i do this and how can I know the exact type of data I am
>>> trying to transfer? Because I tried to do this using the event.data, but
>>> this is not set until later during the actual drop.
>>>
>>> Please advise. Thanks.
>>>
>>> Regards,
>>> Nicole
>>>
>
>
Re: Problem with DND [message #450727 is a reply to message #450654] Thu, 17 February 2005 03:42 Go to previous message
Nicole is currently offline NicoleFriend
Messages: 26
Registered: July 2009
Junior Member
Hi,

No problem. I managed to work around my problem. But still the point I am
trying to put across is that the DropEvent does not contain any
information about the type of object to be dropped. And in my situation,
the target viewer which I am trying to drop the object in does not have
anything to help distinguish between the different types of objects. (E.g.
in the snipplet, the TableItems on which I drop the thing over will
indicate to me which type of object.)

Anyway, really appreciate the help. Thanks a lot. :)

Regards,
Nicole


Veronika Irvine wrote:

> Not quite sure I understand the problem. In any of the callbacks for the
> DragSourceListener, the event.currentDataType contains the type of data that
> will be dropped. This field can be updated (in all but the actual drop
> callback) to change the type of data that will be dropped. You must choose
> one of the types specified in the event.dataTypes field. How you choose
> which type to accept is up to the application. For more information see:

> http://www.eclipse.org/articles/Article-SWT-DND/DND-in-SWT.h tml

> Perhaps what you want is not just the type of the data but the data itself
> in the Drag Over event. This is only supported on Windows. The article
> above describes how to do this.


> "Nicole" <nicole_kidding@yahoo.com> wrote in message
> news:cuv1pn$jrc$1@www.eclipse.org...
>> Hi,
>>
>> First of all, thanks for the reply. This matter has been bugging me for a
>> long time now and I really appreciate the help.
>>
>> Next, I read thru the snipplet code. The target uses the respective
>> TableItems to determine which type of transfer to use. However for my
>> case, my target is a Tree which does not use any mechanism to distinguish
>> between the different types of drop items. I can pull in a Entity and drop
>> it anywhere within the Tree or I can pull in an Inventory and drop it
>> anywhere within the Tree. There is no apparent feature in the Tree which I
>> can reference to in order to know what item I am trying to drop.
>>
>> Is there no other way of doing this? Just out of curiosity, in the
>> DragEvent, I believe there is a field which records the type of item we
>> are trying to drag. Why is it that this information cannot be duplicated
>> in the DropEvent?
>>
>> Anyhow, thanks again.
>>
>> Regards,
>> Nicole
>>
>>
>> Veronika Irvine wrote:
>>
>>> See:
>>
>>>
>>
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet185.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup
>>
>>> "Nicole" <nicole_kidding@yahoo.com> wrote in message
>>> news:cusg3p$f9n$1@www.eclipse.org...
>>>> Hi,
>>>>
>>>> I have a view which contains multiple types of objects. From this view,
>>>> I wish to drag any of these object types in a single TreeViewer in the
>>>> editor. I am using the addDropSupport API of the Treeviewer to pass in a
>>>> ViewerDropAdapter with the respective TransferTypes, say :
>>>>
>>>> Transfer[] inputInventoryTransfer = new Transfer[] {
>>>> InventoryTransfer
>>>> .getInstance(), EntityTypeTransfer.getInstance() };
>>>> inputInventoryTreeViewer.addDropSupport(ops,
>>>> inputInventoryTransfer,
>>>> new InputInventoryDropAdapter(inputInventoryTreeViewer,
>>>> page) {
>>>> public boolean performDrop(Object data) {
>>>> // TODO Auto-generated method stub
>>>> boolean flag = super.performDrop(data);
>>>> if (flag) {
>>>> inputInventoryTreeViewer.refresh();
>>>> inputInventorySPart.markDirty();
>>>> ((ModelTypeFormEditor) page.getEditor())
>>>> .markDirty(true);
>>>> }
>>>> return flag;
>>>> }
>>>> });
>>>>
>>>> InventoryTransfer takes charge of the Inventory object and
>>>> EntityTypeTransfer takes care of the EntityType object. However when I
>>>> try to drop an EntityType object on the TreeViewer, it always seem to
>>>> mistake it for a Inventory object and therefore result in an exception.
>>>> I understand somewhere in my DropAdapter I need to set the
>>>> event.currentDatatype to the correct Transfer type. May I know where
>>>> exactly can i do this and how can I know the exact type of data I am
>>>> trying to transfer? Because I tried to do this using the event.data, but
>>>> this is not set until later during the actual drop.
>>>>
>>>> Please advise. Thanks.
>>>>
>>>> Regards,
>>>> Nicole
>>>>
>>
>>
Previous Topic:RGB tool out there for Eclipse?
Next Topic:running applet which contains swt outside of eclipse
Goto Forum:
  


Current Time: Fri Apr 26 07:06:05 GMT 2024

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

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

Back to the top