Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 311778

Summary: [CommonNavigator] Project Explorer selects File object instead of the requested object in the Explorer tree
Product: [Eclipse Project] Platform Reporter: Duc Luu <dluu>
Component: UIAssignee: Francis Upton IV <francisu>
Status: VERIFIED FIXED QA Contact: Francis Upton IV <francisu>
Severity: major    
Priority: P3 CC: ahunter.eclipse, dmisic, remy.suen
Version: 3.6Flags: remy.suen: review+
Target Milestone: 3.6 RC1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Debug session
none
Proposed Patch for RC1
none
plugin jar file with fix none

Description Duc Luu CLA 2010-05-05 14:40:43 EDT
Build Identifier: eclipse SDK 3.6.0 M7 Build id: I20100426-0852

When we request the CommonNavigator to select a specific element on the explorer tree that is not yet visible, the Project explorer calls the convertSelection method and this changes the requested target object to the File object. Thus, the File is object is selected in Project explorer which is incorrect. Instead, it should expand the tree to show the target element first and then select this requested object. (see attached image).



package org.eclipse.ui.navigator.resources;

public final class ProjectExplorer extends CommonNavigator {
. . .
public void selectReveal(ISelection selection) {
	if (getCommonViewer() != null) {
		getCommonViewer().setSelection(convertSelection(selection), true);
	}
}

private Object convertElement(Object original) {
	NavigatorContentService ncs = (NavigatorContentService) getNavigatorContentService();

	Object found = ncs.getViewerElementData(original);
	if (found != null)
		return original;
	if (original instanceof IAdaptable) {
		IAdaptable adaptable = (IAdaptable) original;
		found = adaptable.getAdapter(IResource.class);
		if (found != null)
			return found;
		IWorkbenchAdapter wba = (IWorkbenchAdapter) adaptable.getAdapter(IWorkbenchAdapter.class);
		if (wba != null) {
			found = wba.getParent(original);
			if (found != null)
				return convertElement(found);
		}
	}
	return original;
}


It should not returns the adaptable.getAdapter(IResource.class) object.


Reproducible: Always

Steps to Reproduce:
1. Expand the tree structure just 1 level deep in the Project Explorer. The tree elements are adaptable to IResource.
2. Invoke the org.eclipse.ui.navigator.resources.ProjectExplorer.selectReveal and pass it a child object that is not yet visible (for example, the target object is 5 levels deep).

Expect: the tree is expanse and select the requested element.
Result: the file object is selected.
Comment 1 Duc Luu CLA 2010-05-05 14:43:09 EDT
Created attachment 167196 [details]
Debug session
Comment 2 Dusko CLA 2010-05-05 14:56:15 EDT
Please note that this is a regression.
Comment 3 Francis Upton IV CLA 2010-05-12 02:14:25 EDT
This was broken by the fix to bug 175882
Comment 4 Francis Upton IV CLA 2010-05-12 10:05:43 EDT
Duc, sorry for the short notice, I intend to have a fix in a couple of hours, and need to get it in to tomorrow's build (means I need to have it reviewed and released today). Would you be able to verify the fix works when I prepare the patch?
Comment 5 Francis Upton IV CLA 2010-05-12 10:36:17 EDT
Created attachment 168151 [details]
Proposed Patch for RC1

I waited to late for a proper fix, so for 3.6RC1 I'm just going to back out the offending changes that fixed bug 175882
Comment 6 Francis Upton IV CLA 2010-05-12 10:40:30 EDT
Remy, can you have a look at this one? It just removes a change introduced in bug 175882 that breaks the selection. Duc needs to verify that this will indeed fix the problem (since I don't have steps), but I think this is the safest way to go for RC1. Of course I will reopen bug 175882 when I release this fix.
Comment 7 Remy Suen CLA 2010-05-12 12:24:12 EDT
This looks like the safest way to correct this regression this late in the game. Thank you Duc for finding this and Francis for correcting the problem.

It is unfortunate that we have to reopen bug 175882 but seeing that that's been around for years with little push/interest from the community I do not see this as a problem.

Francis, please deliver this when you are ready though if you need some time you will need to coordinate with Paul. Thanks.
Comment 8 Duc Luu CLA 2010-05-12 12:29:53 EDT
Yes. I can test it if you can provide me the binary patch -- the plugin jar files that contain the fix.
Comment 9 Francis Upton IV CLA 2010-05-12 12:39:36 EDT
Created attachment 168194 [details]
plugin jar file with fix
Comment 10 Francis Upton IV CLA 2010-05-12 12:41:57 EDT
Released to HEAD 3.6RC1
Comment 11 Francis Upton IV CLA 2010-05-12 12:42:38 EDT
Duc, even though I have released this, please do your testing just to confirm. If there is any issue, I will make sure it gets fixed.
Comment 12 Duc Luu CLA 2010-05-12 14:59:32 EDT
Thanks. The problem is fixed with the given plugins.

NOTE: Please note that I also found a new regression bug with the Project Explorer (bugzilla bug#312686). I tested with your given patch and the bug#312686 is still there.
Comment 13 Francis Upton IV CLA 2010-05-12 15:03:41 EDT
(In reply to comment #12)
> I tested with your given patch and the
> bug#312686 is still there.
Yes, I saw that and we are going to try to get that fix in for RC1, I will attach a plugin in that bug report for you to try.
Comment 14 Francis Upton IV CLA 2010-05-17 16:21:23 EDT
Duc, can you verify this works in the RC1 build?
Comment 15 Duc Luu CLA 2010-05-18 14:43:06 EDT
Yes. The problem is fixed in the eclipse 3.6 RC1 build.