Where SourceDragListener is an own implementation of DragSourceListener. What I want to achieve is, that if someone drags something from the treeViewer object to the Java editor of Eclipse (and only then) some actions are invoked (like formatting the code). Therefore, I need to find out if the item was dropped to the Java Editor of the current Eclipse instance (and not to any arbitrary text editor or other widget that accepts a TextTransfer.

Is there a possibility to achieve that? In the "event" object in the DragSourceListener I can't find such an information unfortunately.

!ENTRY org.eclipse.osgi 4 0 2011-08-30 17:28:05.282
!MESSAGE Application error
!STACK 1
org.eclipse.swt.SWTError: Cannot initialize Drop
at org.eclipse.swt.dnd.DND.error(DND.java:266)
at org.eclipse.swt.dnd.DND.error(DND.java:227)
at org.eclipse.swt.dnd.DropTarget.<init>(DropTarget.java:135)
my class, the line with new DropTarget... --> at my.project.ResultView.partActivated(ResultView.java:268)
at org.eclipse.ui.internal.PartListenerList2$1.run(PartListenerList2.java:70)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.runtime.Platform.run(Platform.java:888)
at org.eclipse.ui.internal.PartListenerList2.fireEvent(PartListenerList2.java:55)
at org.eclipse.ui.internal.PartListenerList2.firePartActivated(PartListenerList2.java:68)
at org.eclipse.ui.internal.PartService.firePartActivated(PartService.java:192)
at org.eclipse.ui.internal.PartService.access$0(PartService.java:177)
at org.eclipse.ui.internal.PartService$PartActivated.fire(PartService.java:100)
at org.eclipse.ui.internal.PartService.processPartJobs(PartService.java:161)
at org.eclipse.ui.internal.PartService$PartListener.handleEvent(PartService.java:88)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1058)
at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1447)
at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:2836)
at org.eclipse.swt.widgets.Widget.wmSetFocus(Widget.java:2403)
at org.eclipse.swt.widgets.Control.WM_SETFOCUS(Control.java:5152)
at org.eclipse.swt.widgets.Canvas.WM_SETFOCUS(Canvas.java:448)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4598)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4972)
at org.eclipse.swt.internal.win32.OS.SetFocus(Native Method)
at org.eclipse.swt.widgets.Control.forceFocus(Control.java:1098)
at org.eclipse.swt.widgets.Control.setSavedFocus(Control.java:3599)
at org.eclipse.swt.widgets.Decorations.restoreFocus(Decorations.java:821)
at org.eclipse.swt.widgets.Shell.open(Shell.java:1248)
at org.eclipse.jface.window.Window.open(Window.java:797)
at org.eclipse.ui.internal.WorkbenchWindow.open(WorkbenchWindow.java:818)
at org.eclipse.ui.internal.Workbench$70.runWithException(Workbench.java:3719)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803)
at org.eclipse.ui.internal.Workbench$33.runWithException(Workbench.java:1595)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)

Any suggestions / ideas what may be wrong?

In fact, I have a TypeDeclaration or MethodDeclaration in a view that I want to drop into the Java Editor and I need the drop action to perform code formatting after insertion and if a method is duplicate to remove the older one. Alternatively I could live with dropping it into the OutlineView but that doesn't work either.
--- snipp ---

Okay -- after reading some Eclipse sourcecode and crawling through the mud I found a solution to my problem. For adding a drop listener to the active workbench editor, one must execute the following steps:

It did not work out in my case. Since I want to transfer BodyDeclarations I had to write my own Transfer type anyhow and add it to the CompilationUnitEditor; thus the solution I found works well for me now.