From fdefa22d3758831c3d35ed4f85df594d186019f6 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Thu, 16 Jul 2015 16:19:39 +0100 Subject: [PATCH] revision for JAL-1749 - ensure view 2D structure menu is removed when no structures are available --- src/jalview/gui/PopupMenu.java | 59 ++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index ad3d6af..5699d9e 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -20,27 +20,6 @@ */ package jalview.gui; -import java.awt.Color; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Arrays; -import java.util.Collections; -import java.util.Hashtable; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import java.util.Vector; - -import javax.swing.ButtonGroup; -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; - import jalview.analysis.AAFrequency; import jalview.analysis.AlignmentAnnotationUtils; import jalview.analysis.AlignmentUtils; @@ -80,6 +59,27 @@ import jalview.util.GroupUrlLink.UrlStringTooLongException; import jalview.util.MessageManager; import jalview.util.UrlLink; +import java.awt.Color; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Arrays; +import java.util.Collections; +import java.util.Hashtable; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import java.util.Vector; + +import javax.swing.ButtonGroup; +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; + /** * DOCUMENT ME! * @@ -204,7 +204,7 @@ public class PopupMenu extends JPopupMenu JMenu jMenu1 = new JMenu(); - JMenuItem proteinStructureMenu = new JMenuItem(); + JMenuItem pdbStructureDialog = new JMenuItem(); JMenu rnaStructureMenu = new JMenu(); @@ -328,6 +328,7 @@ public class PopupMenu extends JPopupMenu } else { + int origCount = rnaStructureMenu.getItemCount(); /* * add menu items to 2D-render any alignment or sequence secondary * structure annotation @@ -388,6 +389,10 @@ public class PopupMenu extends JPopupMenu } } } + if (rnaStructureMenu.getItemCount() == origCount) + { + remove(rnaStructureMenu); + } } menuItem = new JMenuItem( @@ -600,7 +605,7 @@ public class PopupMenu extends JPopupMenu if (seq == null) { sequenceMenu.setVisible(false); - proteinStructureMenu.setVisible(false); + pdbStructureDialog.setVisible(false); rnaStructureMenu.setVisible(false); } @@ -1342,9 +1347,9 @@ public class PopupMenu extends JPopupMenu } }); jMenu1.setText(MessageManager.getString("label.group")); - proteinStructureMenu.setText(MessageManager - .getString("label.view_protein_structure")); - proteinStructureMenu.addActionListener(new ActionListener() + pdbStructureDialog.setText(MessageManager + .getString("label.show_pdbstruct_dialog")); + pdbStructureDialog.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) @@ -1405,7 +1410,7 @@ public class PopupMenu extends JPopupMenu add(groupMenu); add(sequenceMenu); add(rnaStructureMenu); - add(proteinStructureMenu); + add(pdbStructureDialog); if (sequence!=null) { add(hideInsertions); -- 1.7.10.2