Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » An org.eclipse.emf.validation.examples.ocl example plug-in howto
An org.eclipse.emf.validation.examples.ocl example plug-in howto [message #64066] Mon, 03 November 2008 12:38 Go to next message
Ronan B is currently offline Ronan B
Messages: 229
Registered: July 2009
Senior Member
Hi,
I know a lot of people, including myself, have had a lot of trouble
getting the very nice org.eclipse.emf.validation.examples.ocl example
plugin to work [see
http://wiki.eclipse.org/EMF-QTV_1.1_New_and_Noteworthy#New_V alidation_Constraint_Provider_Example]
with their own model/constraints. To this end I have written a quick howto
for new users. If I have time, and if people are interested, I can convert
this into an Eclipse Corner article. Any errors you find please report
them.

In case you don't know the purpose of the plugin was written to allow OCL
constraints to be defined in a text file. These constraints are then
applied to a model and can be validated using the Eclipse Validation
Framework.

So now the howto....

1. Install Eclipse Modeling Environment from
http://www.eclipse.org/downloads/packages/eclipse-modeling-t ools-includes-incubating-components/ganymeder

2. Create a new empty EMF project
File->New Project->Empty EMF Project
Project name: org.mycompany.product

3. Import an existing EMF model into the new project
Select the "model" folder
Right click and select Import->File System
In this example the model imported is myModel.ecore

4. Create the .genmodel for the EMF model so we can autogenerate the GEF
based model editor
New->Other->EMF Model
Name: Product.genmodel
Select Ecore model importer
Select the myModel.ecore model

5. Open the new Product.genmodel
Select the root object and righ click
Select "Generate All"

This will create a GEF based editor off the myModel.ecore model

6. Bring the OCL example code into your project
File->New->Example->OCL Example
File->New->Example->General Validation Example
File->New->Example->Validation Adapter Example

7. Delete the following projects as we do not want to use the generated
"Library" example settings
org.eclipse.emf.examples.library
org.eclipse.emf.examples.library.edit
org.eclipse.emf.examples.library.editor
src folder from under org.eclipse.emf.validation.examples.ocl
Library.ocl file from constraints folder in
org.eclipse.emf.validation.examples.ocl

8. Place our OCL constraints file in the OCL folder in
org.eclipse.emf.validation.examples.ocl
Select the "constraints" folder
Right click and select Import->File System
In this example the constraints imported are Product_constraints.ocl

9. Open plugin.xml in org.eclipse.emf.validation.examples.ocl
Change the last constraintProvider meta-data to match your models
namespace and OCL file

<constraintProvider
class=" org.eclipse.emf.validation.examples.ocl.OCLConstraintProvide r "
category="Constraints from an OCL Document">
<package
namespaceUri=" http:///org/eclipse/emf/examples/library/extlibrary.ecore/1. 0.0"/>
<ocl path="constraints/Product_constraints.ocl"/>
</constraintProvider>

10. Edit plugin.xml in org.eclipse.emf.validation.examples.ocl and change
the namespaceUri as noted below

*Delete
http:///org/eclipse/emf/examples/library/extlibrary.ecore/1. 0.0
*Insert http://www.mycompany/product

11. Fix dependencies in org.eclipse.emf.validation.examples.general
*Remove the following
org.eclipse.emf.examples.library
org.eclipse.emf.examples.library.edit
org.eclipse.emf.examples.library.editor

*Insert the following
myProduct
myProduct.editor
myProduct.edit
myProduct.tests

12. Edit plugin.properties in org.eclipse.emf.validation.examples.general
*Remove the following
EXTLibraryConstraintsCategory=EXT Library Constraints

NonEmptyNameConstraint=Non-Empty Names
NonEmptyNameConstraint.description=All items in an EXT library model
should have some unique identifier or name.

# 0 - An EClass(metaclass) name for the element that was found to have
no unique identifier.
NonEmptyNameConstraint.message=A {0} has been found to have no unique
identifier (name or title).

*Insert the following
ProductConstraintsCategory=Product Constraints

13. Edit plugin.xml in org.eclipse.emf.validation.examples.general
*Replace the first <extension/> with the following

<extension point="org.eclipse.ui.editorActions">
<editorContribution
id=" org.eclipse.emf.validation.examples.general.editorContributi on "
targetID="product.presentation.ProductEditorID">
<menu
label="%_UI_ValidationMenu_label"
path="Product.ProductMenuID/additions"
id="org.eclipse.emf.validationMenuID">
<separator name="additions"/>
</menu>
<action
label="%ValidateElementsAction.label"
icon="$nl$/icons/elcl16/validate_co.gif"

class=" org.eclipse.emf.validation.examples.general.actions.BatchVal idationDelegate "

menubarPath="ProductMenuID/org.eclipse.emf.validationMenuID/additions "

id=" org.eclipse.emf.validation.pde.example.general.ui.validateAc tion "/>
<action
label="%EnableLiveValidationAction.label"

class=" org.eclipse.emf.validation.examples.general.actions.EnableLi veValidationDelegate "

menubarPath="ProductMenuID/org.eclipse.emf.validationMenuID/additions "

id=" org.eclipse.emf.validation.pde.example.general.ui.enableLive ValidationAction "/>
<action
label="%ShowValidationEventsAction.label"

class=" org.eclipse.emf.validation.examples.general.actions.ShowVali dationEventsDelegate "
style="toggle"
state="false"

menubarPath="ProductMenuID/org.eclipse.emf.validationMenuID/additions "

id=" org.eclipse.emf.validation.pde.example.general.ui.showValida tionEventsAction "/>
</editorContribution>
</extension>
<extension point="org.eclipse.ui.popupMenus">
<viewerContribution targetID="Product.presentation.ProductEditorID"
id=" org.eclipse.emf.validation.examples.general.viewerContributi on ">
<menu
label="%_UI_ValidationMenu_label"
path="additions"
id="org.eclipse.emf.validationMenuID">
<separator name="additions"/>
</menu>
<action
label="%ValidateElementsAction.label"
icon="$nl$/icons/elcl16/validate_co.gif"

class=" org.eclipse.emf.validation.examples.general.actions.BatchVal idationDelegate "
menubarPath="org.eclipse.emf.validationMenuID/additions"

id=" org.eclipse.emf.validation.pde.example.general.ui.validateAc tion "/>
<action
label="%EnableLiveValidationAction.label"

class=" org.eclipse.emf.validation.examples.general.actions.EnableLi veValidationDelegate "
menubarPath="org.eclipse.emf.validationMenuID/additions"

id=" org.eclipse.emf.validation.pde.example.general.ui.enableLive ValidationAction "/>
<action
label="%ShowValidationEventsAction.label"

class=" org.eclipse.emf.validation.examples.general.actions.ShowVali dationEventsDelegate "
style="toggle"
state="false"
menubarPath="org.eclipse.emf.validationMenuID/additions"

id=" org.eclipse.emf.validation.pde.example.general.ui.showValida tionEventsAction "/>
</viewerContribution>
</extension>

14. Edit plugin.xml in org.eclipse.emf.validation.examples.general
*Remove the following second <extension/>

<extension point="org.eclipse.emf.validation.constraintProviders">
<category
name="%ProductConstraintsCategory"
id="org.eclipse.emf.validation.pde.example.general.ui.library "/>
<constraintProvider cache="true">
<package
namespaceUri=" http:///org/eclipse/emf/examples/library/extlibrary.ecore/1. 0.0"/>
<constraints
categories="org.eclipse.emf.validation.pde.example.general.ui.library ">
<constraint lang="Java"
class=" org.eclipse.emf.validation.examples.general.constraints.NonE mptyNamesConstraint "
severity="ERROR"
mode="Live"
name="%NonEmptyNameConstraint"
id=" org.eclipse.emf.validation.pde.example.general.ui.NameNotEmp ty "
statusCode="1">
<description>
%NonEmptyNameConstraint.description
</description>
<message>
%NonEmptyNameConstraint.message
</message>
<target class="Library">
<event name="Set">
<feature name="name"/>
</event>
<event name="Unset">
<feature name="name"/>
</event>
</target>
<target class="Book">
<event name="Set">
<feature name="title"/>
</event>
<event name="Unset">
<feature name="title"/>
</event>
</target>
</constraint>
</constraints>
</constraintProvider>
</extension>

15. Edit the BatchValidationDeligate.java file in
org.eclipse.emf.validation.examples.general.actions
Change the following to reflect your model settings
*Delete import
org.eclipse.emf.examples.extlibrary.presentation.EXTLibraryE ditor;

*Insert import
Product.presentation.ProductEditor;

*Delete
protected EXTLibraryEditor editor = null;

*Insert
protected ProductEditor editor = null;

*Delete
public void setActiveEditor(IAction action, IEditorPart targetEditor) {
this.editor = (EXTLibraryEditor) targetEditor;
if ( targetEditor != null ) {
this.shell = targetEditor.getSite().getShell();
}
}

*Insert
public void setActiveEditor(IAction action, IEditorPart targetEditor) {
this.editor = (ProductEditor) targetEditor;
if ( targetEditor != null ) {
this.shell = targetEditor.getSite().getShell();
}
}

16. Edit the EnableLiveValidation.java file in
org.eclipse.emf.validation.examples.general.actions
Change the following to reflect your model settings
*Delete import
org.eclipse.emf.examples.extlibrary.presentation.EXTLibraryE ditor;

*Insert import
Product.presentation.ProductEditor;

*Delete
protected EXTLibraryEditor editor = null;
*Insert
protected ProductEditor editor = null;

*Delete
public void setActiveEditor(IAction action, IEditorPart targetEditor) {
this.editor = (EXTLibraryEditor) targetEditor;
if ( targetEditor != null ) {
this.shell = targetEditor.getSite().getShell();
}
}

*Insert
public void setActiveEditor(IAction action, IEditorPart targetEditor) {
this.editor = (ProductEditor) targetEditor;
if ( targetEditor != null ) {
this.shell = targetEditor.getSite().getShell();
}
}

17. Edit the NonEmptyNamesConstraint.java file in
org.eclipse.emf.validation.examples.general.constraints
*Delete this file

18. Fix dependencies in org.eclipse.emf.validation.examples.adaptor
*Remove
org.eclipse.emf.examples.library

*Insert
myProduct

19. Edit Startup.java file in org.eclipse.emf.validation.examples.adapter
*Delete
import org.eclipse.emf.examples.extlibrary.EXTLibraryPackage;
*Insert
import Product.ProductPackage;

*Delete
public void earlyStartup() {
EValidator.Registry.INSTANCE.put(
EXTLibraryPackage.eINSTANCE,
new EValidatorAdapter());
}

*Insert

public void earlyStartup() {
EValidator.Registry.INSTANCE.put(
ProductPackage.eINSTANCE,
new EValidatorAdapter());
}

20. Edit plugin.properties file in
org.eclipse.emf.validation.examples.adapter
*Remove
dependency org.eclipse.emf.examples.library

21. Edit plugin.xml file in org.eclipse.emf.validation.examples.adapter
*Delete

<extension point="org.eclipse.emf.validation.constraintBindings">
<clientContext id="org.eclipse.emf.validation.examples.adapter">
<enablement>
<and>
<instanceof value="org.eclipse.emf.ecore.EObject"/>
<test
property="org.eclipse.emf.validation.examples.adapter.ePackage "
value=" http:///org/eclipse/emf/examples/library/extlibrary.ecore/1. 0.0"/>
</and>
</enablement>
</clientContext>

<binding
context="org.eclipse.emf.validation.examples.adapter"
category="emf-validation-example"/>
</extension>

*Insert

<extension point="org.eclipse.emf.validation.constraintBindings">
<clientContext id="org.eclipse.emf.validation.examples.adapter">
<enablement>
<and>
<instanceof value="org.eclipse.emf.ecore.EObject"/>
<test
property="org.eclipse.emf.validation.examples.adapter.ePackage "
value="http://www.mycompany/product"/>
</and>
</enablement>
</clientContext>

<binding
context="org.eclipse.emf.validation.examples.adapter"
category="emf-validation-example"/>
</extension>

*Delete

<constraintProvider cache="true">
<package
namespaceUri=" http:///org/eclipse/emf/examples/library/extlibrary.ecore/1. 0.0"/>

<constraints categories="emf-validation-example/adapter">
<constraint
lang="Java"
severity="INFO"
mode="Batch"
name="%example1.name"
id="example1"
statusCode="201"

class=" org.eclipse.emf.validation.examples.adapter.constraints.Exam pleConstraint ">
<description>%example1.desc</description>
<message>%example1.msg</message>
<!-- This constraint applies to any library element. -->
<target class="Library"/>
<target class="Writer"/>
<target class="Book"/>
</constraint>
</constraints>
</constraintProvider>

*Insert

<constraintProvider cache="true">
<package namespaceUri="http://www.mycompany/product"/>

<constraints categories="emf-validation-example/adapter">
<constraint
lang="Java"
severity="INFO"
mode="Batch"
name="%example1.name"
id="example1"
statusCode="201"

class=" org.eclipse.emf.validation.examples.adapter.constraints.Exam pleConstraint ">
<description>%example1.desc</description>
<message>%example1.msg</message>
<!-- This constraint applies to any library element. -->
<target class="Library"/>
<target class="Writer"/>
<target class="Book"/>
</constraint>
</constraints>
</constraintProvider>

22. Create a new Run Configuration so we can see the GEF editor for our
myModel.ecore
Run->Run->Run as Eclipse Application

This operation will result in a new Eclipse workspace session starting.
This new workspace will have the GEF based editor and OCL example plugins
built into it.

23. In the new workspace do the following.
Create a new empty EMF project
File->New Project->Empty EMF Project
Project name: myProduct

This will create a project to hold our instance model

24. In the new workspace do the following.
File->New->Example EMF Model Creation Wizards
Select Product Model
File name: my.Product

25. Create a model instance using the GEF editor

26. Validate the using the context menu (right click a model
element->Validation->Validate Elements... or simply right click a model
element->Validate)

27. Be impressed :)
Re: An org.eclipse.emf.validation.examples.ocl example plug-in howto [message #64091 is a reply to message #64066] Mon, 03 November 2008 14:33 Go to previous messageGo to next message
Mark Melia is currently offline Mark Melia
Messages: 142
Registered: July 2009
Senior Member
Hi Ronan,

This is great! I think that this is really needed for new users getting to
grips with using OCL in EMF/UML2 projects. I would really like to see this
on the wiki or somewhere.

My $0.02 anyway,
Mark
Re: An org.eclipse.emf.validation.examples.ocl example plug-in howto [message #64161 is a reply to message #64066] Tue, 04 November 2008 09:01 Go to previous messageGo to next message
Eclipse User
Originally posted by: cdamus.zeligsoft.com

Hi, Ronan,

(copying the EMF newsgroup which is home to this component)

I second Mark's comment: this is exactly the kind of contribution that
we are thrilled to see in the EMF Wiki. In fact, I think this would be
the first recipe for the validation component. Feel free to add it by
following the "Recipes" link, here:

http://wiki.eclipse.org/EMF/Validation#Documentation

As you probably know, the Wikipedia technology makes formatting a recipe
like yours a snap.

Thanks!

Christian


Ronan wrote:
> Hi,
> I know a lot of people, including myself, have had a lot of trouble
> getting the very nice org.eclipse.emf.validation.examples.ocl example
> plugin to work [see
> http://wiki.eclipse.org/EMF-QTV_1.1_New_and_Noteworthy#New_V alidation_Constraint_Provider_Example]
> with their own model/constraints. To this end I have written a quick
> howto for new users. If I have time, and if people are interested, I can
> convert this into an Eclipse Corner article. Any errors you find please
> report them.
>
> In case you don't know the purpose of the plugin was written to allow
> OCL constraints to be defined in a text file. These constraints are then
> applied to a model and can be validated using the Eclipse Validation
> Framework.
>
> So now the howto....
>
> 1. Install Eclipse Modeling Environment from
> http://www.eclipse.org/downloads/packages/eclipse-modeling-t ools-includes-incubating-components/ganymeder

>
>
> 2. Create a new empty EMF project
> File->New Project->Empty EMF Project
> Project name: org.mycompany.product
>
> 3. Import an existing EMF model into the new project
> Select the "model" folder
> Right click and select Import->File System
> In this example the model imported is myModel.ecore
>
> 4. Create the .genmodel for the EMF model so we can autogenerate the GEF
> based model editor
> New->Other->EMF Model
> Name: Product.genmodel
> Select Ecore model importer
> Select the myModel.ecore model
>
> 5. Open the new Product.genmodel
> Select the root object and righ click
> Select "Generate All"
>
> This will create a GEF based editor off the myModel.ecore model
>
> 6. Bring the OCL example code into your project
> File->New->Example->OCL Example
> File->New->Example->General Validation Example
> File->New->Example->Validation Adapter Example
>
> 7. Delete the following projects as we do not want to use the generated
> "Library" example settings
> org.eclipse.emf.examples.library
> org.eclipse.emf.examples.library.edit
> org.eclipse.emf.examples.library.editor
> src folder from under org.eclipse.emf.validation.examples.ocl
> Library.ocl file from constraints folder in
> org.eclipse.emf.validation.examples.ocl
>
> 8. Place our OCL constraints file in the OCL folder in
> org.eclipse.emf.validation.examples.ocl
> Select the "constraints" folder
> Right click and select Import->File System
> In this example the constraints imported are Product_constraints.ocl
>
> 9. Open plugin.xml in org.eclipse.emf.validation.examples.ocl
> Change the last constraintProvider meta-data to match your models
> namespace and OCL file
>
> <constraintProvider
> class=" org.eclipse.emf.validation.examples.ocl.OCLConstraintProvide r "
> category="Constraints from an OCL Document">
> <package
> namespaceUri=" http:///org/eclipse/emf/examples/library/extlibrary.ecore/1. 0.0"/>
>
> <ocl path="constraints/Product_constraints.ocl"/>
> </constraintProvider>
>
> 10. Edit plugin.xml in org.eclipse.emf.validation.examples.ocl and
> change the namespaceUri as noted below
>
> *Delete
> http:///org/eclipse/emf/examples/library/extlibrary.ecore/1. 0.0
> *Insert http://www.mycompany/product
>
> 11. Fix dependencies in org.eclipse.emf.validation.examples.general
> *Remove the following
> org.eclipse.emf.examples.library
> org.eclipse.emf.examples.library.edit
> org.eclipse.emf.examples.library.editor
>
> *Insert the following
> myProduct
> myProduct.editor
> myProduct.edit
> myProduct.tests
>
> 12. Edit plugin.properties in org.eclipse.emf.validation.examples.general
> *Remove the following
> EXTLibraryConstraintsCategory=EXT Library Constraints
>
> NonEmptyNameConstraint=Non-Empty Names
> NonEmptyNameConstraint.description=All items in an EXT library model
> should have some unique identifier or name.
>
> # 0 - An EClass(metaclass) name for the element that was found to have
> no unique identifier.
> NonEmptyNameConstraint.message=A {0} has been found to have no unique
> identifier (name or title).
>
> *Insert the following
> ProductConstraintsCategory=Product Constraints
>
> 13. Edit plugin.xml in org.eclipse.emf.validation.examples.general
> *Replace the first <extension/> with the following
>
> <extension point="org.eclipse.ui.editorActions">
> <editorContribution
> id=" org.eclipse.emf.validation.examples.general.editorContributi on "
> targetID="product.presentation.ProductEditorID">
> <menu
> label="%_UI_ValidationMenu_label"
> path="Product.ProductMenuID/additions"
> id="org.eclipse.emf.validationMenuID">
> <separator name="additions"/>
> </menu>
> <action
> label="%ValidateElementsAction.label"
> icon="$nl$/icons/elcl16/validate_co.gif"
>
> class=" org.eclipse.emf.validation.examples.general.actions.BatchVal idationDelegate "
>
>
> menubarPath="ProductMenuID/org.eclipse.emf.validationMenuID/additions "
>
> id=" org.eclipse.emf.validation.pde.example.general.ui.validateAc tion "/>
> <action
> label="%EnableLiveValidationAction.label"
>
> class=" org.eclipse.emf.validation.examples.general.actions.EnableLi veValidationDelegate "
>
>
> menubarPath="ProductMenuID/org.eclipse.emf.validationMenuID/additions "
>
> id=" org.eclipse.emf.validation.pde.example.general.ui.enableLive ValidationAction "/>
>
> <action
> label="%ShowValidationEventsAction.label"
>
> class=" org.eclipse.emf.validation.examples.general.actions.ShowVali dationEventsDelegate "
>
> style="toggle"
> state="false"
>
> menubarPath="ProductMenuID/org.eclipse.emf.validationMenuID/additions "
>
> id=" org.eclipse.emf.validation.pde.example.general.ui.showValida tionEventsAction "/>
>
> </editorContribution>
> </extension>
> <extension point="org.eclipse.ui.popupMenus">
> <viewerContribution targetID="Product.presentation.ProductEditorID"
> id=" org.eclipse.emf.validation.examples.general.viewerContributi on ">
> <menu
> label="%_UI_ValidationMenu_label"
> path="additions"
> id="org.eclipse.emf.validationMenuID">
> <separator name="additions"/>
> </menu>
> <action
> label="%ValidateElementsAction.label"
> icon="$nl$/icons/elcl16/validate_co.gif"
> class=" org.eclipse.emf.validation.examples.general.actions.BatchVal idationDelegate "
>
> menubarPath="org.eclipse.emf.validationMenuID/additions"
>
> id=" org.eclipse.emf.validation.pde.example.general.ui.validateAc tion "/>
> <action
> label="%EnableLiveValidationAction.label"
> class=" org.eclipse.emf.validation.examples.general.actions.EnableLi veValidationDelegate "
>
> menubarPath="org.eclipse.emf.validationMenuID/additions"
>
> id=" org.eclipse.emf.validation.pde.example.general.ui.enableLive ValidationAction "/>
>
> <action
> label="%ShowValidationEventsAction.label"
>
> class=" org.eclipse.emf.validation.examples.general.actions.ShowVali dationEventsDelegate "
>
> style="toggle"
> state="false"
> menubarPath="org.eclipse.emf.validationMenuID/additions"
>
> id=" org.eclipse.emf.validation.pde.example.general.ui.showValida tionEventsAction "/>
>
> </viewerContribution>
> </extension>
>
> 14. Edit plugin.xml in org.eclipse.emf.validation.examples.general
> *Remove the following second <extension/>
>
> <extension point="org.eclipse.emf.validation.constraintProviders">
> <category
> name="%ProductConstraintsCategory"
> id="org.eclipse.emf.validation.pde.example.general.ui.library "/>
> <constraintProvider cache="true">
> <package
> namespaceUri=" http:///org/eclipse/emf/examples/library/extlibrary.ecore/1. 0.0"/>
>
> <constraints
> categories="org.eclipse.emf.validation.pde.example.general.ui.library ">
> <constraint lang="Java"
> class=" org.eclipse.emf.validation.examples.general.constraints.NonE mptyNamesConstraint "
>
> severity="ERROR"
> mode="Live"
> name="%NonEmptyNameConstraint"
> id=" org.eclipse.emf.validation.pde.example.general.ui.NameNotEmp ty "
> statusCode="1">
> <description>
> %NonEmptyNameConstraint.description
> </description>
> <message>
> %NonEmptyNameConstraint.message
> </message>
> <target class="Library">
> <event name="Set">
> <feature name="name"/>
> </event>
> <event name="Unset">
> <feature name="name"/>
> </event>
> </target>
> <target class="Book">
> <event name="Set">
> <feature name="title"/>
> </event>
> <event name="Unset">
> <feature name="title"/>
> </event>
> </target>
> </constraint>
> </constraints>
> </constraintProvider>
> </extension>
>
> 15. Edit the BatchValidationDeligate.java file in
> org.eclipse.emf.validation.examples.general.actions
> Change the following to reflect your model settings
> *Delete import
> org.eclipse.emf.examples.extlibrary.presentation.EXTLibraryE ditor;
>
> *Insert import Product.presentation.ProductEditor;
>
> *Delete protected EXTLibraryEditor editor = null;
>
> *Insert protected ProductEditor editor = null;
>
> *Delete
> public void setActiveEditor(IAction action, IEditorPart targetEditor) {
> this.editor = (EXTLibraryEditor) targetEditor;
> if ( targetEditor != null ) {
> this.shell = targetEditor.getSite().getShell();
> }
> }
>
> *Insert
> public void setActiveEditor(IAction action, IEditorPart targetEditor) {
> this.editor = (ProductEditor) targetEditor;
> if ( targetEditor != null ) {
> this.shell = targetEditor.getSite().getShell();
> }
> }
>
> 16. Edit the EnableLiveValidation.java file in
> org.eclipse.emf.validation.examples.general.actions
> Change the following to reflect your model settings
> *Delete import
> org.eclipse.emf.examples.extlibrary.presentation.EXTLibraryE ditor;
>
> *Insert import Product.presentation.ProductEditor;
>
> *Delete protected EXTLibraryEditor editor = null;
> *Insert protected ProductEditor editor = null;
>
> *Delete
> public void setActiveEditor(IAction action, IEditorPart targetEditor) {
> this.editor = (EXTLibraryEditor) targetEditor;
> if ( targetEditor != null ) {
> this.shell = targetEditor.getSite().getShell();
> }
> }
>
> *Insert
> public void setActiveEditor(IAction action, IEditorPart targetEditor) {
> this.editor = (ProductEditor) targetEditor;
> if ( targetEditor != null ) {
> this.shell = targetEditor.getSite().getShell();
> }
> }
>
> 17. Edit the NonEmptyNamesConstraint.java file in
> org.eclipse.emf.validation.examples.general.constraints
> *Delete this file
>
> 18. Fix dependencies in org.eclipse.emf.validation.examples.adaptor
> *Remove
> org.eclipse.emf.examples.library
>
> *Insert
> myProduct
>
> 19. Edit Startup.java file in org.eclipse.emf.validation.examples.adapter
> *Delete import
> org.eclipse.emf.examples.extlibrary.EXTLibraryPackage;
> *Insert import Product.ProductPackage;
>
> *Delete
> public void earlyStartup() {
> EValidator.Registry.INSTANCE.put(
> EXTLibraryPackage.eINSTANCE,
> new EValidatorAdapter());
> }
>
> *Insert
>
> public void earlyStartup() {
> EValidator.Registry.INSTANCE.put(
> ProductPackage.eINSTANCE,
> new EValidatorAdapter());
> }
>
> 20. Edit plugin.properties file in
> org.eclipse.emf.validation.examples.adapter
> *Remove dependency org.eclipse.emf.examples.library
>
> 21. Edit plugin.xml file in org.eclipse.emf.validation.examples.adapter
> *Delete
>
> <extension point="org.eclipse.emf.validation.constraintBindings">
> <clientContext id="org.eclipse.emf.validation.examples.adapter">
> <enablement>
> <and>
> <instanceof value="org.eclipse.emf.ecore.EObject"/>
> <test
> property="org.eclipse.emf.validation.examples.adapter.ePackage "
> value=" http:///org/eclipse/emf/examples/library/extlibrary.ecore/1. 0.0"/>
> </and>
> </enablement>
> </clientContext>
>
> <binding
> context="org.eclipse.emf.validation.examples.adapter"
> category="emf-validation-example"/>
> </extension>
>
> *Insert
>
> <extension point="org.eclipse.emf.validation.constraintBindings">
> <clientContext id="org.eclipse.emf.validation.examples.adapter">
> <enablement>
> <and>
> <instanceof value="org.eclipse.emf.ecore.EObject"/>
> <test
> property="org.eclipse.emf.validation.examples.adapter.ePackage "
> value="http://www.mycompany/product"/>
> </and>
> </enablement>
> </clientContext>
>
> <binding
> context="org.eclipse.emf.validation.examples.adapter"
> category="emf-validation-example"/>
> </extension>
>
> *Delete
>
> <constraintProvider cache="true">
> <package
> namespaceUri=" http:///org/eclipse/emf/examples/library/extlibrary.ecore/1. 0.0"/>
>
>
> <constraints categories="emf-validation-example/adapter">
> <constraint
> lang="Java"
> severity="INFO"
> mode="Batch"
> name="%example1.name"
> id="example1"
> statusCode="201"
>
> class=" org.eclipse.emf.validation.examples.adapter.constraints.Exam pleConstraint ">
>
> <description>%example1.desc</description>
> <message>%example1.msg</message>
> <!-- This constraint applies to any library element. -->
> <target class="Library"/>
> <target class="Writer"/>
> <target class="Book"/>
> </constraint>
> </constraints>
> </constraintProvider>
>
> *Insert
>
> <constraintProvider cache="true">
> <package namespaceUri="http://www.mycompany/product"/>
>
> <constraints categories="emf-validation-example/adapter">
> <constraint
> lang="Java"
> severity="INFO"
> mode="Batch"
> name="%example1.name"
> id="example1"
> statusCode="201"
>
> class=" org.eclipse.emf.validation.examples.adapter.constraints.Exam pleConstraint ">
>
> <description>%example1.desc</description>
> <message>%example1.msg</message>
> <!-- This constraint applies to any library element. -->
> <target class="Library"/>
> <target class="Writer"/>
> <target class="Book"/>
> </constraint>
> </constraints>
> </constraintProvider>
>
> 22. Create a new Run Configuration so we can see the GEF editor for our
> myModel.ecore
> Run->Run->Run as Eclipse Application
>
> This operation will result in a new Eclipse workspace session starting.
> This new workspace will have the GEF based editor and OCL example
> plugins built into it.
>
> 23. In the new workspace do the following.
> Create a new empty EMF project
> File->New Project->Empty EMF Project
> Project name: myProduct
>
> This will create a project to hold our instance model
>
> 24. In the new workspace do the following.
> File->New->Example EMF Model Creation Wizards
> Select Product Model
> File name: my.Product
>
> 25. Create a model instance using the GEF editor
>
> 26. Validate the using the context menu (right click a model
> element->Validation->Validate Elements... or simply right click a model
> element->Validate)
> 27. Be impressed :)
>
Re: An org.eclipse.emf.validation.examples.ocl example plug-in howto [message #64385 is a reply to message #64161] Wed, 05 November 2008 12:36 Go to previous messageGo to next message
Ronan B is currently offline Ronan B
Messages: 229
Registered: July 2009
Senior Member
Hi,
Thanks for that guys. Putting up the recipe is on my todo list for next
week!
Regards,
Ronan
Re: An org.eclipse.emf.validation.examples.ocl example plug-in howto [message #64864 is a reply to message #64385] Tue, 02 December 2008 11:28 Go to previous messageGo to next message
Ronan B is currently offline Ronan B
Messages: 229
Registered: July 2009
Senior Member
Hi all,
I have put up the recipe in the EMF Validation Framework documentation.
See
http://wiki.eclipse.org/EMF/Validation/Recipes#Recipe:_HowTo _use_the_Eclipse_Validation_Framework_with_OCL_constraints_d efined_in_a_separate_file
Ronan
Re: An org.eclipse.emf.validation.examples.ocl example plug-in howto [message #64927 is a reply to message #64864] Wed, 03 December 2008 16:36 Go to previous messageGo to next message
Eclipse User
Originally posted by: cdamus.zeligsoft.com

Thanks, Ronan, for the contribution!

I hope you don't mind, but I took a moment to tweak the formatting a bit
for some text that ran together in and to fix a few typos.

cW


Ronan wrote:
> Hi all,
> I have put up the recipe in the EMF Validation Framework documentation.
> See
> http://wiki.eclipse.org/EMF/Validation/Recipes#Recipe:_HowTo _use_the_Eclipse_Validation_Framework_with_OCL_constraints_d efined_in_a_separate_file
>
> Ronan
>
Re: An org.eclipse.emf.validation.examples.ocl example plug-in howto [message #71486 is a reply to message #64864] Thu, 25 June 2009 08:45 Go to previous message
Eclipse User
Originally posted by: user.domain.invalid

Hi,

I would like to thank you for this Recipe.
I tried it and i have few questions because I did not manage to make it
works. Maybe because I made some confusions.

I followed all the steps but none of the constraints described in my ocl
files are found. Do I need to do something else than fill the constraint
file and following all the indications of the recipe ? ?

And to be sure about a basic thing : When all the steps are done (my emf
project + 3 projects about validation are on the Package Explorer), from
which projet should I launch the program ?

I tried to import the OCL Exemple with the Library Model add other
constraints, and did not succeed. I thing i don't get an important point.


Thank you.

Florine

Ronan wrote:
> Hi all,
> I have put up the recipe in the EMF Validation Framework documentation.
> See
> http://wiki.eclipse.org/EMF/Validation/Recipes#Recipe:_HowTo _use_the_Eclipse_Validation_Framework_with_OCL_constraints_d efined_in_a_separate_file
>
> Ronan
>
Previous Topic:[Announce] MDT OCL 1.3.0 is available
Next Topic:Future MDT-OCL directions
Goto Forum:
  


Current Time: Wed Jul 30 09:20:03 EDT 2014

Powered by FUDForum. Page generated in 0.24826 seconds