Eclipse 4 Application Platform – contributorURI vs contributionURI

All Eclipse 4 applications (from the Eclipse 4.x IDE to your simple e4 RCP) leverage the Eclipse 4 application model who is a representation of your whole application in a well defined and typesafe EMF-Model (you can somehow compare it to your browsers DOM).

The model itself is not static but a so called live model and you can interact with it through your preferred VM-Language eg to add new elements. One of the things done most often is to programmatically add MPart instances to represent your UI-Component.

The code below is taken from the e(fx)clipse code editor component library

public static class DefaultEditorOpener implements EditorOpener {
  EModelService modelService;

  List<FileIconProvider> fileIconProvider;

  public boolean openEditor(String uri) {
    // .....
    MPart part = modelService.createModelElement(MPart.class);

    String iconUri = fileIconProvider
      .filter( f -> f.test(uri))
      .map( f -> f.getFileIconUri(uri))
    part.getPersistedState().put(Constants.DOCUMENT_URL, uri);
    // .....

While most of the code is straight forward most developers stumble upon the 2 very similar MPart attributes:

  • contributionURI: URI to identify the class that is responsible to create the MParts UI
  • contributorURI: URI to identify the bundle who create the model element

Even worse most developers only use contributionURI and never set the contributorURI value which might lead to problems for example if the value is to be translated because the information in the contributorURI is used to retrieve the ResourceBundle through the BundleLocalization-Service.

This entry was posted in e(fx)clipse, e4. Bookmark the permalink.

1 Response to Eclipse 4 Application Platform – contributorURI vs contributionURI

  1. Pingback: Creation of Eclipse 4 Application Model elements in efxclipse 2.2.0 | Tomsondev Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.