Eclipse开普勒依赖注入3.x [英] Eclipse Kepler Dependency Injection in 3.x

查看:421
本文介绍了Eclipse开普勒依赖注入3.x的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse 3.7中有一个工作插件,其中包含视图透视图

现在我尝试将其移动到Eclipse Kepler 4.3,因此我遵循 Jonas Helming的教程

我的所有视图均基于 TemplateView 在另一个插件。此 TemplateView 已转换为 e4 样式 POJO 查看。

我的插件扩展了这个 TemplateView 并添加了包装类(如教程中所述)。



Ip我运行我的应用程序在 e3 样式(意味着 TemplateView 正在扩展 ViewPart )一切都很好,添加了 Perspective
但是当我将它更改为 e4 样式(意味着 TemplateView 正在扩展 POJO ,我在我的 plugin.xml 中使用Wrapper)eclipse不再发送透视图及其视图



我的 e3 code>查看并不真正有趣,因为它主要使用我的自定义api(这只会混淆这里,并且它正常工作 - 因为它以 e3



这是 e4 Wrapper类:

  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);
}
}

这个问题是这个问题的部分,但没有dupe

解决方案

解决方案:
重要的是您使用 @Inject 注释并将复合父作为参数,然后创建内容。像这样:

  @Inject 
public PojoDetailView(Composite parent){
//或者放置创建代码这里或者调用3e风格的函数
createPartControl(parent);
}

我的错误是,我有一个简单的构造函数和一个注释 @PostConstruct on createPartControl(Composite parent)(这应该在 DI ,但显然没有)


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

解决方案

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)

这篇关于Eclipse开普勒依赖注入3.x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