From 20bb45279db7745e7d0062c1084f97644c60db19 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 2 Mar 2017 09:51:17 +0000 Subject: [PATCH] JAL-2295 make 'Jmol' menu appear; enable/disable Superpose option for Chimera --- src/jalview/gui/AppJmol.java | 3 +-- src/jalview/gui/ChimeraViewFrame.java | 10 ++++++++++ src/jalview/gui/StructureViewerBase.java | 8 +++++--- src/jalview/jbgui/GStructureViewer.java | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/jalview/gui/AppJmol.java b/src/jalview/gui/AppJmol.java index ffb9639..5d23f49 100644 --- a/src/jalview/gui/AppJmol.java +++ b/src/jalview/gui/AppJmol.java @@ -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")); diff --git a/src/jalview/gui/ChimeraViewFrame.java b/src/jalview/gui/ChimeraViewFrame.java index 9b0d85b..67eddca 100644 --- a/src/jalview/gui/ChimeraViewFrame.java +++ b/src/jalview/gui/ChimeraViewFrame.java @@ -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); + } } } diff --git a/src/jalview/gui/StructureViewerBase.java b/src/jalview/gui/StructureViewerBase.java index 34ad659..808150f 100644 --- a/src/jalview/gui/StructureViewerBase.java +++ b/src/jalview/gui/StructureViewerBase.java @@ -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 diff --git a/src/jalview/jbgui/GStructureViewer.java b/src/jalview/jbgui/GStructureViewer.java index 6b89ab4..cee8b93 100644 --- a/src/jalview/jbgui/GStructureViewer.java +++ b/src/jalview/jbgui/GStructureViewer.java @@ -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(); -- 1.7.10.2