Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » DND with multiple Transfer Types
icon5.gif  DND with multiple Transfer Types [message #666370] Wed, 20 April 2011 08:17 Go to next message
Remo Blaser is currently offline Remo BlaserFriend
Messages: 9
Registered: August 2010
Junior Member
Hello Community!

I was experiencing the Drag and Drop Function in Eclipse the past few days.
I did a little Project where i can Drag Apps into Smartphones (Android and iPhone Phones), listing the Apps in a TableViewer and the Smartphones in a TreeViewer.
So far i got no Problem, but as i was making it a little bit more complex i got a very strange thing:

If i drag a App onto a Smartphone, i should check: Hey is this App available for this Smartphone?

I wanted to check it via the ViewerDropAdapter.validateDrop() Method to show it directly if someone is draging it over my Smartphone.
But then i saw, i got no Event in this Method but a TransferType Object.
So i tried to create 1 Abstract Transfer Class and two Transfer Classes wich are responsible to their Apps: IphoneAppTransfer and AndroidAppTransfer.
Now heres the Strange thing: I cant change the event.dataType.type property to my own Transfertype so i always get the same Transfertype in the validateDrop() method.
I also searched articles about multiple Transfer Types but i havent find any good Informations.
Would you give me any Hints or good Articles about that?
Re: DND with multiple Transfer Types [message #666467 is a reply to message #666370] Wed, 20 April 2011 14:12 Go to previous messageGo to next message
BLANC Philippe is currently offline BLANC PhilippeFriend
Messages: 89
Registered: July 2009
Member
Hi,
Say me if I'm wrong but your problem is just to know both your app object and your smartphone object in the validateDrop method of your dropListener, isn't it?

You want to drag an object "App" from a tableViewer to your treeviewer that contains the list of "Smartphones".
Then you would like to check if the App object is compatible with your Smartphone object.

On your treeviewer, I suppose that you have assigned your own dragSupport as following:

mSmartphoneViewer.addDropSupport(
	DND.DROP_MOVE, 
        new Transfer[]{myTransfer}, 
        myDropListener());


Is your DropListener an instance of org.eclipse.jface.viewers.ViewerDropAdapter? If not, implements this class.

public class MyDropListener extends ViewerDropAdapter{

    @Override
	public boolean performDrop(Object data) {
             ...
        }

      @Override
	public boolean validateDrop(Object target, int operation,
			TransferData transferType) {
             //The target object corresponds to your "App" Object
             App myApp = (App) target
             // You can get your Smartphone object, you can use the method getSelectedObject()
             Smartphone mysmartPhone = (SmartPhone) getSelectedObject
       }

}


In this case, your transfert object should be able to convert both Smartphone and App objects.

I hope this will help you.

Regards,

Philippe B.
Re: DND with multiple Transfer Types [message #666500 is a reply to message #666467] Wed, 20 April 2011 15:33 Go to previous message
Remo Blaser is currently offline Remo BlaserFriend
Messages: 9
Registered: August 2010
Junior Member
Hello Philippe and thanks for your input!

But the "target" is my smartphone Object in the Treeviewer.
The App comes from the TableViewer as you suggested.
Also the SelectedObject is the current selected Smartphone on the Treeviewer.

Maybe you got annother hint?

Greetings from Switzerland!
Previous Topic:CRT+A / CTR+Z / CTR+Y are not caught by a keylistner in a wizard
Next Topic:Howto access a status line contribution
Goto Forum:
  


Current Time: Thu Nov 27 13:34:51 GMT 2014

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

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