Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How do I listen for changes in an entity and update another one accordingly?
How do I listen for changes in an entity and update another one accordingly? [message #165015] Tue, 11 December 2007 11:53 Go to next message
Eclipse UserFriend
Originally posted by: kristoffer.k.kobosko.ericsson.com

Hi, I have a very basic problem, and I am confused that it has been
so hard to find any info on this in the GMF documentation:

I have two entity types in my model, an Instance and a Prototype.

The Instance has a "Prototype" field which should contain whatever
is in the "Name" field of the Prototype entity, if there is a link
of type InstanceToPrototypeConnection between these.
Given this, what is the best practice in implementing the relationship
Instance.Prototype -> Prototype.Name
so that these two will stay synchronized (i.e contain the same value) no
matter what?
I have tried listening on changes
but can only succeed on doing this by listening on Prototype.Name changes
at the model (EMF) layer and I am unsure how to go from there to the
graphical representation, e.g. how to traverse myself back through that
connection to update the Instance.Prototype attribute as well.

I am confused. Shouldn't this be basic GMF functionality? What am I
missing here?


Kindly
Kristoffer
Re: How do I listen for changes in an entity and update another one accordingly? [message #165030 is a reply to message #165015] Tue, 11 December 2007 12:50 Go to previous message
Boris Blajer is currently offline Boris BlajerFriend
Messages: 217
Registered: July 2009
Senior Member
Hi Kristoffer,

Your problem has little relation to GMF, it is an EMF task, so it is not
surprising that the solution might not be available in the GMF
documentation. Below are 2 different solutions that you may try to use.

You may add a ResourceSetListener to the diagram editing domain to
receive notifications before transactions are committed. The listener
will provide a trigger command to update the prototype field of
associated instances whenever a prototype name is changed or a link
between an instance and a prototype is modified in some way.

Another way would be to declare the prototype field of the Instance to
be derived transient read-only and modify the generated EMF code to
return the correct value in getPrototype() method. Besides, you would
need to associate an Adapter to the Prototype instance to append an EMF
Notification that the Instance.prototype value has changed whenever the
Prototype.name is modified or Instance.instanceToPrototypeConnection is
added/removed/retargeted.

Best regards,
Boris

Kristoffer Kobosko wrote:
> Hi, I have a very basic problem, and I am confused that it has been
> so hard to find any info on this in the GMF documentation:
>
> I have two entity types in my model, an Instance and a Prototype.
>
> The Instance has a "Prototype" field which should contain whatever
> is in the "Name" field of the Prototype entity, if there is a link
> of type InstanceToPrototypeConnection between these.
> Given this, what is the best practice in implementing the relationship
> Instance.Prototype -> Prototype.Name
> so that these two will stay synchronized (i.e contain the same value) no
> matter what? I have tried listening on changes
> but can only succeed on doing this by listening on Prototype.Name
> changes at the model (EMF) layer and I am unsure how to go from there to
> the graphical representation, e.g. how to traverse myself back through
> that connection to update the Instance.Prototype attribute as well.
>
> I am confused. Shouldn't this be basic GMF functionality? What am I
> missing here?
>
>
> Kindly
> Kristoffer
>
>
Previous Topic:size of figure
Next Topic:ocl validation
Goto Forum:
  


Current Time: Fri Apr 19 09:25:57 GMT 2024

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

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

Back to the top