Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » [TreeViewer] How to bring a not yet visible object in view
[TreeViewer] How to bring a not yet visible object in view [message #279546] Wed, 19 January 2005 16:36 Go to next message
Eclipse UserFriend
Originally posted by:


I need to show and select an object that was not yet shown in the tree
programmatically. If the object already was shown in tree
TreeViewer.setSelection() works fine but if the object was not yet
selected this way does not work.

Does anyone know, how is this done in the Eclipse Package Explorer?

Thanks in advance for any hint,
Re: [TreeViewer] How to bring a not yet visible object in view [message #1087362 is a reply to message #279546] Thu, 15 August 2013 14:28 Go to previous message
Leila A is currently offline Leila AFriend
Messages: 17
Registered: February 2013
Junior Member

It can be strange to post the answer under this question after more than 8years. But I think it worth. Because there must be many people like me looking for an answer and have to spend long time to solve it by themselves.

anyway this is how you can refresh package explorer when you add something like a file programmatically to a project and want to see it on package explorer.

//Get the parent on the tree where you added new file to it
ISelectionService service = Workbench.getInstance().getActiveWorkbenchWindow()
ISelection treeselection = service.getSelection();
Object parent = ((ITreeSelection)treeselection).getPaths()[0].getParentPath().getLastSegment();
IResource parent_=(IResource )parent;
int level=((ITreeSelection)treeselection).getPaths()[0].getSegmentCount()-
try {
parent_.refreshLocal(level, null);
} catch (CoreException e) {
// TODO Auto-generated catch block
return null;

Good luck! Smile
Previous Topic:Save the preference settings to a file
Next Topic:TextBoxes
Goto Forum:

Current Time: Thu May 24 06:00:31 GMT 2018

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

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

Back to the top