Gab Royer
Gab Royer

Reputation: 9836

How to dynamically populate an Eclipse popupMenu?

How do you dynamically populate the actions of a popupMenu in Eclipse.

I tried the following tutorial : http://wiki.eclipse.org/Menu_Contributions/Populating_a_dynamic_submenu without much success.

Here is my plugin.xml file

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.ui.popupMenus"> 
   <viewerContribution 
      id="org.eclipse.ui.articles.action.contribution.popup.navigator"
   targetID="org.eclipse.ui.views.ResourceNavigator"> 
   <menu
         id="org.eclipse.ui.articles.action.contribution.navigator.subMenu"
         label="Apply command"
         path="additions">

          <dynamic class="helloworld.DynamicMenu"
          id="org.eclipse.ui.views.problems.groupBy.items"></dynamic>
      </menu>
   </viewerContribution> 
</extension>
</plugin>

The problem is, nothing happens. getContributionItems from DynamicMenu doesn't get called and I don't get any error. Eclipse does warn me though that dynamic is not a legal child of menu.

I am running eclipse 3.7 and building extensions targeting the same version.

Upvotes: 0

Views: 1172

Answers (1)

Martti K&#228;&#228;rik
Martti K&#228;&#228;rik

Reputation: 3621

The tutorial that you are referring to uses org.eclipse.ui.menus extension point rather than org.eclipse.ui.popupMenus. The former is replacement for the latter and should be preferred.

Upvotes: 1

Related Questions