|
|
|
|
|
|
Re: Validating an EMF model programatically [message #622939 is a reply to message #622938] |
Wed, 26 May 2010 15:26 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Hector,
Not all the frameworks support running stand alone. I think you'll need
to run this as an Eclipse application.
Hector Chavez wrote:
> Thanks Jonas,
> I tried the that approach but it did not work in my example, I get an
> exception, this is the code I'm using:
>
>
>
> University univ = UniversityFactory.eINSTANCE.createUniversity();
>
> ValidationDelegateClientSelector.running = true;
>
> IBatchValidator validator = (IBatchValidator)
> ModelValidationService.getInstance().newValidator(Evaluation Mode.BATCH);
> validator.setIncludeLiveConstraints(true);
>
> IStatus status = validator.validate(univ);
>
> ValidationDelegateClientSelector.running = false;
>
>
>
> And the exception:
>
> Exception in thread "main" java.lang.ExceptionInInitializerError
> at emf.examples.university.validation.adapter.EValidatorAdapter .
> <init>(EValidatorAdapter.java:57)
> at university.tests.Main.main(Main.java:23)
> Caused by: java.lang.NullPointerException
> at org.eclipse.emf.validation.internal.EMFModelValidationPlugin
> .getPluginId(EMFModelValidationPlugin.java:201)
> at org.eclipse.emf.validation.service.ModelValidationService.co
> nfigureConstraints(ModelValidationService.java:144)
> at org.eclipse.emf.validation.service.ModelValidationService.<init
> >(ModelValidationService.java:134)
> at
> org.eclipse.emf.validation.service.ModelValidationService.<clinit
> >(ModelValidationService.java:83)
> ... 2 more
>
> Jonas wrote on Wed, 26 May 2010 03:16
>> Hi,
>> it should work like this:
>>
>> YourValidationClientSelector.setRunning(true);
>> IBatchValidator validator = (IBatchValidator)
>> ModelValidationService.getInstance().newValidator(Evaluation
>> Mode.BATCH);
>> validator.setIncludeLiveConstraints(true);
>> IStatus status = validator.validate(object);
>> ValidationClientSelector.setRunning(false);
>>
>> Furthermore I would look into the existing handler of the editor...
>> Cheers
>> Jonas
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.04321 seconds