Name attribute [message #1760342] |
Wed, 26 April 2017 03:30  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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 #1760429 is a reply to message #1760424] |
Thu, 27 April 2017 02:25  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.07634 seconds