Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Creating connector
Creating connector [message #559816] Sun, 19 September 2010 10:30 Go to next message
123star  is currently offline 123star Friend
Messages: 70
Registered: June 2010
Member
Hi,

I need to create a Connector between two ports, I listened to the notification on the model when I create a Connector by hand and I discovered that the Connector is owned by the Class and not by the Port and that no notification is fired from Port, so I don't know if this code is right:

//port1, port2 are the ports to be connected

Connector conn = UMLFactory.eINSTANCE.createConnector();
port1.getEnds().add(conn.createEnd());
port2.getEnds().add(conn.createEnd());

Is it right?

Thanks in advance, 123star



Re: Creating connector [message #559822 is a reply to message #559816] Sun, 19 September 2010 16:11 Go to previous message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 161
Registered: July 2009
Senior Member
I would expect you to have to add the connector to some parent in the model.

StructuredClassifier#createOwnedConnector(String) would do that for you:

StructuredClassifier parent = (StructuredClassifier) port1.getNamespace();
Connector conn = parent.createOwnedConnector(null);


Re: linking connector end with the port - what you are doing should work, but in the end, adding to the ends collection will result on setRole(port) on the connection end. IOW:

port1.getEnds().add(conn.createEnd());


is equivalent to:

ConnectorEnd end1 = conn.createEnd();
end1.setRole(port1);


But I haven't tried any of the code above. Cheers,

Rafael
http://abstratt.com/blog

Previous Topic:Problem adding comment
Next Topic:Problem adding comment
Goto Forum:
  


Current Time: Tue Apr 23 10:29:57 GMT 2024

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

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

Back to the top