From: kiramt Date: Fri, 4 Nov 2016 14:28:57 +0000 (+0000) Subject: JAL-2282 Better check for existing url links X-Git-Tag: Release_2_10_1^2~12^2^2 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=a3b90af5d2d63a54e94e827022325c3c0313384c JAL-2282 Better check for existing url links --- diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 4d10cc8..d06dd26 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -21,6 +21,7 @@ package jalview.gui; import static jalview.util.UrlConstants.EMBLEBI_STRING; +import static jalview.util.UrlConstants.SEQUENCE_ID; import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; @@ -77,6 +78,7 @@ import java.net.URL; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import java.util.ListIterator; import java.util.StringTokenizer; import java.util.Vector; import java.util.concurrent.ExecutorService; @@ -2276,20 +2278,24 @@ 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 links = Preferences.sequenceURLLinks; - if (links == null || links.size() < 1) + + // only need to check links if there is one with a + // SEQUENCE_ID which is not the default EMBL_EBI link + ListIterator li = links.listIterator(); + Boolean check = false; + while (li.hasNext() && !check) { - // there are no links - return; + String link = li.next(); + check = (link.contains(SEQUENCE_ID) && !link + .equals(EMBLEBI_STRING)); } - else if ((links.size() == 1) - && links.get(0).equals(EMBLEBI_STRING)) + if (!check) { - // the only link is the default EMBL-EBI link return; } - // check in case URL links use old style tokens ($SEQUENCE_ID$ for - // sequence id _or_ accession id) + // ask user to check in case URL links use old style tokens + // ($SEQUENCE_ID$ for sequence id _or_ accession id) JPanel msgPanel = new JPanel(); msgPanel.setLayout(new BoxLayout(msgPanel, BoxLayout.PAGE_AXIS)); msgPanel.add(Box.createVerticalGlue()); @@ -2306,7 +2312,6 @@ public class Desktop extends jalview.jbgui.GDesktop implements MessageManager.getString("label.do_not_display_again")); jcb.addActionListener(new ActionListener() { - @Override public void actionPerformed(ActionEvent e) { @@ -2327,7 +2332,6 @@ public class Desktop extends jalview.jbgui.GDesktop implements MessageManager .getString("label.SEQUENCE_ID_no_longer_used"), JOptionPane.WARNING_MESSAGE); - } } });