Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 259908 - SWTBotTreeItem.doubleClick() doesn't work
Summary: SWTBotTreeItem.doubleClick() doesn't work
Status: RESOLVED FIXED
Alias: None
Product: SWTBot
Classification: Technology
Component: SWTBot (show other bugs)
Version: 2.0.0-dev   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 2.2.0   Edit
Assignee: Kristine Jetzke CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 271132
Blocks:
  Show dependency tree
 
Reported: 2009-01-04 05:33 EST by Ketan Padegaonkar CLA
Modified: 2013-12-20 07:02 EST (History)
13 users (show)

See Also:


Attachments
the patch for the fix (1.59 KB, patch)
2009-01-17 23:02 EST, Ketan Padegaonkar CLA
no flags Details | Diff
mylyn/context/zip (11.91 KB, application/octet-stream)
2009-01-17 23:02 EST, Ketan Padegaonkar CLA
no flags Details
test case (2.54 KB, application/octet-stream)
2009-01-17 23:03 EST, Ketan Padegaonkar CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ketan Padegaonkar CLA 2009-01-04 05:33:27 EST
Description copied from http://swtbot.org/bugzilla/show_bug.cgi?id=106:

Example Unit Test showing doubleClick not working

SWTBotTreeItem.doubleClick() should bring up an editor when using it on a Java File from the Package Explorer view, but it does not.

Attached Unit test is the example test I was writing that doesn’t work.
Comment 1 Ketan Padegaonkar CLA 2009-01-17 23:02:41 EST
Created attachment 122869 [details]
the patch for the fix
Comment 2 Ketan Padegaonkar CLA 2009-01-17 23:02:47 EST
Created attachment 122870 [details]
mylyn/context/zip
Comment 3 Ketan Padegaonkar CLA 2009-01-17 23:03:42 EST
Created attachment 122871 [details]
test case
Comment 4 Ketan Padegaonkar CLA 2009-01-17 23:04:16 EST
Kevin,

Found the fix, can you confirm that this patch works for you ? There's a minor change in the MenuFinder as a workaround for the recursive context menu being broken(bug 261360).
Comment 5 Kevin Doyle CLA 2009-01-17 23:42:21 EST
I had to change back the MenuFinder line to be false instead of true or else the test case would fail on the first line to open the new java project wizard.

After that the patch works for the test case, however I extended the testcase with: 

               editor.close();
		
		try {
			bot.activeEditor();
			fail("Active Editor found.");
		} catch (Exception e) {
	
		}
		
		view.setFocus();
		item = tree.getTreeItem(PROJECT_NAME).getNode("src");
		item.doubleClick();
		
		Thread.sleep(10000);

Since there is no api to check expanded state I have the 10 seconds sleep, so I can visually check for now.  I saw that the src folder wasn't being expanded.

I changed the order around for doubleClick a bit to be:

                assertEnabled();
		
		syncExec(new VoidResult() {
			public void run() {
				tree.setSelection(widget);
			}
		});
		
		notifyTree(SWT.Selection);
		notifyTree(SWT.MouseDown);
		notifyTree(SWT.MouseUp);
		notifyTree(SWT.MouseDown);
		notifyTree(SWT.MouseDoubleClick);
		notifyTree(SWT.DefaultSelection);
		notifyTree(SWT.MouseUp);
		return this;

With this change the src folder is collapsed.
Comment 6 Kevin Doyle CLA 2009-01-17 23:45:07 EST
Also to get around using the context menu bug I am using File -> New -> Class to create the class:

bot.menu("File").menu("New").menu("Class").click();
Comment 7 Ketan Patel CLA 2009-01-18 10:07:43 EST
This is a more general problem with how clicking a node in SWT Tree works...see this bug:
http://swtbot.org/bugzilla/show_bug.cgi?id=133

I think better general solution would be to modify how click works then the double click method. 

(In reply to comment #4)
> Kevin,
> 
> Found the fix, can you confirm that this patch works for you ? There's a minor
> change in the MenuFinder as a workaround for the recursive context menu being
> broken(bug 261360).
> 

Comment 8 Joe Luebker CLA 2009-02-02 17:34:09 EST
I just ran across this issue also. Adding myself to the CC list so that I can get an updated SWTBot once this is fixed.
Comment 9 hugulas chen CLA 2009-02-06 03:34:48 EST
I have also encounter this problem.Add me to cc list.
Comment 10 Marc CLA 2009-02-20 06:15:30 EST
Hi,

Here is what I've come to about doubleclick issue.
It is about a table but it's probably the same for tree.
I tell it in case it might help.

I had a TableViewer with Table.
A IDoubleClicListener is set on TableViewer
No direct listener on the Table.

Sending the SWT.mouseDoubleclick event to the the Table had no effect (it has one only if a double click listener is set on the Table)

Sending the SWT.DefaultSelection triggers the IDoubleClicListener.
(thanks hugulas chen for this tip)

So my point of vue is that the IDoubleClikListeners does not listen to double clics (!). It listens to "platform-dependent way of validating in a table"... which happens with a double click or press enter most of the time.

Each platform probably catch a real double clic and silently translate it to SWT.defaultSelection. What we do not do by sending SWT.MouseDoubleClick.

Hope this helps
Comment 11 Eric Jain CLA 2009-04-28 01:22:16 EDT
Confirming this issue with 2.0.0.204-dev.

Given the following code in a view:

  tableViewer.addDoubleClickListener(...open some editor...)

Executing bot.table(0).doubleClick(0, 0) results in the first row being selected, but no editor is opened!
Comment 12 Ketan Padegaonkar CLA 2009-04-28 04:23:00 EDT
Adding a dependency on bug 271132. bug 271132 should solve this long pending issue.
Comment 13 Urtzi Odriozola CLA 2010-01-25 12:27:37 EST
Also I'm following this issue.
Comment 14 Eddie Galvez CLA 2012-10-11 16:22:32 EDT
Just voicing my +1 here. Was sad to see doubleClick not work on a simple table (selected the item, caused no double-click)
Comment 15 Kristine Jetzke CLA 2013-12-06 20:16:12 EST
The problem with TreeItem.doubleClick seems to be already solved. 

Pushed patch to gerrit that sends SWT.DefaultSelection for Table.doubeClick. This should fix the table problem. https://git.eclipse.org/r/19471

(In reply to Marc from comment #10)

> Sending the SWT.DefaultSelection triggers the IDoubleClicListener.
> (thanks hugulas chen for this tip)
>
Comment 16 Mickael Istria CLA 2013-12-10 03:15:42 EST
Kristine's patch works well with good quality, so it got merged. Thanks.