JAL-4392 Fixed failed test cases
[jalview.git] / src / jalview / jbgui / GAlignFrame.java
index 9b9a44a..a8cdcdd 100755 (executable)
@@ -22,6 +22,7 @@ package jalview.jbgui;
 
 import java.awt.BorderLayout;
 import java.awt.Color;
+import java.awt.Component;
 import java.awt.GridLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
@@ -31,6 +32,7 @@ import java.awt.event.KeyEvent;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import javax.swing.BorderFactory;
@@ -193,12 +195,16 @@ public class GAlignFrame extends JInternalFrame
   protected JMenuItem gatherViews = new JMenuItem();
 
   protected JMenuItem expandViews = new JMenuItem();
+  
+  protected JCheckBoxMenuItem showSSConsensus = new JCheckBoxMenuItem();   
 
+  protected JCheckBoxMenuItem showGroupSSConsensus = new JCheckBoxMenuItem();
+  
   protected JCheckBoxMenuItem showGroupConsensus = new JCheckBoxMenuItem();
 
   protected JCheckBoxMenuItem showGroupConservation = new JCheckBoxMenuItem();
 
-  protected JCheckBoxMenuItem showConsensusHistogram = new JCheckBoxMenuItem();
+  protected JCheckBoxMenuItem showConsensusHistogram = new JCheckBoxMenuItem();  
 
   protected JCheckBoxMenuItem showSequenceLogo = new JCheckBoxMenuItem();
 
@@ -855,6 +861,32 @@ public class GAlignFrame extends JInternalFrame
 
     });
 
+    showSSConsensus
+            .setText(MessageManager.getString("label.show_secondary_structure_consensus"));
+    showSSConsensus.addActionListener(new ActionListener()
+    {
+    
+    @Override
+    public void actionPerformed(ActionEvent e)
+    {
+      showSSConsensus_actionPerformed(e);
+    }
+    
+    });
+    
+    showGroupSSConsensus
+            .setText(MessageManager.getString("label.group_ss_consensus"));
+    showGroupSSConsensus.addActionListener(new ActionListener()
+    {
+    
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        showGroupSSConsensus_actionPerformed(e);
+      }
+    
+    });
+
     showGroupConsensus
             .setText(MessageManager.getString("label.group_consensus"));
     showGroupConsensus.addActionListener(new ActionListener()
@@ -878,7 +910,7 @@ public class GAlignFrame extends JInternalFrame
         showConsensusHistogram_actionPerformed(e);
       }
 
