X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FPopupMenu.java;h=3ea689fdba5fd1dc131601f116aaa32e0f2b8b18;hb=b5d61763044c1d72f06ce0e50da2171422a3774b;hp=dc26a36e6c80edc04522da8a739f23547d6a181e;hpb=6c73ca9c7f82edea4e8c4889969e72e917f3296d;p=jalview.git diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index dc26a36..3ea689f 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -25,7 +25,9 @@ import jalview.analysis.AlignmentAnnotationUtils; import jalview.analysis.Conservation; import jalview.commands.ChangeCaseCommand; import jalview.commands.EditCommand; +import jalview.commands.EditCommand.Action; import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentI; import jalview.datamodel.Annotation; import jalview.datamodel.DBRefEntry; import jalview.datamodel.PDBEntry; @@ -1764,12 +1766,13 @@ public class PopupMenu extends JPopupMenu /** * Check for any annotations on the underlying dataset sequences (for the - * current selection group) which are not on the alignment annotations for the - * sequence. If any are found, enable the option to add them to the alignment. - * The criteria for 'on the alignment' is finding an alignment annotation on - * the sequence, that matches on calcId and label. A tooltip is also - * constructed that displays the source (calcId) and type (label) of the - * annotations that can be added. + * current selection group) which are not 'on the alignment'.If any are found, + * enable the option to add them to the alignment. The criteria for 'on the + * alignment' is finding an alignment annotation on the alignment, matched on + * calcId, label and sequenceRef. + * + * A tooltip is also constructed that displays the source (calcId) and type + * (label) of the annotations that can be added. * * @param menuItem * @param forSequences @@ -1796,10 +1799,11 @@ public class PopupMenu extends JPopupMenu /* * For each sequence selected in the alignment, make a list of any * annotations on the underlying dataset sequence which are not already on - * the sequence in the alignment. + * the alignment. * * Build a map of { alignmentSequence, } */ + AlignmentI al = this.ap.av.getAlignment(); final Map> candidates = new LinkedHashMap>(); for (SequenceI seq : forSequences) { @@ -1817,11 +1821,12 @@ public class PopupMenu extends JPopupMenu for (AlignmentAnnotation dsann : datasetAnnotations) { /* - * If the sequence has no annotation that matches this one, then add - * this one to the results list. + * Find matching annotations on the alignment. */ - if (seq.getAlignmentAnnotations(dsann.getCalcId(), dsann.label) - .isEmpty()) + final Iterable matchedAlignmentAnnotations = al + .findAnnotations(seq, dsann.getCalcId(), + dsann.label); + if (!matchedAlignmentAnnotations.iterator().hasNext()) { result.add(dsann); tipEntries.put(dsann.getCalcId(), dsann.label); @@ -1890,8 +1895,14 @@ public class PopupMenu extends JPopupMenu } copyAnn.restrict(startRes, endRes); - // add to the sequence (sets copyAnn.datasetSequence) - seq.addAlignmentAnnotation(copyAnn); + /* + * Add to the sequence (sets copyAnn.datasetSequence), unless the + * original annotation is already on the sequence. + */ + if (!seq.hasAnnotation(ann)) + { + seq.addAlignmentAnnotation(copyAnn); + } // adjust for gaps copyAnn.adjustForAlignment(); // add to the alignment and set visible @@ -1932,7 +1943,9 @@ public class PopupMenu extends JPopupMenu true, true, false, - (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax + (ap.getSeqPanel().seqCanvas.fr != null) ? ap + .getSeqPanel().seqCanvas.fr + .getMinMax() : null); contents.append("

"); } @@ -2649,7 +2662,7 @@ public class PopupMenu extends JPopupMenu System.arraycopy(features, 0, tfeatures, 0, rsize); features = tfeatures; seqs = rseqs; - if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs, + if (ap.getSeqPanel().seqCanvas.getFeatureRenderer().amendFeatures(seqs, features, true, ap)) { ap.alignFrame.setShowSeqFeatures(true); @@ -2707,7 +2720,7 @@ public class PopupMenu extends JPopupMenu { EditCommand editCommand = new EditCommand( MessageManager.getString("label.edit_sequences"), - EditCommand.REPLACE, dialog.getName().replace(' ', + Action.REPLACE, dialog.getName().replace(' ', ap.av.getGapCharacter()), sg.getSequencesAsArray(ap.av.getHiddenRepSequences()), sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());