Merge branch 'develop' into update_212_Dec_merge_with_21125_chamges
[jalview.git] / src / jalview / gui / PopupMenu.java
index 49542db..3c32180 100644 (file)
@@ -56,7 +56,7 @@ import jalview.analysis.AlignmentAnnotationUtils;
 import jalview.analysis.AlignmentUtils;
 import jalview.analysis.Conservation;
 import jalview.api.AlignViewportI;
-import jalview.bin.Cache;
+import jalview.bin.Console;
 import jalview.commands.ChangeCaseCommand;
 import jalview.commands.EditCommand;
 import jalview.commands.EditCommand.Action;
@@ -93,7 +93,6 @@ import jalview.viewmodel.seqfeatures.FeatureRendererModel;
 
 import java.io.IOException;
 import java.net.MalformedURLException;
-
 /**
  * The popup menu that is displayed on right-click on a sequence id, or in the
  * sequence alignment.
@@ -235,13 +234,13 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
         urlLink = new UrlLink(link);
       } catch (Exception foo)
       {
-        Cache.log.error("Exception for URLLink '" + link + "'", foo);
+        Console.error("Exception for URLLink '" + link + "'", foo);
         continue;
       }
 
       if (!urlLink.isValid())
       {
-        Cache.log.error(urlLink.getInvalidMessage());
+        Console.error(urlLink.getInvalidMessage());
         continue;
       }
 
@@ -581,7 +580,6 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
         });
         add(menuItem);
       }
-
       menuItem = new JMenuItem(
               MessageManager.getString("action.hide_sequences"));
       menuItem.addActionListener(new ActionListener()
@@ -705,6 +703,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
       {
         buildGroupURLMenu(sg, groupLinks);
       }
+      // TODO REMOVE FOR 2.12 ?
       // Add a 'show all structures' for the current selection
       Hashtable<String, PDBEntry> pdbe = new Hashtable<>();
       Hashtable<String, PDBEntry> reppdb = new Hashtable<>();
@@ -875,10 +874,14 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
       /*
        * show local rather than linked feature coordinates
        */
-      int[] beginRange = mf.getMappedPositions(start, start);
-      start = beginRange[0];
-      int[] endRange = mf.getMappedPositions(end, end);
-      end = endRange[endRange.length - 1];
+      int[] localRange = mf.getMappedPositions(start, end);
+      if (localRange == null)
+      {
+        // e.g. variant extending to stop codon so not mappable
+        return;
+      }
+      start = localRange[0];
+      end = localRange[localRange.length - 1];
     }
     StringBuilder desc = new StringBuilder();
     desc.append(sf.getType()).append(" ").append(String.valueOf(start));
@@ -1197,12 +1200,12 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
         urlLink = new GroupUrlLink(link);
       } catch (Exception foo)
       {
-        Cache.log.error("Exception for GroupURLLink '" + link + "'", foo);
+        Console.error("Exception for GroupURLLink '" + link + "'", foo);
         continue;
       }
       if (!urlLink.isValid())
       {
-        Cache.log.error(urlLink.getInvalidMessage());
+        Console.error(urlLink.getInvalidMessage());
         continue;
       }
       final String label = urlLink.getLabel();
@@ -1737,7 +1740,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
       menuItem.setEnabled(true);
       for (String calcId : tipEntries.keySet())
       {
-        tooltip.append("<br>" + calcId + "/" + tipEntries.get(calcId));
+        tooltip.append("<br/>" + calcId + "/" + tipEntries.get(calcId));
       }
       String tooltipText = JvSwingUtils.wrapTooltip(true,
               tooltip.toString());
@@ -1845,7 +1848,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
       contents.append("<p><h2>" + MessageManager.formatMessage(
               "label.create_sequence_details_report_annotation_for",
               new Object[]
-              { seq.getDisplayId(true) }) + "</h2></p><p>");
+              { seq.getDisplayId(true) }) + "</h2></p>\n<p>");
       new SequenceAnnotationReport(false).createSequenceAnnotationReport(
               contents, seq, true, true, ap.getSeqPanel().seqCanvas.fr);
       contents.append("</p>");