- annotation.createSequenceMapping(refSeq, refSeqIndex, false);\r
- annotation.adjustForAlignment();\r
- refSeq.addAlignmentAnnotation(annotation);\r
- }\r
-\r
- al.addAnnotation(annotation);\r
-\r
- al.setAnnotationIndex(annotation,\r
+ do {\r
+ // copy before we do any mapping business.\r
+ // TODO: verify that undo/redo with 1:many sequence associated annotations can be undone correctly\r
+ AlignmentAnnotation ann = new AlignmentAnnotation(annotation);\r
+ annotation.createSequenceMapping(refSeq, refSeqIndex, false);\r
+ annotation.adjustForAlignment();\r
+ refSeq.addAlignmentAnnotation(annotation);\r
+ al.addAnnotation(annotation);\r
+ al.setAnnotationIndex(annotation,\r
+ al.getAlignmentAnnotation().length - existingAnnotations -\r
+ 1);\r
+ // and recover our virgin copy to use again if necessary.\r
+ annotation = ann;\r
+ \r
+ } while (refSeqId!=null && (refSeq=al.findName(refSeq, refSeqId, true))!=null);\r
+ } else {\r
+ al.addAnnotation(annotation);\r
+ al.setAnnotationIndex(annotation,\r