Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » custom createItemPropertyDescriptor
custom createItemPropertyDescriptor [message #1815615] Mon, 07 October 2019 09:09 Go to next message
Michael C is currently offline Michael CFriend
Messages: 35
Registered: April 2019
Member
Hello, I managed to restrict the list of eObjects in the provider of the property descriptor. I followed this tutorial : http://gmfsamples.tuxfamily.org/wiki/doku.php?id=emf_tutorial3

I have to restrict the list for most references of my eObjects based on one of their eContainer. I'm not sure that modifying all the generated mehods is the most efficient way since I have lots of them and if I change something on the metamodel there is a chance that it will break everything because of the Generated Not.

Is there a way to override getChoiceOfValues for all my properties decriptor at once. I would need to pass the object and the reference that is modified to get the right content.

Re: custom createItemPropertyDescriptor [message #1815638 is a reply to message #1815615] Mon, 07 October 2019 15:41 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30692
Registered: July 2009
Senior Member
One approach would be to use the GenModel property Edit -> Provide Root Extends Class to specify the fully qualified name of some hand-written extension of ItemProviderAdapter. Then all you generated item providers will extends this class and you could override org.eclipse.emf.edit.provider.ItemProviderAdapter.createItemPropertyDescriptor(AdapterFactory, ResourceLocator, String, String, EStructuralFeature, boolean, boolean, boolean, Object, String, String[], Object) in this one class. You might add your own EAnnotations to your EStructuralFeatures which you could use to implement different behaviors in your specialized "central" property descriptor.
Re: custom createItemPropertyDescriptor [message #1815724 is a reply to message #1815638] Wed, 09 October 2019 06:48 Go to previous messageGo to next message
Michael C is currently offline Michael CFriend
Messages: 35
Registered: April 2019
Member
Hello,

Thanks to your clear answer, I managed to implement an extension of ItemProviderAdapter.

I never used EAnnotations before.
To be sure your idea is to create an EAnnotations for each references and then get the annotation in the code of the extension to chooce the eObjects to return, right ?

I have lots of references so I went with a different solution:
For each eClass of all ePackage, I look for the correct ones with feature.getEReferenceType.isSuperTypeOf(). Then I get the correct eObject containeur (that mostly depends on the ePackage), do eAllContent on this containeur and filter again to get the correct type of eObjects. That's probably not the most efficient way but I was afraid to miss some references otherwise.

Regards,
Re: custom createItemPropertyDescriptor [message #1815741 is a reply to message #1815724] Wed, 09 October 2019 15:07 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30692
Registered: July 2009
Senior Member
The EAnnotation idea was just if you want to somehow selectively control various behaviors on a per-feature basis. The underlying implementation of org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getComboBoxObjects(Object) also does rather brute force visiting of all objects in the resource set to find ones of the correct type. You might just call super and filter to those in in your special "containers". But whatever works, if it performs reasonably, is just fine of course.
Previous Topic:change recorder error eliminateEmptyChanges()
Next Topic:XSD -> ecore -> Xtext: How to deal with anyType in Xtext Grammar?
Goto Forum:
  


Current Time: Sat Dec 14 15:45:08 GMT 2019

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

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

Back to the top