fix for JAL-2419 - don’t trash the current selection
[jalview.git] / src / jalview / gui / SeqPanel.java
index 47b0694..55f23aa 100644 (file)
@@ -35,7 +35,7 @@ import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 import jalview.io.SequenceAnnotationReport;
-import jalview.schemes.CollectionColourSchemeI;
+import jalview.renderer.ResidueShaderI;
 import jalview.schemes.ResidueProperties;
 import jalview.structure.SelectionListener;
 import jalview.structure.SelectionSource;
@@ -1587,34 +1587,15 @@ public class SeqPanel extends JPanel implements MouseListener,
 
     stretchGroup = av.getSelectionGroup();
 
-    if (stretchGroup == null)
+    if (stretchGroup == null || !stretchGroup.contains(sequence, res))
     {
       stretchGroup = av.getAlignment().findGroup(sequence, res);
-      av.setSelectionGroup(stretchGroup);
-    }
-    if (stretchGroup == null
-            || !stretchGroup.getSequences(null).contains(sequence)
-            || (stretchGroup.getStartRes() > res)
-            || (stretchGroup.getEndRes() < res))
-    {
-      stretchGroup = null;
-
-      SequenceGroup[] allGroups = av.getAlignment().findAllGroups(sequence);
-
-      if (allGroups != null)
+      if (stretchGroup != null)
       {
-        for (int i = 0; i < allGroups.length; i++)
-        {
-          if ((allGroups[i].getStartRes() <= res)
-                  && (allGroups[i].getEndRes() >= res))
-          {
-            stretchGroup = allGroups[i];
-            break;
-          }
-        }
+        // only update the current selection if the popup menu has a group to
+        // focus on
+        av.setSelectionGroup(stretchGroup);
       }
-
-      av.setSelectionGroup(stretchGroup);
     }
 
     if (evt.isPopupTrigger()) // Mac: mousePressed
@@ -1655,14 +1636,14 @@ public class SeqPanel extends JPanel implements MouseListener,
 
       if (av.getConservationSelected())
       {
-        SliderPanel.setConservationSlider(ap, av.getViewportColourScheme(),
-                "Background");
+        SliderPanel.setConservationSlider(ap, av.getResidueShading(),
+                ap.getViewName());
       }
 
       if (av.getAbovePIDThreshold())
       {
-        SliderPanel.setPIDSliderSource(ap, av.getViewportColourScheme(),
-                "Background");
+        SliderPanel.setPIDSliderSource(ap, av.getResidueShading(),
+                ap.getViewName());
       }
       if ((stretchGroup != null) && (stretchGroup.getEndRes() == res))
       {
@@ -1733,7 +1714,7 @@ public class SeqPanel extends JPanel implements MouseListener,
       stretchGroup.cs.alignmentChanged(stretchGroup,
               av.getHiddenRepSequences());
 
-      CollectionColourSchemeI groupColourScheme = stretchGroup.getGroupColourScheme();
+      ResidueShaderI groupColourScheme = stretchGroup.getGroupColourScheme();
       String name = stretchGroup.getName();
       if (stretchGroup.cs.conservationApplied())
       {