JAL-2805 removed unused Aptx instance creation code
[jalview.git] / src / jalview / ext / archaeopteryx / AptxInit.java
index fe5f16e..9b89cea 100644 (file)
@@ -1,35 +1,25 @@
 package jalview.ext.archaeopteryx;
 
-import jalview.analysis.TreeBuilder;
-import jalview.datamodel.SequenceI;
-import jalview.ext.treeviewer.ExternalTreeBuilderI;
-import jalview.ext.treeviewer.ExternalTreeViewerBindingI;
+import jalview.ext.forester.io.UtilityMethods;
+import jalview.ext.treeviewer.LoadedTreeAssociationI;
+import jalview.ext.treeviewer.LoadedTreeSequenceAssociation;
+import jalview.ext.treeviewer.TreeFrameI;
+import jalview.ext.treeviewer.TreeI;
+import jalview.ext.treeviewer.TreeViewerUtils;
 import jalview.gui.Desktop;
 import jalview.gui.JvOptionPane;
 import jalview.util.MessageManager;
 import jalview.viewmodel.AlignmentViewport;
 
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
-import javax.swing.JSeparator;
 
 import org.forester.archaeopteryx.AptxUtil;
-import org.forester.archaeopteryx.Archaeopteryx;
 import org.forester.archaeopteryx.Configuration;
-import org.forester.archaeopteryx.MainFrame;
 import org.forester.archaeopteryx.webservices.PhylogeniesWebserviceClient;
 import org.forester.archaeopteryx.webservices.WebserviceUtil;
 import org.forester.io.parsers.PhylogenyParser;
@@ -41,7 +31,6 @@ import org.forester.io.parsers.tol.TolParser;
 import org.forester.io.parsers.util.ParserUtils;
 import org.forester.phylogeny.Phylogeny;
 import org.forester.phylogeny.PhylogenyMethods;
-import org.forester.phylogeny.PhylogenyNode;
 import org.forester.phylogeny.data.Identifier;
 import org.forester.util.ForesterUtil;
 
