JAL-360 JAL-3975 make AlignFrame the parent of FeatureEditor dialog, and have parent...
authorBen Soares <b.soares@dundee.ac.uk>
Tue, 15 Mar 2022 17:13:01 +0000 (17:13 +0000)
committerJim Procter <j.procter@dundee.ac.uk>
Wed, 30 Mar 2022 15:27:00 +0000 (16:27 +0100)
src/jalview/gui/FeatureEditor.java
src/jalview/gui/JvOptionPane.java

index 721c798..844eee4 100644 (file)
  */
 package jalview.gui;
 
-import jalview.api.FeatureColourI;
-import jalview.datamodel.SearchResults;
-import jalview.datamodel.SearchResultsI;
-import jalview.datamodel.SequenceFeature;
-import jalview.datamodel.SequenceI;
-import jalview.gui.JalviewColourChooser.ColourChooserListener;
-import jalview.io.FeaturesFile;
-import jalview.schemes.FeatureColour;
-import jalview.util.ColorUtils;
-import jalview.util.MessageManager;
-
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Dimension;
@@ -59,6 +48,17 @@ import javax.swing.event.ChangeListener;
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
 
+import jalview.api.FeatureColourI;
+import jalview.datamodel.SearchResults;
+import jalview.datamodel.SearchResultsI;
+import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceI;
+import jalview.gui.JalviewColourChooser.ColourChooserListener;
+import jalview.io.FeaturesFile;
+import jalview.schemes.FeatureColour;
+import jalview.util.ColorUtils;
+import jalview.util.MessageManager;
+
 /**
  * Provides a dialog allowing the user to add new features, or amend or delete
  * existing features
@@ -434,7 +434,7 @@ public class FeatureEditor
      * set dialog action handlers for OK (create/Amend) and Cancel options
      * also for Delete if applicable (when amending features)
      */
-    JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.desktop)
+    JvOptionPane dialog = JvOptionPane.newOptionDialog(ap.alignFrame)
             .setResponseHandler(0, okAction)
             .setResponseHandler(2, cancelAction);
     if (!forCreate)
@@ -504,6 +504,7 @@ public class FeatureEditor
     {
       boolean useLastDefaults = features.get(0).getType() == null;
 
+      @Override
       public void run()
       {
         final String enteredType = name.getText().trim();
@@ -560,6 +561,7 @@ public class FeatureEditor
   {
     Runnable deleteAction = new Runnable()
     {
+      @Override
       public void run()
       {
         SequenceFeature sf = features.get(featureIndex);
@@ -668,6 +670,7 @@ public class FeatureEditor
 
       String featureGroup = group.getText();
 
+      @Override
       public void run()
       {
         final String enteredType = name.getText().trim();
index 22396fb..733223d 100644 (file)
@@ -21,9 +21,6 @@
 
 package jalview.gui;
 
-import jalview.util.Platform;
-import jalview.util.dialogrunner.DialogRunnerI;
-
 import java.awt.Component;
 import java.awt.HeadlessException;
 import java.beans.PropertyChangeEvent;
@@ -37,6 +34,9 @@ import javax.swing.Icon;
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 
+import jalview.util.Platform;
+import jalview.util.dialogrunner.DialogRunnerI;
+
 public class JvOptionPane extends JOptionPane
         implements DialogRunnerI, PropertyChangeListener
 {
@@ -874,6 +874,7 @@ public class JvOptionPane extends JOptionPane
     if (action != null)
     {
       action.run();
+      parentComponent.requestFocus();
     }
   }
 }