X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FDesktop.java;h=28606f105e4b7f332244979075aa893357be4b32;hb=742b61afae99cb551f7ac4454d97059dc3627829;hp=f99af3413dc6a232fe1d257e55404753e93fd2d3;hpb=853624fb32058cccc544ae7d13af6ad4b0800b6c;p=jalview.git diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index f99af34..28606f1 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -20,6 +20,9 @@ */ 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; import jalview.bin.Cache; @@ -75,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; @@ -82,9 +86,12 @@ import java.util.concurrent.Executors; import java.util.concurrent.Semaphore; import javax.swing.AbstractAction; +import javax.swing.Box; +import javax.swing.BoxLayout; import javax.swing.DefaultDesktopManager; import javax.swing.DesktopManager; import javax.swing.JButton; +import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JDesktopPane; @@ -382,6 +389,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements showNews.setVisible(false); + checkURLLinks(); + this.addWindowListener(new WindowAdapter() { @Override @@ -941,6 +950,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements public void drop(DropTargetDropEvent evt) { boolean success = true; + // JAL-1552 - acceptDrop required before getTransferable call for + // Java's Transferable for native dnd + evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); Transferable t = evt.getTransferable(); java.util.List files = new ArrayList(); java.util.List protocols = new ArrayList(); @@ -2253,6 +2265,84 @@ public class Desktop extends jalview.jbgui.GDesktop implements new Thread(jvq).start(); } + public void checkURLLinks() + { + // Thread off the URL link checker + addDialogThread(new Runnable() + { + @Override + public void run() + { + if (Cache.getDefault("CHECKURLLINKS", true)) + { + // check what the actual links are - if it's just the default don't + // bother with the warning + Vector links = Preferences.sequenceURLLinks; + + // 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; + List urls = new ArrayList(); + while (li.hasNext()) + { + String link = li.next(); + if (link.contains(SEQUENCE_ID) && !link.equals(EMBLEBI_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()); + JLabel msg = new JLabel( + MessageManager + .getString("label.SEQUENCE_ID_for_DB_ACCESSION1")); + JLabel msg2 = new JLabel( + 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 for "don't show this again" + boolean showWarningAgain = !jcb.isSelected(); + Cache.setProperty("CHECKURLLINKS", + Boolean.valueOf(showWarningAgain).toString()); + } + }); + msgPanel.add(jcb); + + JOptionPane.showMessageDialog(Desktop.desktop, msgPanel, + MessageManager + .getString("label.SEQUENCE_ID_no_longer_used"), + JOptionPane.WARNING_MESSAGE); + } + } + }); + } + /** * Proxy class for JDesktopPane which optionally displays the current memory * usage and highlights the desktop area with a red bar if free memory runs @@ -3180,7 +3270,6 @@ public class Desktop extends jalview.jbgui.GDesktop implements { // Works on Windows and MacOSX Cache.log.debug("Drop handled as javaFileListFlavor"); - evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); for (Object file : (List) t .getTransferData(DataFlavor.javaFileListFlavor)) { @@ -3197,7 +3286,6 @@ public class Desktop extends jalview.jbgui.GDesktop implements { Cache.log.debug("Drop handled as uriListFlavor"); // This is used by Unix drag system - evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); data = (String) t.getTransferData(uriListFlavor); } if (data == null) @@ -3252,7 +3340,6 @@ public class Desktop extends jalview.jbgui.GDesktop implements { Cache.log.debug("Supported transfer dataflavor: " + fl.toString()); - evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); Object df = t.getTransferData(fl); if (df != null) {