JAL-1619 update applet.currentAlignFrame on any menu action (fixes Find
[jalview.git] / src / jalview / appletgui / AlignFrame.java
index 478aa09..b490eb6 100644 (file)
@@ -26,6 +26,7 @@ import jalview.api.AlignViewControllerGuiI;
 import jalview.api.AlignViewControllerI;
 import jalview.api.AlignViewportI;
 import jalview.api.FeatureRenderer;
+import jalview.api.FeatureSettingsControllerI;
 import jalview.api.SequenceStructureBinding;
 import jalview.bin.JalviewLite;
 import jalview.commands.CommandI;
@@ -59,7 +60,6 @@ import jalview.schemes.NucleotideColourScheme;
 import jalview.schemes.PIDColourScheme;
 import jalview.schemes.PurinePyrimidineColourScheme;
 import jalview.schemes.RNAHelicesColourChooser;
-import jalview.schemes.RNAInteractionColourScheme;
 import jalview.schemes.StrandColourScheme;
 import jalview.schemes.TCoffeeColourScheme;
 import jalview.schemes.TaylorColourScheme;
@@ -105,6 +105,8 @@ import java.util.Map;
 import java.util.StringTokenizer;
 import java.util.Vector;
 
+import org.jmol.viewer.Viewer;
+
 public class AlignFrame extends EmbmenuFrame implements ActionListener,
         ItemListener, KeyListener, AlignViewControllerGuiI
 {
@@ -156,6 +158,20 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   public AlignFrame(AlignmentI al, JalviewLite applet,
           String title, boolean embedded, boolean addToDisplay)
   {
+    this(al, null, null, applet, title, embedded, addToDisplay);
+  }
+
+  public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs,
+          ColumnSelection columnSelection, JalviewLite applet,
+          String title, boolean embedded)
+  {
+    this(al, hiddenSeqs, columnSelection, applet, title, embedded, true);
+  }
+
+  public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs,
+          ColumnSelection columnSelection, JalviewLite applet,
+          String title, boolean embedded, boolean addToDisplay)
+  {
     if (applet != null)
     {
       jalviewServletURL = applet.getParameter("APPLICATION_URL");
@@ -191,6 +207,16 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       }
     }
     viewport = new AlignViewport(al, applet);
+
+    if (hiddenSeqs != null && hiddenSeqs.length > 0)
+    {
+      viewport.hideSequence(hiddenSeqs);
+    }
+    if (columnSelection != null)
+    {
+      viewport.setColumnSelection(columnSelection);
+    }
+
     alignPanel = new AlignmentPanel(this, viewport);
     avc = new jalview.controller.AlignViewController(this, viewport,
             alignPanel);
@@ -902,7 +928,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
               : showForSequences);
         aa.visible = visible;
     }
-    alignPanel.validateAnnotationDimensions(false);
+    alignPanel.validateAnnotationDimensions(true);
+    validate();
+    repaint();
   }
 
   private void setAnnotationSortOrder(SequenceAnnotationOrder order)
@@ -941,6 +969,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   @Override
   public void actionPerformed(ActionEvent evt)
   {
+    viewport.applet.currentAlignFrame = this;
+
     Object source = evt.getSource();
 
     if (source == inputText)
@@ -1201,10 +1231,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     {
       changeColour(new PurinePyrimidineColourScheme());
     }
-    else if (source == RNAInteractionColour)
-    {
-      changeColour(new RNAInteractionColourScheme());
-    }
+    // else if (source == RNAInteractionColour)
+    // {
+    // changeColour(new RNAInteractionColourScheme());
+    // }
     else if (source == RNAHelixColour)
     {
       new RNAHelicesColourChooser(viewport, alignPanel);
@@ -1313,7 +1343,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage(
             "label.alignment_output_command", new Object[]
             { e.getActionCommand() }), 600, 500);
-    cap.setText(new AppletFormatAdapter().formatSequences(
+
+    FeatureRenderer fr = this.alignPanel.cloneFeatureRenderer();
+    cap.setText(new AppletFormatAdapter(alignPanel).formatSequences(
             e.getActionCommand(), viewport.getAlignment(),
             viewport.getShowJVSuffix()));
   }
@@ -2544,7 +2576,6 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 
   public void changeColour(ColourSchemeI cs)
   {
-    int threshold = 0;
 
     if (cs != null)
     {
@@ -2567,15 +2598,6 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     }
     viewport.setGlobalColourScheme(cs);
 
-    if (alignPanel.getOverviewPanel() != null)
-    {
-      alignPanel.getOverviewPanel().updateOverviewImage();
-    }
-
-    jalview.structure.StructureSelectionManager
-            .getStructureSelectionManager(viewport.applet)
-            .sequenceColoursChanged(alignPanel);
-
     alignPanel.paintAlignment(true);
   }
 
@@ -2971,10 +2993,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
           MessageManager.getString("label.load_features_annotations"));
 
   MenuItem outputFeatures = new MenuItem(
-          MessageManager.getString("label.export_features").concat("..."));
+          MessageManager.getString("label.export_features"));
 
   MenuItem outputAnnotations = new MenuItem(
-          MessageManager.getString("label.export_annotations").concat("..."));
+          MessageManager.getString("label.export_annotations"));
 
   MenuItem closeMenuItem = new MenuItem(
           MessageManager.getString("action.close"));
