Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Making model changes when changes are made in a connection
Making model changes when changes are made in a connection [message #165891] Wed, 19 December 2007 11:08 Go to next message
Eclipse UserFriend
Originally posted by: gmerin.integranova.com

Hi everyone. I'm developing a Sequence Diagram and I need some help. The
problem I have is that every time a connection is
created/reoriented/re-anchored/destroyed (i.e. a Message drawn between
two lifelines) I must update the semantic model depending of the
graphical changes.

To be more specific, If 2 o more connections (Messages) are drawn
between two elements (Lifelines) the order of the links is quite clear
by just looking at the Diagram. The problem is that the graphical order
must also be represented in the semantic model (the order of the
messages is important. GeneralOrdering elements must be created and
updated depending of the graphical position of the messages).

To make it simple, what I want is to make changes in the semantic model
every time a MessageConnectionNodeEditPart is created, reoriented,
re-anchored or destroyed.

What I have done, at the moment, is to override the
handleNotificatonEvent of the MessageConnectionNodeEditPart so I can be
aware of graphical changes (creation, reorientation and re-anchoring).
The problem (suposing that I have chosen the right path for the goal) is
that, once a graphical change is made, I need to know the new X,Y
position of the source/end of the connection (so I can compare is with
the exising connections).

How do I get this information from the notification? the only way that I
have found is, since the handleNotificationEvent is whithin an EditPart,
ask for its figure and get its points (its a Polyline). This works fine
with reorientation/re-anchoring since graphical changes have already
been made when I get the notification, but this does not happen when I'm
creating a new connection (and I'm not able to extract this information
from the notification).

Any ideas? The only information I have been able to "decode" from de
notification is the new NodeImpl for the source/target reorientation or
the identityAnchor for the source/target anchoring. Any help?

P.S.: I have also tryed to add listener to the GMFResource to be aware
of any graphical changes, but I'm stucked with the same issue commented
above.

Thanks in advance.
Re: Making model changes when changes are made in a connection [message #165922 is a reply to message #165891] Wed, 19 December 2007 13:46 Go to previous messageGo to next message
Boris Blajer is currently offline Boris BlajerFriend
Messages: 217
Registered: July 2009
Senior Member
Hi Gabriel,

You should not try to modify model in handleNotificationEvent method.
Most likely, this method is invoked in the context of a read-only
transaction, so your changes will be rolled back. Normally, if you want
to make a change in the EMF model in response to some other change, and
your editing domain is transactional (which is always the case with
GMF), you should attach a ResourceSetListener to the editing domain and
provide a trigger command from transactionAboutToCommit method.

In your scenario, however, you may prefer to subclass edit policies that
are used to create/reroute/delete/move the elements (take a look at
XYZEditPart#createDefaultEditPolicies() for details on which edit
policies get installed). Your subclasses should return compound commands
that consist of the command from the super-implementation and the
command to do something meaningful with the coordinates that you
normally obtain from the requests.

Best regards,
Boris

Gabriel Merin Cubero wrote:
> Hi everyone. I'm developing a Sequence Diagram and I need some help. The
> problem I have is that every time a connection is
> created/reoriented/re-anchored/destroyed (i.e. a Message drawn between
> two lifelines) I must update the semantic model depending of the
> graphical changes.
>
> To be more specific, If 2 o more connections (Messages) are drawn
> between two elements (Lifelines) the order of the links is quite clear
> by just looking at the Diagram. The problem is that the graphical order
> must also be represented in the semantic model (the order of the
> messages is important. GeneralOrdering elements must be created and
> updated depending of the graphical position of the messages).
>
> To make it simple, what I want is to make changes in the semantic model
> every time a MessageConnectionNodeEditPart is created, reoriented,
> re-anchored or destroyed.
>
> What I have done, at the moment, is to override the
> handleNotificatonEvent of the MessageConnectionNodeEditPart so I can be
> aware of graphical changes (creation, reorientation and re-anchoring).
> The problem (suposing that I have chosen the right path for the goal) is
> that, once a graphical change is made, I need to know the new X,Y
> position of the source/end of the connection (so I can compare is with
> the exising connections).
>
> How do I get this information from the notification? the only way that I
> have found is, since the handleNotificationEvent is whithin an EditPart,
> ask for its figure and get its points (its a Polyline). This works fine
> with reorientation/re-anchoring since graphical changes have already
> been made when I get the notification, but this does not happen when I'm
> creating a new connection (and I'm not able to extract this information
> from the notification).
>
> Any ideas? The only information I have been able to "decode" from de
> notification is the new NodeImpl for the source/target reorientation or
> the identityAnchor for the source/target anchoring. Any help?
>
> P.S.: I have also tryed to add listener to the GMFResource to be aware
> of any graphical changes, but I'm stucked with the same issue commented
> above.
>
> Thanks in advance.
Re: Making model changes when changes are made in a connection [message #165953 is a reply to message #165922] Wed, 19 December 2007 15:32 Go to previous message
Eclipse UserFriend
Originally posted by: gmerin.integranova.com

Hi Boris, thank you very much for your quick answer. I'll try it that way.

Gabriel

Boris Blajer escribió:
> Hi Gabriel,
>
> You should not try to modify model in handleNotificationEvent method.
> Most likely, this method is invoked in the context of a read-only
> transaction, so your changes will be rolled back. Normally, if you want
> to make a change in the EMF model in response to some other change, and
> your editing domain is transactional (which is always the case with
> GMF), you should attach a ResourceSetListener to the editing domain and
> provide a trigger command from transactionAboutToCommit method.
>
> In your scenario, however, you may prefer to subclass edit policies that
> are used to create/reroute/delete/move the elements (take a look at
> XYZEditPart#createDefaultEditPolicies() for details on which edit
> policies get installed). Your subclasses should return compound commands
> that consist of the command from the super-implementation and the
> command to do something meaningful with the coordinates that you
> normally obtain from the requests.
>
> Best regards,
> Boris
>
> Gabriel Merin Cubero wrote:
>> Hi everyone. I'm developing a Sequence Diagram and I need some help.
>> The problem I have is that every time a connection is
>> created/reoriented/re-anchored/destroyed (i.e. a Message drawn between
>> two lifelines) I must update the semantic model depending of the
>> graphical changes.
>>
>> To be more specific, If 2 o more connections (Messages) are drawn
>> between two elements (Lifelines) the order of the links is quite clear
>> by just looking at the Diagram. The problem is that the graphical
>> order must also be represented in the semantic model (the order of the
>> messages is important. GeneralOrdering elements must be created and
>> updated depending of the graphical position of the messages).
>>
>> To make it simple, what I want is to make changes in the semantic
>> model every time a MessageConnectionNodeEditPart is created,
>> reoriented, re-anchored or destroyed.
>>
>> What I have done, at the moment, is to override the
>> handleNotificatonEvent of the MessageConnectionNodeEditPart so I can
>> be aware of graphical changes (creation, reorientation and
>> re-anchoring). The problem (suposing that I have chosen the right path
>> for the goal) is that, once a graphical change is made, I need to know
>> the new X,Y position of the source/end of the connection (so I can
>> compare is with the exising connections).
>>
>> How do I get this information from the notification? the only way that
>> I have found is, since the handleNotificationEvent is whithin an
>> EditPart, ask for its figure and get its points (its a Polyline). This
>> works fine with reorientation/re-anchoring since graphical changes
>> have already been made when I get the notification, but this does not
>> happen when I'm creating a new connection (and I'm not able to extract
>> this information from the notification).
>>
>> Any ideas? The only information I have been able to "decode" from de
>> notification is the new NodeImpl for the source/target reorientation
>> or the identityAnchor for the source/target anchoring. Any help?
>>
>> P.S.: I have also tryed to add listener to the GMFResource to be aware
>> of any graphical changes, but I'm stucked with the same issue
>> commented above.
>>
>> Thanks in advance.
Previous Topic:List with set and get
Next Topic:Error when delete a figure
Goto Forum:
  


Current Time: Thu Apr 25 06:59:20 GMT 2024

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

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

Back to the top