Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Custom ResourceLocator for the generated Validator
Custom ResourceLocator for the generated Validator [message #633136] Fri, 15 October 2010 13:30 Go to next message
Ralph P is currently offline Ralph PFriend
Messages: 30
Registered: September 2010
Location: Frankfurt, Germany
Member
Hello,

I'm having problems with custumizing the EMF-generated MyModelValidator. What I want to do is define custom error messages for my own constraints.

Since I don't want to redefine generic String resources for every possible error during validation, it would be great if I could just add my own Strings to the existing resource. Unfortunately it's not any of the "plugin.properties" files the standard ResourceLocator uses.

There are several examples of how to specialize the Validator class in the EMF handbook but none of them shows how to override the getResourceLocator() method.

This is how the fresh getResourceLocator method looks like:

    /**
     * Returns the resource locator that will be used to fetch messages for this validator's diagnostics.
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * @generated
     */
    @Override
    public ResourceLocator getResourceLocator() {
        // TODO
        // Specialize this to return a resource locator for messages specific to this validator.
        // Ensure that you remove @generated or mark it @generated NOT
        return super.getResourceLocator();
    }


Thanks in advance!
Ralph
Re: Custom ResourceLocator for the generated Validator [message #633151 is a reply to message #633136] Fri, 15 October 2010 14:00 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30554
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090103000806080900060207
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Ralph,

Generally I'd expect it to refer to the plugin for the model and to add
messages to the plugin.properties

public ResourceLocator getResourceLocator()
{
return XyzPlugin.INSTANCE;
}


Ralph wrote:
> Hello,
>
> I'm having problems with custumizing the EMF-generated
> MyModelValidator. What I want to do is define custom error messages
> for my own constraints.
> Since I don't want to redefine generic String resources for every
> possible error during validation, it would be great if I could just
> add my own Strings to the existing resource. Unfortunately it's not
> any of the "plugin.properties" files the standard ResourceLocator uses.
>
> There are several examples of how to specialize the Validator class in
> the EMF handbook but none of them shows how to override the
> getResourceLocator() method.
>
> This is how the fresh getResourceLocator method looks like:
>
> /**
> * Returns the resource locator that will be used to fetch messages
> for this validator's diagnostics.
> * <!-- begin-user-doc --> <!-- end-user-doc -->
> * @generated
> */
> @Override
> public ResourceLocator getResourceLocator() {
> // TODO
> // Specialize this to return a resource locator for messages
> specific to this validator.
> // Ensure that you remove @generated or mark it @generated NOT
> return super.getResourceLocator();
> }
>
> Thanks in advance!
> Ralph

--------------090103000806080900060207
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Ralph,<br>
<br>
Generally I'd expect it to refer to the plugin for the model and to add
messages to the plugin.properties<br>
<blockquote><small>  public ResourceLocator getResourceLocator()</small><br>
<small>  {</small><br>
<small>    return XyzPlugin.INSTANCE;</small><br>
<small>  }</small><br>
</blockquote>
<br>
Ralph wrote:
<blockquote cite="mid:i99kqr$26u$1@news.eclipse.org" type="cite">Hello,
<br>
<br>
I'm having problems with custumizing the EMF-generated
MyModelValidator. What I want to do is define custom error messages for
my own constraints. <br>
Since I don't want to redefine generic String resources for every
possible error during validation, it would be great if I could just add
my own Strings to the existing resource. Unfortunately it's not any of
the "plugin.properties" files the standard ResourceLocator uses.
<br>
<br>
There are several examples of how to specialize the Validator class in
the EMF handbook but none of them shows how to override the
getResourceLocator() method.
<br>
<br>
This is how the fresh getResourceLocator method looks like:
<br>
<br>
   /**
<br>
    * Returns the resource locator that will be used to fetch messages
for this validator's diagnostics.
<br>
    * &lt;!-- begin-user-doc --&gt; &lt;!-- end-user-doc --&gt;
<br>
    * @generated
<br>
    */
<br>
   @Override
<br>
   public ResourceLocator getResourceLocator() {
<br>
       // TODO
<br>
       // Specialize this to return a resource locator for messages
specific to this validator.
<br>
       // Ensure that you remove @generated or mark it @generated NOT
<br>
       return super.getResourceLocator();
<br>
   }
<br>
<br>
Thanks in advance!
<br>
Ralph
<br>
</blockquote>
</body>
</html>

--------------090103000806080900060207--
Previous Topic:CDO persistence
Next Topic:Non-changeable containment references
Goto Forum:
  


Current Time: Tue Oct 22 06:43:18 GMT 2019

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

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

Back to the top