问题
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