make URL links from description string when link is a regex and it matches on descrip...
authorjprocter <Jim Procter>
Tue, 9 Sep 2008 10:08:00 +0000 (10:08 +0000)
committerjprocter <Jim Procter>
Tue, 9 Sep 2008 10:08:00 +0000 (10:08 +0000)
src/jalview/appletgui/APopupMenu.java
src/jalview/gui/PopupMenu.java

index 1fa9f7c..9b21f60 100755 (executable)
@@ -227,21 +227,19 @@ public class APopupMenu extends java.awt.PopupMenu implements
             }
             // addshowLink(linkMenu, target, url_pref + id + url_suff);
           }
-          // TODO: introduce applet parameter option to dis/en/able URl generation from description
-          // hard-disable the construction of URLs from regexes that match the description
-//          if (descr != null)
-//          {
-//            // create link for this URL from description where regex matches
-//            String[] urls = urlLink.makeUrls(descr, false);
-//            if (urls != null)
-//            {
-//              for (int u = 0; u < urls.length; u += 2)
-//              {
-//                addshowLink(linkMenu, label, urls[u + 1]);
-//              }
-//            }
-//            // addshowLink(linkMenu, target, url_pref + id + url_suff);
-//          }
+          // Now construct URLs from description but only try to do it for regex URL links
+          if (descr != null && urlLink.getRegexReplace()!=null)
+          {
+            // create link for this URL from description only if regex matches
+            String[] urls = urlLink.makeUrls(descr, true);
+            if (urls != null)
+            {
+              for (int u = 0; u < urls.length; u += 2)
+              {
+                addshowLink(linkMenu, label, urls[u + 1]);
+              }
+            }
+          }
         }
         else
         {
index d89c776..fee7e3f 100755 (executable)
@@ -473,20 +473,19 @@ public class PopupMenu extends JPopupMenu
               }
             }
           }
-          // hard-disable construction of URLs from regexes that match the description
-          // TODO: introduce a Cache preferences option to dis/en/able URl generation from description
-//          if (descr != null)
-//          {
-//            // create link for this URL from description where regex matches
-//            String[] urls = urlLink.makeUrls(descr, false);
-//            if (urls != null)
-//            {
-//              for (int u = 0; u < urls.length; u += 2)
-//              {
-//                addshowLink(linkMenu, label, urls[u + 1]);
-//              }
-//            }
-//          }
+          // Create urls from description but only for URL links which are regex links
+          if (descr != null && urlLink.getRegexReplace()!=null)
+          {
+            // create link for this URL from description where regex matches
+            String[] urls = urlLink.makeUrls(descr, true);
+            if (urls != null)
+            {
+              for (int u = 0; u < urls.length; u += 2)
+              {
+                addshowLink(linkMenu, label, urls[u + 1]);
+              }
+            }
+          }
         }
         else
         {