Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » EContentAdapter behaviour ?
|
Re: EContentAdapter behaviour ? [message #44280 is a reply to message #44248] |
Thu, 10 August 2006 13: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 #44311 is a reply to message #44248] |
Thu, 10 August 2006 13:09 |
Eclipse User |
|
|
|
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 |
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 #584975 is a reply to message #44248] |
Thu, 10 August 2006 13: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 13:09 |
Ed Merks 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 |
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
>>
|
|
| |
Goto Forum:
Current Time: Fri Apr 19 01:05:19 GMT 2024
Powered by FUDForum. Page generated in 0.02572 seconds
|