Skip to main content



      Home
Home » Modeling » EMF » Name attribute
Name attribute [message #1760342] Wed, 26 April 2017 03:30 Go to next message
Eclipse UserFriend
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 12:18 Go to previous messageGo to next message
Eclipse UserFriend
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 01:17 Go to previous messageGo to next message
Eclipse UserFriend
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 02:25 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 13:39:00 EDT 2025

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

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

Back to the top