Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334101 - [Tree] DND with multiselection in tree viewers is broken
Summary: [Tree] DND with multiselection in tree viewers is broken
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: JFace (show other bugs)
Version: 1.4   Edit
Hardware: PC Windows 7
: P2 normal (vote)
Target Milestone: 1.4 M5   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-12 08:55 EST by Michael Klein CLA
Modified: 2011-01-21 12:05 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Klein CLA 2011-01-12 08:55:40 EST
Environment: Firefox 3.6.13/IE 8.0.7600 on Win7

The bug occurs using RAP 1.4 M4.

Steps to reproduce:
* create a tree viewer
* add drag support to the tree viewer
* fill it with some items
* select more than one item
* try to drag the selected items
-> The selection is reduced to one single item and the drag contains only one item

Expected:
The multiselection is untouched and the drag contains all selected items


Here is a snippet to reproduce:

public class Snippet implements IEntryPoint {

	public int createUI() {
		Display display = new Display();
		Shell shell = new Shell(display, SWT.TITLE);
		createContent(shell);
		shell.layout();
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		return 0;
	}

	private void createContent(Shell shell) {
		shell.setLayout(new GridLayout(1, false));

		Tree tree = new Tree(shell, SWT.NONE | SWT.MULTI);
		tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		TreeViewer viewer = new TreeViewer(tree);
		viewer.setLabelProvider(new LabelProvider());

		viewer.setContentProvider(new ITreeContentProvider() {
			public Object[] getElements(Object inputElement) {
				return new Object[] {"Root"};
			}
			public Object[] getChildren(Object parentElement) {
				if (hasChildren(parentElement)) {
					String[] input = new String[10];
					for (int i = 0; i < input.length; i++) {
						input[i] = "Item " + i;
					}
					return input;
				}
				return new Object[0];
			}
			public boolean hasChildren(Object element) {
				return element.toString().startsWith("Root");
			}
			public void dispose() {
			}
			public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
			}
			public Object getParent(Object element) {
				return null;
			}
		});
		
		viewer.addDragSupport(DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK, new Transfer[] {TextTransfer.getInstance()}, new DragSourceAdapter());

		viewer.setInput(new Object[0]);
		viewer.expandAll();
	}

}
Comment 1 Ivan Furnadjiev CLA 2011-01-18 04:11:25 EST
Reproducible with Examples Demo -> Tree page too. DnD on multi Table works fine. The problem is that on mouse down for the start drag operation the multi selection is replaced with a single one.
Comment 2 Tim Buschtoens CLA 2011-01-20 08:25:09 EST
I checked against SWT/WIN. The RWT-Tree and SWT-Tree actually have the same behavior as long as the Tree is not a drag-source. If its a drag-source, the SWT-Tree changes its behavior and updates the selection on mouseup instead on mousedown (multi-seletion only). We have to do the same.
Comment 3 Tim Buschtoens CLA 2011-01-21 12:05:45 EST
Fixed in CVS HEAD. 

However, visuel drag-feedback is still limited to one item, this would be another issue.