Cloning an Interaction [message #614489] |
Sun, 06 May 2007 18:30 |
Andrew Carton Messages: 104 Registered: July 2009 |
Senior Member |
|
|
Hi,
I'd like to clone a interaction (sequence diagram). I want a complete
copy of all the elements, any references to external classes and
operations can remain intact. Does anyone know an easy way to achieve this?
My initial thoughts were something like this, but it doesn't seem to
work properly. Anyone got any ideas how to accomplish something like this?
Thanks,
Andrew.
public static Interaction cloneInteraction(Interaction interaction)
{
Interaction newInter = UMLFactory.eINSTANCE.createInteraction();
for (EAttribute ea : interaction.eClass().getEAllAttributes())
{
newInter.eSet(ea, interaction.eGet(ea));
}
for (Element element : interaction.allOwnedElements())
{
Element newElement = (Element)
UMLFactory.eINSTANCE.create(element.eClass());
for (EAttribute ea : element.eClass().getEAllAttributes())
{
newElement.eSet(ea, newElement.eGet(ea));
newInter.allOwnedElements().add(newElement);
}
}
return interaction;
}
|
|
|
Powered by
FUDForum. Page generated in 0.02498 seconds