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

五迷三道 提交于 2020-01-11 13:10:07

问题


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).


回答1:


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.



来源:https://stackoverflow.com/questions/12764483/how-can-i-create-a-view-using-the-e4-programming-model-to-be-a-plug-in-for-eclip

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!