Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 299034 - [DnD] Drag and Drop from view to editor is not working
Summary: [DnD] Drag and Drop from view to editor is not working
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: JFace (show other bugs)
Version: 1.3   Edit
Hardware: All All
: P3 critical with 8 votes (vote)
Target Milestone: 1.3 M5   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-07 08:23 EST by fmetral CLA
Modified: 2010-01-13 06:35 EST (History)
0 users

See Also:


Attachments
fix (6.03 KB, patch)
2010-01-11 11:48 EST, Tim Buschtoens CLA
ruediger.herrmann: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description fmetral CLA 2010-01-07 08:23:18 EST
I'm using eclipse 3.6M3 and RAP 1.3M4.
I'm doing a POC to convert an existing RCP application to RAP.
The drag and drop feature works well when I drag elements from a view and drop them to an other view but it doesn't work when I drop them to an editor.

The code responsible of drop is the same in the view and the editor.
Table t = new Table(parent, SWT.NONE);
TableViewer tViewer = new TableViewer(t);
tViewer.addDropSupport(DND.DROP_MOVE | DND.DROP_COPY, new Transfer[] { ObjectTransfer.getInstance() }, new DefaultDropTargetListener());

And I get the following exception:
java.lang.ArrayIndexOutOfBoundsException: 0
at org.eclipse.swt.internal.widgets.displaykit.DNDSupport.proce ssDragEnter(DNDSupport.java:161)
at org.eclipse.swt.internal.widgets.displaykit.DNDSupport.acces s$3(DNDSupport.java:147)
at org.eclipse.swt.internal.widgets.displaykit.DNDSupport$1.run (DNDSupport.java:119)
at org.eclipse.rwt.lifecycle.ProcessActionRunner.executeNext(Pr ocessActionRunner.java:57)
at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.readAndDispa tch(RWTLifeCycle.java:238)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :982

To reproduce it, create a view with a viewer on a tree. Add a drag support on the treeViwer:
viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
viewer.setContentProvider(new ViewContentProvider());
viewer.setLabelProvider(new ViewLabelProvider());
viewer.setInput(createDummyModel());
viewer.addDragSupport(DND.DROP_MOVE, new Transfer[] { ObjectTransfer.getInstance() }, new DefaultDragSourceListener());

Create an editor with a tableViewer associated to a table:
Table t = new Table(parent, SWT.NONE);
TableViewer tViewer = new TableViewer(t);
tViewer.addDropSupport(DND.DROP_MOVE | DND.DROP_COPY, new Transfer[] { ObjectTransfer.getInstance() }, new DefaultDropTargetListener());

Try to drag element on the tree and drop them in the table of editor.

This corrections is critical for us because it will prvent us to use RAP technology as we use Drag and Drop.
Regards,
Comment 1 Tim Buschtoens CLA 2010-01-11 11:48:19 EST
Created attachment 155764 [details]
fix

The described scenario resulted in a dropTarget being a child of another dropTarget. Both received the events dispatched by DragAndDropHandler, causing an inconsistent state in DNDSupport.js. Solved by calling event.stopPropagation(). Test included.
Comment 2 Rüdiger Herrmann CLA 2010-01-13 06:34:02 EST
Applied patch to CVS HEAD