wiki:Migrate_Plugin_Component_To_E4

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

  1. In fragment.e4xmi file select Model Fragments under Model Fragment Definition
  2. Right click and select Add child -> Model Fragment
  3. This would add a new Model Fragment to Model Fragments
  4. Fill information for this model fragment
    1. Select this Model Fragment under Model Fragments
    2. Click Find for Extended Element ID
      1. Type Application in Container-Type
      2. Select the core application org.grits.toolbox.core.application
      3. then select OK
    3. Type "commands" in Feature Name
  5. Add a Command to it
    1. Right click and select Add child -> Command
    2. Fill information for this command
      1. 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

  1. Repeat steps 1 to 4b from previous command section
  2. Type "handlers" in Feature Name
  3. Add Handler to it
    1. Right click and select Add child -> Handler
    • Fill information for this handler
      1. Give an id (you can use the same handler id from 3.x plugin)
      2. find the corresponding command for this handler
      3. 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

  1. Repeat steps 1 to 4a from previous command section
  2. For Extended Element ID use the location uri where you want to place it
  3. Type "children" in Feature Name
  4. Add Menu to it
    1. Right click and select Add child -> Menu
    • Fill information for this menu
      1. Give an id (you can use the same menu id from 3.x plugin)
      2. Add child "Handled Menu Item" or "Direct Menu Item" to this menu using Add child option by right clicking on Menu

Model Fragment Tutorial

Last modified 3 years ago Last modified on 09/07/2016 07:31:28 PM