Bug 103078 NPE during Java drag and drop
From time to time, when I drag and drop a Java file into a package in the Java perspective, I get the following exception and a dialog that an error has occurred. !ENTRY org.eclipse.jdt.ui 4 2 2005-07-07 16:33:08.671 !MESSAGE Problems occurred when invoking code from plug- in: "org.eclipse.jdt.ui". !STACK 0 java.lang.NullPointerException at org.eclipse.jdt.internal.ui.packageview.FileTransferDropAdapter.validateDrop (FileTransferDropAdapter.java:74) at org.eclipse.jdt.internal.ui.dnd.JdtViewerDropAdapter.validateDrop (JdtViewerDropAdapter.java:148) at org.eclipse.jdt.internal.ui.dnd.JdtViewerDropAdapter.dragOver (JdtViewerDropAdapter.java:188) at org.eclipse.jdt.internal.ui.dnd.DelegatingDropAdapter$2.run (DelegatingDropAdapter.java:116) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:1044) at org.eclipse.core.runtime.Platform.run(Platform.java:783) at org.eclipse.jdt.internal.ui.dnd.DelegatingDropAdapter.dragOver (DelegatingDropAdapter.java:114) at org.eclipse.swt.dnd.DNDListener.handleEvent(DNDListener.java:59) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:867) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:852) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:660) at org.eclipse.swt.dnd.DropTarget.notifyListeners(DropTarget.java:480) at org.eclipse.swt.dnd.DropTarget.DragOver(DropTarget.java:326) at org.eclipse.swt.dnd.DropTarget.access$5(DropTarget.java:304) at org.eclipse.swt.dnd.DropTarget$3.method4(DropTarget.java:234) at org.eclipse.swt.internal.ole.win32.COMObject.callback4 (COMObject.java:99) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1656) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2711) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:367) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:103) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:226) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:376) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:163) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:85) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:58) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:60) at java.lang.reflect.Method.invoke(Method.java:391) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334) at org.eclipse.core.launcher.Main.basicRun(Main.java:278) at org.eclipse.core.launcher.Main.run(Main.java:973)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/FileTransferDropAdapter.java
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.ui.dnd.JdtViewerDropAdapter;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
/**
 * Adapter to handle file drop from other applications.
 */ 
class FileTransferDropAdapter extends JdtViewerDropAdapter implements TransferDropTargetListener {
	
	FileTransferDropAdapter(AbstractTreeViewer viewer) {
		super(viewer, DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND);
	}
	
	
	public Transfer getTransfer() {
		return FileTransfer.getInstance();
	}
	
	public boolean isEnabled(DropTargetEvent event) {
		Object target= event.item != null ? event.item.getData() : null;
		if (target == null)
			return false;
		return target instanceof IJavaElement || target instanceof IResource;
	}
	
	
	public void validateDrop(Object target, DropTargetEvent event, int operation) {
		event.detail= DND.DROP_NONE;
		
		boolean isPackageFragment= target instanceof IPackageFragment;