Problems invoking selectReveal() on ProjectExplorer view [message #1767305] |
Tue, 04 July 2017 14:43  |
Eclipse User |
|
|
|
Hey guys,
we want to select a file in the Project Explorer when we are clicking on an certain item in another view.
Therefore, we do the following:
final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
final IViewPart viewPart = page.findView(IPageLayout.ID_PROJECT_EXPLORER);
((ISetSelectionTarget)viewPart).selectReveal(new StructuredSelection(iResource));
The selectReveal() method works very fine, when the path to the file which has to be selected, was expanded and selected once BEFORE.
When the file is selected and we click the "Collapse All" button and then we click on our item in the other view again, then the file is not selected. The project stays collapsed and the tree is not expanded.
We already opened a topic on Stackoverflow too, but there were no successful solutions:
https://stackoverflow.com/questions/44903291/selecting-a-resource-programatically-in-eclipse-does-not-expand-tree
Are we doing something wrong or is this maybe a known bug?
Kind Regards and thanks in advance!
|
|
|
Re: Problems invoking selectReveal() on ProjectExplorer view [message #1767396 is a reply to message #1767305] |
Wed, 05 July 2017 15:39   |
Eclipse User |
|
|
|
selectReveal() is the same codepath that's used by the Project Explorer's Link with Editor[/em] that automatically reveals the resources associated with an editor. That opens and reveals resources, and it provides org.eclipse.core.resources.IFile instances.
So you need to heed the faint voice of Obiwan Kenobi urging you to "Use the Source, Luke!"[/em] and use your debugger and start stepping into the code to find out what is happening.
Brian.
|
|
|
Re: Problems invoking selectReveal() on ProjectExplorer view [message #1767441 is a reply to message #1767396] |
Thu, 06 July 2017 06:46   |
Eclipse User |
|
|
|
Thanks for the fast answer =)
We didn't even need "The Source", because it's already working =).
The problem was that we had integrated CDT in our product. When we did this, the "Link with Editor" feature did not work anymore. When we deactivated the navigator part of CDT, "Link with Editor" worked fine again and additionally also selectReveal() worked of course.
|
|
|
|
Powered by
FUDForum. Page generated in 0.04122 seconds