private class PipelineListener extends OperationPipelineAdapter {
@Override
public void activityInserted(PipelineActivityInsertedEvent evt) {
PipelineActivityNode begin = pipelineActivityNodes.get(evt.getPrevious());
if (begin != null) {
// Note that this also removes the incoming routes from the node
// representing evt.getNext(), so we don't have to do that ourselves
begin.removeAllOutgoingRoutes();
}
PipelineActivityNode prevNode = begin;
OperationWrapperNode parentNode = getNodeForPipeline(evt.getSource());
PipelineActivity inserted = evt.getInsertedActivity();
PipelineActivityNode insertedNode = NodeFactory.createNode(inserted, parentNode);
pipelineActivityNodes.put(inserted, insertedNode);
if (prevNode != null) {
prevNode.addOutgoingRoute(new PipelineActivityEdge(prevNode, insertedNode));
}
PipelineActivityNode end = pipelineActivityNodes.get(evt.getNext());
if (end != null) {
insertedNode.addOutgoingRoute(new PipelineActivityEdge(insertedNode, end));
}
// The OperationWrapperNode's children must appear in the same order as they do in the pipeline
// for the automatic layout to work properly.