EContentAdapter behaviour ? [message #44248] |
Thu, 10 August 2006 08:44  |
Eclipse User |
|
|
|
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 09:01   |
Eclipse User |
|
|
|
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 #44830 is a reply to message #44368] |
Fri, 11 August 2006 04:40  |
Eclipse User |
|
|
|
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 09:01  |
Eclipse User |
|
|
|
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 09:09  |
Eclipse User |
|
|
|
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 #585022 is a reply to message #44311] |
Thu, 10 August 2006 09:12  |
Eclipse User |
|
|
|
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 04:40  |
Eclipse User |
|
|
|
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
>>>
|
|
|
Powered by
FUDForum. Page generated in 0.05022 seconds