Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » emf validation question(How to add more validation?)
emf validation question [message #509239] Thu, 21 January 2010 18:30 Go to next message
John Ye is currently offline John YeFriend
Messages: 20
Registered: July 2009
Junior Member
I have an emf model and editor generated from a wsdl file. I don't see validator code generated except interfaces with comments like:

"This doesn't really do anything, and it's not a real EMF artifact."

The default ValidateAction already does some work. It seems to be using EObjectValidator. I would like to add more validation such as uniqueness of keys.

Should I create a new EValidator and register it or use org.eclipse.emf.validation.constraintProviders extension?

A related question is cell editor validation, for example, I want to prevent duplicate keys from being entered. I am using PropertyEditingSupport. Should I override its getCellEditor method to set my own ICellEditorValidator or there is better way to do it?

Thanks a lot!
John

Re: emf validation question [message #509398 is a reply to message #509239] Fri, 22 January 2010 11:23 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30620
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040406030604080506050102
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

John,

Comments below.

John Ye wrote:
> I have an emf model and editor generated from a wsdl file. I don't see
> validator code generated except interfaces with comments like:
> "This doesn't really do anything, and it's not a real EMF artifact."
I'm not sure what you're referring to here.
>
> The default ValidateAction already does some work. It seems to be
> using EObjectValidator. I would like to add more validation such as
> uniqueness of keys.
If using IDs or EReference.eKeys aren't sufficient you can define your
own constraints in the model and then implement them in the generated
validator:
< http://help.eclipse.org/galil/index.jsp?topic=/org.eclipse.e mf.doc/references/overview/EMF.Validation.html>


http://help.eclipse.org/galil/index.jsp?topic=/org.eclipse.e mf.doc/references/overview/EMF.Validation.html

>
> Should I create a new EValidator and register it or use
> org.eclipse.emf.validation.constraintProviders extension?
It's possible to use the extended validation framework as well; it's not
clear you need that though.
>
> A related question is cell editor validation, for example, I want to
> prevent duplicate keys from being entered. I am using
> PropertyEditingSupport. Should I override its getCellEditor method to
> set my own ICellEditorValidator or there is better way to do it?
There isn't support within the property descriptors to do this type of
validation, so I suppose you'd need a specialized cell editor for that.
> Thanks a lot!
> John
>
>

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

<!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">
John,<br>
<br>
Comments below.<br>
<br>
John Ye wrote:
<blockquote cite="mid:hja6fb$fvk$1@build.eclipse.org" type="cite">I
have an emf model and editor generated from a wsdl file. I don't see
validator code generated except interfaces with comments like: <br>
"This doesn't really do anything, and it's not a real EMF artifact."
<br>
</blockquote>
I'm not sure what you're referring to here.<br>
<blockquote cite="mid:hja6fb$fvk$1@build.eclipse.org" type="cite"><br>
The default ValidateAction already does some work. It seems to be using
EObjectValidator. I would like to add more validation such as
uniqueness of keys.
<br>
</blockquote>
If using IDs or EReference.eKeys aren't sufficient you can define your
own constraints in the model and then implement them in the generated
validator:<a
href=" http://help.eclipse.org/galil/index.jsp?topic=/org.eclipse.e mf.doc/references/overview/EMF.Validation.html"><br>
</a>
<blockquote><a
href=" http://help.eclipse.org/galil/index.jsp?topic=/org.eclipse.e mf.doc/references/overview/EMF.Validation.html"> http://help.eclipse.org/galil/index.jsp?topic=/org.eclipse.e mf.doc/references/overview/EMF.Validation.html</a><br>
</blockquote>
<blockquote cite="mid:hja6fb$fvk$1@build.eclipse.org" type="cite"><br>
Should I create a new EValidator and register it or use
org.eclipse.emf.validation.constraintProviders extension?
<br>
</blockquote>
It's possible to use the extended validation framework as well; it's
not clear you need that though.<br>
<blockquote cite="mid:hja6fb$fvk$1@build.eclipse.org" type="cite"><br>
A related question is cell editor validation, for example, I want to
prevent duplicate keys from being entered. I am using
PropertyEditingSupport. Should I override its getCellEditor method to
set my own ICellEditorValidator or there is better way to do it? <br>
</blockquote>
There isn't support within the property descriptors to do this type of
validation, so I suppose you'd need a specialized cell editor for that.<br>
<blockquote cite="mid:hja6fb$fvk$1@build.eclipse.org" type="cite">Thanks
a lot!
<br>
John
<br>
<br>
<br>
</blockquote>
</body>
</html>

--------------040406030604080506050102--
Re: emf validation question [message #509555 is a reply to message #509398] Fri, 22 January 2010 21:36 Go to previous messageGo to next message
John Ye is currently offline John YeFriend
Messages: 20
Registered: July 2009
Junior Member

Ed,

Thanks for the tips. My ecore model is generated from wsdl, which itself is also generated and the original source doesn't support key and references.

Now I use setID on key attributes and validateAction is able to catch duplicate keys. I don't think composite keys are supported.

I ran into a new problem with implementing IGotoMarker. It seems that the default EValidator.MARKER only provides URI_ATTRIBUTE. How do I look up an EObject based on that information? I tried resource.getEObject, but it did not work.

Thanks,
John

Re: emf validation question [message #509577 is a reply to message #509555] Sat, 23 January 2010 04:13 Go to previous message
John Ye is currently offline John YeFriend
Messages: 20
Registered: July 2009
Junior Member

EditUIMarkerHelper's getTargetObjects(editingDomain, marker) seems to do the trick of finding the right objects. This saves me a lot of time.

Thanks,
John



Previous Topic:Root class for models?
Next Topic:Get rid of Example EMF Model Creation Wizards
Goto Forum:
  


Current Time: Mon Nov 11 19:57:47 GMT 2019

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

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

Back to the top