Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Create a connection between two nodes programmaticaly
Create a connection between two nodes programmaticaly [message #630535] Sun, 03 October 2010 21:49 Go to next message
bachra04  is currently offline bachra04 Friend
Messages: 148
Registered: April 2010
Senior Member
I tried to create a connection between two nodes programmatically by adding the semantic connection elements. The problem is that the notation is not refreshed automatically so I don't see the link unless I close and reopen the diagram.
I tried all the internet solutions but without success.

Please help.

Thanks
Re: Create a connection between two nodes programmaticaly [message #630546 is a reply to message #630535] Mon, 04 October 2010 02:41 Go to previous messageGo to next message
Fernando Herrera is currently offline Fernando HerreraFriend
Messages: 49
Registered: January 2010
Member
Can you post the code?. I have to do the same that you. Try casting the connectioneditpart of your created connection and after do yourConnectionEditPart.getPrimaryShape().repaint()
Re: Create a connection between two nodes programmaticaly [message #630637 is a reply to message #630535] Mon, 04 October 2010 13:11 Go to previous messageGo to next message
bachra04  is currently offline bachra04 Friend
Messages: 148
Registered: April 2010
Senior Member
I didn't get yet into the point of creating the connectionEditPart.
My connectionEditPart is created through my CanonicalEditPolicy
but I couldn't find a way to refresh or trigger the CanonicalEdityPolicy once I added semantic elements : so this part of sync between semantic and notational model is missing
Re: Create a connection between two nodes programmaticaly [message #630648 is a reply to message #630535] Mon, 04 October 2010 13:35 Go to previous messageGo to next message
emil salageanu is currently offline emil salageanuFriend
Messages: 94
Registered: June 2010
Location: Nice, France
Member
Hi,

I had that problem and the only solution I could find was to refresh the entire model:

EditPart mainEditPart = (EditPart)(AnyOfMyEditParts.getRoot().getChildren().get(0));
		 CanonicalEditPolicy cep = (CanonicalEditPolicy)mainEditPart.getEditPolicy(EditPolicyRoles.CANONICAL_ROLE);
		 if (cep!=null)
			 cep.refresh();


This is rather a workaround then a clean solution and it might cause other problems. If you find a better solution please post.

cheers,
emil.
Re: Create a connection between two nodes programmaticaly [message #630790 is a reply to message #630648] Tue, 05 October 2010 03:06 Go to previous messageGo to next message
bachra04  is currently offline bachra04 Friend
Messages: 148
Registered: April 2010
Senior Member
Hi Emil,

I tried that but for some reason it didn't work.

Thanks
Re: Create a connection between two nodes programmaticaly [message #630900 is a reply to message #630535] Tue, 05 October 2010 14:17 Go to previous messageGo to next message
bachra04  is currently offline bachra04 Friend
Messages: 148
Registered: April 2010
Senior Member
I finally get it working.

Thanks Guys.
Re: Create a connection between two nodes programmaticaly [message #631339 is a reply to message #630535] Thu, 07 October 2010 07:12 Go to previous messageGo to next message
emil salageanu is currently offline emil salageanuFriend
Messages: 94
Registered: June 2010
Location: Nice, France
Member
Bravo,
How did you do ? Smile

Re: Create a connection between two nodes programmaticaly [message #631489 is a reply to message #631339] Thu, 07 October 2010 17:00 Go to previous message
bachra04  is currently offline bachra04 Friend
Messages: 148
Registered: April 2010
Senior Member
I just called:

CreateConnectionViewAndElementRequest.getCreateCommand ... code

then I added the code you provided:

EditPart mainEditPart = (EditPart)(AnyOfMyEditParts.getRoot().getChildren().get(0));
CanonicalEditPolicy cep = (CanonicalEditPolicy)mainEditPart.getEditPolicy(EditPolicyRo les.CANONICAL_ROLE);
if (cep!=null)
cep.refresh();


And it works.
Previous Topic:Arrange with partitions
Next Topic:Problems with a layout: not resize the Top Nodes
Goto Forum:
  


Current Time: Thu Apr 25 13:46:10 GMT 2024

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

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

Back to the top