Creating connector [message #559816] |
Sun, 19 September 2010 06:30  |
Eclipse User |
|
|
|
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 12:11  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.06098 seconds