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 User
Originally posted by: michael.simons.uniopt.net

Hello,

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,
Michael
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 A
Messages: 17
Registered: February 2013
Junior Member
Hi,

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()
.getSelectionService();
ISelection treeselection = service.getSelection();
Object parent = ((ITreeSelection)treeselection).getPaths()[0].getParentPath().getLastSegment();
IResource parent_=(IResource )parent;
int level=((ITreeSelection)treeselection).getPaths()[0].getSegmentCount()-
((ITreeSelection)treeselection).getPaths()[0].getParentPath().getSegmentCount();
try {
parent_.refreshLocal(level, null);
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}


Good luck! Smile
Leila
Previous Topic:How to explore feature contents?
Next Topic:Contributing Popup Menus for CDT Projects
Goto Forum:
  


Current Time: Fri Oct 24 07:47:34 GMT 2014

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

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