Disposing listeners added to Selection service [message #325908] |
Mon, 03 March 2008 01:27  |
Eclipse User |
|
|
|
Originally posted by: swetha.yahoo.com
Hi
I have added few selection listeners in my perspective that contains many
views.
Now I want to remove these selection listeners when I switch perspective.
I am aware of the removeSelectionListener(IselectionListener) in
SelectionService.But the problem is that I do not have a reference of the
listener registered.
It could be easy for me if there is something like
removeAllSelectionListeners() in SelectionService.
Is there any way to remove all the selectionlisteners registered without
knowing their references.
Thanks
Swetha
|
|
|
|
|
Re: Disposing listeners added to Selection service [message #325929 is a reply to message #325920] |
Mon, 03 March 2008 09:25  |
Eclipse User |
|
|
|
Ed Merks wrote:
> Manu,
>
> Yes, I think the views that are listeners need to manage this
> themselves. After all, all views might well be visible in the new
> perspective as well since any view can be shown in any perspective using
> Preferences->Show Viewer->Other...
What Ed says is true, any listener you add you must remove at the
appropriate point in your lifecycle.
In 3.4 made the ISelectionService available through the getService(*)
mechanism. Any listeners you add will be cleaned up when your service
locator is disposed.
i.e. if you use workbenchWindow.getService(ISelectionService.class) to
get the selection service, your listeners would be cleaned up when the
workbenchWindow is closed. If you use
getSite().getService(ISelectionService.class) to get the selection
service, your listeners would be cleaned up when your part is disposed.
But if you were to use listeners at the "perspective" level, you would
probably get the ISelectionService from the workbenchWindow and you
would still be responsible for removing them when the perspective closes
(since it has a shorter lifecycle than the window, but a longer one that
your views).
Later,
PW
--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
|
|
|
Powered by
FUDForum. Page generated in 1.05994 seconds