I'm creating a TableViewer
which has to respond to selections in other components.
I'm doing some actions in the implemented selectionChanged
method.
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
}
I want to avoid triggering the operations in selectionChanged
method when I close the view.
I tried checking the received part:
if(part.getSite().getId()!="myviewid")
{
}
But I always get the part of the previous selection (in my case ResourceNavigator
).
How can I check if I selected my view and avoid doing some operations ?
You should remove your selection listener from the selection service when your view part is disposed
@Override
public void dispose()
{
ISelectionService service = (ISelectionService)getSite().getService(ISelectionService.class);
service.removeSelectionListener(myListener);
super.dispose();
}