From 1b378087ec2d5be9b290cd63c45bfdb9e75269fb Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 18 Feb 2020 16:32:31 +0000 Subject: [PATCH] JAl-3187 JAL-3535 JAL-3534 update open feature settings when a different view is selected or close when none shown --- src/jalview/api/SplitContainerI.java | 6 ++++++ src/jalview/gui/AlignFrame.java | 15 +++++++++++++++ src/jalview/gui/Desktop.java | 20 ++++++++++++++++++-- src/jalview/gui/FeatureSettings.java | 9 +++++++++ src/jalview/gui/SplitFrame.java | 6 ++++++ 5 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/jalview/api/SplitContainerI.java b/src/jalview/api/SplitContainerI.java index d68aa36..6b037f5 100644 --- a/src/jalview/api/SplitContainerI.java +++ b/src/jalview/api/SplitContainerI.java @@ -87,4 +87,10 @@ public interface SplitContainerI void closeFeatureSettings(FeatureSettingsControllerI featureSettings, boolean closeContainingFrame); + /** + * + * @return true if a feature settings panel is currently open + */ + boolean isFeatureSettingsOpen(); + } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 5413c4b..0297a74 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -4746,6 +4746,21 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, viewport = alignPanel.av; avc.setViewportAndAlignmentPanel(viewport, alignPanel); setMenusFromViewport(viewport); + if (featureSettings != null && featureSettings.isOpen() + && featureSettings.fr.getViewport() != viewport) + { + if (viewport.isShowSequenceFeatures()) + { + // refresh the featureSettings to reflect UI change + showFeatureSettingsUI(); + } + else + { + // close feature settings for this view. + featureSettings.close(); + } + } + } /* diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 22280ed..ed9ed50 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -1935,7 +1935,9 @@ public class Desktop extends jalview.jbgui.GDesktop // transfer reference for existing feature settings to new alignFrame if (ap == af.alignPanel) { - newaf.featureSettings = viewFeatureSettings; + newaf.featureSettings = (viewFeatureSettings.fr.ap == ap) + ? viewFeatureSettings + : null; newaf.setFeatureSettingsGeometry(fsBounds); } @@ -1954,6 +1956,14 @@ public class Desktop extends jalview.jbgui.GDesktop addInternalFrame(newaf, af.getTitle(), AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); + // and materialise a new feature settings dialog instance for the new alignframe + // (closes the old as if 'OK' was pressed) + if (ap == af.alignPanel && newaf.featureSettings != null + && newaf.featureSettings.isOpen() + && af.alignPanel.getAlignViewport().isShowSequenceFeatures()) + { + newaf.showFeatureSettingsUI(); + } } af.alignPanels.clear(); @@ -1995,7 +2005,7 @@ public class Desktop extends jalview.jbgui.GDesktop if (gatherThis) { - if (af.featureSettings != null) + if (af.featureSettings != null && af.featureSettings.isOpen()) { if (source.featureSettings == null) { @@ -2015,6 +2025,12 @@ public class Desktop extends jalview.jbgui.GDesktop } } } + // refresh the feature setting UI for the source frame if it exists + if (source.featureSettings != null + && source.featureSettings.isOpen()) + { + source.showFeatureSettingsUI(); + } } diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index 2fbbdf2..82f6acf 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -2005,6 +2005,15 @@ public class FeatureSettings extends JPanel return button; } } + + public boolean isOpen() + { + if (af.getSplitViewContainer() != null) + { + return af.getSplitViewContainer().isFeatureSettingsOpen(); + } + return frame != null && !frame.isClosed(); + } } class FeatureIcon implements Icon diff --git a/src/jalview/gui/SplitFrame.java b/src/jalview/gui/SplitFrame.java index 5117e3d..dca77bf 100644 --- a/src/jalview/gui/SplitFrame.java +++ b/src/jalview/gui/SplitFrame.java @@ -1038,4 +1038,10 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI } } } + + @Override + public boolean isFeatureSettingsOpen() + { + return featureSettingsUI != null && !featureSettingsUI.isClosed(); + } } \ No newline at end of file -- 1.7.10.2