JAL-2316 Refactoring of functionality to provide urls to gui
[jalview.git] / src / jalview / gui / Desktop.java
index d06dd26..63f797d 100644 (file)
@@ -20,7 +20,6 @@
  */
 package jalview.gui;
 
-import static jalview.util.UrlConstants.EMBLEBI_STRING;
 import static jalview.util.UrlConstants.SEQUENCE_ID;
 
 import jalview.api.AlignViewportI;
@@ -38,6 +37,7 @@ import jalview.structure.StructureSelectionManager;
 import jalview.util.ImageMaker;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
+import jalview.util.UrlProviderI;
 import jalview.viewmodel.AlignmentViewport;
 import jalview.ws.params.ParamManager;
 
@@ -2277,17 +2277,26 @@ public class Desktop extends jalview.jbgui.GDesktop implements
         {
           // check what the actual links are - if it's just the default don't
           // bother with the warning
-          Vector<String> links = Preferences.sequenceURLLinks;
+          Vector<String> links = Preferences.sequenceUrlLinks
+                  .getLinksForDisplay();
 
           // only need to check links if there is one with a
           // SEQUENCE_ID which is not the default EMBL_EBI link
           ListIterator<String> li = links.listIterator();
-          Boolean check = false;
-          while (li.hasNext() && !check)
+          boolean check = false;
+          List<JLabel> urls = new ArrayList<JLabel>();
+          while (li.hasNext())
           {
             String link = li.next();
-            check = (link.contains(SEQUENCE_ID) && !link
-                    .equals(EMBLEBI_STRING));
+            if (link.contains(SEQUENCE_ID)
+                    && !link.equals(UrlProviderI.DEFAULT_STRING))
+            {
+              check = true;
+              int barPos = link.indexOf("|");
+              String urlMsg = barPos == -1 ? link : link.substring(0,
+                      barPos) + ": " + link.substring(barPos + 1);
+              urls.add(new JLabel(urlMsg));
+            }
           }
           if (!check)
           {
@@ -2306,6 +2315,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements
                   MessageManager
                           .getString("label.SEQUENCE_ID_for_DB_ACCESSION2"));
           msgPanel.add(msg);
+          for (JLabel url : urls)
+          {
+            msgPanel.add(url);
+          }
           msgPanel.add(msg2);
 
           final JCheckBox jcb = new JCheckBox(
@@ -2315,15 +2328,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements
             @Override
             public void actionPerformed(ActionEvent e)
             {
-              // update Cache settings if checkbox is selected
-              if (jcb.isSelected())
-              {
-                Cache.setProperty("CHECKURLLINKS", "false");
-              }
-              else
-              {
-                Cache.setProperty("CHECKURLLINKS", "true");
-              }
+              // update Cache settings for "don't show this again"
+              boolean showWarningAgain = !jcb.isSelected();
+              Cache.setProperty("CHECKURLLINKS",
+                      Boolean.valueOf(showWarningAgain).toString());
             }
           });
           msgPanel.add(jcb);