Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Update connection when target-attribute changes
Update connection when target-attribute changes [message #484365] Mon, 07 September 2009 08:56 Go to next message
Peter Lang is currently offline Peter LangFriend
Messages: 153
Registered: July 2009
Senior Member
I've got a connection, that is not defined by an element with source/target attributes, but only as target-attribute of the source-node.

Something like
<node name="Node1">
<link target="Node2" />
</node>
<node name="Node2" />
where node is represented as a Node, link as Border-Node and target as connection.

This works fine, but when the user changes the target-attribute, the connection still points to the old node. When I press F5 on the connection, it is removed.

I can react to this change in handleNotificationEvent, but what do I have to do have the connection revalidated (or removed and re-added)?

Thanks!
Re: Update connection when target-attribute changes [message #484386 is a reply to message #484365] Mon, 07 September 2009 10:51 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Peter,

> I can react to this change in handleNotificationEvent, but what do I
> have to do have the connection revalidated (or removed and re-added)?
You have to either set proper target View for the underlying Edge object
or call DiagramCanonicalEditPolicy to perform total update for you (like
F5 pressing).

-----------------
Alex Shatalin
Re: Update connection when target-attribute changes [message #484396 is a reply to message #484386] Mon, 07 September 2009 11:44 Go to previous messageGo to next message
Peter Lang is currently offline Peter LangFriend
Messages: 153
Registered: July 2009
Senior Member
> call DiagramCanonicalEditPolicy to perform total update
> for you (like F5 pressing).
Thank you Alex, it works like this:

if(notification.getFeature() instanceof ENamedElement
&& "targetName" .equals(((ENamedElement)notification.getFeature()).getName() )) {
EditPart mainEditPart = (EditPart)(getRoot().getChildren().get(0));
EditPolicy policy = mainEditPart.getEditPolicy(EditPolicyRoles.CANONICAL_ROLE);
if(policy != null && policy instanceof CanonicalEditPolicy) {
((CanonicalEditPolicy)policy).refresh();
}
}

> set proper target View for the underlying Edge object
Out of curiosity, where and how would I set the target view?
Re: Update connection when target-attribute changes [message #484813 is a reply to message #484396] Wed, 09 September 2009 12:31 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Peter,

> Out of curiosity, where and how would I set the target view?
You can create new command calling Edge.setTarget() method with an appropriate
(new) target view from this method listening to underlying domain model notifications.

-----------------
Alex Shatalin
Previous Topic:Child has parent, but that parent doesn't have the child??
Next Topic:Remove and add several child-elements in one command
Goto Forum:
  


Current Time: Fri Apr 26 00:33:36 GMT 2024

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

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

Back to the top