Merge branch 'develop' of https://source.jalview.org/git/jalview.git into develop
[jalview.git] / src / jalview / gui / SeqPanel.java
index e0b80fe..1432fcb 100644 (file)
@@ -59,6 +59,7 @@ import java.awt.event.MouseMotionListener;
 import java.awt.event.MouseWheelEvent;
 import java.awt.event.MouseWheelListener;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import javax.swing.JPanel;
@@ -1484,6 +1485,11 @@ public class SeqPanel extends JPanel implements MouseListener,
     }
   }
 
+  /**
+   * Handler for double-click on a position with one or more sequence features.
+   * Opens the Amend Features dialog to allow feature details to be amended, or
+   * the feature deleted.
+   */
   @Override
   public void mouseClicked(MouseEvent evt)
   {
@@ -1502,20 +1508,23 @@ public class SeqPanel extends JPanel implements MouseListener,
               .findFeaturesAtRes(sequence.getDatasetSequence(),
                       sequence.findPosition(findRes(evt)));
 
-      if (features != null && features.size() > 0)
+      if (!features.isEmpty())
       {
+        /*
+         * highlight the first feature at the position on the alignment
+         */
         SearchResultsI highlight = new SearchResults();
         highlight.addResult(sequence, features.get(0).getBegin(), features
                 .get(0).getEnd());
         seqCanvas.highlightSearchResults(highlight);
-      }
-      if (features != null && features.size() > 0)
-      {
-        seqCanvas.getFeatureRenderer().amendFeatures(
-                new SequenceI[] { sequence },
-                features.toArray(new SequenceFeature[features.size()]),
-                false, ap);
 
+        /*
+         * open the Amend Features dialog; clear highlighting afterwards,
+         * whether changes were made or not
+         */
+        List<SequenceI> seqs = Collections.singletonList(sequence);
+        seqCanvas.getFeatureRenderer().amendFeatures(seqs, features, false,
+                ap, null);
         seqCanvas.highlightSearchResults(null);
       }
     }
@@ -1956,9 +1965,20 @@ public class SeqPanel extends JPanel implements MouseListener,
     // shared between viewports.
     boolean iSentTheSelection = (av == source || (source instanceof AlignViewport && ((AlignmentViewport) source)
             .getSequenceSetId().equals(av.getSequenceSetId())));
-    if (iSentTheSelection || !av.followSelection)
+
+    if (iSentTheSelection)
     {
-      return;
+      // respond to our own event by updating dependent dialogs
+      if (ap.getCalculationDialog() != null)
+      {
+        ap.getCalculationDialog().validateCalcTypes();
+      }
+
+      // process further ?
+      if (!av.followSelection)
+      {
+        return;
+      }
     }
 
     /*
@@ -2056,6 +2076,13 @@ public class SeqPanel extends JPanel implements MouseListener,
       PaintRefresher.Refresh(this, av.getSequenceSetId());
       // ap.paintAlignment(false);
     }
+
+    // lastly, update dependent dialogs
+    if (ap.getCalculationDialog() != null)
+    {
+      ap.getCalculationDialog().validateCalcTypes();
+    }
+
   }
 
   /**
@@ -2095,6 +2122,12 @@ public class SeqPanel extends JPanel implements MouseListener,
             av);
     av.setColumnSelection(cs);
 
+    // lastly, update any dependent dialogs
+    if (ap.getCalculationDialog() != null)
+    {
+      ap.getCalculationDialog().validateCalcTypes();
+    }
+
     PaintRefresher.Refresh(this, av.getSequenceSetId());
 
     return true;