Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » EMenuService is null(EMenuService parameter is Null in the @Execute method)
EMenuService is null [message #1292206] Fri, 11 April 2014 16:12 Go to next message
Martin Bayer is currently offline Martin Bayer
Messages: 26
Registered: December 2012
Junior Member
Hi,
I have following handler implemented:
@Execute
	public void execute(
			IEclipseContext eclipseContext,
			EMenuService service,
			@Named(value = ContextVariables.CANVAS_OBJECTS_MANAGER) ICanvasManager canvasManager) {
...
}

Following error is thrown:
MenuService: TrimmedWindowImpl (cz.martinbayer.e4.analyser.trimmedwindow.0) Context: org.eclipse.e4.core.di.InjectionException: Unable to process "MenuService.myPart": no actual value was found for the argument "MPart".

service parameter is null even when this handler is registered in application model but regarding previous error message it is obvious there is no EMenuService registered for context of the part.
Am I missing something? I tried to register the handler to the:
*Application->Handlers
*Application->Windows->Trimmed window->Handlers

Any advice would be appreciated.
Thank you very much,
M.
Re: EMenuService is null [message #1295347 is a reply to message #1292206] Mon, 14 April 2014 07:31 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 597
Registered: December 2010
Senior Member

Normally one would use the EMenuService in a part context (it internally tries to inject a part). What's your scenario for needing it from the window level? Can't you inject directly from the part you're trying to use it?
Re: EMenuService is null [message #1295425 is a reply to message #1295347] Mon, 14 April 2014 08:56 Go to previous messageGo to next message
Martin Bayer is currently offline Martin Bayer
Messages: 26
Registered: December 2012
Junior Member
Hi,
I use it during deserialization of my objects placed on the canvas which is contained on the one of my parts. I have an EMenuService instance set as transient so I'd like to reinitialize the service during deserialization.
Now I'm using workaround and I manually inject the menu service to the created object during insertion objects to canvas.

So the whole process is:
1) press the Open menu item in menu
2) OpenHandler is used to handle the operation
3) method wich annotation @Execute contains deserialization of the objects
4) during deserialization, it would be nice to be able to initialize menu service for the object

But why there is no EMenuService contained in the context? I thought it searches for variables in the context hierarchically, so it should be found at least in the main context for the application. Do I understand it well?
Thanks for your responses,

Martin
Re: EMenuService is null [message #1295601 is a reply to message #1295425] Mon, 14 April 2014 12:05 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 597
Registered: December 2010
Senior Member

You do understand it well. However, look at the error message. It is not saying "I can't find an EMS", it's saying I can't find an MPart to initialize the EMS. Internally the EMS implementation has an @Inject MPart part; which fails in this context and its hierarchy.

Can you sysout the eclipseContext that you get as a parameter?
Re: EMenuService is null [message #1295980 is a reply to message #1295601] Mon, 14 April 2014 18:35 Go to previous messageGo to next message
Martin Bayer is currently offline Martin Bayer
Messages: 26
Registered: December 2012
Junior Member
Hi, so the sysout of the context property is:
TrimmedWindowImpl (cz.martinbayer.e4.analyser.trimmedwindow.0) Context


Also the content of the context's Map is attached.
I need to complete my diploma thesis now but after that it will be a pleasure to try to help with debugging this behavior.
Re: EMenuService is null [message #1298361 is a reply to message #1295425] Wed, 16 April 2014 07:56 Go to previous messageGo to next message
Frank Schaare is currently offline Frank Schaare
Messages: 8
Registered: July 2009
Junior Member
Hi,
Martin Bayer wrote on Mon, 14 April 2014 04:56
Hi,
But why there is no EMenuService contained in the context? I thought it searches for variables in the context hierarchically, so it should be found at least in the main context for the application. Do I understand it well?
Thanks for your responses,
Martin

this question is FAQ meanwhile, you will find at least 5 questions (all unanswered) to this topic in the threads below.
I spent some time searching for an answer, because in all PartDescriptors, the EMenuservice is NULL too, which is quite anoying.
The EMenuservice is not a e4 core service, it is a declarative service provided by the SWT renderer. For these services, the hierarchically lookup seems to be buggy, the DI-Container just searches the actual context and injects NULL without proceeding to higher contextes.
A solution may be to manually retrieve the service context and access the EMenuservice directly, without 'DI-Magic'.
I hope, some day, a committer will answer to this topic.....
Re: EMenuService is null [message #1298393 is a reply to message #1298361] Wed, 16 April 2014 08:28 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 597
Registered: December 2010
Senior Member

Frank Schaare wrote on Wed, 16 April 2014 09:56
Hi,
Martin Bayer wrote on Mon, 14 April 2014 04:56
Hi,
But why there is no EMenuService contained in the context? I thought it searches for variables in the context hierarchically, so it should be found at least in the main context for the application. Do I understand it well?
Thanks for your responses,
Martin

this question is FAQ meanwhile, you will find at least 5 questions (all unanswered) to this topic in the threads below.
I spent some time searching for an answer, because in all PartDescriptors, the EMenuservice is NULL too, which is quite anoying.
The EMenuservice is not a e4 core service, it is a declarative service provided by the SWT renderer. For these services, the hierarchically lookup seems to be buggy, the DI-Container just searches the actual context and injects NULL without proceeding to higher contextes.
A solution may be to manually retrieve the service context and access the EMenuservice directly, without 'DI-Magic'.
I hope, some day, a committer will answer to this topic.....


You really have no idea what you're talking about, do you? The EMenuService is provided by a context function called MenuServiceCreationFunction. Whatever .....

@Martin, can't you put the EMS injection at the @Postconstruct of the part which has this canvas? You can see from the debug statement that the context in question is the workbench and there's no part in it, or above it. Is there an active part around when this handler is called?
Re: EMenuService is null [message #1298504 is a reply to message #1298393] Wed, 16 April 2014 10:01 Go to previous messageGo to next message
Frank Schaare is currently offline Frank Schaare
Messages: 8
Registered: July 2009
Junior Member
Sopot Cela wrote on Wed, 16 April 2014 04:28

You really have no idea what you're talking about, do you? The EMenuService is provided by a context function called MenuServiceCreationFunction. Whatever .....

Well, it was a suggestion as i saw the service declaration in SWT-Renderer. Unfortunately, my company pays my me for application development, not for code reviewing Sad
Do you know, where the implemantation of that 'context function' is ? Maybe, that could bring some light into it ....

[Updated on: Wed, 16 April 2014 10:04]

Report message to a moderator

Re: EMenuService is null [message #1322333 is a reply to message #1298504] Tue, 29 April 2014 20:19 Go to previous message
Martin Bayer is currently offline Martin Bayer
Messages: 26
Registered: December 2012
Junior Member
Hi, sorry for late response but I was quite busy.
Sepot, you're absolutely right with active part thought and I'm really stupid on the other hand:). The problem doesn't occur when part is focused before the handler is invoked.
Previous Topic:Eclipse 4 RCP application memory leakage
Next Topic:Best practise for using Translation Service (Luna M6)
Goto Forum:
  


Current Time: Fri Oct 24 16:27:39 GMT 2014

Powered by FUDForum. Page generated in 0.01797 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software