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

Bug 324161

Summary: [Commands] menu contributions added using 'endof' should appear before contributions added using 'after'
Product: [Eclipse Project] Platform Reporter: Deepak Azad <deepakazad>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, Michael_Rennie, prakash, pwebster, remy.suen
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug
Attachments:
Description Flags
screenshot none

Description Deepak Azad CLA 2010-09-01 00:26:53 EDT
Created attachment 177912 [details]
screenshot

I20100831-1001

We want to add a new menu contribution to the Navigate menu (bug 48880).

The command is defined as 
     <command
            categoryId="org.eclipse.ui.category.navigate"
            description="New command"
            id="org.eclipse.jdt.ui.command.NewCommand"
            name="New Command">
      </command>

and the menu contribution is

  <extension 
         point="org.eclipse.ui.menus">
       <menuContribution
            locationURI="menu:navigate?endof=open.ext2">
        <command
          commandId="org.eclipse.jdt.ui.command.NewCommand"
          style="push">
        </command>
       </menuContribution>
   </extension>

But an unnecessary separator appears above this contribution.

Now o.e.pde.ui adds the following menu contribution using the 'after' placement option, and it is this separator added here which is a problem
     <extension
             point="org.eclipse.ui.menus">
          <menuContribution
                locationURI="menu:navigate?after=open.ext2">
             <separator
                   name="org.eclipse.pde.ui.openPluginArtifactSeparator"
                   visible="true">
             </separator>
             <command
                   commandId="org.eclipse.pde.ui.openPluginArtifact"
                   icon="$nl$/icons/obj16/open_artifact_obj.gif"
                   label="%pluginsearch.action.menu.name">
                <visibleWhen>
                <or>

I would expect contributions added using 'endof' to appear before contributions added using 'after' placement clause. In the current behavior I do not see a difference between 'endof' and 'after'.
Comment 1 Eric Moffatt CLA 2010-09-01 11:25:31 EDT
Deepak, the docs are fairly clear here...an excerpt from the 'Separator' spec:

The 'id' of this contribution. If defined then it can be used as a reference in the Query part of the location defining whether the additions are to go before or after this element (or at the end of the logical group containing this element using the 'endof' value). 
Separator contributions that have an id define the start of a logical group so the result of using the 'endof' value for placement is to search forward in the current menu to locate the next separator and to place the inserted elements before that element. If no trailing separator is found then the items are placed at the end of the menu. 

visible - Indicates whether or not the separator should be visible in the UI. false by default. 

In this case you want to use 'after' I think, 'endof' is clearly meant to place the addition as near the end of the group as it can.
Comment 2 Deepak Azad CLA 2010-09-02 02:12:57 EDT
(In reply to comment #1)
> Separator contributions that have an id define the start of a logical group so
> the result of using the 'endof' value for placement is to search forward in the
> current menu to locate the next separator and to place the inserted elements
> before that element. If no trailing separator is found then the items are
> placed at the end of the menu. 
Exactly my point!
When this menucontribution (in JDT) is being added to the navigate menu
<extension 
         point="org.eclipse.ui.menus">
       <menuContribution
            locationURI="menu:navigate?endof=open.ext2">
        <command
          commandId="org.eclipse.jdt.ui.command.NewCommand"
          style="push">
        </command>
       </menuContribution>
   </extension>

the separator that is added by PDE (the one shown below) would be the next separator and the 'New Command' should be added 'before' this separator
   <extension
             point="org.eclipse.ui.menus">
          <menuContribution
                locationURI="menu:navigate?after=open.ext2">
             <separator                                       *//this one!!*
                   name="org.eclipse.pde.ui.openPluginArtifactSeparator"
                   visible="true">
             </separator>
             <command
                   commandId="org.eclipse.pde.ui.openPluginArtifact"



> In this case you want to use 'after' I think, 'endof' is clearly meant to place
> the addition as near the end of the group as it can.
No, I want to use 'endof' only and place the addition as near the end as possible. But someone else uses 'after' and that contribution comes before the 'endof' contribution.
Comment 3 Paul Webster CLA 2010-09-02 09:47:25 EDT
The position target id groups menu contributions, and then they are applied in plugin.id order.  So JDT will be applied before PDE.

There might be something we can do here, but it's not a simple re-arrangement.

PW
Comment 4 Deepak Azad CLA 2010-09-02 18:28:33 EDT
argh.. I debugged what is happening, and I guess my understanding of 'after' was wrong. So far I was thinking that 'after' will cause the menu contribution to be added after the logical group defined by a separator (and this is how the PDE contribution looks to be working as well). But now I realize that 'after' will just add the menuContribution right after the separator. 

The confusion arises from the fact that other items in the same logical group are added using actionSets, and actionSets are processed after menuContributions - I think this is wrong (and should probably be fixed along with bug 324160 ?)

I also think PDE made the same mistake as me in using 'after' for their menuContribution, I think they should use 'endof' to add their stuff to the end of the logical group of open.ext2 separator.

Paul, does this make sense?
Comment 5 Paul Webster CLA 2010-09-07 07:43:47 EDT
(In reply to comment #4)
> PDE contribution looks to be working as well). But now I realize that 'after'
> will just add the menuContribution right after the separator. 

Right, the processing for "after" is to find that group marker, and start inserting the menuContribution (in document order).

> The confusion arises from the fact that other items in the same logical group
> are added using actionSets, and actionSets are processed after
> menuContributions - I think this is wrong (and should probably be fixed along
> with bug 324160 ?)

No, this is by design.  actionSets (all action extension points) are applied after programmatic contributions and menuContributions.


> I also think PDE made the same mistake as me in using 'after' for their
> menuContribution, I think they should use 'endof' to add their stuff to the end
> of the logical group of open.ext2 separator.

endof wasn't available right at the beginning, so migrating to endof might be an option for PDE.

PW
Comment 6 Eclipse Genie CLA 2020-07-24 13:55:24 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.