How can I create a view using the E4 programming model to be a plug-in for Eclipse 4.2 or above?

StackOverflow https://stackoverflow.com/questions/12764483

  •  05-07-2021
  •  | 
  •  

Question

Most of the existing Eclipse plug-ins use the extension registry and subclasses of ViewPart, coupled with the compatibility layer. As a result, writing a new view (especially using the new plug-in wizard in PDE) results in plug-ins that look like:

<plugin>
  <extension point="org.eclipse.ui.views">
    <view name="Example View" class="org.example.ExampleView"/>
  </extension>
</plugin>

public class ExampleView extends ViewPart {
  public void createPartControl(Composite parent) {
    ...
  }
}

Is it possible to take advantage of the E4 programming model to create a view like:

public class Example {
  @Inject
  public Example(Composite parent) {
    ...
  }
}

and have that hooked into an existing Eclipse 4.2 instance, so that it shows up in the 'Show View' menu? If so, how is it declaratively wired in (since that the LegacyIDE.e4xmi is immutable and can't be added to).

Was it helpful?

Solution

Look at the code I've written for the e4 model editor (http://git.eclipse.org/c/e4/org.eclipse.e4.tools.git/tree/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x).

I've a set of wrappers for this at http://git.eclipse.org/c/e4/org.eclipse.e4.tools.git/tree/bundles/org.eclipse.e4.tools.compat for 4.3 we plan on direct support.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top