Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Inject not working with non xtext plugin(Inject not working with non xtext plugin)
Inject not working with non xtext plugin [message #1698501] Tue, 16 June 2015 06:47 Go to next message
Girish Kumar is currently offline Girish KumarFriend
Messages: 48
Registered: May 2011
Member
Hi All,

I have DSL plugin, i have generated artifacts and works perfectly fine.

the plugins are as below

a.dsl
a.dsl.test
a.dsl.ui

@Inject works fine within this three plugins.

I have another plugin say b.ui depends on a.dsl and a.dsl.ui

b.ui has a multipage editor and add xtext editor has one of the page
I want to inject some data in some class of b.ui

how can this be done ?

Regards
Girish

[Updated on: Tue, 16 June 2015 06:51]

Report message to a moderator

Re: Inject not working with non xtext plugin [message #1698509 is a reply to message #1698501] Tue, 16 June 2015 07:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
http://koehnlein.blogspot.de/2012/11/xtext-tip-how-do-i-get-guice-injector.html

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Inject not working with non xtext plugin [message #1698518 is a reply to message #1698509] Tue, 16 June 2015 08:11 Go to previous messageGo to next message
Girish Kumar is currently offline Girish KumarFriend
Messages: 48
Registered: May 2011
Member
Thanks Christian,

As per the blog, i can make injector to inject to particular object, can i make this more global. something like giving a class name and it does for all the instance of it.

Re: Inject not working with non xtext plugin [message #1698520 is a reply to message #1698518] Tue, 16 June 2015 08:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

can be more specific about the "where" you want to use the injector?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Inject not working with non xtext plugin [message #1698530 is a reply to message #1698520] Tue, 16 June 2015 09:31 Go to previous messageGo to next message
Girish Kumar is currently offline Girish KumarFriend
Messages: 48
Registered: May 2011
Member
[DSL]Activator.getInstance().getInjector("").injectMembers(this); will inject members and fields of this object.

What i am looking is something like this [DSL]Activator.getInstance().getInjector("").injectMembersTo(SomeClass.class); ??

So that i dont have to specify this [DSL]Activator.getInstance().getInjector("").injectMembers(this); for all the objects of SomeClass
Re: Inject not working with non xtext plugin [message #1698534 is a reply to message #1698530] Tue, 16 June 2015 09:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

and where / how someclasses are created?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Inject not working with non xtext plugin [message #1698537 is a reply to message #1698534] Tue, 16 June 2015 09:53 Go to previous messageGo to next message
Girish Kumar is currently offline Girish KumarFriend
Messages: 48
Registered: May 2011
Member
Ok I have 3 plugins which is generated by Xtext that is dsl, dsl.ui, dsl.tests.

I have one more plugin which depends on dsl, dsl.ui, lets name it as someplugin

In someplugin , i have a class named SomeClass, which needs formatter,generator, etc

so i do this
SomeClass some = new SomeClass();
[DSL]Activator.getInstance().getInjector("").injectMembers(some);
//now formatter and generator which has @inject is set

my question, is there a way i can say injectMembers to all Instances of SomeClass which will be created in future so that i don't have to call [DSL]Activator.getInstance().getInjector("").injectMembers(some); everytime the object created.

[Updated on: Tue, 16 June 2015 09:54]

Report message to a moderator

Re: Inject not working with non xtext plugin [message #1698544 is a reply to message #1698537] Tue, 16 June 2015 10:44 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
not if you use the new constructor. but you can ask the injector for a Provider of someClass and use that one to create the new instances.

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Cannot import org.eclipse.xtext.ui.editor.autoedit.DefaultAutoEditStrategyProvider
Next Topic:Saving DSL script triggers the application main program.
Goto Forum:
  


Current Time: Fri Apr 26 00:30:49 GMT 2024

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

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

Back to the top