Merge branch 'develop' into features/JAL-2446NCList
[jalview.git] / src / jalview / gui / Desktop.java
index 624054b..4877d7f 100644 (file)
@@ -20,6 +20,8 @@
  */
 package jalview.gui;
 
+import static jalview.util.UrlConstants.SEQUENCE_ID;
+
 import jalview.api.AlignViewportI;
 import jalview.api.AlignmentViewPanel;
 import jalview.bin.Cache;
@@ -28,6 +30,7 @@ import jalview.io.DataSourceType;
 import jalview.io.FileFormat;
 import jalview.io.FileFormatException;
 import jalview.io.FileFormatI;
+import jalview.io.FileFormats;
 import jalview.io.FileLoader;
 import jalview.io.IdentifyFile;
 import jalview.io.JalviewFileChooser;
@@ -35,11 +38,14 @@ import jalview.io.JalviewFileView;
 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.params.ParamManager;
+import jalview.ws.utils.UrlDownloadClient;
 
 import java.awt.BorderLayout;
 import java.awt.Color;
@@ -67,19 +73,19 @@ import java.awt.event.FocusListener;
 import java.awt.event.KeyEvent;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
-import java.beans.PropertyVetoException;
 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;
@@ -87,9 +93,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;
@@ -97,7 +106,6 @@ import javax.swing.JFrame;
 import javax.swing.JInternalFrame;
 import javax.swing.JLabel;
 import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JPopupMenu;
 import javax.swing.JProgressBar;
@@ -105,6 +113,8 @@ import javax.swing.KeyStroke;
 import javax.swing.SwingUtilities;
 import javax.swing.event.HyperlinkEvent;
 import javax.swing.event.HyperlinkEvent.EventType;
+import javax.swing.event.InternalFrameAdapter;
+import javax.swing.event.InternalFrameEvent;
 import javax.swing.event.MenuEvent;
 import javax.swing.event.MenuListener;
 
@@ -119,6 +129,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements
         DropTargetListener, ClipboardOwner, IProgressIndicator,
         jalview.api.StructureSelectionManagerProvider
 {
+  private static int DEFAULT_MIN_WIDTH = 300;
+
+  private static int DEFAULT_MIN_HEIGHT = 250;
+
+  private static final String EXPERIMENTAL_FEATURES = "EXPERIMENTAL_FEATURES";
 
   private JalviewChangeSupport changeSupport = new JalviewChangeSupport();
 
@@ -317,19 +332,6 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     instance = this;
     doVamsasClientCheck();
 
-    groovyShell = new JMenuItem();
-    groovyShell.setText(MessageManager.getString("label.groovy_console"));
-    groovyShell.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        groovyShell_actionPerformed();
-      }
-    });
-    toolsMenu.add(groovyShell);
-    groovyShell.setVisible(true);
-
     doConfigureStructurePrefs();
     setTitle("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
     setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@@ -384,6 +386,12 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     showConsole(showjconsole);
 
     showNews.setVisible(false);
+    
+    experimentalFeatures.setSelected(showExperimental());
+
+    getIdentifiersOrgData();
+
+    checkURLLinks();
 
     this.addWindowListener(new WindowAdapter()
     {
@@ -400,7 +408,16 @@ public class Desktop extends jalview.jbgui.GDesktop implements
       @Override
       public void mousePressed(MouseEvent evt)
       {
-        if (evt.isPopupTrigger())
+        if (evt.isPopupTrigger()) // Mac
+        {
+          showPasteMenu(evt.getX(), evt.getY());
+        }
+      }
+
+      @Override
+      public void mouseReleased(MouseEvent evt)
+      {
+        if (evt.isPopupTrigger()) // Windows
         {
           showPasteMenu(evt.getX(), evt.getY());
         }
@@ -437,7 +454,6 @@ public class Desktop extends jalview.jbgui.GDesktop implements
       }
     });
 
-    // displayed.
     // Thread off a new instance of the file chooser - this reduces the time it
     // takes to open it later on.
     new Thread(new Runnable()
@@ -448,9 +464,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
         Cache.log.debug("Filechooser init thread started.");
         String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
         JalviewFileChooser.forRead(Cache.getProperty("LAST_DIRECTORY"),
-        // jalview.io.AppletFormatAdapter.READABLE_EXTENSIONS,
-        // jalview.io.AppletFormatAdapter.READABLE_FNAMES,
-                fileFormat, true);
+                fileFormat);
         Cache.log.debug("Filechooser init thread finished.");
       }
     }).start();
