Migrating 3.x ui components from plugin.xml to e4
Here are some of the basic steps to migrate ui components from 3.x plugin to e4 plugin
Add fragment.e4xmi file
Add a fragment.e4xmi to your plugin using the wizard
- File -> New -> Other opens eclipse wizard
- under Eclipse 4 -> Model select New Model Fragment
- click Next
- Browse your plugin in the next page
- click Finish
- Using the wizard also
- adds the org.eclipse.e4.workbench.model extension to your plugin.xml
- updates the MANIFEST.MF file with e4 dependency plugin
- updates the build.properties file by including the fragment in the build
Migrating UI definitions from plugin.xml
The plugin.xml file should not contain any definition of ui components as these will be added through the e4xmi file. Get rid of any of these extensions if they are there in your plugin
- org.eclipse.ui.commands
- org.eclipse.ui.handlers
- org.eclipse.ui.menus
- org.eclipse.ui.editors
- All other extensions from org.eclipse.ui.*
- org.grits.toolbox.core.entryeditor
Here is a break down of steps for replacing the above extensions with model fragments in the fragment.e4xmi file
Replacing org.eclipse.ui.commands
Add a Command Model Fragment in fragment.e4xmi file
- In fragment.e4xmi file select Model Fragments under Model Fragment Definition
- Right click and select Add child -> Model Fragment
- This would add a new Model Fragment to Model Fragments
- Fill information for this model fragment
- Select this Model Fragment under Model Fragments
- Click Find for Extended Element ID
- Type Application in Container-Type
- Select the core application org.grits.toolbox.core.application
- then select OK
- Type "commands" in Feature Name
- Add a Command to it
- Right click and select Add child -> Command
- Fill information for this command
- id, name and description
- you can use the same command id from 3.x plugin
Replacing org.eclipse.ui.handlers
Add a Handler Model Fragment in fragment.e4xmi file similar to previous section
- Repeat steps 1 to 4b from previous command section
- Type "handlers" in Feature Name
- Add Handler to it
- Right click and select Add child -> Handler
- Fill information for this handler
- Give an id (you can use the same handler id from 3.x plugin)
- find the corresponding command for this handler
- select Class URI and create a Class for this using the wizard
Replacing org.eclipse.ui.menus
Add a Menu Fragment (or Handled Menu Item/Direct Menu Item for placing under an existing menu) in fragment.e4xmi file similar to previous section
- Repeat steps 1 to 4a from previous command section
- For Extended Element ID use the location uri where you want to place it
- Type "children" in Feature Name
- Add Menu to it
- Right click and select Add child -> Menu
- Fill information for this menu
- Give an id (you can use the same menu id from 3.x plugin)
- Add child "Handled Menu Item" or "Direct Menu Item" to this menu using Add child option by right clicking on Menu