@@ -54,9 +43,19 @@ import org.forester.util.ForesterUtil;
  */
 public final class AptxInit
 {
-  private final static Configuration APTX_CONFIG = new Configuration(
-          "_aptx_jalview_configuration_file",
-            false, false, false);
+  public final static InputStream CONFIG_LOC = AptxInit.class
+
+          .getResourceAsStream("/_aptx_jalview_configuration_file.txt");
+
+  public final static Configuration APTX_CONFIG = new Configuration(
+          CONFIG_LOC,
+          false, false);
+  // static
+  // {
+  // APTX_CONFIG.setBaseFontFamilyName(
+  // Desktop.instance.getFont().getFamily().replaceAll(" ", "_"));
+  // APTX_CONFIG.setBaseFontSize(Desktop.instance.getFont().getSize());
+  // }
 
   private final static boolean VALIDATE_PHYLOXML_XSD = APTX_CONFIG
           .isValidatePhyloXmlAgainstSchema();
@@ -73,22 +72,30 @@ public final class AptxInit
   private final static NHXParser.TAXONOMY_EXTRACTION TAXONOMY_EXTRACTION = APTX_CONFIG
           .getTaxonomyExtraction();
 
-  private static Map<MainFrame, JalviewBinding> activeAptx = new HashMap<>();
 
+  public static TreeFrameI createInstanceFromNhx(String treeTitle,
+          String nhxString, AlignmentViewport viewport)
+          throws IOException
+  {
+    if (Desktop.instance != null)
+    {
+      Desktop.instance.startLoading(treeTitle);
+    }
 
+    Phylogeny aptxPhylogeny = Phylogeny
+            .createInstanceFromNhxString(nhxString);
+    aptxPhylogeny.setName(treeTitle);
 
-  public static MainFrame createInstanceFromCalculation(
-          final TreeBuilder calculatedTree)
-  {
-    ExternalTreeBuilderI<Phylogeny, PhylogenyNode> aptxTreeBuilder = new AptxTreeBuilder(
-            calculatedTree);
+    TreeFrameI aptxFrame = createAptxFrame(aptxPhylogeny, viewport,
+            treeTitle);
 
-    Phylogeny aptxTree = aptxTreeBuilder.buildTree();
+    if (Desktop.instance != null)
+    {
+      Desktop.instance.stopLoading();
+    }
+
+    return aptxFrame;
 
-    MainFrame aptxApp = createAptxFrame(aptxTree,
-            calculatedTree.getAvport(), null);
-            
-    return aptxApp;
   }
 
   /**
@@ -100,77 +107,85 @@ public final class AptxInit
    * @throws IOException
    * @throws FileNotFoundException
    */
-  public static MainFrame[] createInstancesFromFile(String filePath,
+  public static TreeFrameI[] createInstancesFromFile(File treeFile,
           AlignmentViewport viewport)
           throws FileNotFoundException, IOException
   {
-    File treeFile = new File(filePath);
-    final String err = ForesterUtil.isReadableFile(treeFile);
-    if (!ForesterUtil.isEmpty(err))
+    TreeFrameI[] aptxFrames = null;
+    if (UtilityMethods.canForesterReadFile(treeFile))
     {
-      JvOptionPane.showMessageDialog(Desktop.desktop, err,
-              MessageManager.getString("label.problem_reading_tree_file"),
-              JvOptionPane.WARNING_MESSAGE);
-    }
 
-    if (Desktop.instance != null)
-    {
-      Desktop.instance.startLoading(filePath);
-    }
-    boolean nhx_or_nexus = false;
-    final PhylogenyParser parser = ParserUtils.createParserDependingOnFileType(
-            treeFile, VALIDATE_PHYLOXML_XSD);
-    if (parser instanceof NHXParser)
-    {
-      nhx_or_nexus = true;
-      final NHXParser nhx = (NHXParser) parser;
-      nhx.setReplaceUnderscores(REPLACE_NHX_UNDERSCORES);
-      nhx.setIgnoreQuotes(false);
-      nhx.setTaxonomyExtraction(TAXONOMY_EXTRACTION);
-    }
-    else if (parser instanceof NexusPhylogeniesParser)
-    {
-      nhx_or_nexus = true;
-      final NexusPhylogeniesParser nex = (NexusPhylogeniesParser) parser;
-      nex.setReplaceUnderscores(REPLACE_NHX_UNDERSCORES);
-      nex.setIgnoreQuotes(false);
-    }
-    else if (parser instanceof PhyloXmlParser)
-    {
-      if (VALIDATE_PHYLOXML_XSD == false)
+      if (Desktop.instance != null)
       {
-        JvOptionPane.showInternalMessageDialog(Desktop.desktop,
-                MessageManager.getString("error.phyloxml_validation"),
-                MessageManager.getString("label.file_open_error"),
-                                       JvOptionPane.WARNING_MESSAGE );
+        Desktop.instance.startLoading(treeFile.getCanonicalPath());
       }
-    }
-    Phylogeny[] trees = PhylogenyMethods.readPhylogenies(parser, treeFile);
-    MainFrame[] aptxFrames = new MainFrame[trees.length];
-
+      boolean nhx_or_nexus = false;
+      final PhylogenyParser parser = ParserUtils
+              .createParserDependingOnFileType(treeFile,
+                      VALIDATE_PHYLOXML_XSD);
+      if (parser instanceof NHXParser)
+      {
+        nhx_or_nexus = true;
+        final NHXParser nhx = (NHXParser) parser;
+        nhx.setReplaceUnderscores(REPLACE_NHX_UNDERSCORES);
+        nhx.setIgnoreQuotes(false);
+        nhx.setTaxonomyExtraction(TAXONOMY_EXTRACTION);
+      }
+      else if (parser instanceof NexusPhylogeniesParser)
+      {
+        nhx_or_nexus = true;
+        final NexusPhylogeniesParser nex = (NexusPhylogeniesParser) parser;
+        nex.setReplaceUnderscores(REPLACE_NHX_UNDERSCORES);
+        nex.setIgnoreQuotes(false);
+      }
+      else if (parser instanceof PhyloXmlParser)
+      {
+        if (VALIDATE_PHYLOXML_XSD == false)
+        {
+          JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+                  MessageManager.getString("error.phyloxml_validation"),
+                  MessageManager.getString("label.file_open_error"),
+                  JvOptionPane.WARNING_MESSAGE);
+        }
+      }
+      Phylogeny[] trees = PhylogenyMethods.readPhylogenies(parser,
+              treeFile);
+      aptxFrames = new TreeFrameI[trees.length];
 
-    for (int i = 0; i < trees.length; i++)
+      for (int i = 0; i < trees.length; i++)
       {
-      Phylogeny tree = trees[i];
+        Phylogeny aptxPhylogeny = trees[i];
 
-      if (nhx_or_nexus && INTERNAL_NUMBERS_AS_CONFIDENCE)
+        if (nhx_or_nexus && INTERNAL_NUMBERS_AS_CONFIDENCE)
+        {
+          PhylogenyMethods
+                  .transferInternalNodeNamesToConfidence(aptxPhylogeny, "");
+        }
+        String treeTitle = treeFile.getName() + "[" + i + "]";
+        aptxPhylogeny.setName(treeTitle);
+        aptxFrames[i] = createAptxFrame(aptxPhylogeny, viewport, treeTitle);
+
+      }
+      if (Desktop.instance != null)
       {
-        PhylogenyMethods.transferInternalNodeNamesToConfidence(tree, "");
+        Desktop.instance.stopLoading();
       }
-      String treeTitle = treeFile.getName() + "[" + i + "]";
-      tree.setName(treeTitle);
-      aptxFrames[i] = createAptxFrame(tree, viewport, treeTitle);
-
-    }
-    if (Desktop.instance != null)
-    {
-      Desktop.instance.stopLoading();
     }
     return aptxFrames;
-    }
+  }
 
 
-  public static MainFrame[] createInstancesFromUrl(URL treeUrl,
+  public static TreeFrameI[] createInstancesFromFile(
+          String filePath,
+          AlignmentViewport viewport)
+          throws FileNotFoundException, IOException
+  {
+    File treeFile = new File(filePath);
+    return createInstancesFromFile(treeFile, viewport);
+
+    }
+
+  public static TreeFrameI[] createInstancesFromUrl(URL treeUrl,
           AlignmentViewport viewport)
           throws FileNotFoundException, IOException, RuntimeException
   {
@@ -185,11 +200,11 @@ public final class AptxInit
              REPLACE_NHX_UNDERSCORES, INTERNAL_NUMBERS_AS_CONFIDENCE,
             TAXONOMY_EXTRACTION, MIDPOINT_REROOT);
 
-    MainFrame[] aptxFrames = new MainFrame[trees.length];
+    TreeFrameI[] aptxFrames = new TreeFrameI[trees.length];
     for (int i = 0; i < trees.length; i++)
     {
-      Phylogeny tree = trees[i];
-      aptxFrames[i] = createAptxFrame(tree, viewport, treeTitle);
+      Phylogeny aptxTree = trees[i];
+      aptxFrames[i] = createAptxFrame(aptxTree, viewport, treeTitle);
     }
 
     if (Desktop.instance != null)
@@ -208,13 +223,14 @@ public final class AptxInit
    * @param viewport
    * @return
    */
-  public static MainFrame[] createInstancesFromDb(
+  public static TreeFrameI[] createInstancesFromDb(
           PhylogeniesWebserviceClient treeDbClient, String identifier,
           AlignmentViewport viewport)
   {
 
     URL url = null;
     Phylogeny[] trees = null;
+    TreeFrameI[] aptxFrames = null;
 
     if ((identifier != null) && (identifier.trim().length() > 0))
     {
@@ -240,7 +256,7 @@ public final class AptxInit
                           { identifier }),
                   MessageManager.getString("label.invalid_url"),
                   JvOptionPane.ERROR_MESSAGE);
-          return new MainFrame[0];
+          return new TreeFrameI[0];
         }
         identifier = id + "";
       }
