Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » How to generate ID for model element in GMF Editor generated by Eugenia  () 1 Vote
How to generate ID for model element in GMF Editor generated by Eugenia [message #1702638] Thu, 23 July 2015 16:40 Go to next message
Dung Le is currently offline Dung LeFriend
Messages: 6
Registered: July 2015
Junior Member
Hi,

I'm new to Epsilon, I have just created an GMF diagram editor using Eugenia (following the screencast). But after I draw and save the file, there is no id for the element in my new model.

I also modified the .gmfgen file: change the "Model ID" in the Gen Editor Generator to Ecore, but it still did not work.

How should I generate ID for the elements in my model in this case?

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 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

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/
Re: How to generate ID for model element in GMF Editor generated by Eugenia [message #1702739 is a reply to message #1702716] Fri, 24 July 2015 12:10 Go to previous messageGo to next message
Dung Le is currently offline Dung LeFriend
Messages: 6
Registered: July 2015
Junior Member
Thanks for your answer Antonio Garcia-Dominguez.

Quote:
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.


I have ID field defined in my .ecore file but still there is no ID in the generated model elements.

Quote:
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.


Do you mean that I need to rewrite my own ModelImpl classes instead of using the generated file from Eugenia? Currently these file extends EObjectImpl?

Re: How to generate ID for model element in GMF Editor generated by Eugenia [message #1702745 is a reply to message #1702739] Fri, 24 July 2015 12:33 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

You only need to modify the subclass of XMIResourceImpl that EMF has generated for you. There should be one in the .util subpackage.
Re: How to generate ID for model element in GMF Editor generated by Eugenia [message #1702899 is a reply to message #1702745] Mon, 27 July 2015 10:00 Go to previous messageGo to next message
Dung Le is currently offline Dung LeFriend
Messages: 6
Registered: July 2015
Junior Member
Eugenia generated some ModelImpl classes and they all extend EObjectImpl. There are only AdapterFactory and Switch classes under .util subpackage.

I have just modified the constructors to generate ID for each object.
Re: How to generate ID for model element in GMF Editor generated by Eugenia [message #1703479 is a reply to message #1702899] Fri, 31 July 2015 23:50 Go to previous messageGo to next message
Nikos Margaritis is currently offline Nikos MargaritisFriend
Messages: 65
Registered: September 2014
Member

You could also take a look here
Re: How to generate ID for model element in GMF Editor generated by Eugenia [message #1703690 is a reply to message #1703479] Tue, 04 August 2015 09:53 Go to previous message
Dung Le is currently offline Dung LeFriend
Messages: 6
Registered: July 2015
Junior Member
Thanks Nikos, I used EcoreUtil.generateUUID() in the constructor.

[Updated on: Tue, 04 August 2015 13:53]

Report message to a moderator

Previous Topic:Problem with XSDEcoreBuilder
Next Topic:Some Questions about epsilon and EVL
Goto Forum:
  


Current Time: Fri Apr 26 19:27:22 GMT 2024

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

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

Back to the top