Search code examples
eclipse-plugine4

CompoundContributionItem In E4


I have an implementation of CompoundContributionItem that I want to get to work in an pure E4 application. I found some kind of documentation for other IContributionItems, but not for this one.

What's the mechanism for implementing CompoundContributionItemin E4?


Solution

  • It's done via the @AboutToShow annotation:

    public class PluginEnablementContributionItem {
    
        @AboutToShow
        public void aboutToShow(List<MMenuElement> items) {
            MDirectMenuItem item = MMenuFactory.INSTANCE.createDirectMenuItem();
            item.setLabel("My Menu Item");
            item.setContributorURI("platform:/plugin/org.acme.project");
            item.setContributionURI("bundleclass://org.acme.project/org.acme.project.MyHandler");
            items.add(item);
        }
    
    }