Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Inject Part - What did I miss?
Inject Part - What did I miss? [message #1005611] Sun, 27 January 2013 09:04 Go to previous message
Kirsten M. Z. is currently offline Kirsten M. Z.
Messages: 106
Registered: July 2010
Senior Member
Injection can be really neat, but if something doesn't work, you have no idea Sad

Injection works for almost all stuff I tried, but not for (visible) parts. Create a new e4 Project and modify the AboutHandler:


public class AboutHandler {
	
	@Execute
	public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, @Active AppPart a) {
		MessageDialog.openInformation(shell, "About", "e4 Application example.");
	}
	
	@CanExecute
	public boolean canExecute(MApplication app,  EModelService service, @Optional AppPart appPartInjected) {
	    PartImpl element = (PartImpl) service.find("myapp.part.0", app);
	    AppPart appPart = (AppPart) element.getObject();
            return true;
	}
}


"appPartInjected" is always null. I also tried @Named("myapp.part.0") or @Active, but null. If I don't use @Optional, the method is not called, of course.

I worked through several tutorials (maybe a little bit too fast?), but could not find any hint, that injection of parts does not work that easily. Instead I found the code I am using within "canExecute". This code also works and I get my part, so the part is available! And should be active, right? It is the only part I am using, and it is also visible at startup? However, why is injection not working in that case?

BTW: AppPart is just a regular part. I haven't specified anything special, e.g. @Singleton... but I tried of course. I also tried @Creatable, but this is not the correct effect Wink

Thanks in advance!
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic:What's up with the Package Explorer selection in Juno?
Next Topic:How to connect to DB / Legacy system in parallel to eclipse start?
Goto Forum:
  


Current Time: Tue May 21 23:04:43 EDT 2013

Powered by FUDForum. Page generated in 0.04504 seconds