Bug 16282 - [Contributions] ordering: Determining the order of action sets
Summary: [Contributions] ordering: Determining the order of action sets
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P3 enhancement with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Paul Webster CLA
QA Contact:
URL:
Whiteboard:
Keywords: investigate
: 75229 152457 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-05-17 13:26 EDT by Dirk Baeumer CLA
Modified: 2007-06-20 12:13 EDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2002-05-17 13:26:25 EDT
Build 20020515

Due to the conversion to the new menu structure JDT ended up having four 
actions sets named org.eclipse.jdt.ui.OpenActionSet, 
org.eclipse.jdt.ui.JavaActionSet, org.eclipse.jdt.ui.CodingActionSet and 
org.eclipse.jdt.ui.SearchActionSet. In the navigate menu we want to create the 
following order:

OpenActionSet
CodingActionSet
JavaActionSet.

The only way to do that is to name the OpenActionSet A_OpenActionSet. This lets 
us look stupid. Any other idea ?
Comment 1 Nick Edgar CLA 2002-05-17 14:35:33 EDT
The order should be based on id comparision, not name comparison.
So we will only look stupid to developers, not end users.
Comment 2 Nick Edgar CLA 2002-05-17 14:38:01 EDT
Let me know if this is critical for 2.0.
Comment 3 Dirk Baeumer CLA 2002-05-17 14:55:11 EDT
Yes, we don't look stupid for the user, only for developers using JDT. I am 
only asking since we define these constants as API. It is not critical for 2.0 
since we have a workaround.
Comment 4 Nick Edgar CLA 2002-05-18 21:28:30 EDT
Deferring then.
Comment 5 Randy Giffen CLA 2002-08-12 09:57:24 EDT
Reopen for investigation
Comment 6 Nick Edgar CLA 2002-11-20 12:04:33 EST
We should look at adding order numbers to action sets and possibly other kinds 
of contributions.  A simple "order" attribute on the action set would suffice.
E.g. if action set A has order=10, and action set B has order=5, then B appears 
before A regardless of the order of their ids.  
Action sets with no order number, should still get ordered by id, after any 
ones with a specific order number.  This could also be used to break ties 
between action sets having the same order number.

This order also has to be stable independent of incremental changes to the 
perspective (see bug 18357).

Comment 7 Nick Edgar CLA 2002-11-20 12:05:19 EST
Should use float for order numbers.
Comment 8 Simon Arsenault CLA 2002-12-04 13:57:21 EST
Were you actually seeing the order change by adding the "A_" prefix to the 
action set id? The registry readers only sort on plugin ids, not action set 
ids. Once the IConfigurationElement(s) are sorted by plugin id, we read the 
action sets entries for each IConfigurationElement, in no special order (ie 
what ever order the IConfigurationElement returns them in).

Nevertheless, we still have an ordering problem when action sets are 
added/removed from the visible list.
Comment 9 Simon Arsenault CLA 2002-12-04 14:40:07 EST
Sorry, I spoke (wrote?) too soon... There is a snippet of code that will order 
plugin action set contributions based on their ids.
Comment 10 Simon Arsenault CLA 2002-12-05 14:27:42 EST
Not going to be fixed for 2.1 M4

We would like to address the real problem which is allowing developers better 
control of the order of each action. The solution should also keep in mind 
possible future features like user customizing where an action lives in the 
menu/tool bars.
Comment 11 Nick Edgar CLA 2003-05-06 09:43:12 EDT
Should also take plugin prerequisites into account in order, if an explicit 
ordering is not given.  See bug 36929 for more context.
Comment 12 Nick Edgar CLA 2004-09-29 14:21:26 EDT
*** Bug 75229 has been marked as a duplicate of this bug. ***
Comment 13 Dirk Baeumer CLA 2004-10-05 09:55:57 EDT
Bug 71710#6 contains steps to reproduce the use of different menu definitions 
based on different activation sequences.
Comment 14 Nick Edgar CLA 2004-10-05 11:21:45 EDT
Related words from Dirk:

IMO there are two different issues here:

1.) the ordering problem
2.) the pricipal need of a menu redefinition. If plug-in B requires plug-in A
which defines a menu M
      and B wants to contribute to that menu M there shouldn't be any need for B
to redefine the menu
      M. It should only add actions or additional groups. 

Regarding the steps I mentioned see bug 71710 comment 6. There both search and
junit plug-in defines
the same search menu but depending on some activation sequence either the menu
from search or the
one from junit is taken.

I had similar problems with the Refactoring & Source when I tried to move the
menu definition of the refactoring
menu  down to LTK. Depedining on the activation squence the order was either
Refactoring Source or 
Source Refactoring.
Comment 15 Mark Melvin CLA 2005-05-11 14:29:45 EDT
I'm running into issue #2 of this bug:

2.) the pricipal need of a menu redefinition. If plug-in B requires plug-in A
which defines a menu M
      and B wants to contribute to that menu M there shouldn't be any need for B
to redefine the menu
      M. It should only add actions or additional groups.

I have a core plugin declaring a base menu to which I want to add stuff from
other plugins with require my core plugin, but the menu creation in these
sub-plugins is failing because the core plugin has not created the menu yet.

