Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How can I select an item in a tree programmatically?(Want to expand a CNF tree to show a specific item that has been selected in a dialog box)
How can I select an item in a tree programmatically? [message #523781] Mon, 29 March 2010 09:58 Go to next message
John Ormerod is currently offline John OrmerodFriend
Messages: 39
Registered: January 2010
Member
Hello
I have a search dialog that I open from a CNF tree, which is populated with entries from the model that match the search string. When one of the entries is selected, I want the CNF tree to expand and highlight the item.

I have seen this behaviour in the IDE (though I can't recall a specific example!), so I know it's possible. Despite searching on a variety of keywords, I still haven't found a solution.

If anyone can help, I would be really grateful.

BTW, I'm not using a viewer filter for two reasons:
1. I never managed to figure out how to filter a tree!
2. If I did manage to figure out how to do it, I assume that I would end up with a list of items matching the search string, but I need to see the selected item in its tree context .

Regards, John
Re: How can I select an item in a tree programmatically? [message #851061 is a reply to message #523781] Fri, 20 April 2012 15:59 Go to previous messageGo to next message
Gerd  Wütherich is currently offline Gerd WütherichFriend
Messages: 12
Registered: July 2009
Junior Member
I just stumble over this two-years-old but unfortunately unanswered question. As I have exactly the same problem, does anybody have a practical solution?

Regards,
Gerd
Re: How can I select an item in a tree programmatically? [message #851075 is a reply to message #851061] Fri, 20 April 2012 16:16 Go to previous message
Gerd  Wütherich is currently offline Gerd WütherichFriend
Messages: 12
Registered: July 2009
Junior Member
Ok, this one was fairly easy ;-/

IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (page != null) {
    
  IViewPart view = page.findView(navigatorViewId);

  if (view != null && view instanceof CommonNavigator) {
   CommonNavigator cn = (CommonNavigator) view;
   cn.getCommonViewer().setSelection(new StructuredSelection(objToSelect));
  }
}
Previous Topic:RCP with loosely coupled editors
Next Topic:swt browser class, how to get the value of the html controls
Goto Forum:
  


Current Time: Wed Apr 24 23:53:17 GMT 2024

Powered by FUDForum. Page generated in 0.02859 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top