I was asked a question today about whether or not Eclipse RCP can integrate with Firefox. The short answer is “yes”. The longer answer is “what do you mean by ‘integrate’?”.
An RCP application can, for example, be the drop target of a link dragged off a browser. SWT code snippet #84 shows how you can build a drag and drop source and target. Firefox seems to do the drag part a little different from the way that Internet Explorer. With both, you can drag a link from the address bar. With Firefox, you can drag links from within the page content to the running example. However, with Internet Explorer this doesn’t work.
When a drop event occurs, its contents are potentially represented in multiple formats and the drop target can pick what formats it wants to accept. You specify the types to accept by providing a org.eclipse.swt.dnd.DropTarget
with an array of org.eclipse.swt.dnd.Transfer
instances (subclasses, actually); it is the transfer objects that are responsible for determining what types of objects can be dropped and ultimately for decoding the contents of the event data. Snippet #84 uses an org.eclipse.swt.dnd.TextTransfer
instance which facilitates the dropping of text. Unfortunately, a drop from a link from Internet Explorer is not provided in the text format, so the drop is denied (it does work for drag events that originate from the address bar). You can figure out what types are loaded in the drop event by running snippet #83.
There is an org.eclipse.swt.dnd.HtmlTransfer
which sounds promising, but doesn’t do the job (this is intended for the case when you drag and drop a chunk of HTML text). Even more promising is the org.eclipse.swt.dnd.URLTransfer
class, but it also doesn’t appear to work (and is not actually visible outside the package anyway). I haven’t yet been able to find a transfer instance that does the job. Snippet #83 actually provides a custom implementation that looks promising; I may go that route. I’ll let you know how it works out. Whatever the case, even though it works, it doesn’t seem right to accept a URL in text format if you really are expecting a URL…
I’m going to play with this a little longer and then maybe open a bug report if it makes sense. I’m also going to see how this all works in Linux. More later.