Bug 155415 - [Contributions] Only ViewerContribution should listen to selection changes, not its actions
Summary: [Contributions] Only ViewerContribution should listen to selection changes, n...
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2006-08-28 12:18 EDT by Nick Edgar CLA
Modified: 2016-11-10 13:12 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Edgar CLA 2006-08-28 12:18:07 EDT
3.2

- add a viewer contribution action to some view's menu
- set a breakpoint in the contributed action's selectionChanged method
- pop up the menu
- choose the action, to ensure that its plugin is activated
- pop up the menu again
- notice the action's selectionChanged method gets hit twice

If you look at the list of selection changed listeners on the view's viewer, you'll notice that it contains not only the ViewerContribution but also the ViewerContribution's plugin actions.

The intent here is that only the ViewerContribution gets notified, and it then iterates over its actions, propagating the selection changed event itself.

There is a comment in ViewerActionBuilder$ViewerContribution's selection changed method that states:
		 * Rather than hooking up each action as a selection listener,
		 * the contribution itself is added, and propagates
		 * the selection changed notification to all actions.
		 * This simplifies cleanup, in addition to potentially reducing the number of listeners.

But it's still adding the individual actions.  This could be a performance hit if the action's selectionChanged methods are expensive.
Comment 1 Paul Webster CLA 2007-04-05 19:05:30 EDT
Assigning to component owner
PW
Comment 2 Remy Suen CLA 2008-07-14 16:00:28 EDT
I cannot reproduce this problem on 3.4.

My IViewActionDelegate's implementation's selectionChanged(IAction, ISelection) method seems to only be called once when I change the selection in the view I'm targeting.
Comment 3 Paul Webster CLA 2009-03-02 11:40:28 EST
Updated as per http://wiki.eclipse.org/Platform_UI/Bug_Triage
PW
Comment 4 Gaston CLA 2009-04-30 13:55:34 EDT
(In reply to comment #2)
> I cannot reproduce this problem on 3.4.
> 
> My IViewActionDelegate's implementation's selectionChanged(IAction, ISelection)
> method seems to only be called once when I change the selection in the view I'm
> targeting.
> 

I can reproduce a similar problem on 3.4

This is my similar question:
http://www.eclipse.org/newsportal/article.php?id=1580&group=eclipse.platform.pde#1580

Is there solution for that?
Comment 5 Mickael Istria CLA 2016-11-10 13:12:52 EST
Action, popupMenus and viewerContribution extensions are deprecated in favor of org.eclipse.ui.commands/org.eclipse.ui.menus. No work will be planned about actions.