Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » browser + drag and drop
browser + drag and drop [message #463023] Sun, 04 February 2007 02:30 Go to next message
Daniel Beck is currently offline Daniel BeckFriend
Messages: 4
Registered: July 2009
Junior Member
Hello RCP mailing list,


I want to implement drag and drop functionality between the
org.eclipse.swt.browser and a custom made editor. Particularly, the
software should support dragging pictures or text from the browser to
the editor.

I was not successful in implementing that drag and drop functionality. I
wanted to ask if someone already did it, and how. (a code snippet would
be great)

Thanks and regards,
Daniel
Re: browser + drag and drop [message #463073 is a reply to message #463023] Mon, 05 February 2007 23:41 Go to previous messageGo to next message
Jacek Pospychala is currently offline Jacek PospychalaFriend
Messages: 159
Registered: July 2009
Senior Member
Daniel,
it's possible. Look at swt snippet83, available at www.eclipse.org/swt

With a bit modified code you can see that, dragging a text provides you
with a String, while dragging an image provides with a path to image
file cached by the browser on disk.

To see this, let's change Snippet83.getNameFromId(int) to
getNameFromId(int,TransferData), and then modify the method so its part
will look like this:

case COM.CF_HDROP: // image
name = "CF_HDROP";
if (transferData != null) {
FileTransfer ft = FileTransfer.getInstance();
String[] r= (String[]) ft.nativeToJava(transferData);
name += " " + r[0]; // Append a path to file with image
}
break;
case COM.CF_TEXT: // text
name = "CF_TEXT";
if (transferData != null) {
name += " " +TextTransfer.getInstance().nativeToJava(transferData);
// append copied text
}
break;

Remember, to pass transferData in dragEnter(...) and null in constructor.

Jacek Pospychala

Daniel Beck napisał(a):
> Hello RCP mailing list,
>
>
> I want to implement drag and drop functionality between the
> org.eclipse.swt.browser and a custom made editor. Particularly, the
> software should support dragging pictures or text from the browser to
> the editor.
>
> I was not successful in implementing that drag and drop functionality. I
> wanted to ask if someone already did it, and how. (a code snippet would
> be great)
>
> Thanks and regards,
> Daniel
Re: browser + drag and drop [message #463295 is a reply to message #463073] Thu, 08 February 2007 02:56 Go to previous message
Daniel Beck is currently offline Daniel BeckFriend
Messages: 4
Registered: July 2009
Junior Member
Jacek,

your solution worked, thanks!


Daniel


> Daniel,
> it's possible. Look at swt snippet83, available at www.eclipse.org/swt
>
> With a bit modified code you can see that, dragging a text provides you
> with a String, while dragging an image provides with a path to image
> file cached by the browser on disk.
>
> To see this, let's change Snippet83.getNameFromId(int) to
> getNameFromId(int,TransferData), and then modify the method so its part
> will look like this:
>
> case COM.CF_HDROP: // image
> name = "CF_HDROP";
> if (transferData != null) {
> FileTransfer ft = FileTransfer.getInstance();
> String[] r= (String[]) ft.nativeToJava(transferData);
> name += " " + r[0]; // Append a path to file with image
> }
> break;
> case COM.CF_TEXT: // text
> name = "CF_TEXT";
> if (transferData != null) {
> name += " " +TextTransfer.getInstance().nativeToJava(transferData);
> // append copied text
> }
> break;
>
> Remember, to pass transferData in dragEnter(...) and null in constructor.
>
> Jacek Pospychala
>
> Daniel Beck napisał(a):
>> Hello RCP mailing list,
>>
>>
>> I want to implement drag and drop functionality between the
>> org.eclipse.swt.browser and a custom made editor. Particularly, the
>> software should support dragging pictures or text from the browser to
>> the editor.
>>
>> I was not successful in implementing that drag and drop functionality.
>> I wanted to ask if someone already did it, and how. (a code snippet
>> would be great)
>>
>> Thanks and regards,
>> Daniel
Previous Topic:Listening to file changes outside the workspace
Next Topic:Detailes ProgressMassge in SplashScreen
Goto Forum:
  


Current Time: Sat Sep 07 11:06:27 GMT 2024

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

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

Back to the top