Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » EContentAdapter behaviour ?
EContentAdapter behaviour ? [message #44248] Thu, 10 August 2006 12:44 Go to next message
Mark Robinson is currently offline Mark RobinsonFriend
Messages: 37
Registered: July 2009
Member
I have three model objects (A, B and C) in a GEF Editor.

B has child C added to it. At this point B has and eContentAdapter added
to it.

I now want to add B as a child to A. I add another eContentAdapter to A.
Do I need to remove B's eContentAdapter before I add B to A?

Thanks in advance.
Mark Robinson
Re: EContentAdapter behaviour ? [message #44280 is a reply to message #44248] Thu, 10 August 2006 13:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Mark,

This question would be more appropriate in the eclipse.tools.emf newsgroup,
but I'll try to answer.

If the EContentAdapter that is on A is the *same instance* as the
EContentAdapter that is on B, then you don't need to worry, because it will
detect that it is already attached to B when you add B to A.

If it is not the same instance, then you want to make sure that it is,
otherwise you'll have to ensure that the one adapter is removed from B and
all of its contents (recursively) to avoid replication of adapters.

HTH,

Christian


Mark Robinson wrote:

> I have three model objects (A, B and C) in a GEF Editor.
>
> B has child C added to it. At this point B has and eContentAdapter added
> to it.
>
> I now want to add B as a child to A. I add another eContentAdapter to A.
> Do I need to remove B's eContentAdapter before I add B to A?
>
> Thanks in advance.
> Mark Robinson
Re: EContentAdapter behaviour ? [message #44311 is a reply to message #44248] Thu, 10 August 2006 13:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------050800040600080904020909
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Mark,

The content adapter doesn't check whether it's already attached and will
attach itself to all the children automatically, so unless you
specialize this method

protected void addAdapter(Notifier notifier)
{
notifier.eAdapters().add(this);
}

to look like this

protected void addAdapter(Notifier notifier)
{
List eAdapters = notifier.eAdapters();
if (!eAdapters.contains(this))
{
eAdapters.add(this);
}
}

I suspect you'll end up with B having the adapter attached twice (which
is probably what you've noticed and why you are asking).

Are A, B, and C in a resource such that you could attach the adapter to
the resource instead?


Mark Robinson wrote:
> I have three model objects (A, B and C) in a GEF Editor.
>
> B has child C added to it. At this point B has and eContentAdapter
> added to it.
>
> I now want to add B as a child to A. I add another eContentAdapter to
> A. Do I need to remove B's eContentAdapter before I add B to A?
>
> Thanks in advance.
> Mark Robinson
>


--------------050800040600080904020909
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Mark,<br>
<br>
The content adapter doesn't check whether it's already attached and
will attach itself to all the children automatically, so unless you
specialize this method<br>
<blockquote><small>
Re: EContentAdapter behaviour ? [message #44368 is a reply to message #44311] Thu, 10 August 2006 13:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Ed,

This must be what the content adapters I have worked with in the past did
for themselves. Thanks for the correction!

cW


Ed Merks wrote:

> Mark,
>
> The content adapter doesn't check whether it's already attached and will
> attach itself to all the children automatically, so unless you
> specialize this method
>
> protected void addAdapter(Notifier notifier)
> {
> notifier.eAdapters().add(this);
> }
>
> to look like this
>
> protected void addAdapter(Notifier notifier)
> {
> List eAdapters = notifier.eAdapters();
> if (!eAdapters.contains(this))
> {
> eAdapters.add(this);
> }
> }
>
> I suspect you'll end up with B having the adapter attached twice (which
> is probably what you've noticed and why you are asking).
>
> Are A, B, and C in a resource such that you could attach the adapter to
> the resource instead?
>
>
> Mark Robinson wrote:
>> I have three model objects (A, B and C) in a GEF Editor.
>>
>> B has child C added to it. At this point B has and eContentAdapter
>> added to it.
>>
>> I now want to add B as a child to A. I add another eContentAdapter to
>> A. Do I need to remove B's eContentAdapter before I add B to A?
>>
>> Thanks in advance.
>> Mark Robinson
>>
Re: EContentAdapter behaviour ? [message #44830 is a reply to message #44368] Fri, 11 August 2006 08:40 Go to previous message
Mark Robinson is currently offline Mark RobinsonFriend
Messages: 37
Registered: July 2009
Member
Many thanks guys.

Leaving the old adapter on the child was causing strange knock on effects
(eg figures not displaying properly). I resolved the problems by removing
the adapter on the source/child before adding it to the target/parent,
and adding a new adapter to parent.

I'm not sure if I can attach the adapter to a resource. Our model is kind
of complicated with a lot of references to objects in different ecore
files. I'll look into that later.

Thanks again.


Christian W. Damus wrote:


> Hi, Ed,

> This must be what the content adapters I have worked with in the past did
> for themselves. Thanks for the correction!

> cW


> Ed Merks wrote:

>> Mark,
>>
>> The content adapter doesn't check whether it's already attached and will
>> attach itself to all the children automatically, so unless you
>> specialize this method
>>
>> protected void addAdapter(Notifier notifier)
>> {
>> notifier.eAdapters().add(this);
>> }
>>
>> to look like this
>>
>> protected void addAdapter(Notifier notifier)
>> {
>> List eAdapters = notifier.eAdapters();
>> if (!eAdapters.contains(this))
>> {
>> eAdapters.add(this);
>> }
>> }
>>
>> I suspect you'll end up with B having the adapter attached twice (which
>> is probably what you've noticed and why you are asking).
>>
>> Are A, B, and C in a resource such that you could attach the adapter to
>> the resource instead?
>>
>>
>> Mark Robinson wrote:
>>> I have three model objects (A, B and C) in a GEF Editor.
>>>
>>> B has child C added to it. At this point B has and eContentAdapter
>>> added to it.
>>>
>>> I now want to add B as a child to A. I add another eContentAdapter to
>>> A. Do I need to remove B's eContentAdapter before I add B to A?
>>>
>>> Thanks in advance.
>>> Mark Robinson
>>>
Re: EContentAdapter behaviour ? [message #584975 is a reply to message #44248] Thu, 10 August 2006 13:01 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Mark,

This question would be more appropriate in the eclipse.tools.emf newsgroup,
but I'll try to answer.

If the EContentAdapter that is on A is the *same instance* as the
EContentAdapter that is on B, then you don't need to worry, because it will
detect that it is already attached to B when you add B to A.

If it is not the same instance, then you want to make sure that it is,
otherwise you'll have to ensure that the one adapter is removed from B and
all of its contents (recursively) to avoid replication of adapters.

HTH,

Christian


Mark Robinson wrote:

> I have three model objects (A, B and C) in a GEF Editor.
>
> B has child C added to it. At this point B has and eContentAdapter added
> to it.
>
> I now want to add B as a child to A. I add another eContentAdapter to A.
> Do I need to remove B's eContentAdapter before I add B to A?
>
> Thanks in advance.
> Mark Robinson
Re: EContentAdapter behaviour ? [message #584990 is a reply to message #44248] Thu, 10 August 2006 13:09 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------050800040600080904020909
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Mark,

The content adapter doesn't check whether it's already attached and will
attach itself to all the children automatically, so unless you
specialize this method

protected void addAdapter(Notifier notifier)
{
notifier.eAdapters().add(this);
}

to look like this

protected void addAdapter(Notifier notifier)
{
List eAdapters = notifier.eAdapters();
if (!eAdapters.contains(this))
{
eAdapters.add(this);
}
}

I suspect you'll end up with B having the adapter attached twice (which
is probably what you've noticed and why you are asking).

Are A, B, and C in a resource such that you could attach the adapter to
the resource instead?


Mark Robinson wrote:
> I have three model objects (A, B and C) in a GEF Editor.
>
> B has child C added to it. At this point B has and eContentAdapter
> added to it.
>
> I now want to add B as a child to A. I add another eContentAdapter to
> A. Do I need to remove B's eContentAdapter before I add B to A?
>
> Thanks in advance.
> Mark Robinson
>


--------------050800040600080904020909
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Mark,<br>
<br>
The content adapter doesn't check whether it's already attached and
will attach itself to all the children automatically, so unless you
specialize this method<br>
<blockquote><small>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EContentAdapter behaviour ? [message #585022 is a reply to message #44311] Thu, 10 August 2006 13:12 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Ed,

This must be what the content adapters I have worked with in the past did
for themselves. Thanks for the correction!

cW


Ed Merks wrote:

> Mark,
>
> The content adapter doesn't check whether it's already attached and will
> attach itself to all the children automatically, so unless you
> specialize this method
>
> protected void addAdapter(Notifier notifier)
> {
> notifier.eAdapters().add(this);
> }
>
> to look like this
>
> protected void addAdapter(Notifier notifier)
> {
> List eAdapters = notifier.eAdapters();
> if (!eAdapters.contains(this))
> {
> eAdapters.add(this);
> }
> }
>
> I suspect you'll end up with B having the adapter attached twice (which
> is probably what you've noticed and why you are asking).
>
> Are A, B, and C in a resource such that you could attach the adapter to
> the resource instead?
>
>
> Mark Robinson wrote:
>> I have three model objects (A, B and C) in a GEF Editor.
>>
>> B has child C added to it. At this point B has and eContentAdapter
>> added to it.
>>
>> I now want to add B as a child to A. I add another eContentAdapter to
>> A. Do I need to remove B's eContentAdapter before I add B to A?
>>
>> Thanks in advance.
>> Mark Robinson
>>
Re: EContentAdapter behaviour ? [message #585277 is a reply to message #44368] Fri, 11 August 2006 08:40 Go to previous message
Mark Robinson is currently offline Mark RobinsonFriend
Messages: 37
Registered: July 2009
Member
Many thanks guys.

Leaving the old adapter on the child was causing strange knock on effects
(eg figures not displaying properly). I resolved the problems by removing
the adapter on the source/child before adding it to the target/parent,
and adding a new adapter to parent.

I'm not sure if I can attach the adapter to a resource. Our model is kind
of complicated with a lot of references to objects in different ecore
files. I'll look into that later.

Thanks again.


Christian W. Damus wrote:


> Hi, Ed,

> This must be what the content adapters I have worked with in the past did
> for themselves. Thanks for the correction!

> cW


> Ed Merks wrote:

>> Mark,
>>
>> The content adapter doesn't check whether it's already attached and will
>> attach itself to all the children automatically, so unless you
>> specialize this method
>>
>> protected void addAdapter(Notifier notifier)
>> {
>> notifier.eAdapters().add(this);
>> }
>>
>> to look like this
>>
>> protected void addAdapter(Notifier notifier)
>> {
>> List eAdapters = notifier.eAdapters();
>> if (!eAdapters.contains(this))
>> {
>> eAdapters.add(this);
>> }
>> }
>>
>> I suspect you'll end up with B having the adapter attached twice (which
>> is probably what you've noticed and why you are asking).
>>
>> Are A, B, and C in a resource such that you could attach the adapter to
>> the resource instead?
>>
>>
>> Mark Robinson wrote:
>>> I have three model objects (A, B and C) in a GEF Editor.
>>>
>>> B has child C added to it. At this point B has and eContentAdapter
>>> added to it.
>>>
>>> I now want to add B as a child to A. I add another eContentAdapter to
>>> A. Do I need to remove B's eContentAdapter before I add B to A?
>>>
>>> Thanks in advance.
>>> Mark Robinson
>>>
Previous Topic:CDO committed to CVS
Next Topic:Accessing a Container via OCL
Goto Forum:
  


Current Time: Fri Apr 19 01:05:19 GMT 2024

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

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

Back to the top