Raj
Raj

Reputation: 13

Add a new sub menu to compare with menu in Package explorer and project explorer

I am trying to add a new command to "compare with" menu present in context menu of Package Explorer and Project Explorer. Command is getting displayed only in Package Explorer. I am not getting any command in Project Explorer. I want the command to be present only in these two views. Below is my code.

<menuContribution
            allPopups="false"
            locationURI="popup:org.eclipse.jdt.ui.PackageExplorer?after=additions">
         <menu
               id="compareWithMenu"
               label="Compare With">
            <separator
                  name="compareWithGroup">
            </separator>
         </menu>
</menuContribution>
<menuContribution
            allPopups="false"
            locationURI="popup:org.eclipse.ui.navigator.ProjectExplorer?after=additions">
         <menu
               id="compareWithMenu"
               label="Compare With">
            <separator
                  name="compareWithGroup">
            </separator>
        </menu>
</menuContribution>

<menuContribution
            allPopups="false"
            locationURI="popup:compareWithMenu?after=additions">
         <command
               commandId="com.test.compareWithEachOther"               
               label="Compare with each other"               
               style="push">
            <visibleWhen
                  checkEnabled="true">
            </visibleWhen>
         </command>
</menuContribution>
<menuContribution
            allPopups="false"
            locationURI="popup:compareWithMenu?after=additions">
         <command
               commandId="com.test.compareWithEachOther"             
               label="Compare with each other"               
               style="push">
            <visibleWhen
                  checkEnabled="true">
            </visibleWhen>
         </command>
</menuContribution>

I tried changing my id menu contribution also. But then in Package Explorer a new compare with option is coming. I think this is expected. I want the command to be present only in these two views. Am i missing something?

Upvotes: 0

Views: 450

Answers (1)

greg-449
greg-449

Reputation: 111142

The popup menu id for Project Explorer appears to be

org.eclipse.ui.navigator.ProjectExplorer#PopupMenu

Alternatively the PDE plugin uses:

<menuContribution
       allPopups="false"
       locationURI="popup:org.eclipse.ui.popup.any?after=additions">

to add its 'Compare With > API Baseline' menu item.

Upvotes: 0

Related Questions