Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Accessing language preferences
Accessing language preferences [message #1062984] Tue, 11 June 2013 11:26 Go to next message
Erick Fonseca is currently offline Erick Fonseca
Messages: 63
Registered: December 2011
Member
I set up my language preferences page in my UI project, and can access them inside the UI packages like this:

    IPreferenceStore store = DSLActivator.getInstance().getPreferenceStore();
    String data = store.getString("whatever");


Now, I want to access it from the main Xtext project (i.e., the one with the grammar, validator, etc.). However, my DSLActivator is inside an internal UI package. I could export it, but it seems it was not supposed to be. How else can I access preferences?
Re: Accessing language preferences [message #1062999 is a reply to message #1062984] Tue, 11 June 2013 12:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6126
Registered: July 2009
Senior Member
Hi

did you try to inject IPreferenceStoreAccess instead?
Re: Accessing language preferences [message #1063028 is a reply to message #1062999] Tue, 11 June 2013 16:21 Go to previous messageGo to next message
Erick Fonseca is currently offline Erick Fonseca
Messages: 63
Registered: December 2011
Member
I couldn't get it to work with IPreferenceStoreAccess, but I found a way with IPreferencesService:

    IPreferencesService prefs = Platform.getPreferencesService();
    String data = prefs.getString("my.dsl.ui", "whatever", "unknown", null);
Re: Accessing language preferences [message #1063030 is a reply to message #1063028] Tue, 11 June 2013 16:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6126
Registered: July 2009
Senior Member
what was the symptoms with IPreferenceStoreAccess?
Re: Accessing language preferences [message #1063036 is a reply to message #1063030] Tue, 11 June 2013 16:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6126
Registered: July 2009
Senior Member
Btw i am dont know if it is a good idea to do it this way since standalone there is not platform pref service available
Re: Accessing language preferences [message #1064117 is a reply to message #1062984] Mon, 17 June 2013 13:36 Go to previous messageGo to next message
Erick Fonseca is currently offline Erick Fonseca
Messages: 63
Registered: December 2011
Member
I simply couldn't get the preference values from the IPreferenceStoreAccess.
Re: Accessing language preferences [message #1321693 is a reply to message #1064117] Tue, 29 April 2014 08:42 Go to previous messageGo to next message
Michael Bischoff is currently offline Michael Bischoff
Messages: 7
Registered: August 2012
Junior Member
Hello,
I have the same problem. I created an additional preferences page for an xtext DSL and I am able to configure values in the UI.
I want to access that configuration while running the xtext-maven-plugin. I tried the Platform approach and can confirm it's not available for Standalone setup (also not if adding the required dependencies).
The IPreferenceStoreAccess sits in the UI project, but I need the access from the generator project.

Is the proposed solution to add the UI project as a dependency?

Best regards,
Michael

Re: Accessing language preferences [message #1322044 is a reply to message #1321693] Tue, 29 April 2014 13:01 Go to previous message
Michael Bischoff is currently offline Michael Bischoff
Messages: 7
Registered: August 2012
Junior Member
Hi,
I'm no longer convinced that the question was a good one.
In standalone setups, the data shouldn't even be pulled from some Eclipse configuration storage, but rather depend on the environment.
For invocations via xtext-maven-plugin, for example, the <configuration> section of the pom.xml should provide the values. Not sure if such functionality is already supported.
For now, I'll go and do an easy fallback, and provide configuration from environment or system properties.

Best regards,
Michael
Previous Topic:how to enforce resource generation when having deep cross-reference over multiple resources
Next Topic:How to add custom compiler settings?
Goto Forum:
  


Current Time: Wed Jul 23 16:22:27 EDT 2014

Powered by FUDForum. Page generated in 0.11908 seconds