Bug 35796 Drag and drop freezes Windows explorer(modal dialog problem) [dnd]
- Close all programs(important) - Create an empty resource project - Select any file and drop it into a folder in the project - Bring the Windows explorer to front so that it covers the middle of the screen, but that the folder in the project remains visible. Make sure there is only *one* Windows explorer window running(important). - Drag and drop the same file to the same place - The Windows explorer window now appears to be frozen. *Behind* the Windows explorer there is a modal requester asking whether the file should be replaced. Click in the Eclipse window, close requester, and Windows explorer now works again. No exceptions in log.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/FileTransferDropAdapter.java
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.dnd.JdtViewerDropAdapter;
import org.eclipse.jdt.internal.ui.dnd.TransferDropTargetListener;
/**
 * Adapter to handle file drop from other applications.
 */ 
class FileTransferDropAdapter extends JdtViewerDropAdapter implements IOverwriteQuery, TransferDropTargetListener {
	
	FileTransferDropAdapter(AbstractTreeViewer viewer) {
		super(viewer, DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND);
	}
	
	public String queryOverwrite(String file) {
		
		String[] returnCodes= {YES, ALL, NO, CANCEL};
		int returnVal= openDialog(getViewer().getControl(), file);
		return returnVal < 0 ? CANCEL : returnCodes[returnVal];
	}	
	
	private int openDialog(final Control control, final String file) {
		final int[] result= { Dialog.CANCEL };
		control.getDisplay().syncExec(new Runnable() {
			public void run() {
				String title= PackagesMessages.getString("DropAdapter.question"); 
				String msg= PackagesMessages.getFormattedString("DropAdapter.alreadyExists", file); 
				String[] options= {IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL};
				MessageDialog dialog= new MessageDialog(control.getShell(), title, null, msg, MessageDialog.QUESTION, options, 0);
				result[0]= dialog.open();
			}