Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Injection into ContentProvider / LabelProvider(How to give content and label providers access to services)
Injection into ContentProvider / LabelProvider [message #1723460] Mon, 15 February 2016 19:10 Go to next message
Gernot Krause is currently offline Gernot KrauseFriend
Messages: 22
Registered: June 2014
Junior Member
Hi!

I am still using SWT / JFace for my E4 RCP app. The content and label providers often need access to services that I usually provide via context injection. For example, the numbers shown in a table are calculated by a service request, or, the way numbers are formatted depends on user preferences, etc.

Is it a good idea to create the content / label providers via ContextInjectionFactory.make()?

Or should I pass the IEclipseContext reference to the providers?

Since I use EMF the adapter factory needs to be passed anyway. However, since my adapter factory is available via context injection, too, the first solution seems to have some benefits.

Thanks for your help.

Cheers,
Gernot.
Re: Injection into ContentProvider / LabelProvider [message #1723484 is a reply to message #1723460] Tue, 16 February 2016 04:04 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 876
Registered: January 2012
Senior Member

By passing in an IEclipseContext, you're tying yourself to a particular implementation. I'd have your ContentProvider and LabelProvider annotate instances with @Inject and inject the instances with CIF.make().

Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Re: Injection into ContentProvider / LabelProvider [message #1724973 is a reply to message #1723484] Sun, 28 February 2016 10:09 Go to previous message
Gernot Krause is currently offline Gernot KrauseFriend
Messages: 22
Registered: June 2014
Junior Member
Thanks for your feedback.

Seems I was on the right track with my first idea and using CIF.make().
Previous Topic:Is there a convenience method for Class<?> to contribution URI?
Next Topic:Eclipse and OpenJDK 9
Goto Forum:
  


Current Time: Thu Sep 24 12:40:47 GMT 2020

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

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

Back to the top