// List of source nodes that have been copied
ArrayList copiedSourceNodes = new ArrayList();
// Socket that contains the selected parameters
NodeSocket paramHolder = null;
for (FigureEnumeration fe = workspaceView.selectionElements(); fe.hasMoreElements();)
{
Figure next = fe.nextFigure();
if (next instanceof NodeFigure)
{
NodeFigure nodeFigure = (NodeFigure) next;
nodeFigure.encodeGeometry();
Node node = nodeFigure.getNode();
// Remember that we have copied this one
copiedSourceNodes.add(node);
// Clone the node and add it to the process
node = (Node) node.clone();
process.addNode(node);
copyFlavor = ClientFlavors.PROCESS_ITEM;
}
else if (next instanceof TextElementFigure)
{
TextElementFigure textElementFigure = (TextElementFigure) next;
textElementFigure.encodeGeometry();
TextElement textElement = textElementFigure.getTextElement();
// Clone the element and add it to the process
textElement = (TextElement) textElement.clone();
process.addTextElement(textElement);
copyFlavor = ClientFlavors.PROCESS_ITEM;
}
else if (next instanceof SocketFigure)
{
SocketFigure socketFigure = (SocketFigure) next;
socketFigure.encodeGeometry();
NodeSocket socket = socketFigure.getNodeSocket();
if (socketHolder == null)
{
socketHolder = new ActivityNodeImpl();
socketHolder.setName("NodeDummy");
process.addNode(socketHolder);
}
// Clone the socketand add it to the dummy node
socket = (NodeSocket) socket.clone();
socketHolder.addSocket(socket);
copyFlavor = ClientFlavors.NODE_SOCKETS;
}