@@ -318,6 +334,7 @@ public final class AptxInit
         // _main_frame.getMainPanel().setWaitCursor();
         // }
         trees = ForesterUtil.readPhylogeniesFromUrl(url, parser);
+        aptxFrames = new TreeFrameI[trees.length];
       } catch (final MalformedURLException e)
       {
         exception = true;
@@ -359,20 +376,22 @@ public final class AptxInit
       }
       if ((trees != null) && (trees.length > 0))
       {
-        for (final Phylogeny phylogeny : trees)
+        int i = 0;
+        for (final Phylogeny aptxTree : trees)
         {
-          if (!phylogeny.isEmpty())
+          if (!aptxTree.isEmpty())
           {
             if (treeDbClient.getName().equals(WebserviceUtil.TREE_FAM_NAME))
             {
-              phylogeny.setRerootable(false);
-              phylogeny.setRooted(true);
+              aptxTree.setRerootable(false);
+              aptxTree.setRooted(true);
             }
             if (treeDbClient.getProcessingInstructions() != null)
             {
               try
               {
-                WebserviceUtil.processInstructions(treeDbClient, phylogeny);
+                WebserviceUtil.processInstructions(treeDbClient,
+                        aptxTree);
               } catch (final PhyloXmlDataFormatException e)
               {
                 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
@@ -384,7 +403,7 @@ public final class AptxInit
             {
               try
               {
-                PhylogenyMethods.transferNodeNameToField(phylogeny,
+                PhylogenyMethods.transferNodeNameToField(aptxTree,
                         treeDbClient.getNodeField(), false);
               } catch (final PhyloXmlDataFormatException e)
               {
@@ -393,44 +412,47 @@ public final class AptxInit
                         JvOptionPane.ERROR_MESSAGE);
               }
             }
-            phylogeny.setIdentifier(
+            aptxTree.setIdentifier(
                     new Identifier(identifier, treeDbClient.getName()));
             // _main_frame.getJMenuBar().remove(_main_frame.getHelpMenu());
-            // _main_frame.getMenuBarOfMainFrame()
+            // _main_frame.getMenuBarOfExternalTreeFrameI()
             // .add(_main_frame.getHelpMenu());
-            // _main_frame.getMainPanel().addPhylogenyInNewTab(phylogeny,
+            // _main_frame.getMainPanel().addExternalTreeIInNewTab(ExternalTreeI,
             // _main_frame.getConfiguration(),
             // new File(url.getFile()).getName(), url.toString());
 
-            MainFrame aptxApp = createAptxFrame(phylogeny, viewport,
+
+            TreeFrameI aptxApp = createAptxFrame(aptxTree,
+                    viewport,
                     url.getFile());
             String my_name_for_file = "";
-            if (!ForesterUtil.isEmpty(phylogeny.getName()))
+            if (!ForesterUtil.isEmpty(aptxTree.getName()))
             {
-              my_name_for_file = new String(phylogeny.getName())
+              my_name_for_file = new String(aptxTree.getName())
                       .replaceAll(" ", "_");
             }
-            else if (phylogeny.getIdentifier() != null)
+            else if (aptxTree.getIdentifier() != null)
             {
               final StringBuffer sb = new StringBuffer();
               if (!ForesterUtil
-                      .isEmpty(phylogeny.getIdentifier().getProvider()))
+                      .isEmpty(aptxTree.getIdentifier().getProvider()))
               {
-                sb.append(phylogeny.getIdentifier().getProvider());
+                sb.append(aptxTree.getIdentifier().getProvider());
                 sb.append("_");
               }
-              sb.append(phylogeny.getIdentifier().getValue());
+              sb.append(aptxTree.getIdentifier().getValue());
               my_name_for_file = new String(
                       sb.toString().replaceAll(" ", "_"));
             }
-            aptxApp.getMainPanel().getCurrentTreePanel()
+            aptxApp.getTreePanel()
                     .setTreeFile(new File(my_name_for_file));
-            AptxUtil.lookAtSomeTreePropertiesForAptxControlSettings(
-                    phylogeny, aptxApp.getMainPanel().getControlPanel(),
-                    APTX_CONFIG);
-            // _main_frame.getMainPanel().getControlPanel().showWhole();
+            // AptxUtil.lookAtSomeTreePropertiesForAptxControlSettings(
+            // aptxTree, aptxApp.getMainPanel().getControlPanel(),
+            // APTX_CONFIG);
+            aptxApp.getTreeControls().displayEntireTree();
 
-            aptxApp.activateSaveAllIfNeeded();
+            aptxApp.checkMultipleTrees();
+            aptxFrames[i++] = aptxApp;
           }
         }
       }
@@ -454,196 +476,86 @@ public final class AptxInit
         {
           // Not important if this fails, do nothing.
         }
-        // _main_frame.getContentPane().repaint();
       }
     }
 
-    System.gc();
-
 
     if (Desktop.instance != null)
     {
       Desktop.instance.stopLoading();
     }
-    return null;
+    return aptxFrames;
 
 
   }
 
 
 
