[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.rcp] Re: Linking View vs Editor(ISelectionProvider ISelectionListener)

Venkataramana M wrote:

Oh ! I thought you dont know which listener to setup. Code-organization is a
software political issue :-)..I dont have anything to say regarding this.

Thanks
~Venkat


--
View in EZ forum:
http://www.eclipsezone.com/eclipse/forums/m91954284.htmlSolved.

Solution is (but I have a bug! see below):

public class TableView extends ViewPart {
    ...
    public void createPartControl(Composite parent) {
         top = new Composite(parent, SWT.NONE);
         top.setLayout(new FillLayout());
         createTable();
    }

    private void createTablePatients() {
         patientsViewer = new TableViewer(top, SWT....);
         ...
         this.getSite().setSelectionProvider(patientsViewer);
    }
}


public class EditorForm extends EditorPart implements ISelectionListener {

    private ISelectionListener pageSelectionListener;

private void hookSomeSelection(IEditorSite site) {
pageSelectionListener = new ISelectionListener() {
public void selectionChanged(
IWorkbenchPart part, ISelection selection) {
someSelectionChanged(part, selection);
}
};
site.getPage().addPostSelectionListener(pageSelectionListener);
}

protected void someSelectionChanged(
IWorkbenchPart part,
ISelection selection) {
/* Determine which page chaged selection & do something.*/
}


public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
hookSomeSelection(site);
}
...
public void dispose() {
if (pageSelectionListener != null) {
IWorkbenchSite site = this.getSite();
IEditorSite site2 = this.getEditorSite();
IWorkbenchPage pageSite = site.getPage();
IWorkbenchPage pageEditorSite = site2.getPage();

//removePostSelectionListener(pageSelectionListener);
}

super.dispose();
}
...
...
...
}


But I have a problem!!!

As you have noticed my dispose method isn`t working! That`s because variables site & site2 is NULL`s! Why? Actually hookSomeSelection(..) must be hooked at the end of createPartControl(), but at that moment this.getSite & this.getEditorSite() are also nulls?

How can I retireve them? Or maybe I have wrongly initialized Editor?