// 2. Clone the object
// 3. Add the cloned object to the dummy process
// 4. Generate reference names from the actual object references (e. g. for actions, sub processes, data types etc.)
// Node that contains the selected sockets
ActivityNodeImpl socketHolder = null;
// 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;
}
else if (next instanceof ParamFigure)
{
ParamFigure paramFigure = (ParamFigure) next;
NodeParam param = paramFigure.getNodeParam();
if (paramHolder == null)
{
if (socketHolder == null)
{
socketHolder = new ActivityNodeImpl();
socketHolder.setName("NodeDummy");
process.addNode(socketHolder);
}
paramHolder = new NodeSocketImpl();
paramHolder.setName("SocketDummy");
socketHolder.addSocket(paramHolder);
}
// Clone the socket and add it to the dummy node
param = (NodeParam) param.clone();
paramHolder.addParam(param, - 1);