@@ -470,6 +484,19 @@ public class Desktop extends jalview.jbgui.GDesktop implements
             });
   }
 
+  /**
+   * Answers true if user preferences to enable experimental features is True
+   * (on), else false
+   * 
+   * @return
+   */
+  public boolean showExperimental()
+  {
+    String experimental = Cache.getDefault(EXPERIMENTAL_FEATURES,
+            Boolean.FALSE.toString());
+    return Boolean.valueOf(experimental).booleanValue();
+  }
+
   public void doConfigureStructurePrefs()
   {
     // configure services
@@ -510,6 +537,29 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     });
   }
 
+  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)
   {
@@ -790,6 +840,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements
 
     openFrameCount++;
 
+    frame.setMinimumSize(new Dimension(DEFAULT_MIN_WIDTH,
+            DEFAULT_MIN_HEIGHT));
     frame.setVisible(makeVisible);
     frame.setClosable(true);
     frame.setResizable(resizable);
@@ -808,32 +860,53 @@ public class Desktop extends jalview.jbgui.GDesktop implements
               * ((openFrameCount - 1) % 10) + yOffset);
     }
 
+    /*
+     * add an entry for the new frame in the Window menu 
+     * (and remove it when the frame is closed)
+     */
     final JMenuItem menuItem = new JMenuItem(title);
-    frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
+    frame.addInternalFrameListener(new InternalFrameAdapter()
     {
       @Override
-      public void internalFrameActivated(
-              javax.swing.event.InternalFrameEvent evt)
+      public void internalFrameActivated(InternalFrameEvent evt)
       {
         JInternalFrame itf = desktop.getSelectedFrame();
         if (itf != null)
         {
           itf.requestFocus();
         }
-
       }
 
       @Override
-      public void internalFrameClosed(
-              javax.swing.event.InternalFrameEvent evt)
+      public void internalFrameClosed(InternalFrameEvent evt)
       {
         PaintRefresher.RemoveComponent(frame);
-        openFrameCount--;
+
+        /*
+         * defensive check to prevent frames being
+         * added half off the window
+         */
+        if (openFrameCount > 0)
+        {
+          openFrameCount--;
+        }
+
+        /*
+         * ensure no reference to alignFrame retained by menu item listener
+         */
+        if (menuItem.getActionListeners().length > 0)
+        {
+          menuItem.removeActionListener(menuItem.getActionListeners()[0]);
+        }
         windowMenu.remove(menuItem);
         JInternalFrame itf = desktop.getSelectedFrame();
         if (itf != null)
         {
           itf.requestFocus();
+          if (itf instanceof AlignFrame)
+          {
+            Jalview.setCurrentAlignFrame((AlignFrame) itf);
+          }
         }
         System.gc();
       };
@@ -854,51 +927,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements
         }
       }
     });
-    menuItem.addMouseListener(new MouseListener()
-    {
-
-      @Override
-      public void mouseReleased(MouseEvent e)
-      {
-      }
-
-      @Override
-      public void mousePressed(MouseEvent e)
-      {
-      }
-
-      @Override
-      public void mouseExited(MouseEvent e)
-      {
-        try
-        {
-          frame.setSelected(false);
-        } catch (PropertyVetoException e1)
-        {
-        }
-      }
-
-      @Override
-      public void mouseEntered(MouseEvent e)
-      {
-        try
-        {
-          frame.setSelected(true);
-        } catch (PropertyVetoException e1)
-        {
-        }
-      }
 
-      @Override
-      public void mouseClicked(MouseEvent e)
-      {
-
-      }
-    });
+    desktop.add(frame);
 
     windowMenu.add(menuItem);
 
