views:

91

answers:

1

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.createPartControl(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

A: 

Did you try, like in this class:

ISelectionProvider provider = site.getSelectionProvider();
if (provider instanceof TreeViewer) {
   ...
VonC
the selectionProvider for the site is null, because the superclass did not register the Viewer as a selectionProvider - in fact this is the reason that I am extending the class so i can add the viewer as a selectionProvider and use the selected objects in my other View objects...
Tom