JAL-2295 make 'Jmol' menu appear; enable/disable Superpose option for
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 2 Mar 2017 09:51:17 +0000 (09:51 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 2 Mar 2017 09:51:17 +0000 (09:51 +0000)
Chimera

src/jalview/gui/AppJmol.java
src/jalview/gui/ChimeraViewFrame.java
src/jalview/gui/StructureViewerBase.java
src/jalview/jbgui/GStructureViewer.java

index ffb9639..5d23f49 100644 (file)
@@ -45,7 +45,6 @@ import java.util.Vector;
 
 import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JInternalFrame;
-import javax.swing.JMenu;
 import javax.swing.JPanel;
 import javax.swing.JSplitPane;
 import javax.swing.SwingUtilities;
@@ -147,7 +146,7 @@ public class AppJmol extends StructureViewerBase
   {
     super.initMenus();
 
-    viewerActionMenu = new JMenu(MessageManager.getString("label.jmol"));
+    viewerActionMenu.setText(MessageManager.getString("label.jmol"));
 
     viewerColour
             .setText(MessageManager.getString("label.colour_with_jmol"));
index 9b0d85b..67eddca 100644 (file)
@@ -851,10 +851,20 @@ public class ChimeraViewFrame extends StructureViewerBase
     return "Chimera";
   }
 
+  /**
+   * Override superclass method to make the 'Chimera' menu always visible, but
+   * 'Superpose with...' only enabled if there is more than one structure shown
+   */
   @Override
   public void updateTitleAndMenus()
   {
     super.updateTitleAndMenus();
     viewerActionMenu.setVisible(true);
+    viewSelectionMenu.setEnabled(false);
+    if (getBinding().getPdbFile().length > 1
+            && getBinding().getSequence().length > 1)
+    {
+      viewSelectionMenu.setEnabled(true);
+    }
   }
 }
index 34ad659..808150f 100644 (file)
@@ -110,6 +110,8 @@ public abstract class StructureViewerBase extends GStructureViewer
 
   protected boolean allChainsSelected = false;
 
+  protected JMenu viewSelectionMenu;
+
   /**
    * Default constructor
    */
@@ -744,17 +746,17 @@ public abstract class StructureViewerBase extends GStructureViewer
       @Override
       public void itemStateChanged(ItemEvent e)
       {
-        alignStructs.setEnabled(_alignwith.size() > 0);
+        alignStructs.setEnabled(!_alignwith.isEmpty());
         alignStructs.setToolTipText(MessageManager.formatMessage(
                 "label.align_structures_using_linked_alignment_views",
                 new String[] { String.valueOf(_alignwith.size()) }));
       }
     };
-    JMenu alpanels = new ViewSelectionMenu(
+    viewSelectionMenu = new ViewSelectionMenu(
             MessageManager.getString("label.superpose_with"), this,
             _alignwith, handler);
     handler.itemStateChanged(null);
-    viewerActionMenu.add(alpanels);
+    viewerActionMenu.add(viewSelectionMenu);
     viewerActionMenu.addMenuListener(new MenuListener()
     {
       @Override
index 6b89ab4..cee8b93 100644 (file)
@@ -181,7 +181,7 @@ public abstract class GStructureViewer extends JInternalFrame implements
       }
     });
 
-    viewerActionMenu = new JMenu();
+    viewerActionMenu = new JMenu(); // text set in sub-classes
     viewerActionMenu.setVisible(false);
     viewerActionMenu.add(alignStructs);
     colourMenu = new JMenu();