From 0e8bd9f4db76c85561be7e65f1e987c2d78b4fd6 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Tue, 15 Mar 2022 17:13:01 +0000 Subject: [PATCH] JAL-360 JAL-3975 make AlignFrame the parent of FeatureEditor dialog, and have parent Component request focus after JvOptionPane action. --- src/jalview/gui/FeatureEditor.java | 27 +++++++++++++++------------ src/jalview/gui/JvOptionPane.java | 7 ++++--- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/jalview/gui/FeatureEditor.java b/src/jalview/gui/FeatureEditor.java index 721c798..844eee4 100644 --- a/src/jalview/gui/FeatureEditor.java +++ b/src/jalview/gui/FeatureEditor.java @@ -20,17 +20,6 @@ */ 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(); diff --git a/src/jalview/gui/JvOptionPane.java b/src/jalview/gui/JvOptionPane.java index 22396fb..733223d 100644 --- a/src/jalview/gui/JvOptionPane.java +++ b/src/jalview/gui/JvOptionPane.java @@ -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(); } } } -- 1.7.10.2