Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » create connection programmatically
icon5.gif  create connection programmatically [message #505691] Mon, 04 January 2010 09:25 Go to next message
Azalgo is currently offline AzalgoFriend
Messages: 9
Registered: November 2009
Junior Member
Hi, I have a little problem with gmf.

I have found how to create nodes programmatically and it works but now I want to create connection between these nodes alors programmatically but I can't find where to do it and how to do it.

To understand what I want to do :

I create a node A which create automatically a node B and a node C, I need a connection between A and B and between A and C.

Another little question, after creating nodes B and C automatically, how to place them near A ? They are always top left at this time.
Re: create connection programmatically [message #505726 is a reply to message #505691] Mon, 04 January 2010 16:41 Go to previous messageGo to next message
Azalgo is currently offline AzalgoFriend
Messages: 9
Registered: November 2009
Junior Member
I don't know what I do wrong :

if(getArchi()==null){
	getComponent().setArchitecture((MuArchitecture)getComponent().eContainer());
	getArchi().getComponents().add(getComponent());
}
if(getComponent().getProvided()==null){
	InterfaceP interf = new MuadlFactoryImpl().createInterfaceP();
	interf.setArchiIP(getArchi());
	interf.setProvider(getComponent());
	getComponent().setProvided(interf);
	getArchi().getProviders().add(interf);
}
if(getComponent().getRequired()==null){
	InterfaceR interf = new MuadlFactoryImpl().createInterfaceR();
	interf.setArchiIR(getArchi());
	interf.setRequirer(getComponent());
	getComponent().setRequired(interf);
	getArchi().getRequirers().add(interf);
				}

I explain a little more :

I have an architecture with inside components, when I create a component, the code creates an InterfaceP and an InterfaceR, I add the two interfaces into my architecture then I link the interfaces with the component with require et provide but I have no connections between them...
Re: create connection programmatically [message #505805 is a reply to message #505691] Tue, 05 January 2010 02:51 Go to previous messageGo to next message
Peder Herborg is currently offline Peder HerborgFriend
Messages: 5
Registered: July 2009
Junior Member
Hi Alzago,

I found the GMF Tutorial Part 3 very useful when trying to achieve something similar.

If you look at the use of the DeferredCreateConnectionViewAndElementCommand

(http://wiki.eclipse.org/GMF_Tutorial_Part_3#Custom_Actions)

This will guide you in the right direction I think.
Re: create connection programmatically [message #506130 is a reply to message #505691] Wed, 06 January 2010 05:07 Go to previous messageGo to next message
Azalgo is currently offline AzalgoFriend
Messages: 9
Registered: November 2009
Junior Member
Well, I have found how to create the node and the connection outside the container (muarchitecture) but when I do the same thing into the container, the connection is invisible.

I don't know why and what to do to fix that.
Re: create connection programmatically [message #506175 is a reply to message #505691] Wed, 06 January 2010 13:01 Go to previous messageGo to next message
Azalgo is currently offline AzalgoFriend
Messages: 9
Registered: November 2009
Junior Member
New evolution ! The connection is created but I can't see it, I need to close the diagram et reopen it to see it.

I think I need to refresh something after the link is created. Now need to know how to do it.
Re: create connection programmatically [message #506936 is a reply to message #505691] Mon, 11 January 2010 12:40 Go to previous message
Thomas is currently offline ThomasFriend
Messages: 79
Registered: October 2009
Member
hi, is it possible to explain me, how to create a node and a connection programmatically? I need to create a Node A, which connects to a Node B, maybe it should connect to a node C, D, E, F,....

Thanks
Thomas
Previous Topic:Specify diagram code generation target source folder
Next Topic:gmf diagram file stops writing to model xml file (diagram is a RCP app and also Eclipse plugin)
Goto Forum:
  


Current Time: Tue Apr 23 08:28:25 GMT 2024

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

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

Back to the top