|
|
Re: How can I enumerate all of the generated classes? [message #901491 is a reply to message #901489] |
Mon, 13 August 2012 07:03 |
Michael Spertus Messages: 78 Registered: July 2009 |
Member |
|
|
Ed Merks wrote on Mon, 13 August 2012 02:08Mike,
If you know the model, then XyzPackage.eINSTANCE.getEClassifiers()
returns all the classifiers of the model and from that you can filter to
give just the EClasses.
Thanks for the response Ed. Actually, I don't know the model, but you still gave me just what I need because
public static Collection<EClassifier> enumerateModeledClassifiers() {
Collection<EClassifier> classifiers = new ArrayList<EClassifier>();
try {
IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.emf.ecore.generated_package");
for(IConfigurationElement e : config) {
String uri=e.getAttribute("uri")
classifiers.addAll(EPackage.Registry.INSTANCE.getEPackage(e.getAttribute("uri")).getEClassifiers());
}
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
return classifiers;
}
and filtering does the trick.
Thanks again,
Mike
Quote:
On 13/08/2012 7:15 AM, Michael Spertus wrote:
> In my RCP program, I'd like to enumerate all of its modeled classes'
> Class objects. Is there a reasonable way to do this?
>
> Thanks,
>
> Mike
|
|
|
Re: How can I enumerate all of the generated classes? [message #901507 is a reply to message #901491] |
Mon, 13 August 2012 08:03 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Michael,
You can iterate directly over the EPackage.Registry.INSTANCE's contents
given they're populated by consulting the configuration elements already.
On 13/08/2012 9:03 AM, Michael Spertus wrote:
> Ed Merks wrote on Mon, 13 August 2012 02:08
>> Mike,
>>
>> If you know the model, then XyzPackage.eINSTANCE.getEClassifiers()
>> returns all the classifiers of the model and from that you can filter
>> to give just the EClasses.
>
> Thanks for the response Ed. Actually, I don't know the model, but you
> still gave me just what I need because
> public static Collection<EClassifier> enumerateModeledClassifiers() {
> Collection<EClassifier> classifiers = new ArrayList<EClassifier>();
> try {
> IConfigurationElement[] config =
> Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.emf.ecore.generated_package");
> for(IConfigurationElement e : config) {
> String uri=e.getAttribute("uri")
> classifiers.addAll(EPackage.Registry.INSTANCE.getEPackage(e.getAttribute("uri")).getEClassifiers());
> }
> } catch (Exception ex) {
> System.out.println(ex.getMessage());
> }
> return classifiers;
> }
>
> and filtering does the trick.
>
> Thanks again,
>
> Mike
> Quote:
>> On 13/08/2012 7:15 AM, Michael Spertus wrote:
>> > In my RCP program, I'd like to enumerate all of its modeled
>> classes' > Class objects. Is there a reasonable way to do this?
>> >
>> > Thanks,
>> >
>> > Mike
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.03238 seconds