Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 312686 - [CommonNavigator] double click on a tree item causes File to open in the editor
Summary: [CommonNavigator] double click on a tree item causes File to open in the editor
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.6 RC1   Edit
Assignee: Francis Upton IV CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-12 14:38 EDT by Duc Luu CLA
Modified: 2010-05-18 14:42 EDT (History)
6 users (show)

See Also:
bokowski: review+


Attachments
Debug session (218.95 KB, image/jpeg)
2010-05-12 14:43 EDT, Duc Luu CLA
no flags Details
Patch for RC1 (1.68 KB, patch)
2010-05-12 15:01 EDT, Francis Upton IV CLA
no flags Details | Diff
plugin to test with (106.50 KB, application/octet-stream)
2010-05-12 15:05 EDT, Francis Upton IV CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Duc Luu CLA 2010-05-12 14:38:38 EDT
Build Identifier: eclipse SDK 3.6.0 M7 Build id: I20100426-0852

When double click on a tree item that is adaptable to IResource class, eclipse launches the editor for the file that was returned by the tree item via the call ((IAdaptable)treeItem).getAdapter(IResource.class)

See debug session in the attachment.

This is a regression bug.



Reproducible: Always

Steps to Reproduce:
1. Open a logical model tree that contains some tree items that are adaptable to IResource (such as sub model element).
2. double click on the tree item that is adaptable to IResource class

Result:
The eclipse's OpenActionProvider launches the editor for the file that was returned by the tree item via the call ((IAdaptable)treeItem).getAdapter(IResource.class)
Comment 1 Duc Luu CLA 2010-05-12 14:43:31 EDT
Created attachment 168227 [details]
Debug session
Comment 2 Francis Upton IV CLA 2010-05-12 14:49:15 EDT
Just when I thought I was done with RC1.

This was caused by a fix in M7 to call the OpenFileAction.selectionChanged() to address another bug 288997.

Investigating how to deal with this now.
Comment 3 Francis Upton IV CLA 2010-05-12 15:01:36 EDT
Created attachment 168233 [details]
Patch for RC1

This backs out the change made by the fix to bug 288997
Comment 4 Francis Upton IV CLA 2010-05-12 15:05:10 EDT
Created attachment 168235 [details]
plugin to test with

Duc, can you test this one?
Comment 5 Boris Bokowski CLA 2010-05-12 15:13:03 EDT
(In reply to comment #0)
> Result:
> The eclipse's OpenActionProvider launches the editor for the file that was
> returned by the tree item via the call
> ((IAdaptable)treeItem).getAdapter(IResource.class)

Why is this wrong? What did you expect to happen (or what did happen in 3.5) upon a double-click?
Comment 6 Francis Upton IV CLA 2010-05-12 15:39:01 EDT
(In reply to comment #5)

> Why is this wrong? What did you expect to happen (or what did happen in 3.5)
> upon a double-click?
So the issue here as far as I understand it only happens when the Java content is not enabled, because the Java content provider overrides the resources one. So when the OpenActionProvider is enabled, it controls setting the selection for the workbench's OpenFileAction. Previously, it would call the OpenFileAction to set the selection state only if it had a single file selected, so that if you had something in the navigator that adapted to file, the OpenFileAction's selection state would never see it.

WIth the fix it would set the selection state using the workbench code to calculate this which would include anything that could be adapted to a file.

Later, the viewer's open mechanism would call this action handler and it would open whatever it thought was selected (or nothing if nothing was selected).

So if you had an object in the navigator that could be adapted to a file, the OpenFileAction would always be called (probably first) to open it, so then when the real action provided what wanted to open this was called later, it would be too late since the editor was already opened.

The original fix to bug 288997 needs to be more sophisticated to handle this case.
Comment 7 Boris Bokowski CLA 2010-05-12 15:45:44 EDT
+1 for reverting, given where we are in the cycle that's the best we can do. Can you please reopen bug 288997 to make sure it doesn't fall through the cracks? Thanks.
Comment 8 Dusko CLA 2010-05-12 15:46:41 EDT
We have our own handler to hndle the double-click. The tree item adapts to multiple things and IFile is just one of them. When double-click happens we open a specialized editor that handles portion ofthe file. But because of the new behavior the main editor for the entire file gets opened instead.
Comment 9 Francis Upton IV CLA 2010-05-12 15:50:52 EDT
Released to HEAD 3.6RC1
Comment 10 Duc Luu CLA 2010-05-12 17:01:08 EDT
Yes. The test fix is good.
I tested the attached test plugin (org.eclipse.ui.navigator.resources) and it resolved this wrong editor open problem.
Thanks.
Comment 11 Francis Upton IV CLA 2010-05-12 17:15:16 EDT
(In reply to comment #10)
> Yes. The test fix is good.
> I tested the attached test plugin (org.eclipse.ui.navigator.resources) and it
> resolved this wrong editor open problem.
> Thanks.
Thanks for your good initial debugging on this and your quick response on the testing; hopefully there won't be any further regressions you find.
Comment 12 Francis Upton IV CLA 2010-05-17 16:21:40 EDT
Duc, can you verify this works in the RC1 build?
Comment 13 Duc Luu CLA 2010-05-18 14:41:33 EDT
Yes. The problem is fixed in the eclipse 3.6 RC1 build.