Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Contextual EMF Factories ?
Contextual EMF Factories ? [message #800043] Thu, 16 February 2012 16:11 Go to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
Hello,


Here's my problem: I'd want to provide a specific implementation for the GMF Notation Metamodel.

It can be easily done through the org.eclipse.emf.ecore.factory_override extension point. I can register my own GMF Factory, which will instantiate my own Notation objects. However, it would contaminate any GMF-based diagram, which might quickly become a problem.

So, I was looking for a way to define a contextual Factory. This seems to be possible in a resource parser:

getResourceSet().getPackageRegistry().put(NotationPackage.eNS_URI, myNotationPackage);


However, the factory associated to my own EPackage implementation will only be used during the resource loading. When creating new elements, the default, static, singleton one will be used (Unless I find & override each and every call to it, which is most likely impossible Smile )


So, here's the question: is there a way to use a contextual EMF Factory for a shared metamodel, which I can't modify directly ? Are there plans do make this possible in the future (Relying, for example, on E4 Contexts and Dependency Injection) ? Or is there another way to solve the initial problem, which is to have my own implementation of GMF notation elements in my own Diagrams ?


Thank you,
Camille


Camille Letavernier
Re: Contextual EMF Factories ? [message #800054 is a reply to message #800043] Thu, 16 February 2012 16:22 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Camille,

No, sorry can't think of a way to do this for direct uses of
NotationFactory.eINSTANCE in the GMF framework. If I recall correctly,
the Notation model extends EModelElement so it's possible to add
EAnnotations to it. Perhaps you can use this to decorate Notation model
instance with your additional information...


On 16/02/2012 5:11 PM, Camille Letavernier wrote:
> Hello,
>
>
> Here's my problem: I'd want to provide a specific implementation for
> the GMF Notation Metamodel.
>
> It can be easily done through the
> org.eclipse.emf.ecore.factory_override extension point. I can register
> my own GMF Factory, which will instantiate my own Notation objects.
> However, it would contaminate any GMF-based diagram, which might
> quickly become a problem.
>
> So, I was looking for a way to define a contextual Factory. This seems
> to be possible in a resource parser:
>
> getResourceSet().getPackageRegistry().put(NotationPackage.eNS_URI,
> myNotationPackage);
>
> However, the factory associated to my own EPackage implementation will
> only be used during the resource loading. When creating new elements,
> the default, static, singleton one will be used (Unless I find &
> override each and every call to it, which is most likely impossible :) )
>
>
> So, here's the question: is there a way to use a contextual EMF
> Factory for a shared metamodel, which I can't modify directly ? Are
> there plans do make this possible in the future (Relying, for example,
> on E4 Contexts and Dependency Injection) ? Or is there another way to
> solve the initial problem, which is to have my own implementation of
> GMF notation elements in my own Diagrams ?
>
>
> Thank you,
> Camille


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Contextual EMF Factories ? [message #800064 is a reply to message #800054] Thu, 16 February 2012 16:38 Go to previous message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
Thank you for the quick answer. Unfortunately, simply annotating the model is not possible (And, actually, not all Notation Classes extend EModelElement ; only the Views do), as I want to change the implementation of existing methods, not add new data. Annotating the model would involve to rewrite all the calls to existing methods, which is way too intrusive (And not always possible).

I'll think of another way, then, but I'm afraid I cannot solve this in a clean way Sad


Camille Letavernier
Previous Topic:disposing a resource set
Next Topic:Binding: ComputedList/ObserveDetail resets wrong Element
Goto Forum:
  


Current Time: Tue Apr 16 21:29:15 GMT 2024

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

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

Back to the top