Search code examples
eclipse-rcprcpe4

Dynamic Menu contribution and PersistedState


How do I get the menu instance in the answer given in the following question?

Existing Question


Solution

  • Use the EModelService to find the menu by its id.

    @Inject
    EModelService modelService;
    
    List<MMenu> list = modelService.findElements(app, "menu id", MMenu.class, 
                              Collections.emptyList(), EModelService.IN_MAIN_MENU);
    

    You must use the findElements call with the EModelService.IN_MAIN_MENU flag to search the menus.