开发者

How to find components within IWorkbenchPart?

开发者 https://www.devze.com 2023-01-22 09:50 出处:网络
I\'m writing a plugin for a poorly-documented Eclipse RCP application and I need to add a listener to what I believe is a TreeViewer within a view.I have access to the IWorkbenchPart representing the

I'm writing a plugin for a poorly-documented Eclipse RCP application and I need to add a listener to what I believe is a TreeViewer within a view. I have access to the IWorkbenchPart representing the view, but how can I get the TreeViewer it contains? I'd guess I need a method to return the child components (i.e. something equivalent to AWT's getComponents() method), but I see 开发者_C百科no such method.


If the part contains a TreeViewer then it is likely that this viewer been set as the ISelectionProvider for the IWorkbenchSite containing the view.

Therefore you could try the following using the IViewPart reference that you have:

IViewPart; // Your reference to the IViewPart instance

ISelectionProvider provider = part.getSite().getSelectionProvider(); //Hopefully the TreeViewer

provider.addSelectionChangedListener(yourListener);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号