Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » RCP: Cannot inject invisible parts
RCP: Cannot inject invisible parts [message #1001849] Thu, 17 January 2013 12:53 Go to next message
Rafael Fogel is currently offline Rafael FogelFriend
Messages: 21
Registered: January 2013
Junior Member
I am facing a trouble that i can't understand.

Here's my problem:

I have a part stack with 2 parts:

PartStack
-> Part A
-> Part B

A and B are noted with @Creatable and @Singleton

And i have a class which manage my views like that:

public class Manager
{
@Inject private A a;
@Inject private B b;

When I make A and B visible at least one time, i can instantiate this class without problem, but when those classes were never been visible, i got the message : "no actual value was found for the argument" for the Injected classes. I figured out that this comes when the class wasn't instantiated and never got inserted on context, but even when i force the instantiation, i got the error.

I don't know if I make myself clear but I would like to know what process the framework do to insert the class on context, or if there is something i'm doing wrong.

Thanks.
Re: RCP: Cannot inject invisible parts [message #1001943 is a reply to message #1001849] Thu, 17 January 2013 15:35 Go to previous messageGo to next message
Joseph Carroll is currently offline Joseph CarrollFriend
Messages: 174
Registered: May 2012
Location: Milwaukee, WI
Senior Member

Remove the @Creatable and @Singleton, that is not what they are for.

E4 Dependency Injection
Re: RCP: Cannot inject invisible parts [message #1001976 is a reply to message #1001943] Thu, 17 January 2013 16:32 Go to previous messageGo to next message
Rafael Fogel is currently offline Rafael FogelFriend
Messages: 21
Registered: January 2013
Junior Member
I don't get it. Without those notes I can't inject my classes.

Classes annotated with @Creatable will be automatically created by the injector if an instance was not present in the injection context. The automatically-generated instance is not stored in the context.

How do I inject my classes then?
Re: RCP: Cannot inject invisible parts [message #1002001 is a reply to message #1001976] Thu, 17 January 2013 17:31 Go to previous messageGo to next message
Joseph Carroll is currently offline Joseph CarrollFriend
Messages: 174
Registered: May 2012
Location: Milwaukee, WI
Senior Member

The framework takes care of it. @Creatable is for resources not in the context *AND* not referenced in the running model. Your part class is referenced in your MPart from the running model. The framework automatically creates it for you.
Re: RCP: Cannot inject invisible parts [message #1002359 is a reply to message #1002001] Fri, 18 January 2013 13:07 Go to previous messageGo to next message
Rafael Fogel is currently offline Rafael FogelFriend
Messages: 21
Registered: January 2013
Junior Member
Ok, i am starting on rcp and it isn't very clear to me.

I am accessing this class this way:

Manager manager = ContextInjectionFactory.make(Manager.class, context);

Without those notes, I can't do it. How do you suggest I access this class? ( assuming I won't just instantiate like a pojo )
Re: RCP: Cannot inject invisible parts [message #1002366 is a reply to message #1002359] Fri, 18 January 2013 13:23 Go to previous messageGo to next message
Eclipse UserFriend
MParts usually are created by the framework (renderer). The creation involves instantiating the contribution object (the URI class), constructing the runtime representation of MPart and putting it to the context. This creation follows the lazy loading approach in that only parts that are visible are created, otherwise Eclipse would start in 10 minutes if it had to instantiate each and every view in the model (which is an MPart). So it creates only what is visible.

The 'one time visible' situation may happen because when you try to force the creation through @Creatable the contribution object is not created. Usually it is not a good idea to force the creation of parts when they are not visible yet, though it depends on the case. If you want to do some form of processing on the part you can register a listener (IEventBroker) on part creation and do your stuff there, and let the renderer (LazyStackRenderer) decide when to instantiate the part.

That said, @Creatable is used to do a CIF.make on a class and @Singleton is used to prevent multiple instances in a given scope.
Re: RCP: Cannot inject invisible parts [message #1002499 is a reply to message #1002366] Fri, 18 January 2013 17:59 Go to previous message
Rafael Fogel is currently offline Rafael FogelFriend
Messages: 21
Registered: January 2013
Junior Member
Now it's way more clear to me. Thanks for the support, Sopot
Previous Topic:Draggable toolbars in pure E4 application
Next Topic:Properties view (or other "standard" view) in pure eclipse e4 perspective
Goto Forum:
  


Current Time: Fri Apr 19 05:01:18 GMT 2024

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

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

Back to the top