Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » ChildCreationExtenderManager and Inherited Extensible models
ChildCreationExtenderManager and Inherited Extensible models [message #425602] Wed, 03 December 2008 10:14 Go to next message
Xavier Maysonnave is currently offline Xavier MaysonnaveFriend
Messages: 30
Registered: July 2009
Member
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 #425605 is a reply to message #425602] Wed, 03 December 2008 11:59 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30879
Registered: July 2009
Senior Member
Xavier,

Comments below.

Xavier Maysonnave wrote:
> 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.
Regenerating with these new flags enabled won't upset your existing
architecture... I'm not sure I follow...
> However the current implementation analyse extenders based on the
> current extensible model.
Yes, the base must be generated to consider extensions and the derived
model must be generated to contribute those extensions.
> Does it make sense to analyse extenders from the inherited extensible
> model ?
It's the base that needs extending so it has to look for the extensions...
> As such we could resolve newChildDecriptors on models derived from
> inherited models.
I'm not following the "derived from inherited models" comment. You mean
there is some base model you can't change to be extensible?
>
>
> Thanks.
>
Re: ChildCreationExtenderManager and Inherited Extensible models [message #425610 is a reply to message #425605] Wed, 03 December 2008 12:39 Go to previous messageGo to next message
Xavier Maysonnave is currently offline Xavier MaysonnaveFriend
Messages: 30
Registered: July 2009
Member
A schema is probably better to explain what I need to address. As I use
the newsportal it is not very convenient to do so.

1 - Model A is extensible and has child models.
Model B is extensible and has child models.
Child models from A and B are different.
2 - Model B uses Model A.
Classes defined in B inherit abstract classes or interfaces from model A.
3 - Each model is generated in their own plugin.

When newChildDescriptors are built for a B object (let's say b),
collectNewChildDescriptors is called in its ItemProvider (usual mechanism)
then as the adapterFactory is a IChildCreationExtender,
newChildDescriptors are solved against its extenders.
Nothing particular here, this is the normal behaviour.

I would like to collect newChildDescriptors for b from child models of A.

Does-it make sense without any model refactoring ? I can merge B and A,
this will solve this issue but it should be avoded as a requirement.

I hope my explanations are better ?
I could provide a schema with a private mail if necessary.

Thanks.
Re: ChildCreationExtenderManager and Inherited Extensible models [message #425615 is a reply to message #425610] Wed, 03 December 2008 12:54 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30879
Registered: July 2009
Senior Member
Xavier,

Comments below.

Xavier Maysonnave wrote:
> A schema is probably better to explain what I need to address. As I
> use the newsportal it is not very convenient to do so.
Thunderbird is so much better...
>
> 1 - Model A is extensible and has child models.
> Model B is extensible and has child models.
> Child models from A and B are different.
> 2 - Model B uses Model A.
> Classes defined in B inherit abstract classes or interfaces from model A.
> 3 - Each model is generated in their own plugin.
>
> When newChildDescriptors are built for a B object (let's say b),
> collectNewChildDescriptors is called in its ItemProvider (usual
> mechanism) then as the adapterFactory is a IChildCreationExtender,
> newChildDescriptors are solved against its extenders.
> Nothing particular here, this is the normal behaviour.
>
> I would like to collect newChildDescriptors for b from child models of A.
Hmmm.
>
> Does-it make sense without any model refactoring ?
I think so. But it seems to me that the child models of A will need to
know about B to extend B.
> I can merge B and A, this will solve this issue but it should be
> avoded as a requirement.
>
> I hope my explanations are better ? I could provide a schema with a
> private mail if necessary.
I think if the child model of A had B as one of it's used GenPackage,
but I think the importer doesn't add used GenPackage unless there is an
explicit dependency that requires it...

Probably I need to see the full example...
>
> Thanks.
>
Re: ChildCreationExtenderManager and Inherited Extensible models [message #425617 is a reply to message #425615] Wed, 03 December 2008 13:01 Go to previous messageGo to next message
Xavier Maysonnave is currently offline Xavier MaysonnaveFriend
Messages: 30
Registered: July 2009
Member
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.
Re: ChildCreationExtenderManager and Inherited Extensible models [message #425622 is a reply to message #425617] Wed, 03 December 2008 13:49 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30879
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.
>
Re: ChildCreationExtenderManager and Inherited Extensible models [message #425624 is a reply to message #425622] Wed, 03 December 2008 13:54 Go to previous message
Xavier Maysonnave is currently offline Xavier MaysonnaveFriend
Messages: 30
Registered: July 2009
Member
I agree.
We are preparing a small sample to show you what we are doing.
Thanks.
Previous Topic:Problem: Pasting Non Containment References when withInverseElist is true.
Next Topic:How to force a node to refresh it's properties view
Goto Forum:
  


Current Time: Mon Feb 17 01:05:26 GMT 2020

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

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

Back to the top