JAl-3187 JAL-3535 JAL-3534 update open feature settings when a different view is...
authorJim Procter <jprocter@issues.jalview.org>
Tue, 18 Feb 2020 16:32:31 +0000 (16:32 +0000)
committerJim Procter <jprocter@issues.jalview.org>
Tue, 18 Feb 2020 17:33:37 +0000 (17:33 +0000)
src/jalview/api/SplitContainerI.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/Desktop.java
src/jalview/gui/FeatureSettings.java
src/jalview/gui/SplitFrame.java

index d68aa36..6b037f5 100644 (file)
@@ -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();
+
 }
index 5413c4b..0297a74 100644 (file)
@@ -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();
+        }
+      }
+
     }
 
     /*
index 22280ed..ed9ed50 100644 (file)
@@ -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();
+    }
 
   }
 
index 2fbbdf2..82f6acf 100644 (file)
@@ -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
index 5117e3d..dca77bf 100644 (file)
@@ -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