Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 336634 - Doubleclick in tree viewers with DND support is broken
Summary: Doubleclick in tree viewers with DND support is broken
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: JFace (show other bugs)
Version: 1.4   Edit
Hardware: All All
: P1 normal (vote)
Target Milestone: 1.4 M6   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-08 11:20 EST by Michael Klein CLA
Modified: 2011-02-10 06:30 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-02-08 11:20:38 EST
Environment: Firefox 3.6.13/IE 8.0.7600 on Win7

The bug occurs only using RAP 1.4 M5. With 1.4 M4 it works correctly.


Steps to reproduce:
* create a tree viewer
* add a IDoubleClickListener to the tree viewer
* add drag support to the tree viewer
* fill it with some items
* double-click on any (not selected) item
-> The IDoubleClickListener is called as expected
* select one item
* double-click on the selected item
-> The IDoubleClickListener is not called

Expected:
The IDoubleClickListener is called on every double-click.


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.addDoubleClickListener(new IDoubleClickListener() {
  			public void doubleClick(DoubleClickEvent event) {
  				MessageDialog.openInformation(shell, "Test", "Doubleclicked");
  			}
  		});
  		
  		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 Michael Klein CLA 2011-02-08 11:22:54 EST
Just a wild guess: perhaps this issue is related to bug 334101
Comment 2 Tim Buschtoens CLA 2011-02-08 12:26:06 EST
That(In reply to comment #1)
> Just a wild guess: perhaps this issue is related to bug 334101

That would be a pretty good guess. I think the double-click detection fails because the item does not get focused on mousedown in this scenario. Not yet sure how to handle this, needs some research.
Comment 3 Ralf Sternberg CLA 2011-02-08 17:24:09 EST
Marking as P1 because it's a regression.
Comment 4 Tim Buschtoens CLA 2011-02-10 06:30:41 EST
Fixed CVS HEAD.

The issue was acutally that due to the fix for bug 334101, the double click detection wass called twice for one click, canceling each other out.