*/
package jalview.gui;
+import static jalview.util.UrlConstants.SEQUENCE_ID;
+
import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.bin.Cache;
import jalview.jbgui.GSplitFrame;
import jalview.jbgui.GStructureViewer;
import jalview.structure.StructureSelectionManager;
+import jalview.urls.IdOrgSettings;
import jalview.util.ImageMaker;
import jalview.util.MessageManager;
import jalview.util.Platform;
+import jalview.util.UrlConstants;
import jalview.viewmodel.AlignmentViewport;
+import jalview.ws.UrlDownloadClient;
import jalview.ws.params.ParamManager;
import java.awt.BorderLayout;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
+import java.io.IOException;
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;
showNews.setVisible(false);
+ getIdentifiersOrgData();
+
checkURLLinks();
this.addWindowListener(new WindowAdapter()
});
}
+ public void getIdentifiersOrgData()
+ {
+ // Thread off the identifiers fetcher
+ addDialogThread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ Cache.log.debug("Downloading data from identifiers.org");
+ UrlDownloadClient client = new UrlDownloadClient();
+ try
+ {
+ client.download(IdOrgSettings.getUrl(),
+ IdOrgSettings.getDownloadLocation());
+ } catch (IOException e)
+ {
+ Cache.log.debug("Exception downloading identifiers.org data"
+ + e.getMessage());
+ }
+ }
+ });
+ }
+
@Override
protected void showNews_actionPerformed(ActionEvent e)
{
{
if (Cache.getDefault("CHECKURLLINKS", true))
{
- // check in case URL links use old style tokens ($SEQUENCE_ID$ for
- // sequence id _or_ accession id)
+ // check what the actual links are - if it's just the default don't
+ // bother with the warning
+ Vector<String> links = Preferences.sequenceUrlLinks
+ .getLinksForMenu();
+
+ // 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;
+ List<JLabel> urls = new ArrayList<JLabel>();
+ while (li.hasNext())
+ {
+ String link = li.next();
+ if (link.contains(SEQUENCE_ID)
+ && !link.equals(UrlConstants.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)
+ {
+ return;
+ }
+
+ // 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());
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(
MessageManager.getString("label.do_not_display_again"));
jcb.addActionListener(new ActionListener()
{
-
@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);
- JOptionPane.showMessageDialog(null, msgPanel, MessageManager
- .getString("label.SEQUENCE_ID_no_longer_used"),
+ JOptionPane.showMessageDialog(Desktop.desktop, msgPanel,
+ MessageManager
+ .getString("label.SEQUENCE_ID_no_longer_used"),
JOptionPane.WARNING_MESSAGE);
}
}