@@ -3040,7 +3062,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 
   MenuItem purinePyrimidineColour = new MenuItem();
 
-  MenuItem RNAInteractionColour = new MenuItem();
+  // MenuItem RNAInteractionColour = new MenuItem();
 
   MenuItem RNAHelixColour = new MenuItem();
 
@@ -3223,8 +3245,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     removeAllGapsMenuItem.setLabel(MessageManager
             .getString("action.remove_all_gaps"));
     removeAllGapsMenuItem.addActionListener(this);
-    removeRedundancyMenuItem.setLabel(MessageManager.getString(
-            "action.remove_redundancy").concat("..."));
+    removeRedundancyMenuItem.setLabel(MessageManager
+            .getString("action.remove_redundancy"));
     removeRedundancyMenuItem.addActionListener(this);
 
     /*
@@ -3248,7 +3270,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     grpsFromSelection.addActionListener(this);
     createGroup.setLabel(MessageManager.getString("action.create_group"));
     unGroup.setLabel(MessageManager.getString("action.remove_group"));
-    annotationColumnSelection.setLabel("Select by Annotation");
+    annotationColumnSelection.setLabel(MessageManager
+            .getString("action.select_by_annotation"));
     annotationColumnSelection.addActionListener(this);
 
     /*
@@ -3278,7 +3301,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     hideAllSelection.addActionListener(this);
     showAllHidden.addActionListener(this);
     featureSettings.setLabel(MessageManager
-            .getString("label.feature_settings"));
+            .getString("action.feature_settings"));
     featureSettings.addActionListener(this);
     sequenceFeatures.setLabel(MessageManager
             .getString("label.show_sequence_features"));
@@ -3410,9 +3433,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     purinePyrimidineColour.setLabel(MessageManager
             .getString("label.purine_pyrimidine"));
     purinePyrimidineColour.addActionListener(this);
-    RNAInteractionColour.setLabel(MessageManager
-            .getString("label.rna_interaction"));
-    RNAInteractionColour.addActionListener(this);
+    // RNAInteractionColour.setLabel(MessageManager
+    // .getString("label.rna_interaction"));
+    // RNAInteractionColour.addActionListener(this);
     RNAHelixColour.setLabel(MessageManager
             .getString("action.by_rna_helixes"));
     RNAHelixColour.addActionListener(this);
@@ -3843,10 +3866,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   public SequenceStructureBinding addStructureViewInstance(
           Object jmolviewer, String[] sequenceIds)
   {
-    org.jmol.api.JmolViewer viewer = null;
+    Viewer viewer = null;
     try
     {
-      viewer = (org.jmol.api.JmolViewer) jmolviewer;
+      viewer = (Viewer) jmolviewer;
     } catch (ClassCastException ex)
     {
       System.err.println("Unsupported viewer object :"
@@ -3919,7 +3942,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     boolean needtoadd = false;
     if (toaddpdb != null)
     {
-      Vector pdbe = toaddpdb.getPDBId();
+      Vector pdbe = toaddpdb.getAllPDBEntries();
       PDBEntry pdbentry = null;
       if (pdbe != null && pdbe.size() > 0)
       {
@@ -4179,6 +4202,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     this.splitFrame = sf;
   }
 
+    // may not need this
   @Override
   public void setShowSeqFeatures(boolean b)
   {
@@ -4193,4 +4217,20 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     // setMenusFromViewport(viewport);
 
   }
+  @Override
+  public void refreshFeatureUI(boolean enableIfNecessary)
+  {
+    if (enableIfNecessary)
+    {
+      sequenceFeatures.setState(true);
+      alignPanel.av.setShowSequenceFeatures(true);
+    }
+  }
+
+  @Override
+  public FeatureSettingsControllerI getFeatureSettingsUI()
+  {
+    return alignPanel.av.featureSettings;
+  }
+
 }