Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » LifeCycle and EPartService Injection Problem
LifeCycle and EPartService Injection Problem [message #1185799] Thu, 14 November 2013 04:17 Go to next message
Johannes Spreemann is currently offline Johannes Spreemann
Messages: 19
Registered: August 2013
Location: Germany/Netherlands
Junior Member
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 #1185813 is a reply to message #1185799] Thu, 14 November 2013 04:30 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 589
Registered: December 2010
Senior Member

It's probably in the window context and the default injection is looking for it in the app context. I'd put an addon which on it's post construct has the MApplication injected, grabs its first MWindow and does MWindow#getContext()#get(EPartService.class) and then does the stuff you want it to.
Re: LifeCycle and EPartService Injection Problem [message #1185824 is a reply to message #1185813] Thu, 14 November 2013 04:39 Go to previous message
Johannes Spreemann is currently offline Johannes Spreemann
Messages: 19
Registered: August 2013
Location: Germany/Netherlands
Junior Member
Thank you very much. Your idea works!

I Injected the IEclipseContext in the postContextCreate and retrieved the EPartService from the context.
Previous Topic:perspective bar
Next Topic:Eclipse 4 on Red Hat Linux
Goto Forum:
  


Current Time: Thu Apr 24 01:30:02 EDT 2014

Powered by FUDForum. Page generated in 0.04857 seconds