JAL-1541 BioJs MSA Viewer export option implementation
[jalview.git] / src / jalview / jbgui / GAlignFrame.java
index 3b8568c..741c124 100755 (executable)
@@ -20,6 +20,8 @@
  */
 package jalview.jbgui;
 
+import jalview.bin.Cache;
+import jalview.gui.JvSwingUtils;
 import jalview.schemes.ColourSchemeProperty;
 import jalview.util.MessageManager;
 
@@ -186,8 +188,6 @@ public class GAlignFrame extends JInternalFrame
 
   public JCheckBoxMenuItem showSeqFeaturesHeight = new JCheckBoxMenuItem();
 
-  JMenuItem chooseAnnotations = new JMenuItem();
-
   JMenuItem deleteGroups = new JMenuItem();
 
   JMenuItem createGroup = new JMenuItem();
@@ -210,6 +210,8 @@ public class GAlignFrame extends JInternalFrame
 
   JMenuItem createPNG = new JMenuItem();
 
+  JMenuItem createBioJS = new JMenuItem();
+
   protected JMenuItem font = new JMenuItem();
 
   public JCheckBoxMenuItem seqLimits = new JCheckBoxMenuItem();
@@ -304,6 +306,10 @@ public class GAlignFrame extends JInternalFrame
 
   JMenuItem showAllhidden = new JMenuItem();
 
+  protected JMenuItem showAllAnnotations = new JMenuItem();
+
+  protected JMenuItem hideAllAnnotations = new JMenuItem();
+
   protected JCheckBoxMenuItem hiddenMarkers = new JCheckBoxMenuItem();
 
   JMenuItem invertColSel = new JMenuItem();
@@ -384,6 +390,7 @@ public class GAlignFrame extends JInternalFrame
       }
     } catch (Exception e)
     {
+      System.err.println(e.toString());
     }
 
     if (!new jalview.util.Platform().isAMac())
@@ -824,7 +831,7 @@ public class GAlignFrame extends JInternalFrame
       }
     });
     removeRedundancyMenuItem.setText(MessageManager
-            .getString("action.remove_redundancy"));
+            .getString("action.remove_redundancy").concat("..."));
     removeRedundancyMenuItem.setAccelerator(javax.swing.KeyStroke
             .getKeyStroke(java.awt.event.KeyEvent.VK_D, Toolkit
                     .getDefaultToolkit().getMenuShortcutKeyMask(), false));
@@ -1058,17 +1065,41 @@ public class GAlignFrame extends JInternalFrame
     annotationPanelMenuItem.setActionCommand("");
     annotationPanelMenuItem.setText(MessageManager
             .getString("label.show_annotations"));
-    annotationPanelMenuItem.setState(jalview.bin.Cache.getDefault(
-            "SHOW_ANNOTATIONS", true));
-    annotationPanelMenuItem
-            .addActionListener(new java.awt.event.ActionListener()
-            {
-              @Override
-              public void actionPerformed(ActionEvent e)
-              {
-                annotationPanelMenuItem_actionPerformed(e);
-              }
-            });
+    annotationPanelMenuItem.setState(Cache.getDefault("SHOW_ANNOTATIONS",
+            true));
+    annotationPanelMenuItem.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        annotationPanelMenuItem_actionPerformed(e);
+      }
+    });
+    /*
+     * Show/hide all annotations only enabled if annotation panel is shown
+     */
+    showAllAnnotations.setText(MessageManager
+            .getString("label.show_all_annotations"));
+    showAllAnnotations.setEnabled(annotationPanelMenuItem.getState());
+    showAllAnnotations.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        showAllAnnotations_actionPerformed();
+      }
+    });
+    hideAllAnnotations.setText(MessageManager
+            .getString("label.hide_all_annotations"));
+    hideAllAnnotations.setEnabled(annotationPanelMenuItem.getState());
+    hideAllAnnotations.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        hideAllAnnotations_actionPerformed();
+      }
+    });
     colourTextMenuItem.setText(MessageManager
             .getString("label.colour_text"));
     colourTextMenuItem
@@ -1089,6 +1120,19 @@ public class GAlignFrame extends JInternalFrame
         htmlMenuItem_actionPerformed(e);
       }
     });
