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