LifeCycle and EPartService Injection Problem [message #1185799] |
Thu, 14 November 2013 04:17  |
Eclipse User |
|
|
|
Good morning, good day or good night,
I have a small problem with the activation of a part. My part is in a tab in the background. It is necessary to create the part before its first activation. I tried to instantiate it manually within my LifeCycleManager, but the EPartService isn't injected at all. Not in the postContextCreate (The method is not called when the EPartService is added as a parameter) or as a "global" injection (InjectionException).
Case #1:
@PostContextCreate
void postContextCreate(final IEventBroker eventBroker, final EPartService partService) {
eventBroker.subscribe(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE,
new EventHandler() {
@Override
public void handleEvent(Event event) {
partService.showPart(
"myapp.part.statistics",
PartState.CREATE);
eventBroker.unsubscribe(this);
}
});
}
Case #2:
@Inject
EPartService partService; // InjectionException
void postContextCreate(final IEventBroker eventBroker) {
...
partService.showPart(...);
...}
Any ideas why the injection doesn't work?
|
|
|
|
|
|
|
Re: LifeCycle and EPartService Injection Problem [message #1386618 is a reply to message #1386565] |
Wed, 18 June 2014 13:52  |
Eclipse User |
|
|
|
Hi Thomas, thanks for the answer.
Well, I actually have the problem in other classes as well (those which are not parts). I just checked in the LyfeCycle manager class because was easier to test.
In the previous comments it was not said that it cannot be done
Johannes Spreemann wrote on Thu, 14 November 2013 10:39Thank you very much. Your idea works!
I Injected the IEclipseContext in the postContextCreate and retrieved the EPartService from the context.
Besides, @PostContextCreate, doesnt it mean that everything is created already?
The curious thing is that it was working few days ago.
It seems it is randomly when is not a Part class (which are referred in the e4xmi file andtherefore I guess Eclipse Workbench knows of).
Therefore let me rephrase the question: How can I get a Part from a class which is not a Part it self?
This doesn't work:
class A{
@Inject EPartService _partservice;
void method(){
...
MPart mpart = _epartservice.findPart("aa.bb.cc.mypart");
_epartservice.showPart(mpart, PartState.ACTIVATE); // _epartservice is null
...
}//- method
}//- class A
Thanks again
|
|
|
Powered by
FUDForum. Page generated in 0.06115 seconds