Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to be notified of an EList change
How to be notified of an EList change [message #484452] Mon, 07 September 2009 14:22 Go to next message
CHENG is currently offline CHENGFriend
Messages: 1
Registered: July 2009
Junior Member
Hi all,

I'm currently having some problems trying to catch an EList change
(add/remove).

I have designed an ecore diagram on which an EClass "A" can contains an
array of an EClass "B" (let's call this array "arrayOfB"). The generated
model code automatically declare the array as follow "EList<B> arrayOfB =
null;"
and generate an array accessor "public EList<B> getarrayOfB()".

Now from a class user point of view, the user will instantiate a new "A"
and will add a new "B" to the array:
A newA = Factory.createA();
B newB = Factory.createB();
newA.getarrayOfB().add(newB);


In this case, I need to execute some code juste before the newB is added
to the array. Is there a way to be notified of an EList add/remove event?

Thanks in advance.
Re: How to be notified of an EList change [message #484459 is a reply to message #484452] Mon, 07 September 2009 14:49 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------050300070004060102060408
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Cheng,

Comments below.

CHENG wrote:
> Hi all,
>
> I'm currently having some problems trying to catch an EList change
> (add/remove).
>
> I have designed an ecore diagram on which an EClass "A" can contains
> an array of an EClass "B" (let's call this array "arrayOfB"). The
> generated model code automatically declare the array as follow
> "EList<B> arrayOfB = null;"
> and generate an array accessor "public EList<B> getarrayOfB()".
>
> Now from a class user point of view, the user will instantiate a new
> "A" and will add a new "B" to the array:
> A newA = Factory.createA();
> B newB = Factory.createB();
> newA.getarrayOfB().add(newB);
>
>
> In this case, I need to execute some code juste before the newB is
> added to the array. Is there a way to be notified of an EList
> add/remove event?
An Adapter on an A instance will be notified *after *the value is added
to the list. You can specialize the list itself to override methods
like didChange, didAdd and so on to do things as the value is being added.
>
> Thanks in advance.
>

--------------050300070004060102060408
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">
</head>
<body bgcolor="#ffffff" text="#000000">
Cheng,<br>
<br>
Comments below.<br>
<br>
CHENG wrote:
<blockquote
cite="mid:59270c8267a5ab4b6ebb08e556ebc26b$1@www.eclipse.org"
type="cite">Hi all,
<br>
<br>
I'm currently having some problems trying to catch an EList change
(add/remove).
<br>
<br>
I have designed an ecore diagram on which an EClass "A" can contains an
array of an EClass "B" (let's call this array "arrayOfB"). The
generated model code automatically declare the array as follow
"EList&lt;B&gt; arrayOfB = null;"
<br>
and generate an array accessor "public EList&lt;B&gt; getarrayOfB()".
<br>
<br>
Now from a class user point of view, the user will instantiate a new
"A" and will add a new "B" to the array:
<br>
A newA = Factory.createA();
<br>
B newB = Factory.createB();
<br>
newA.getarrayOfB().add(newB);
<br>
<br>
<br>
In this case, I need to execute some code juste before the newB is
added to the array. Is there a way to be notified of an EList
add/remove event?
<br>
</blockquote>
An Adapter on an A instance will be notified <b>after </b>the value
is added to the list.


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Moving referenced model / how to update it programmitcally
Next Topic:XSD equivalent of @extends?
Goto Forum:
  


Current Time: Fri Apr 26 20:03:19 GMT 2024

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

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

Back to the top