-
-
-  public static MainFrame createAptxFrame(
-          final Phylogeny aptxTree,
-          final AlignmentViewport jalviewAlignport, String treeTitle)
+  public static TreeFrameI createAptxFrame(TreeI aptxTree,
+          AlignmentViewport jalviewAlignport, String treeTitle)
   {
-    if (APTX_CONFIG == null || APTX_CONFIG.isCouldReadConfigFile() == false)
-    {
-      int keepGoing = JvOptionPane.showConfirmDialog(Desktop.desktop,
-              MessageManager.getString("label.aptx_config_not_found"),
-              MessageManager.formatMessage("label.couldnt_locate",
-                      new String[]
-                      { "_aptx_jalview_configuration_file" }),
-              JvOptionPane.YES_NO_CANCEL_OPTION);
-
-      if (keepGoing == JvOptionPane.CANCEL_OPTION
-              || keepGoing == JvOptionPane.CLOSED_OPTION
-              || keepGoing == JvOptionPane.NO_OPTION)
-      {
-        return null;
-      }
-
-    }
-    MainFrame aptxApp = Archaeopteryx.createApplication(aptxTree,
-            APTX_CONFIG, treeTitle);
-
-
-    LoadedTreeSequenceAssociation bindAptxNodes = new LoadedTreeSequenceAssociation(
-            jalviewAlignport.getAlignment().getSequencesArray(), aptxTree);
+    validateConfig(APTX_CONFIG);
+    TreeFrameI aptxApp = aptxTree
+            .createTreeViewerFromTree(treeTitle);
+    TreeI jalviewTree = aptxApp.getTree();
+    LoadedTreeAssociationI bindAptxNodes = new LoadedTreeSequenceAssociation(
+            jalviewAlignport.getAlignment().getSequencesArray(),
+            jalviewTree);
     bindAptxNodes.associateLeavesToSequences();
 
-    bindNodesToJalviewSequences(aptxApp, jalviewAlignport,
+    TreeViewerUtils.associateNodesWithJalviewSequences(aptxApp, jalviewAlignport,
             bindAptxNodes.getAlignmentWithNodes(),
             bindAptxNodes.getNodesWithAlignment());
-    bindTreeViewFrameToJalview(aptxApp);
+    TreeViewerUtils.addTreeViewFrameToJalview(aptxApp);
 
-    adaptAptxGui(aptxApp);
+    // adaptAptxGui(aptxApp); //moved to AptxFrame
     return aptxApp;
   }
 
 
-  public static ExternalTreeViewerBindingI<?> bindNodesToJalviewSequences(
-          final MainFrame aptxApp,
-          final AlignmentViewport jalviewAlignViewport,
-          final Map<SequenceI, PhylogenyNode> alignMappedToNodes,
-          final Map<PhylogenyNode, SequenceI> nodesMappedToAlign)
+  protected static TreeFrameI createAptxFrame(
+          final Phylogeny aptxTree,
+          final AlignmentViewport jalviewAlignport, String treeTitle)
   {
-    JalviewBinding treeBinding = new JalviewBinding(aptxApp,
-            jalviewAlignViewport,
-            alignMappedToNodes, nodesMappedToAlign);
-    activeAptx.put(aptxApp, treeBinding);
-    return treeBinding;
-  }
+    validateConfig(APTX_CONFIG);
+    TreeFrameI aptxApp = new AptxFrame(aptxTree, APTX_CONFIG,
+            treeTitle);
+    TreeI jalviewTree = aptxApp.getTree();
+    LoadedTreeAssociationI bindAptxNodes = new LoadedTreeSequenceAssociation(
+            jalviewAlignport.getAlignment().getSequencesArray(),
+            jalviewTree);
+    bindAptxNodes.associateLeavesToSequences();
 
+    TreeViewerUtils.associateNodesWithJalviewSequences(aptxApp, jalviewAlignport,
+            bindAptxNodes.getAlignmentWithNodes(),
+            bindAptxNodes.getNodesWithAlignment());
+    TreeViewerUtils.addTreeViewFrameToJalview(aptxApp);
 
-  public static MainFrame bindTreeViewFrameToJalview(
-          final MainFrame aptxApp)
-  {
-    int width = 400;
-    int height = 550;
-    aptxApp.setMinimumSize(new Dimension(width, height));
-    // aptxApp.setFont(Desktop.instance.getFont());
-    // aptxApp.getMainPanel().setFont(Desktop.instance.getFont());
-    String frameTitle = MessageManager.getString("label.aptx_title");
-    File treeFile = aptxApp.getMainPanel().getCurrentTreePanel()
-            .getTreeFile();
-    if (treeFile != null)
-    {
-      frameTitle += MessageManager.formatMessage("label.aptx_title_append",
-              new String[]
-              { treeFile.getAbsolutePath() });
-    }
-    Desktop.addInternalFrame(aptxApp, frameTitle, true, width, height, true,
-            true);
+    // adaptAptxGui(aptxApp); //moved to AptxFrame
     return aptxApp;
-
   }
 
-  /**
-   * Hides certain redundant Archaeopteryx GUI elements such as the menu items
-   * for reading in trees and adds extra items related to Jalview such as the
-   * tree sorting item.
-   * 
-   * 
-   * @param aptxFrame
-   */
-  private static void adaptAptxGui(MainFrame aptxFrame)
-  {
-    JMenuBar frameBar = aptxFrame.getJMenuBar();
-    boolean epsAdded = false;
-    for (int i = 0; i < frameBar.getMenuCount();i++) {
-      JMenu menu = frameBar.getMenu(i);
-      int menuCount = menu.getMenuComponentCount();
-
-      if (menu.getText().contains("File"))
-      {
-        // hide all "Read from ..." and "New" menu items and any Separators that
-        // come directly after them
-        Component previousComp = null;
-        for (int x = 0; x < menuCount; x++)
-        {
-          Component menuItem = menu.getMenuComponent(x);
-          if (previousComp instanceof JMenuItem)
-          {
-            JMenuItem previousMenuItem = (JMenuItem) previousComp;
-            if (previousMenuItem.getText().startsWith("Read")
-                    || previousMenuItem.getText()
-                            .startsWith("New")
-                    || previousMenuItem.getText()
-                            .startsWith("Close Tab"))
-            {
-              previousComp.setVisible(false);
-
-              if (menuItem instanceof JSeparator)
-              {
-                menuItem.setVisible(false);
-              }
-
-            }
-
-            if ((!epsAdded) && previousMenuItem.getText()
-                    .startsWith("Export to"))
-            {
-              JMenuItem exportEps = new JMenuItem("Export to EPS file...");
-              menu.add(exportEps, x);
-              exportEps.addActionListener(new ActionListener()
-              {
-
-                @Override
-                public void actionPerformed(ActionEvent e)
-                {
-                  // TODO Auto-generated method stub
 
-                }
-                
-              });
-              epsAdded = true;
+  private static boolean validateConfig(Configuration aptxConfig)
+  {
+    if (aptxConfig == null || aptxConfig.isCouldReadConfigFile() == false)
+    {
+      int keepGoing = JvOptionPane.showConfirmDialog(Desktop.desktop,
+              MessageManager.getString("label.aptx_config_not_found"),
+              MessageManager.formatMessage("label.couldnt_locate",
+                      new String[]
+                      { "_aptx_jalview_configuration_file" }),
+              JvOptionPane.YES_NO_CANCEL_OPTION);
 
-            }
-          }
-          previousComp = menuItem;
-        }
-      }
-      else if (menu.getText().contains("Inference"))
+      if (keepGoing == JvOptionPane.CANCEL_OPTION
+              || keepGoing == JvOptionPane.CLOSED_OPTION
+              || keepGoing == JvOptionPane.NO_OPTION)
       {
-        menu.setVisible(false);
-      }
-      else if (menu.getText().contains("View"))
-      {
-        menu.addSeparator();
-        JMenuItem sortByTree = new JMenuItem("Sort alignment by tree");
-        JMenuItem refreshJalview = new JMenuItem(
-                "Filter alignment to show only currently visible sequences");
-
-        refreshJalview.setFont(menu.getFont());
-
-        menu.add(sortByTree);
-        menu.add(refreshJalview);
-
-        sortByTree.setFont(menu.getFont());
-        refreshJalview.addActionListener(activeAptx.get(aptxFrame));
-
-
+        return false;
       }
 
     }
-    aptxFrame.validate();
-  }
-
-  public static Map<MainFrame, JalviewBinding> getAllAptxFrames()
-  {
-    return activeAptx;
+    return true;
   }