Replies: 16 comments
-
|
The simplest (low-level) solution would be to iterate on EcorePackage.eINSTANCE.getClassifiers() (For predefined Ecore EClassifiers, like EString or EInt) and on resourceSet/resources/getAllContents() to find all local EClassifiers in the current model. However, the plug-in org.eclipse.emf.ecore.edit should contain a list of (auto-generated) adapters covering this use case (e.g. org.eclipse.emf.edit.provider.IItemPropertyDescriptor.getChoiceOfValues(Object)) It's not easy to navigate in these classes, let me see if I can find a small example |
Beta Was this translation helpful? Give feedback.
-
|
Here's an example for retrieving the possible super types of an EClass. It works in a similar way for any reference (Including EAttribute#EType). Note that you'll need to add a dependency to org.eclipse.emf.ecore.edit on the server side, as it's currently not included. I've simplified the code for readability, but the Adapter Factory should be created only once, as it's quite expensive |
Beta Was this translation helpful? Give feedback.
-
|
[Leo Knoll] Thank you for the answer! |
Beta Was this translation helpful? Give feedback.
-
|
As Camille pointed out the cleanest solution would be to use the method he provided, the problem is that you would pull in many dependencies as emf.edit is depending on org.eclipse.ui . |
Beta Was this translation helpful? Give feedback.
-
You scared me for a second, so I checked again, and it doesn't :) It only depends on eclipse.core.runtime and eclipse.core.resources, and even these dependencies are optional |
Beta Was this translation helpful? Give feedback.
-
|
Sorry, I mixed it up with the |
Beta Was this translation helpful? Give feedback.
-
|
[Leo Knoll] |
Beta Was this translation helpful? Give feedback.
-
|
[Leo Knoll] Thank you for the tips, I decided to use the simple approach suggested, here is my solution. |
Beta Was this translation helpful? Give feedback.
-
|
Be careful: all lists in EMF are returned by reference. So if you add elements to an existing EList, it will actually modify the underlying model |
Beta Was this translation helpful? Give feedback.
-
|
To aggregate the results of EcorePackage EDataTypes and the EDataTypes from the current resource, you should start by creating a copy of the listOfTypes, and only add elements to this copy |
Beta Was this translation helpful? Give feedback.
-
|
[Leo Knoll] Good point, I made sure to copy it first now! :-) |
Beta Was this translation helpful? Give feedback.
-
|
@leo-knoll I have some question about your code:
|
Beta Was this translation helpful? Give feedback.
-
ResourceManager is a service from the GLSP Ecore Server, which is responsible for loading the model (Initializing the ResourceSet, etc) |
Beta Was this translation helpful? Give feedback.
-
|
[Leo Knoll]
|
Beta Was this translation helpful? Give feedback.
-
I think Eugen meant 'EcorePackage.eINSTANCE.getEClassifiers()', which returns a List of EClassifiers :)
+1 |
Beta Was this translation helpful? Give feedback.
-
|
[Leo Knoll] I see that makes more sense :D |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working on issue #37 and wont to get a list of all possible EAttribute Types from ecore.
After quite some time of looking and googleing I can't find any function which would return me all possible Types.
Anyone knows where to look?
original thread by Leo Knoll
Beta Was this translation helpful? Give feedback.
All reactions