Merge branch 'develop' into features/JAL-2295setChimeraAttributes
[jalview.git] / src / jalview / gui / PopupMenu.java
index b342f86..e1b2560 100644 (file)
@@ -38,6 +38,8 @@ import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
+import jalview.io.FileFormat;
+import jalview.io.FileFormatI;
 import jalview.io.FormatAdapter;
 import jalview.io.SequenceAnnotationReport;
 import jalview.schemes.AnnotationColourGradient;
@@ -254,10 +256,9 @@ public class PopupMenu extends JPopupMenu
     colours.add(purinePyrimidineColour);
     colours.add(RNAInteractionColour);
 
-    for (int i = 0; i < jalview.io.FormatAdapter.WRITEABLE_FORMATS.length; i++)
+    for (String ff : FileFormat.getWritableFormats(true))
     {
-      JMenuItem item = new JMenuItem(
-              jalview.io.FormatAdapter.WRITEABLE_FORMATS[i]);
+      JMenuItem item = new JMenuItem(ff);
 
       item.addActionListener(new java.awt.event.ActionListener()
       {
@@ -641,6 +642,16 @@ public class PopupMenu extends JPopupMenu
 
     addshowLinks(linkMenu, linkset.values());
 
+    // disable link menu if there are no valid entries
+    if (linkMenu.getItemCount() > 0)
+    {
+      linkMenu.setEnabled(true);
+    }
+    else
+    {
+      linkMenu.setEnabled(false);
+    }
+
     if (sequence != null)
     {
       sequenceMenu.add(linkMenu);
@@ -649,6 +660,7 @@ public class PopupMenu extends JPopupMenu
     {
       add(linkMenu);
     }
+
   }
 
 
@@ -1666,7 +1678,7 @@ public class PopupMenu extends JPopupMenu
   public void createSequenceDetailsReport(SequenceI[] sequences)
   {
     CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
-    StringBuffer contents = new StringBuffer();
+    StringBuilder contents = new StringBuilder(128);
     for (SequenceI seq : sequences)
     {
       contents.append("<p><h2>"
@@ -1681,7 +1693,6 @@ public class PopupMenu extends JPopupMenu
                       seq,
                       true,
                       true,
-                      false,
                       (ap.getSeqPanel().seqCanvas.fr != null) ? ap
                               .getSeqPanel().seqCanvas.fr.getMinMax()
                               : null);
@@ -2078,14 +2089,14 @@ public class PopupMenu extends JPopupMenu
     {
       if (dialog.getName().indexOf(" ") > -1)
       {
-        JOptionPane
+        JvOptionPane
                 .showMessageDialog(
                         ap,
                         MessageManager
                                 .getString("label.spaces_converted_to_backslashes"),
                         MessageManager
                                 .getString("label.no_spaces_allowed_sequence_name"),
-                        JOptionPane.WARNING_MESSAGE);
+                        JvOptionPane.WARNING_MESSAGE);
       }
 
       sequence.setName(dialog.getName().replace(' ', '_'));
@@ -2184,10 +2195,10 @@ public class PopupMenu extends JPopupMenu
       jalview.util.BrowserLauncher.openURL(url);
     } catch (Exception ex)
     {
-      JOptionPane.showInternalMessageDialog(Desktop.desktop,
+      JvOptionPane.showInternalMessageDialog(Desktop.desktop,
               MessageManager.getString("label.web_browser_not_found_unix"),
               MessageManager.getString("label.web_browser_not_found"),
-              JOptionPane.WARNING_MESSAGE);
+              JvOptionPane.WARNING_MESSAGE);
 
       ex.printStackTrace();
     }
@@ -2263,8 +2274,8 @@ public class PopupMenu extends JPopupMenu
     // or we simply trust the user wants
     // wysiwig behaviour
 
-    cap.setText(new FormatAdapter(ap).formatSequences(e.getActionCommand(),
-            ap, true));
+    FileFormatI fileFormat = FileFormat.forName(e.getActionCommand());
+    cap.setText(new FormatAdapter(ap).formatSequences(fileFormat, ap, true));
   }
 
   public void sequenceFeature_actionPerformed()