Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Validating against non EMF context(How to do per instance synamic validation)
Validating against non EMF context [message #1843624] Wed, 11 August 2021 07:00 Go to next message
Jeff Lowcock is currently offline Jeff LowcockFriend
Messages: 17
Registered: July 2009
Junior Member
I have an embedded editor mostly working. The editor has a context which the editor contents are validated against - for example I have a variable that must be associated with an external value from a combo. In this case it is a currency name that must match the externally selected currency, This all works as I have modified the Validator with the appropriate check.

When I have two editors open the issue is that the Validation is a singleton and hence the state/context is shared between the open editors - which is unworkable as obviously I would like to be able to edit more than one resource at a time and I do not want to face the issue of only a single currency able to be selected at a time.

I have spent the last 3-4 weeks looking at code, trying to understand how xtext hangs together and at this point I admit defeat.

So my question how can I apply the context of each editor instance independently. I suspect this means I will have to supply another validator to do context based validation - but so far I cannot even see where to begin.

Need some guidelines here - where next?
Re: Validating against non EMF context [message #1843625 is a reply to message #1843624] Wed, 11 August 2021 07:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi, for each embedded editor you create a resource. you should be able to add the information there as an Adapter and retrieve it from validation

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Validating against non EMF context [message #1843654 is a reply to message #1843625] Thu, 12 August 2021 09:35 Go to previous message
Jeff Lowcock is currently offline Jeff LowcockFriend
Messages: 17
Registered: July 2009
Junior Member
Christian thank for the hint - I had to read a bit more so learned a few more lessons. In brief I made an Adapter class to hold the context information. Applied this class to the resource after creation. In the validator I return the adapter from the eResource referenced from the EObject being validated. Every thing works as intended. I am left with a small niggle as I feel I am not really using Adapters as intended - however I will resolve that with more reading. For now my 3-4 week long journey ended in 30 minutes or coding and testing with no further issues (except code clean up). Once again thank you for your guidance.
Previous Topic:Context Validation
Next Topic:Customize Java-Expression "toString"
Goto Forum:
  


Current Time: Tue Apr 16 14:31:17 GMT 2024

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

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

Back to the top