ChildCreationExtenderManager and Inherited Extensible models [message #425602] |
Wed, 03 December 2008 05:14  |
Eclipse User |
|
|
|
Hi,
We have a set of existing models implemented with EMF 2.3. We are
currently implementing the new Extensible and Extender mechanism
introduced with EMF 2.4.
The idea is to have a single editor who discovers new child with this
mechanism.
Our first pre-requisite is to keep our existing models architecture.
However the current implementation analyse extenders based on the current
extensible model.
Does it make sense to analyse extenders from the inherited extensible
model ? As such we could resolve newChildDecriptors on models derived from
inherited models.
Thanks.
|
|
|
|
|
|
|
Re: ChildCreationExtenderManager and Inherited Extensible models [message #425622 is a reply to message #425617] |
Wed, 03 December 2008 08:49   |
Eclipse User |
|
|
|
Xavier,
My sense is that you'd be able to accomplish the same goal but modifying
child-of-A model's edit project's plugin.xml to indicate that it's
extender for A's nsURI is also an extender for B's nsURI, but without an
running example, I'm a bit confused and can't definitively say if that
will work. I just have a feeling that's what all the logic you've added
is doing...
Without an example, I really can't be sure if there's some bug or
something I've overlooked.
Xavier Maysonnave wrote:
> Hi Ed, I can't use thunderbird. nntp is not an option behind our proxy.
> so sad...
>
> Here is a code snippet of the desired behaviour :
>
> I modified the getNewChildDescriptors from ChildCreationExtenderManager.
> A you can see, this not an optimized version as such result are built
> each time for a particular object.
>
> /**
> * Returns the list of new child descriptors accumulated from each of
> the child creation extenders.
> * @param object the owner object of the descriptors.
> * @param editingDomain the domain for the descriptors.
> * @return the list of new child descriptors accumulated from each of
> the child creation extenders.
> */
> public List<?> getNewChildDescriptors(Object object, EditingDomain
> editingDomain)
> {
> List<Object> result = getInheritedNewChildDescriptors(object,
> editingDomain);
> for (IChildCreationExtender childCreationExtender :
> getChildCreationExtenders())
> {
>
> result.addAll(childCreationExtender.getNewChildDescriptors(o bject,
> editingDomain));
> }
> return result;
> }
>
> public List<Object> getInheritedNewChildDescriptors(Object object,
> EditingDomain editingDomain) {
> List<Object> result = new ArrayList<Object>();
> if (object instanceof EObject) {
> EObject eObject = (EObject) object;
> // Build inherited namespaces
> List<String> inheritedNamespaces = new ArrayList<String>();
> for (EClass eClass : eObject.eClass().getEAllSuperTypes()) {
> String currentNamespace = eClass.getEPackage().getNsURI();
> if (currentNamespace.equals(namespace) == false &&
> inheritedNamespaces.contains(currentNamespace) == false) {
> inheritedNamespaces.add(currentNamespace);
> }
> }
> // Build childCreationExtenders from inherited namespaces
> ChildCreationExtenderList inheritedChildCreationExtenders = new
> ChildCreationExtenderList();
> for (String inheritedNamespace : inheritedNamespaces) {
> for (IChildCreationExtender.Descriptor descriptor :
> IChildCreationExtender.Descriptor.Registry.INSTANCE.getDescr iptors(inheritedNamespace))
> {
>
> inheritedChildCreationExtenders.add(descriptor.createChildCr eationExtender());
>
> }
> }
> // Process childCreationExtenders from inherited namespaces
> for (IChildCreationExtender childCreationExtender :
> inheritedChildCreationExtenders) {
>
> result.addAll(childCreationExtender.getNewChildDescriptors(o bject,
> editingDomain));
> } }
> return result;
> }
>
> Thanks.
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.06898 seconds