JAL-1632 one PCA/Tree per panel, closed when panel is closed
[jalview.git] / src / jalview / gui / CalculationChooser.java
index d3b7cfc..7b3bf22 100644 (file)
@@ -50,6 +50,8 @@ import javax.swing.JLabel;
 import javax.swing.JLayeredPane;
 import javax.swing.JPanel;
 import javax.swing.JRadioButton;
+import javax.swing.event.InternalFrameAdapter;
+import javax.swing.event.InternalFrameEvent;
 
 /**
  * A dialog where a user can choose and action Tree or PCA calculation options
@@ -99,6 +101,7 @@ public class CalculationChooser extends JPanel
   {
     this.af = alignFrame;
     init();
+    af.alignPanel.setCalculationDialog(this);
   }
 
   /**
@@ -221,10 +224,28 @@ public class CalculationChooser extends JPanel
 
     int width = 350;
     int height = includeParams ? 400 : 220;
+    String title = MessageManager.getString("label.choose_calculation");
+    if (af.getViewport().viewName != null)
+    {
+      title = title + " (" + af.getViewport().viewName + ")";
+    }
+
     Desktop.addInternalFrame(frame,
-            MessageManager.getString("label.choose_calculation"), width,
+            title, width,
             height, false);
 
+    /*
+     * null the AlignmentPanel's reference to the dialog when it is closed
+     */
+    frame.addInternalFrameListener(new InternalFrameAdapter()
+    {
+      @Override
+      public void internalFrameClosed(InternalFrameEvent evt)
+      {
+        af.alignPanel.setCalculationDialog(null);
+      };
+    });
+
     frame.setLayer(JLayeredPane.PALETTE_LAYER);
   }