|
Re: How to generate ID for model element in GMF Editor generated by Eugenia [message #1702716 is a reply to message #1702638] |
Fri, 24 July 2015 09:33 |
|
When you refer to "ID"s, are you referring to the xmi:id attributes that appear in the files for some modeling tools? To produce those, you need to use a subclass of XMLResourceImpl that overrides useUUIDs() to return true. Both XMLResourceImpl and XMIResourceImpl return false for that method. Ed Merks explains this in this EMF thread:
https://www.eclipse.org/forums/index.php/t/129116/
One option for having unique identifiers is to mark in your .ecore the fields with unique values from your own classes with ID=true: EMF will use these instead of automatically generated UUIDs. This could be done with a polishing transformation on the .ecore file:
https://www.eclipse.org/epsilon/doc/articles/eugenia-polishing/
If you really, really need those automatically generated xmi:id attributes, you could simply add something like this to the "*ResourceImpl" generated by EMF (it should be on the .util package), which should be a subclass of XMIResourceImpl:
/**
* @generated NOT
*/
@Override
protected boolean useUUIDs() {
return true;
}
I think the .genmodel does not have any option for automatically producing this bit, but I may be wrong. Nevertheless, if you'd like to keep this refinement explicit, you could leave out the "NOT" in the @generated bit and use Eugenia's support for custom patches:
https://www.eclipse.org/epsilon/doc/articles/eugenia-patching/
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04186 seconds