Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Recipe for using XText providers elsewhere
Recipe for using XText providers elsewhere [message #641315] Wed, 24 November 2010 21:56 Go to next message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Hi,

I'd like to be able to use the xtext Label Provider in another context, specifically for my EMF ItemProvider. Is there an easy obtain this adapter so that I can delegate to it from my EMF ItemProviderAdapter or is there an even better way to do this? Ideally, I'd just have everything delegated.

thanks,

Miles
Re: Recipe for using XText providers elsewhere [message #641370 is a reply to message #641315] Thu, 25 November 2010 08:50 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
Obtaining the adapter through the Guice Injector should do the trick (see §4.2.2 and §5.2 of the User Guide).

Re: Recipe for using XText providers elsewhere [message #641505 is a reply to message #641370] Thu, 25 November 2010 17:47 Go to previous messageGo to next message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Meinte Boersma wrote on Thu, 25 November 2010 03:50
Obtaining the adapter through the Guice Injector should do the trick (see §4.2.2 and §5.2 of the User Guide).


Hi Miente,

Thanks very much for the reference. I'll admit that I was hoping that you didn't use the word "injector" in your response and that I could get it programmatically. Like just grabbing an AdapterFactory.

I just now tried some stuff like:


		Injector inj = Guice.createInjector(new MyDSLRuntimeModule());
		ILabelProvider labelProvider = inj.getInstance(ILabelProvider.class);
		return labelProvider.getText(object);


But didn't work -- I'm probably still not grokking something. At some point I am really just going to have to sit down and figure all of that stuff out since E4 is using it as well. Very Happy So I'll get back to this when I have a more intelligent question to ask.

cheers,

Miles
Re: Recipe for using XText providers elsewhere [message #641587 is a reply to message #641505] Fri, 26 November 2010 08:52 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Am 11/25/10 6:47 PM, schrieb Miles Parker:
> Meinte Boersma wrote on Thu, 25 November 2010 03:50
>> Obtaining the adapter through the Guice Injector should do the trick
>> (see §4.2.2 and §5.2 of the User Guide).
>
>
> Hi Miente,
>
> Thanks very much for the reference. I'll admit that I was hoping that
> you didn't use the word "injector" in your response and that I could get
> it programmatically. Like just grabbing an AdapterFactory.

You could also instantiate the concrete classes using their constructors.

Sven


--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Re: Recipe for using XText providers elsewhere [message #641691 is a reply to message #641587] Fri, 26 November 2010 19:04 Go to previous message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
[quote title=Sven Efftinge wrote on Fri, 26 November 2010 03:52]Am 11/25/10 6:47 PM, schrieb Miles Parker:
>I'll admit that I was hoping that
> you didn't use the word "injector" in your response and that I could get
> it programmatically. Like just grabbing an AdapterFactory.

You could also instantiate the concrete classes using their constructors.
[QUOTE]

Oh I see, looks like I could just pass null for AdapterFactoryLabelProvider. I thought the delegate was being used in the dispatch chain but it looks like it isn't. At the very least I could just call the text methods assuming that I have such methods explicitly defined for each member.

BTW, one reason I wanted to do this is that I find the Xtext LabelProvider pattern to be much more easy to maintain then the EMF.Edit pattern, though the EMF.Edit pattern has important advantages as well of course.

cheers,

Miles
Previous Topic:Using \uXXXX in terminals?
Next Topic:scope with internal rule
Goto Forum:
  


Current Time: Fri May 10 14:51:26 GMT 2024

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

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

Back to the top