JAL-2373 set state of Above PID, By Conservation in Popup Menu
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 5 Jan 2017 11:35:21 +0000 (11:35 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 5 Jan 2017 11:35:21 +0000 (11:35 +0000)
src/jalview/appletgui/APopupMenu.java
src/jalview/gui/PopupMenu.java

index 015734f..6e5f130 100644 (file)
@@ -244,8 +244,12 @@ public class APopupMenu extends java.awt.PopupMenu implements
       {
         menu1.setLabel(MessageManager.getString("action.edit_group"));
         groupMenu.remove(createGroupMenuItem);
+        if (sg.cs != null)
+        {
+          abovePIDColour.setState(sg.cs.getThreshold() > 0);
+          conservationMenuItem.setState(sg.cs.conservationApplied());
+        }
       }
-
     }
     else
     {
@@ -500,23 +504,28 @@ public class APopupMenu extends java.awt.PopupMenu implements
   @Override
   public void itemStateChanged(ItemEvent evt)
   {
-    if (evt.getSource() == abovePIDColour)
+    Object source = evt.getSource();
+    if (source == abovePIDColour)
     {
       abovePIDColour_itemStateChanged();
     }
-    else if (evt.getSource() == showColourText)
+    else if (source == conservationMenuItem)
+    {
+      conservationMenuItem_itemStateChanged();
+    }
+    else if (source == showColourText)
     {
       showColourText_itemStateChanged();
     }
-    else if (evt.getSource() == showText)
+    else if (source == showText)
     {
       showText_itemStateChanged();
     }
-    else if (evt.getSource() == showBoxes)
+    else if (source == showBoxes)
     {
       showBoxes_itemStateChanged();
     }
-    else if (evt.getSource() == displayNonconserved)
+    else if (source == displayNonconserved)
     {
       this.showNonconserved_itemStateChanged();
     }
@@ -579,10 +588,6 @@ public class APopupMenu extends java.awt.PopupMenu implements
     {
       noColourmenuItem_actionPerformed();
     }
-    else if (source == conservationMenuItem)
-    {
-      conservationMenuItem_itemStateChanged();
-    }
     else if (source == unGroupMenuItem)
     {
       unGroupMenuItem_actionPerformed();
index e1b2560..a93c92e 100644 (file)
@@ -79,7 +79,6 @@ import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JColorChooser;
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
 import javax.swing.JPopupMenu;
 import javax.swing.JRadioButtonMenuItem;
 
@@ -249,7 +248,6 @@ public class PopupMenu extends JPopupMenu
     colours.add(strandColour);
     colours.add(turnColour);
     colours.add(buriedColour);
-    colours.add(abovePIDColour);
     colours.add(userDefinedColour);
     colours.add(PIDColour);
     colours.add(BLOSUM62Colour);
@@ -536,9 +534,16 @@ public class PopupMenu extends JPopupMenu
         noColourmenuItem.setSelected(true);
       }
 
-      if (sg.cs != null && sg.cs.conservationApplied())
+      if (sg.cs != null)
       {
+        if (sg.cs.conservationApplied())
+        {
         conservationMenuItem.setSelected(true);
+        }
+        if (sg.cs.getThreshold() > 0)
+        {
+          abovePIDColour.setSelected(true);
+        }
       }
       displayNonconserved.setSelected(sg.getShowNonconserved());
       showText.setSelected(sg.getDisplayText());