Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Disposing listeners added to Selection service
Disposing listeners added to Selection service [message #325908] Mon, 03 March 2008 06:27 Go to next message
Eclipse UserFriend
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 #325913 is a reply to message #325908] Mon, 03 March 2008 07:34 Go to previous messageGo to next message
Manuel Selva is currently offline Manuel SelvaFriend
Messages: 189
Registered: July 2009
Location: Grenoble, France
Senior Member
Hi,

I think such a method doesn't exist since listeners can be added from an
other part than yours and i will also delete these listeners ....

I think you have to keep your own references.

Manu
http://manuelselva.wordpress.com


Re: Disposing listeners added to Selection service [message #325920 is a reply to message #325913] Mon, 03 March 2008 12:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

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


Manuel Selva wrote:
> Hi,
>
> I think such a method doesn't exist since listeners can be added from
> an other part than yours and i will also delete these listeners ....
> I think you have to keep your own references.
>
> Manu
> http://manuelselva.wordpress.com
>
Re: Disposing listeners added to Selection service [message #325929 is a reply to message #325920] Mon, 03 March 2008 14:25 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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


Previous Topic:extension points in org.eclipse.ltk.core.refactoring
Next Topic:property tester that returns true if a certain file exist on the project
Goto Forum:
  


Current Time: Sat Jul 13 17:16:00 GMT 2024

Powered by FUDForum. Page generated in 0.04090 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top