Eclipse Kepler Dependency Injection in 3.x

徘徊边缘 提交于 2019-12-12 05:23:44

问题


I have a working plugin in Eclipse 3.7 with Views and a Perspective.
Now I try to move this to Eclipse Kepler 4.3 therefore i follow the Tutorial from Jonas Helming
All my Views are based on a TemplateView in another Plugin. This TemplateView was transformed to an e4 style POJO View.
My Plugin extends this TemplateView and adds the wrapper class (as described in the Tutorial).

Iff i run my application in e3 style (means TemplateView is extending ViewPart) everything is fine and the Perspective gets added. But when i change it to the e4 style (means TemplateView is extending POJO and i use the Wrapper in my plugin.xml) eclipse does no longer dispay the Perspective and its Views.

my e3 Viewis not really interesting, as its mostly using my custom api (which would only confuse here & it is working correctly - as it starts as e3)

and this is the e4 Wrapper class:

import org.eclipse.e4.tools.compat.parts.DIViewPart;
import lumo.views.contact.e3.PojoDetailView;

public class E4DetailView extends DIViewPart<PojoDetailView> {
    public E4DetailView() {
        super(PojoDetailView.class);
    }
}

this problem is part of this question, but no dupe


回答1:


Solution: it is important you do use a constructer with @Inject Annotation and have Composite parent as parameters, then create the content. like this:

@Inject
public PojoDetailView(Composite parent) {
  // either put creation code here or call the 3e styled function
  createPartControl(parent);
}

my mistake was that i had a plain constructer and an Annotation @PostConstruct on createPartControl(Composite parent) (this should execute after DI, but obviously did not)



来源:https://stackoverflow.com/questions/17853139/eclipse-kepler-dependency-injection-in-3-x

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