SUGGESTED FIX
Name: agR10216 Date: 08/01/2002
Implement IDataObject::SetData() so that data in the CFSTR_PERFORMEDDROPEFFECT
format could be set by the Windows shell. Use the drop effect set in SetData()
if one supplied from DoDragDrop() is none.
----------------------------------------------------------------------------
--- awt_DnDDS.h Tue Jul 30 13:03:05 2002
***************
*** 233,238 ****
--- 233,240 ----
POINT m_dropPoint;
BOOL m_fNC;
+ DWORD m_dwPerformedDropEffect;
+
// static's ...
static jclass dSCClazz;
----------------------------------------------------------------------------
--- awt_DnDDS.cpp Wed Jul 31 14:40:01 2002
***************
*** 83,88 ****
--- 83,93 ----
&effects
);
+ if (effects == DROPEFFECT_NONE && dragSource->m_dwPerformedDropEffect != DROPEFFECT_NONE) {
+ effects = dragSource->m_dwPerformedDropEffect;
+ }
+ dragSource->m_dwPerformedDropEffect = DROPEFFECT_NONE;
+
call_dSCddfinished(env, peer, res == DRAGDROP_S_DROP && effects != DROPEFFECT_NONE,
convertDROPEFFECTToActions(effects),
dragSource->m_dragPoint.x, dragSource->m_dragPoint.y);
***************
*** 132,137 ****
--- 137,144 ----
m_dropPoint.x = 0;
m_dropPoint.y = 0;
+ m_dwPerformedDropEffect = DROPEFFECT_NONE;
+
LoadCache(formats);
AddRef();
***************
*** 846,852 ****
*/
HRESULT __stdcall AwtDragSource::SetData(FORMATETC __RPC_FAR *pFormatEtc, STGMEDIUM __RPC_FAR *pmedium, BOOL fRelease) {
! return E_NOTIMPL;
}
/**
--- 853,869 ----
*/
HRESULT __stdcall AwtDragSource::SetData(FORMATETC __RPC_FAR *pFormatEtc, STGMEDIUM __RPC_FAR *pmedium, BOOL fRelease) {
! static CLIPFORMAT CF_PERFORMEDDROPEFFECT = ::RegisterClipboardFormat(CFSTR_PERFORMEDDROPEFFECT);
!
! if (pFormatEtc->cfFormat == CF_PERFORMEDDROPEFFECT && pmedium->tymed == TYMED_HGLOBAL) {
! m_dwPerformedDropEffect = *(DWORD*)::GlobalLock(pmedium->hGlobal);
! ::GlobalUnlock(pmedium->hGlobal);
! if (fRelease) {
! ::ReleaseStgMedium(pmedium);
! }
! return S_OK;
! }
! return E_UNEXPECTED;
}
/**
###@###.### 2002-07-31
======================================================================
|
EVALUATION
Name: agR10216 Date: 07/29/2002
I reproduced the bug with the build 1.4.1-rc-b18 with the following test
case.
----------------------------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import java.awt.datatransfer.*;
import java.awt.dnd.*;
import java.io.*;
public class FileDropTest {
private Frame frame = new Frame();
FileDropTest() {
final DragSourceListener dsl = new DragSourceAdapter() {
public void dragDropEnd(DragSourceDropEvent e) {
System.err.println("drop success=" + e.getDropSuccess());
}
};
DragGestureListener dgl = new DragGestureListener() {
public void dragGestureRecognized(DragGestureEvent dge) {
dge.startDrag(null, new FileListSelection(), dsl);
}
};
new DragSource().createDefaultDragGestureRecognizer(frame,
DnDConstants.ACTION_MOVE, dgl);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
System.exit(0);
}
});
frame.setSize(100, 100);
frame.setVisible(true);
}
public static void main(String[] args) {
new FileDropTest();
}
}
class FileListSelection implements Transferable {
private static final int FL = 0;
private static final DataFlavor[] flavors =
new DataFlavor[] { DataFlavor.javaFileListFlavor };
private java.util.List data;
public FileListSelection(java.util.List data) {
this.data = data;
}
public FileListSelection() {
data = new java.util.ArrayList();
File file = new File("data.txt");
data.add(file);
}
public DataFlavor[] getTransferDataFlavors() {
return (DataFlavor[])flavors.clone();
}
public boolean isDataFlavorSupported(DataFlavor flavor) {
for (int i = 0; i < flavors.length; i++) {
if (flavor.equals(flavors[i])) {
return true;
}
}
return false;
}
public Object getTransferData(DataFlavor flavor)
throws UnsupportedFlavorException, java.io.IOException
{
if (flavor.equals(flavors[FL])) {
return (Object)data;
} else {
throw new UnsupportedFlavorException(flavor);
}
}
}
----------------------------------------------------------------------------
DoDragDrop() supplies IDropSource with the drop effect, which
indicates how the drag-and-drop operation affected the source data.
In our current implementation the drop success is determined by comparing
the drop effect with DROPEFFECT_NONE.
The Windows shell normally uses an optimized move to move files, so
there is no need for the source to delete the original file.
The protocol of the optimized move differs from one of the ordinary unoptimized
move; particularly, some value other than DROPEFFECT_MOVE (typically
DROPEFFECT_NONE) is passed to the drag source.
###@###.### 2002-07-29
======================================================================
|