0

I am new to extention creation in eclipse. I am trying to add same context menu to Project Explorer and Package Explorer.

XXX_label is menu and XXX, YYY and ZZZ are commands.

For project Explorer as described in Link, I added entry for project explorer and package Explorer.

Plugin.xml

<plugin>     
<extension
     point="org.eclipse.ui.menus">
  <menuContribution
        allPopups="false"
        locationURI="popup:org.eclipse.ui.navigator.ProjectExplorer#PopupMenu?after=additions">
     <menu
           id="XXX_Project"
           label="XXX_label">
     </menu>
  </menuContribution>
  <menuContribution
        allPopups="false"
        locationURI="popup:XXX_Project?after=additions">
     <command
           commandId="demoeeeeeeeemenu.XXX"
           id="XXX"
           label="XXX"
           style="push">
        <visibleWhen>
           <with
                 variable="activeMenuSelection">
              <iterate
                    ifEmpty="true"
                    operator="or">
                 //Only option to get the Project instance in core expression is adapt type!!
                 <adapt
                       type="org.eclipse.core.internal.resources.Project">
                 </adapt>
              </iterate>
           </with>
        </visibleWhen>
     </command>
     <command
           commandId="demoeeeeeeeemenu.YYY"
           label="YYY"
           style="push">
     </command>
     <command
           commandId="demoeeeeeeeemenu.ZZZ"
           label="ZZZ"
           style="push">
     </command>
  </menuContribution>
  <menuContribution
        allPopups="false"
        locationURI="popup:popup:org.eclipse.jdt.ui.PackageExplorer#PopupMenu?after=additions">
     <menu
           id="XXX_package"
           label="XXX_label">
     </menu>
  </menuContribution>
  <menuContribution
        allPopups="false"
        locationURI="popup:XXX_package?after=additions">
     <command
           commandId="demoeeeeeeeemenu.XXX"
           label="XXX"
           style="push">
     </command>
     <command
           commandId="demoeeeeeeeemenu.YYY"
           label="YYY"
           style="push">
     </command>
     <command
           commandId="demoeeeeeeeemenu.ZZZ"
           label="ZZZ"
           style="push">
     </command>
  </menuContribution>
</extension>
<extension
     point="org.eclipse.ui.commands">
  <command
        id="demoeeeeeeeemenu.XXX"
        name="XXX">
  </command>
  <command
        id="demoeeeeeeeemenu.YYY"
        name="YYY">
  </command>
  <command
        id="demoeeeeeeeemenu.ZZZ"
        name="ZZZ">
  </command>
</extension>
</plugin>

How to eliminate extra entry done by package explorer? Any of Help is Appreciated.

EDIT : I think it is better to use locationURI="popup:org.eclipse.ui.popup.any?after=additions" as single popup entry which will add menu entry in both package explorer, Project Explorer and Navigator.

Community
  • 1
  • 1
  • The string `popup:popup:` doesn't look right in the PackageExplorer contribution. – greg-449 Aug 31 '15 at 10:12
  • Greg, If i remove one "popup:" then i am not able to find menu entry in package explorer. – Milankumar Ardeshana Aug 31 '15 at 11:44
  • do you recommend locationURI="popup:org.eclipse.ui.popup.any?after=additions" ? I was searching around and found this. This URI is working rather then two separate menu contribution, in one menu contribution only i can get entries in both project explorer as well package explorer. – Milankumar Ardeshana Aug 31 '15 at 11:47
  • You can use that, it will add the menu to other pop ups as well. I believe the locationURI for package explorer is just 'popup:org.eclipse.jdt.ui.PackageExplorer' – greg-449 Aug 31 '15 at 12:12
  • Yes. With that i made massive Core Expression for my task. If i use only 'popup:org.eclipse.jdt.ui.PackageExplorer' it worked as whatever i wants. Thanks greg.. – Milankumar Ardeshana Sep 01 '15 at 05:30

1 Answers1

1

Location URI for package explorer is : popup:org.eclipse.jdt.ui.PackageExplorer.