I have a View which extends a View provided by another plugin like this:
public class View2 extends some.other.package.View1
{
    public void createPartControl(Composite parent) 
    {  
        super.createP开发者_运维技巧artControl(parent);  
        //I want to do this, but I can't because its private  
        //getSite().setSelectionProvider(treeViewer);  
    }  
}  
But I can't edit the super class, so I need to access the viewer from the Control.
public class some.other.package.View1 extends ViewPart
{  
    private TreeViewer treeViewer;  
    public void createPartControl(Composite parent) {  
        treeViewer = new TreeViewer(parent, SWT.V_SCROLL);  
    }  
}  
I tried using parent.getChildren(); to get a Tree object, but I can't see that it can be coerced into an ISElectionProvider as required
Isn't there some getter which would allow you to get this Treeviewer? Anyway, if there's not, then the only way to get it that comes to my mind is by using reflection.
Did you try, like in this class:
ISelectionProvider provider = site.getSelectionProvider();
if (provider instanceof TreeViewer) {
   ...
There is an init method that passes in the IViewSite, on which you can set the selection provider (inherited from IWorkbenchPartSite).
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论