|
|
|
|
|
Re: ChildCreationExtenderManager and Inherited Extensible models [message #425622 is a reply to message #425617] |
Wed, 03 December 2008 13:49 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
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.
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.04345 seconds