Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 31963

Summary: [ActionSets] Customize Perspective changes action set processing order
Product: [Eclipse Project] Platform Reporter: Lynne Kues <lynne_kues>
Component: UIAssignee: Simon Arsenault <simon_arsenault>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: n.a.edgar
Version: 2.1   
Target Milestone: 2.1 RC2   
Hardware: PC   
OS: other   
Whiteboard:
Bug Depends on:    
Bug Blocks: 29835    

Description Lynne Kues CLA 2003-02-16 12:17:35 EST
Build 200302141436

I put a println in PluginActionSet>>(IWorkbenchWindow, IActionBars). This is 
the method that processes action set contributions.

1.  Run Eclipse with a new workspace.  The println leads to the following order:

reading desc org.eclipse.help.internal.ui.HelpActionSet
reading desc org.eclipse.search.searchActionSet
reading desc org_eclipse_ui_examples_readmetool_actionSet
reading desc org.eclipse.ui.externaltools.ExternalToolsSet
reading desc org.eclipse.ui.workbench.texteditor.actionSet.navigation
reading desc org.eclipse.update.ui.softwareUpdates
reading desc org.eclipse.ui.NavigateActionSet

2. Go to Customize Perspective.  Don't even change anything, just say "Ok".
3. Exit and restart Eclipse.  The action sets are now processed in this order:

reading desc org.eclipse.ui.workbench.texteditor.actionSet.navigation
reading desc org.eclipse.ui.externaltools.ExternalToolsSet
reading desc org.eclipse.help.internal.ui.HelpActionSet
reading desc org_eclipse_ui_examples_readmetool_actionSet
reading desc org.eclipse.ui.NavigateActionSet
reading desc org.eclipse.search.searchActionSet
reading desc org.eclipse.update.ui.softwareUpdates

So action sets are not being processed in the same order.  Is this a bug?  Nick 
seemed to think so.  Or is it only the loading that is guaranteed to occur in 
the same order?
Comment 1 Nick Edgar CLA 2003-02-17 09:31:49 EST
Neither of these orders is correct.
The behaviour should be:
- initial order is in alphabetical order of action set id (using 
String.compareTo -- case sensitive and locale independent)
- action sets can be added/removed/rearranged in Customize Perspective
- action sets can also be rearranged by DnD
- if no customization or rearrangement is done, the order is the initial order
- saving/restoring the workbench should preserve the customized list of action 
sets and their order (and not re-apply the initial order)


Comment 2 Lynne Kues CLA 2003-02-17 09:51:20 EST
Okay, my approach for combining action sets on the coolbar was not assuming the 
following:

"saving/restoring the workbench should preserve the customized list of action 
sets and their order (and not re-apply the initial order)"

So this bug report does not need to be addressed for the coolbar work.
Comment 3 Lynne Kues CLA 2003-02-17 10:13:35 EST
Actually I take that back.  "Action sets processed in sorted order on initial 
load" would need to be fixed so that plugin users know what will be on a 
particular coolitem (the fix is necessary only if we go with the original 
coolbar action set combining approach - not the sort by action set id 
approach). 
Comment 4 Lynne Kues CLA 2003-02-17 16:32:45 EST
Simon, would it be possible to maintain the initial add order of action sets 
even when Customize Perspective is used and use this to restore the workbench?  
By initial add order I mean the following:

On initial load, plugin action sets are added in this order:

  A, B, C, D

Customize Perspective is used, action set E is added.  The order would be:
 
  A, B, C, D, E

Customize Perspective is used, action set B is removed.  The order would be:

  A, C, D, E

Customize Perspective is used, action set B is added back.  The order would be:

  A, B, C, D, E

Action set B is removed again, the workbench is exited, the workbench is 
restarted and action set B is added back.  The order would be:

  A, C, D, E, B

There would be no need to preserve removed information when saving the 
workbench state.  Would this be possible?  Would this "break" other things?  
I'm not sure about rearranging action sets.  I cannot get DnD to work in the 
Customize Perspectives dialog.
Comment 5 Nick Edgar CLA 2003-02-18 09:56:46 EST
Lynne needs this for combining cool items, and for proper coolbar ordering in 
2.1.

Note that we have decided not to follow a strict ordering based on action set 
ids in the toolbars, as we do in the menus, for the following reasons:
- users can rearrange the items (and we need to persist this order)
- the current approach in the toolbar is more flexible and we would not be able 
to achieve the order of items we would like with a strict ordering without 
jumping through hoops.

The order we're following for the toolbars is as follows (Lynne, please correct 
me if I'm wrong again here).
- process in order of action set id (case insensitive, not locale-specific)
  (this requires the fix requested here)
- within an action set, groups are added at the end in the order encountered
- if an action set adds-in to another action set's toolbar, then its 
contributions go at the end
- unless a before-group is specified when adding a new group to another action 
set's toolbar, in which case the new group is added immediately before the 
mentioned before-group
- processing of regular contributions is done for all action sets before 
processing of add-ins

This is for the initial order only.  If the order is subsequently changed by 
DnD or adding/removing action sets, then we need to persist the visible order.

Comment 6 Lynne Kues CLA 2003-02-18 11:20:43 EST
I agree with everything except:

This is for the initial order only.  If the order is subsequently changed by 
DnD or adding/removing action sets, then we need to persist the visible order.

Even if action sets are added/removed, I need the action sets to be restored in 
the order in which the action sets are initially added.  This will preserve 
visible order on restart.

I have looked a little into the processing action sets in two stages.  Simon, I 
will send you code to review regarding this.
Comment 7 Simon Arsenault CLA 2003-02-18 13:22:21 EST
I'll take a look into this but I have reservation about this. This action set 
list the workbench page is holding onto is modifier in multiple places (for 
example, when initially created, restore, customize, part activation, etc). 
Also, the perspective hold onto at least 3 different lists of action sets 
(seems these are the ones being saved). Anyway, I'm not too familiar with this 
area so maybe its not really as complex as it looks from my quick browsing 
around. I'm also concern that we now have (or will have) code in different 
areas to control the order of action sets.
Comment 8 Simon Arsenault CLA 2003-02-20 16:16:06 EST
To be done in 2.1 RC2  Simon to look whether we can keep the action set list in 
a sorted order without making things to complicate (or causing other side 
effects). If not possible, Lynne will look at sorting them during contribution 
time.
Comment 9 Lynne Kues CLA 2003-02-21 10:47:43 EST
If I am going to maintain items in a coolitem based on sorted order (i.e., 
after base groups, after base items, before base groups), I do not need the 
current behavior to change.  The coolitem creation algorithm will still have to 
handle action sets being processed in non-sorted order since ALL action sets 
are not processed at the same time (i.e., Customize Perspective, Switching 
Perspectives process groups of action sets).  
Comment 10 Nick Edgar CLA 2003-02-21 10:53:50 EST
So it's OK for us to close this PR with no action required?  Just making sure.
Comment 11 Lynne Kues CLA 2003-02-21 10:58:26 EST
Yes, you can close.
Comment 12 Nick Edgar CLA 2003-02-21 11:06:55 EST
Closing.  Current behaviour is OK.
Comment 13 Nick Edgar CLA 2003-02-21 11:07:16 EST
Meant to close as WORKSFORME.
Comment 14 Nick Edgar CLA 2003-02-21 11:07:39 EST
Closing.