Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Name attribute
Name attribute [message #1760342] Wed, 26 April 2017 07:30 Go to next message
Julien Charon is currently offline Julien CharonFriend
Messages: 2
Registered: April 2017
Junior Member
My situation is as follows: in a GMF command, the
org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil.getName(EObject)
method is called to get the name of an EObject defined in my ecore model.
Now, my EObject does't have a name attribute. However, I have another string attribute that I'd like to be used as name.
How can I achieve that? I'd prefer a solution that avoids to change the ecore.
Re: Name attribute [message #1760399 is a reply to message #1760342] Wed, 26 April 2017 16:18 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29128
Registered: July 2009
Senior Member
It's a GMF question. Looking at that code it really only works if there is a feature called "name" in the EClass so to make that work, only changing the Ecore model would work. Failing that, you have to specialize the code that calls this getName method. Perhaps you could define a name attribute, make it transient, volatile, derived, and non-changeable, mark it as have suppressed visibility (i.e., add an annotation exactly like what org.eclipse.emf.ecore.util.EcoreUtil.setSuppressedVisibility(EStructuralFeature, int, boolean) does) so that it's not visible in the generated interface, and then implement the getName method in the Impl class to return your other string attribute's value.
Re: Name attribute [message #1760424 is a reply to message #1760399] Thu, 27 April 2017 05:17 Go to previous messageGo to next message
Julien Charon is currently offline Julien CharonFriend
Messages: 2
Registered: April 2017
Junior Member
Ok, I kind of expected that. Thank you for your help.
Re: Name attribute [message #1760429 is a reply to message #1760424] Thu, 27 April 2017 06:25 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5582
Registered: July 2009
Senior Member
Hi

The GenModel support has a heuristic to find the most 'name'-like EAttribute for use as the ID. You might raise a Bugzilla to encourage GMF to re-use it.

Regards

Ed Willink
Previous Topic:resource change location not updated at saving time
Next Topic:[CDO] Correct usage of CDOView in a multithreaded application
Goto Forum:
  


Current Time: Sat Jan 20 22:46:23 GMT 2018

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

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