-    });
+    });    
     showSequenceLogo
             .setText(MessageManager.getString("label.show_consensus_logo"));
     showSequenceLogo.addActionListener(new ActionListener()
@@ -1785,11 +1817,61 @@ public class GAlignFrame extends JInternalFrame
     addMenuActionAndAccelerator(keyStroke, copyHighlighted, al);
     copyHighlighted.addActionListener(al);
 
+    ButtonGroup ssButtonGroup = new ButtonGroup();   
+
     JMenu tooltipSettingsMenu = new JMenu(
             MessageManager.getString("label.sequence_id_tooltip"));
     JMenu autoAnnMenu = new JMenu(
             MessageManager.getString("label.autocalculated_annotation"));
 
+    JMenu showSS = new JMenu(
+            MessageManager.getString("label.show_secondary_structure")); 
+    
+    JRadioButtonMenuItem radioButtonAllSS = new JRadioButtonMenuItem(MessageManager.getString("option.ss_providers_all"));
+    radioButtonAllSS.addActionListener(new ActionListener() {
+      @Override
+      public void actionPerformed(ActionEvent e) {
+          showOrHideSecondaryStructureForSource(MessageManager.getString("option.ss_providers_all"), true);
+          // Select all checkboxes if "All" is selected
+          Component[] components = showSS.getMenuComponents();
+          for (Component component : components) {
+              if (component instanceof JCheckBoxMenuItem) {
+                  ((JCheckBoxMenuItem) component).setSelected(true);
+              }
+          }
+      }
+    });
+    ssButtonGroup.add(radioButtonAllSS);
+    showSS.add(radioButtonAllSS);
+    
+    JRadioButtonMenuItem radioButtonNoneSS = new JRadioButtonMenuItem(MessageManager.getString("option.ss_providers_none"));
+    radioButtonNoneSS.addActionListener(new ActionListener() {
+      @Override
+      public void actionPerformed(ActionEvent e) {
+          showOrHideSecondaryStructureForSource(MessageManager.getString("option.ss_providers_none"), false);
+          // Remove selection of all checkboxes if "None" is selected
+          Component[] components = showSS.getMenuComponents();
+          for (Component component : components) {
+              if (component instanceof JCheckBoxMenuItem) {
+                  ((JCheckBoxMenuItem) component).setSelected(false);
+              }
+          }
+      }
+    });
+    ssButtonGroup.add(radioButtonNoneSS);
+    showSS.add(radioButtonNoneSS);
+    showSS.addSeparator();
+    
+    annotationsMenu.addMouseListener(new MouseAdapter() {
+      
+      @Override
+      public void mouseEntered(MouseEvent e) {
+
+        updateShowSecondaryStructureMenu(showSS, ssButtonGroup); // Update radio buttons every time the menu is clicked
+         
+      }
+    });
+    
     JMenu exportImageMenu = new JMenu(
             MessageManager.getString("label.export_image"));
     JMenu fileMenu = new JMenu(MessageManager.getString("action.file"));
@@ -1890,6 +1972,8 @@ public class GAlignFrame extends JInternalFrame
     annotationsMenu.add(sortAnnBySequence);
     annotationsMenu.add(sortAnnByLabel);
     annotationsMenu.addSeparator();
+    annotationsMenu.add(showSS);
+    annotationsMenu.addSeparator();
     autoAnnMenu.add(showAutoFirst);
     autoAnnMenu.add(showAutoLast);
     autoAnnMenu.addSeparator();
@@ -1897,9 +1981,11 @@ public class GAlignFrame extends JInternalFrame
     autoAnnMenu.add(showConsensusHistogram);
     autoAnnMenu.add(showSequenceLogo);
     autoAnnMenu.add(normaliseSequenceLogo);
+    //autoAnnMenu.add(showSSConsensus);
     autoAnnMenu.addSeparator();
     autoAnnMenu.add(showGroupConservation);
     autoAnnMenu.add(showGroupConsensus);
+    autoAnnMenu.add(showGroupSSConsensus);
     annotationsMenu.add(autoAnnMenu);
 
     sort.add(sortIDMenuItem);
@@ -1981,6 +2067,12 @@ public class GAlignFrame extends JInternalFrame
     // selectMenu.add(listenToViewSelections);
   }
 
+  protected void showSSConsensus_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+    
+  }
+
   protected void createPNG_actionPerformed(ActionEvent object)
   {
     // TODO Auto-generated method stub
@@ -2247,6 +2339,12 @@ public class GAlignFrame extends JInternalFrame
     // TODO Auto-generated method stub
 
   }
+  
+  protected void showGroupSSConsensus_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
 
   protected void showGroupConservation_actionPerformed(ActionEvent e)
   {
@@ -2523,10 +2621,6 @@ public class GAlignFrame extends JInternalFrame
 
   }
 
-  protected void jpred_actionPerformed(ActionEvent e)
-  {
-  }
-
   protected void scaleAbove_actionPerformed(ActionEvent e)
   {
   }
@@ -2790,4 +2884,23 @@ public class GAlignFrame extends JInternalFrame
   protected void showComplement_actionPerformed(boolean complement)
   {
   }
+
+  protected List<String> updateShowSSRadioButtons()
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  protected void showOrHideSecondaryStructureForSource(String ssSourceSelection, boolean visible)
+  {
+    // TODO Auto-generated method stub
+    
+  }
+
+  protected void updateShowSecondaryStructureMenu(JMenu showSS,
+          ButtonGroup ssButtonGroup)
+  {
+    // TODO Auto-generated method stub
+    
+  }
 }