-    desktop.add(frame);
     frame.toFront();
     try
     {
@@ -955,6 +988,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();
     List<String> files = new ArrayList<String>();
     List<DataSourceType> protocols = new ArrayList<DataSourceType>();
@@ -1012,10 +1048,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
   {
     String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
     JalviewFileChooser chooser = JalviewFileChooser.forRead(
-            Cache.getProperty("LAST_DIRECTORY"),
-            // AppletFormatAdapter.READABLE_EXTENSIONS,
-            // AppletFormatAdapter.READABLE_FNAMES,
-            fileFormat, true);
+            Cache.getProperty("LAST_DIRECTORY"), fileFormat);
 
     chooser.setFileView(new JalviewFileView());
     chooser.setDialogTitle(MessageManager
@@ -1030,20 +1063,21 @@ public class Desktop extends jalview.jbgui.GDesktop implements
       Cache.setProperty("LAST_DIRECTORY", chooser
               .getSelectedFile().getParent());
 
-      FileFormatI format = null;
-      if (chooser.getSelectedFormat() != null
-              && chooser.getSelectedFormat() == FileFormat.Jalview)
-      {
-        format = FileFormat.Jalview;
-      }
-      else
+      FileFormatI format = chooser.getSelectedFormat();
+
+      /*
+       * Call IdentifyFile to verify the file contains what its extension implies.
+       * Skip this step for dynamically added file formats, because
+       * IdentifyFile does not know how to recognise them.
+       */
+      if (FileFormats.getInstance().isIdentifiable(format))
       {
         try
         {
           format = new IdentifyFile().identify(choice, DataSourceType.FILE);
         } catch (FileFormatException e)
         {
-          // format is null
+          // format = null; //??
         }
       }
 
@@ -1064,11 +1098,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements
    * 
    * @param e
    *          DOCUMENT ME!
-   * @throws FileFormatException
    */
   @Override
   public void inputURLMenuItem_actionPerformed(AlignViewport viewport)
-  // throws FileFormatException
   {
     // This construct allows us to have a wider textfield
     // for viewing
@@ -1097,11 +1129,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements
       }
     }
 
-    int reply = JOptionPane.showInternalConfirmDialog(desktop, panel,
+    int reply = JvOptionPane.showInternalConfirmDialog(desktop, panel,
             MessageManager.getString("label.input_alignment_from_url"),
-            JOptionPane.OK_CANCEL_OPTION);
+            JvOptionPane.OK_CANCEL_OPTION);
 
-    if (reply != JOptionPane.OK_OPTION)
+    if (reply != JvOptionPane.OK_OPTION)
     {
       return;
     }
@@ -1135,11 +1167,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements
 
       if (format == null)
       {
-        JOptionPane.showInternalMessageDialog(Desktop.desktop,
+        JvOptionPane.showInternalMessageDialog(Desktop.desktop,
                 MessageManager.formatMessage("label.couldnt_locate",
                         new Object[] { url }), MessageManager
                         .getString("label.url_not_found"),
-                JOptionPane.WARNING_MESSAGE);
+                JvOptionPane.WARNING_MESSAGE);
 
         return;
       }
@@ -1235,9 +1267,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements
   public void aboutMenuItem_actionPerformed(ActionEvent e)
   {
     // StringBuffer message = getAboutMessage(false);
-    // JOptionPane.showInternalMessageDialog(Desktop.desktop,
+    // JvOptionPane.showInternalMessageDialog(Desktop.desktop,
     //
-    // message.toString(), "About Jalview", JOptionPane.INFORMATION_MESSAGE);
+    // message.toString(), "About Jalview", JvOptionPane.INFORMATION_MESSAGE);
     new Thread(new Runnable()
     {
       @Override
@@ -1333,6 +1365,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
   @Override
   public void closeAll_actionPerformed(ActionEvent e)
   {
+    // TODO show a progress bar while closing?
     JInternalFrame[] frames = desktop.getAllFrames();
     for (int i = 0; i < frames.length; i++)
     {
@@ -1343,6 +1376,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
       {
       }
     }
+    Jalview.setCurrentAlignFrame(null);
     System.out.println("ALL CLOSED");
     if (v_client != null)
     {
@@ -1359,6 +1393,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     {
       ssm.resetAll();
     }
+    System.gc();
   }
 
   @Override
@@ -1533,8 +1568,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
   @Override
   public void saveState_actionPerformed(ActionEvent e)
   {
-    JalviewFileChooser chooser = new JalviewFileChooser(
-            Cache.getProperty("LAST_DIRECTORY"), "jvp", "Jalview Project",
+    JalviewFileChooser chooser = new JalviewFileChooser("jvp",
             "Jalview Project");
 
     chooser.setFileView(new JalviewFileView());
@@ -1573,11 +1607,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements
             Cache.log.error(
                     "Problems whilst trying to save to " + choice.getName(),
                     ex);
-            JOptionPane.showMessageDialog(me, MessageManager.formatMessage(
+            JvOptionPane.showMessageDialog(me, MessageManager.formatMessage(
                     "label.error_whilst_saving_current_state_to",
                     new Object[] { choice.getName() }), MessageManager
                     .getString("label.couldnt_save_project"),
-                    JOptionPane.WARNING_MESSAGE);
+                    JvOptionPane.WARNING_MESSAGE);
           }
           setProgressBar(null, choice.hashCode());
         }
@@ -1639,12 +1673,12 @@ public class Desktop extends jalview.jbgui.GDesktop implements
           {
             Cache.log.error("Problems whilst loading project from "
                     + choice, ex);
-            JOptionPane.showMessageDialog(Desktop.desktop, MessageManager
+            JvOptionPane.showMessageDialog(Desktop.desktop, MessageManager
                     .formatMessage(
                             "label.error_whilst_loading_project_from",
                             new Object[] { choice }), MessageManager
                     .getString("label.couldnt_load_project"),
-                    JOptionPane.WARNING_MESSAGE);
+                    JvOptionPane.WARNING_MESSAGE);
           }
           setProgressBar(null, choice.hashCode());
         }
@@ -1929,7 +1963,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
         String fle = chooser.getSelectedFile().toString();
         if (!vamsasImport(chooser.getSelectedFile()))
         {
-          JOptionPane
+          JvOptionPane
                   .showInternalMessageDialog(
                           Desktop.desktop,
                           MessageManager.formatMessage(
@@ -1937,7 +1971,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
                                   new Object[] { fle }),
                           MessageManager
                                   .getString("label.vamsas_document_import_failed"),
-                          JOptionPane.ERROR_MESSAGE);
+                          JvOptionPane.ERROR_MESSAGE);
         }
       }
     }
@@ -2188,9 +2222,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements
   {
     if (v_client != null)
     {
-      JalviewFileChooser chooser = new JalviewFileChooser(
-              Cache.getProperty("LAST_DIRECTORY"), "vdj",
-              "Vamsas Document", "Vamsas Document");
+   // TODO: VAMSAS DOCUMENT EXTENSION is VDJ
+      JalviewFileChooser chooser = new JalviewFileChooser("vdj",
+              "Vamsas Document");
 
       chooser.setFileView(new JalviewFileView());
       chooser.setDialogTitle(MessageManager
@@ -2228,9 +2262,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements
         removeProgressPanel(progpanel);
         if (warnmsg != null)
         {
-          JOptionPane.showInternalMessageDialog(Desktop.desktop,
+          JvOptionPane.showInternalMessageDialog(Desktop.desktop,
 
-          warnmsg, warnttl, JOptionPane.ERROR_MESSAGE);
+          warnmsg, warnttl, JvOptionPane.ERROR_MESSAGE);
         }
       }
     }
@@ -2246,7 +2280,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
    */
   public void setVamsasUpdate(boolean b)
   {
-    jalview.bin.Cache.log.debug("Setting gui for Vamsas update "
+    Cache.log.debug("Setting gui for Vamsas update "
             + (b ? "in progress" : "finished"));
 
     if (vamUpdate != null)
@@ -2281,6 +2315,86 @@ 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
+          List<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());
+          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);
+
+          JvOptionPane.showMessageDialog(Desktop.desktop, msgPanel,
+                  MessageManager
+                          .getString("label.SEQUENCE_ID_no_longer_used"),
+                  JvOptionPane.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
@@ -2387,8 +2501,6 @@ public class Desktop extends jalview.jbgui.GDesktop implements
 
   }
 
-  protected JMenuItem groovyShell;
-
   /**
    * Accessor method to quickly get all the AlignmentFrames loaded.
    * 
@@ -2474,6 +2586,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
   /**
    * Add Groovy Support to Jalview
    */
+  @Override
   public void groovyShell_actionPerformed()
   {
     try
@@ -2482,11 +2595,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     } catch (Exception ex)
     {
       jalview.bin.Cache.log.error("Groovy Shell Creation failed.", ex);
-      JOptionPane.showInternalMessageDialog(Desktop.desktop,
+      JvOptionPane.showInternalMessageDialog(Desktop.desktop,
 
       MessageManager.getString("label.couldnt_create_groovy_shell"),
               MessageManager.getString("label.groovy_support_failed"),
-              JOptionPane.ERROR_MESSAGE);
+              JvOptionPane.ERROR_MESSAGE);
     }
   }
 
@@ -2542,8 +2655,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
   {
     getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
             KeyStroke.getKeyStroke(KeyEvent.VK_Q, Toolkit
-                    .getDefaultToolkit().getMenuShortcutKeyMask()),
-            "Quit");
+                    .getDefaultToolkit().getMenuShortcutKeyMask()), "Quit");
     getRootPane().getActionMap().put("Quit", new AbstractAction()
     {
       @Override
@@ -2750,13 +2862,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements
 
     if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
     {
-      if (jalview.ws.jws2.Jws2Discoverer.getDiscoverer().isRunning())
-      {
-        jalview.ws.jws2.Jws2Discoverer.getDiscoverer().setAborted(true);
-      }
       t2 = jalview.ws.jws2.Jws2Discoverer.getDiscoverer().startDiscoverer(
               changeSupport);
-
     }
     Thread t3 = null;
     {
@@ -2828,7 +2935,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
                  * 
                  * jd.waitForInput();
                  */
-                JOptionPane
+                JvOptionPane
                         .showConfirmDialog(
                                 Desktop.desktop,
                                 new JLabel(
@@ -2840,8 +2947,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements
                                                 + "<p>Check the <em>Connections</em> and <em>Web services</em> tab<br/>of the"
                                                 + " Tools->Preferences dialog box to change them.</p></html>"),
                                 "Web Service Configuration Problem",
-                                JOptionPane.DEFAULT_OPTION,
-                                JOptionPane.ERROR_MESSAGE);
+                                JvOptionPane.DEFAULT_OPTION,
+                                JvOptionPane.ERROR_MESSAGE);
                 serviceChangedDialog = null;
 
               }
@@ -2898,11 +3005,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements
           jalview.util.BrowserLauncher.openURL(url);
         } catch (Exception ex)
         {
-          JOptionPane.showInternalMessageDialog(Desktop.desktop,
+          JvOptionPane.showInternalMessageDialog(Desktop.desktop,
                   MessageManager
                           .getString("label.web_browser_not_found_unix"),
                   MessageManager.getString("label.web_browser_not_found"),
-                  JOptionPane.WARNING_MESSAGE);
+                  JvOptionPane.WARNING_MESSAGE);
 
           ex.printStackTrace();
         }
@@ -3210,11 +3317,10 @@ 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))
       {
-        files.add(((File)file).toString());
+        files.add(((File) file).toString());
         protocols.add(DataSourceType.FILE);
       }
     }
@@ -3227,7 +3333,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)
@@ -3282,7 +3387,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)
             {
@@ -3297,4 +3401,14 @@ public class Desktop extends jalview.jbgui.GDesktop implements
       }
     }
   }
+
+  /**
+   * Sets the Preferences property for experimental features to True or False
+   * depending on the state of the controlling menu item
+   */
+  @Override
+  protected void showExperimental_actionPerformed(boolean selected)
+  {
+    Cache.setProperty(EXPERIMENTAL_FEATURES, Boolean.toString(selected));
+  }
 }