Search code examples
javaeclipseeclipse-rcpjface

Refresh IContributorManager when underlying IAction contribution item gets updated


I have a IContributionManager... which gets passed into a class as a constructor argument. To each of them we add a custom defined IAction which has a menu creator set on it (setMenuCreator()). The menu creator is custom defined and implements IMenuCreator.

Now every time the view changes I have a method which gets called. Within this method, I need my custom IAction to return different menu items depending on the view type.

However, I can't seem to update the IContributionManager as the view changes and it simply shows the menu with items which were contained in the menu of the menu creator of the custom IAction when it was first constructed.

I have tried to reset the menu creator on the action every time view changes, removed the action and re-added it and tried IContributionManager#update(true) but none of them have worked. Any suggestions/recommendations? We're on Java 7 if that matters.


Solution

  • We removed the action from the contribution manager and re-created the action every time the view was refreshed. That helped in refreshing the view with the latest menu items.