I'm unclear on the status of this bug.  Is is possible to reliably "trick" the
platform into loading the actionSets in a particular order by strategically
naming them, or is there no workaround for this behaviour?
Comment 16 Mark Melvin CLA 2005-05-11 15:04:53 EDT
I just found bug #15670, and I now see that the alphabetical order dependency is
on on the plugin id, not the actionSet id.  I also found the workaround of
essentially recreating the menu in each plugin, and that seems to work.  Kinda
messy though.
Comment 17 Chris Morris CLA 2005-08-04 10:04:23 EDT
This bug reads like the same problem I'm having with my plug-in in 3.1, but I'm
not sure ... can anyone familiar with this bug let me know? I have the following
section in my plugin.xml:

   <extension
         point="org.eclipse.ui.popupMenus">
      <objectContribution
            objectClass="org.eclipse.jdt.core.IType" 
            id="com.einstruction.eclipse.plugin.cpsassist.contribution1">
         <menu
               label="eI"
               path="additions"
               id="com.einstruction.eclipse.plugin.menu">
            <separator
                  name="group1">
            </separator>
         </menu>
         <action
               class="com.einstruction.eclipse.plugin.cpsassist.UnitTest"
               enablesFor="1"
               id="com.einstruction.eclipse.plugin.cpsassist.unittest"
               label="Open Unit Test Class"
               menubarPath="com.einstruction.eclipse.plugin.menu/group1"/>
         <action
               label="Update Mock"
               class="com.einstruction.eclipse.plugin.cpsassist.UpdateMock"
               menubarPath="com.einstruction.eclipse.plugin.menu/group1"
               enablesFor="1"
               id="com.einstruction.eclipse.plugin.cpsassist.updatemock">
         </action>
      </objectContribution>
   </extension>
 
... and I can't figure out a way to control the order of the two actions as the
appear in the context menu. I even re-structured the actions so that each action
was in its own objectContribution tag, and still I couldn't control the order.

I resorted to the following, which is less than ideal because each item is now
in its own group, with a separator in between.

   <extension
         point="org.eclipse.ui.popupMenus">
      <objectContribution
            objectClass="org.eclipse.jdt.core.IType" 
            id="com.einstruction.eclipse.plugin.cpsassist.contribution1">
         <menu
               label="eI"
               path="additions"
               id="com.einstruction.eclipse.plugin.menu">
            <separator
                  name="group1">
            </separator>
            <separator
                  name="group2">
            </separator>
         </menu>
         <action
               class="com.einstruction.eclipse.plugin.cpsassist.UnitTest"
               enablesFor="1"
               id="com.einstruction.eclipse.plugin.cpsassist.unittest"
               label="Open Unit Test Class"
               menubarPath="com.einstruction.eclipse.plugin.menu/group1"/>
      </objectContribution>
      <objectContribution
            adaptable="false"
            id="com.einstruction.eclipse.plugin.cpsassist.contribution2"
            objectClass="org.eclipse.jdt.core.IType">
         <action
               label="Update Mock"
               class="com.einstruction.eclipse.plugin.cpsassist.UpdateMock"
               menubarPath="com.einstruction.eclipse.plugin.menu/group2"
               enablesFor="1"
               id="com.einstruction.eclipse.plugin.cpsassist.updatemock">
         </action>
      </objectContribution>
   </extension>
Comment 18 Michael Van Meekeren CLA 2006-04-21 13:56:33 EDT
Moving Dougs bugs
Comment 19 Paul Webster CLA 2006-08-01 12:13:12 EDT
*** Bug 152457 has been marked as a duplicate of this bug. ***
Comment 20 Eric Woodruff CLA 2007-01-07 15:43:49 EST
I just wasted hours trying to figure out why an antecedent plugin could contribute to a dependent plugin menu, but not the other way around. Then I found that the RegistryReader compares by plugin id and not by the plugin dependency hierarchy!

Here's the comment from the orderExtensions method:
 // By default, the order is based on plugin id sorted
 // in ascending order. The order for a plugin providing
 // more than one extension for an extension point is
 // dependent in the order listed in the XML file.

I can't figure out how this bug can be considered an "enhancement", this is broken behavior. I should not have to rename my plugin id to something that starts with a z to make sure its extensions are read last so all of the menus it depends on are initialized first. In my opinion, this bug is P2/Normal.
Comment 21 Paul Webster CLA 2007-01-07 18:50:45 EST
You can't contribute to the menu from one action set to another (well you can, but we won't do it correctly).  From the extension point description:

"There is an implementation limitation which currently affects action sets. It is important to define the entire menu structure that is to be referenced within the action set. So, for example, if another action set defines a menu called "example", it is not possible to rely on "example" existing. It is necessary to redefine the "example" menu in every action set that wishes to use it."

However, there is work on the org.eclipse.ui.menus extension point, see bug 154130  As part of defining menus through org.eclipse.ui.menus, you will be able to reference existing menus defined in other plugins regardless of "plugin order", and with IDs you will be able to order contributions.

PW
Comment 22 Eric Woodruff CLA 2007-01-07 23:32:44 EST
(In reply to comment #21)
> You can't contribute to the menu from one action set to another

Is that true? What is it called when plug-ins contribute to the edit menu or the top-level menu? I didn't see any examples redefining /those/ menus to contribute to them.
Comment 23 Paul Webster CLA 2007-01-08 08:05:39 EST
(In reply to comment #22)
> (In reply to comment #21)
> > You can't contribute to the menu from one action set to another
> 
> Is that true? What is it called when plug-ins contribute to the edit menu or
> the top-level menu? I didn't see any examples redefining /those/ menus to
> contribute to them.

Those menu entries are not contained in action sets

PW
Comment 24 Paul Webster CLA 2007-04-05 19:01:35 EDT
Assigning to component owner
PW
Comment 25 Paul Webster CLA 2007-06-20 12:13:09 EDT
These will not be worked on.  Please re-open if you feel the community should
get a crack at them.