Search code examples
eclipse-plugineclipse-rcpe4

Cannot add menu to org.eclipse.ui.main.menu through Model Fragment Definition in Eclipse 4 model editor


I have a eclipse-rcp application developed with Eclipse 4. This application is modularized with several plugins and features. This application is built with maven-tycho using pomless. The project structure follows the guidelines proposed by vogella for Eclipse Tycho.

This project has a main Application model defined in the plugin app.rcp (Application.e4xmi). It has several plugins that extend this application model through several fragment.e4xmi files. Specifically, in one of them, I modify the application model to add a menu to the application main menu with the following line in the frament.e4xmi:

Extended Element-ID: org.eclipse.ui.main.menu Feature Name: children Position in list: index:1000

This model fragment allows me to add menus, handled menus and so on without any problem through the Eclipse 4 model editor.

At this point, my objective is to build a separate feature, which is not in the same project, to add a similar menu to the application main menu, which will be installed in the original application using a p2 update site.

For this, I have created a plug-in with an application model fragment (fragment.e4xmi). I try to modify the file with the Eclipse 4 model editor pushing Find... of Extended Element-ID field. However, when I select Menu in Container-Type, there is no item that I can select. In the other plugin I can select the Main menu (org.eclipse.ui.main.menu) and other created menus.

I have tried to add dependencies to the plugins of the main application. The project compiles in the command line (mvn clean verify), but in Eclipse IDE it shows that it cannot find the plug-ins of the main application.

EDIT:

The problem here is that the combo to add Menu, MenuSeparator, HandledMenuItem, etc is disabled, so I have no way of adding any of it. When I push the add button, it does nothing. I have tried to use a text editor to change the fragment.e4xmi file directly, but I haven't been able to test if that works.

The combo box that I refer to is located below the "Position in list" field of the model fragment ( see Model Fragment editor image)


Solution

  • You must add the menu to the 'Imports' section in the fragment.e4xmi to make the 'Find' dialog work.

    You can also just add the id manually, it should still be resolved properly when the model is being loaded.