+
+    // TODO uncomment when supported by MassageManager
+    // createBioJS.setText(MessageManager.getString("label.biojs_html_export"));
+    createBioJS.setText("BioJS");
+    createBioJS.addActionListener(new java.awt.event.ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        bioJSMenuItem_actionPerformed(e);
+      }
+    });
+
     overviewMenuItem.setText(MessageManager
             .getString("label.overview_window"));
     overviewMenuItem.addActionListener(new java.awt.event.ActionListener()
@@ -1182,6 +1226,8 @@ public class GAlignFrame extends JInternalFrame
     findMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
             java.awt.event.KeyEvent.VK_F, Toolkit.getDefaultToolkit()
                     .getMenuShortcutKeyMask(), false));
+    findMenuItem.setToolTipText(JvSwingUtils.wrapTooltip(true,
+            MessageManager.getString("label.find_tip")));
     findMenuItem.addActionListener(new java.awt.event.ActionListener()
     {
       @Override
@@ -1210,16 +1256,6 @@ public class GAlignFrame extends JInternalFrame
         showSeqFeatures_actionPerformed(actionEvent);
       }
     });
-    chooseAnnotations.setText(MessageManager
-            .getString("label.choose_annotations") + "...");
-    chooseAnnotations.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent actionEvent)
-      {
-        chooseAnnotations_actionPerformed();
-      }
-    });
     /*
      * showSeqFeaturesHeight.setText("Vary Sequence Feature Height");
      * showSeqFeaturesHeight.addActionListener(new ActionListener() { public
@@ -1412,8 +1448,6 @@ public class GAlignFrame extends JInternalFrame
       }
     });
     delete.setText(MessageManager.getString("action.delete"));
-    delete.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
-            java.awt.event.KeyEvent.VK_BACK_SPACE, 0, false));
     delete.addActionListener(new java.awt.event.ActionListener()
     {
       @Override
@@ -1478,7 +1512,6 @@ public class GAlignFrame extends JInternalFrame
         font_actionPerformed(e);
       }
     });
-
     seqLimits.setText(MessageManager
             .getString("label.show_sequence_limits"));
     seqLimits.setState(jalview.bin.Cache.getDefault("SHOW_JVSUFFIX", true));
@@ -1921,7 +1954,6 @@ public class GAlignFrame extends JInternalFrame
         showAllhidden_actionPerformed(e);
       }
     });
-
     hiddenMarkers.setText(MessageManager
             .getString("action.show_hidden_markers"));
     hiddenMarkers.addActionListener(new ActionListener()
@@ -2133,6 +2165,8 @@ public class GAlignFrame extends JInternalFrame
     viewMenu.addSeparator();
     viewMenu.add(followHighlightMenuItem);
     viewMenu.add(annotationPanelMenuItem);
+    viewMenu.add(showAllAnnotations);
+    viewMenu.add(hideAllAnnotations);
     autoAnnMenu.add(applyAutoAnnotationSettings);
     autoAnnMenu.add(showConsensusHistogram);
     autoAnnMenu.add(showSequenceLogo);
@@ -2143,7 +2177,6 @@ public class GAlignFrame extends JInternalFrame
     viewMenu.add(autoAnnMenu);
     viewMenu.addSeparator();
     viewMenu.add(showSeqFeatures);
-    viewMenu.add(chooseAnnotations);
     // viewMenu.add(showSeqFeaturesHeight);
 
     viewMenu.add(openFeatureSettings);
@@ -2206,6 +2239,7 @@ public class GAlignFrame extends JInternalFrame
     jMenu2.add(htmlMenuItem);
     jMenu2.add(epsFile);
     jMenu2.add(createPNG);
+    jMenu2.add(createBioJS);
     addSequenceMenu.add(addFromFile);
     addSequenceMenu.add(addFromText);
     addSequenceMenu.add(addFromURL);
@@ -2253,9 +2287,27 @@ public class GAlignFrame extends JInternalFrame
   }
 
   /**
-   * Action on menu item "Show/hide sequence annotations..."
+   * Action on clicking Show all annotations.
    */
-  protected void chooseAnnotations_actionPerformed()
+  protected void showAllAnnotations_actionPerformed()
+  {
+    setAllAnnotationsVisibility(true);
+  }
+
+  /**
+   * Action on clicking Hide all annotations.
+   */
+  protected void hideAllAnnotations_actionPerformed()
+  {
+    setAllAnnotationsVisibility(false);
+  }
+
+  /**
+   * Set the visibility of all annotations to true or false.
+   * 
+   * @param visible
+   */
+  protected void setAllAnnotationsVisibility(boolean visible)
   {
 
   }
@@ -2418,6 +2470,11 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
+  protected void bioJSMenuItem_actionPerformed(ActionEvent e)
+  {
+
+  }
+
   protected void closeMenuItem_actionPerformed(boolean b)
   {
   }