Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Modeling (top-level project) » Use attributes in model validation messages
Use attributes in model validation messages [message #717194] Fri, 19 August 2011 14:53 Go to next message
Dmitry Spiridenok is currently offline Dmitry SpiridenokFriend
Messages: 12
Registered: August 2011
Junior Member
Dear all,

I'm pretty new to Eclipse. Currently i'm busy with extending an existing model with extra validations.
For that i use org.eclipse.emf.validation.* features (think it's a pretty common way to do validations in Eclipse).

I got my validations working. However i would like to make the validation message (the message that is shown in case a validation fails) more user friendly. Currently i have something like that in my validations:
         <constraint
                lang="OCL"
                severity="ERROR"
                mode="Batch"
                name="Constraint name"
                id="Constraint"
                statusCode="160">
                <message>Incorrect node {0}</message>
                <target class="DecisionNode"/>
         <![CDATA[... some condition ... ]]>
       </constraint>

However what i really would like to have is something like
         <message>Incorrect node {0}.name</message> 

The difference is {0}.name iso {0} - the name of the node is much more user friendly then the node itself.

Is it possible to use attributes of the objects iso the objects themselves in the message text? If yes, could you please provide an example of how i can access attributes of the objects within a message.

Thank you in advance!

P.S. One possible solution would be to implement constraints in Java. This is however not a real option to me because all my validations are pretty simple OCL expressions and i would like to stick to OCL in my model validation.
Re: Use attributes in model validation messages [message #717231 is a reply to message #717194] Fri, 19 August 2011 16:22 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
It's best to use eclipse.tools.emf for asking questions about EMF. More
comments below.


On 19/08/2011 7:53 AM, D. Spiridenok wrote:
> Dear all,
>
> I'm pretty new to Eclipse. Currently i'm busy with extending an
> existing model with extra validations.
> For that i use org.eclipse.emf.validation.* features (think it's a
> pretty common way to do validations in Eclipse).
>
> I got my validations working. However i would like to make the
> validation message (the message that is shown in case a validation
> fails) more user friendly. Currently i have something like that in my
> validations:
>
> <constraint
> lang="OCL"
> severity="ERROR"
> mode="Batch"
> name="Constraint name"
> id="Constraint"
> statusCode="160">
> <message>Incorrect node {0}</message>
> <target class="DecisionNode"/>
> <![CDATA[... some condition ... ]]>
> </constraint>
>
> However what i really would like to have is something like
> <message>Incorrect node {0}.name</message> The difference is {0}.name
> iso {0} - the name of the node is much more user friendly then the
> node itself.
>
> Is it possible to use attributes of the objects iso the objects
> themselves in the message text? If yes, could you please provide an
> example of how i can access attributes of the objects within a message.
I'm not so familiar with the details of the extended validation
framework. Are the label providers being used to produce the
substitution for {0}?
>
> Thank you in advance!
>
> P.S. One possible solution would be to implement constraints in Java.
> This is however not a real option to me because all my validations are
> pretty simple OCL expressions and i would like to stick to OCL in my
> model validation.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Use attributes in model validation messages [message #717724 is a reply to message #717231] Mon, 22 August 2011 07:44 Go to previous message
Dmitry Spiridenok is currently offline Dmitry SpiridenokFriend
Messages: 12
Registered: August 2011
Junior Member
Ed,

Thanks for the tip, i've posted this message also in tools.emf

I'm not sure what you exactly mean with your question. What i found is that the message is of type java string. I also found the following info
Quote:
The localized strings in the plugin.properties file follow the usual pattern. The one exception is the message string, which for OCL constraints can specify the {0} placeholder one or more times to be replaced by the label for the element that was validated (see the MessageFormat API for details). Usually, the label will look something like "Writer Isaac Asimov"; this can be customized via the IItemLabelProvider adapter mechanism in the EMF.Edit framework.


Is that what you meant?
Previous Topic:How does eclipse resolve model URI's?
Next Topic:Modeling with RAS(IBM) and Eclipse
Goto Forum:
  


Current Time: Fri Apr 19 00:40:39 GMT 2024

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

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

Back to the top