Minor updates
[jalview.git] / src / jalview / gui / Desktop.java
index 8b12ca8..3cecfdd 100644 (file)
@@ -227,18 +227,6 @@ public class Desktop extends GDesktop
 
   public JInternalFrame PIDSlider;
 
-  /**
-   * just an instance (for testng, probably); no actual frames
-   * 
-   * This flag, when set true, allows a headless-like operation, with a Desktop
-   * object but no actual frames. Though not headless, this option disallows
-   * dialogs to run in test environments.
-   * 
-   * It is set by invoking Desktop.getInstanceOnly().
-   * 
-   */
-  static boolean instanceOnly;
-
   class MyDesktopManager implements DesktopManager
   {
 
@@ -377,20 +365,6 @@ public class Desktop extends GDesktop
             : (Desktop) ApplicationSingletonProvider
                     .getInstance(Desktop.class);
   }
-
-  /**
-   * For TestNG, this constructor can be utilized to allow the creation of a
-   * singleton Desktop instance with the creation of frames, but no addition to
-   * the Desktop object, as in headless mode. Dialogs are not initiated.
-   * Cache.log is also initialized for some tests that require it despite there
-   * being no Desktop.
-   * 
-   */
-  public static Desktop getInstanceOnly()
-  {
-    instanceOnly = true;
-    return getInstance();
-  }
   
   /**
    * Private constructor enforces singleton pattern. It is called by reflection
@@ -497,88 +471,94 @@ public class Desktop extends GDesktop
 
         getIdentifiersOrgData();
 
-        checkURLLinks();
+        if (Jalview.isInteractive())
+        {
+          // disabled for SeqCanvasTest
+          checkURLLinks();
 
-        // Spawn a thread that shows the splashscreen
+          // Spawn a thread that shows the splashscreen
 
-        SwingUtilities.invokeLater(new Runnable()
-        {
-          @Override
-          public void run()
+          SwingUtilities.invokeLater(new Runnable()
           {
-            new SplashScreen();
-          }
-        });
+            @Override
+            public void run()
+            {
+              new SplashScreen();
+            }
+          });
 
-        // Thread off a new instance of the file chooser - this reduces the time
-        // it
-        // takes to open it later on.
-        new Thread(new Runnable()
-        {
-          @Override
-          public void run()
+          // Thread off a new instance of the file chooser - this reduces the
+          // time
+          // it
+          // takes to open it later on.
+          new Thread(new Runnable()
           {
-            Cache.log.debug("Filechooser init thread started.");
-            String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
-            JalviewFileChooser.forRead(Cache.getProperty("LAST_DIRECTORY"),
-                    fileFormat);
-            Cache.log.debug("Filechooser init thread finished.");
-          }
-        }).start();
-        // Add the service change listener
-        changeSupport.addJalviewPropertyChangeListener("services",
-                new PropertyChangeListener()
-                {
-
-                  @Override
-                  public void propertyChange(PropertyChangeEvent evt)
+            @Override
+            public void run()
+            {
+              Cache.log.debug("Filechooser init thread started.");
+              String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
+              JalviewFileChooser.forRead(
+                      Cache.getProperty("LAST_DIRECTORY"), fileFormat);
+              Cache.log.debug("Filechooser init thread finished.");
+            }
+          }).start();
+          // Add the service change listener
+          changeSupport.addJalviewPropertyChangeListener("services",
+                  new PropertyChangeListener()
                   {
-                    Cache.log.debug("Firing service changed event for "
-                            + evt.getNewValue());
-                    JalviewServicesChanged(evt);
-                  }
-
-                });
 
-      }
+                    @Override
+                    public void propertyChange(PropertyChangeEvent evt)
+                    {
+                      Cache.log.debug("Firing service changed event for "
+                              + evt.getNewValue());
+                      JalviewServicesChanged(evt);
+                    }
 
-      this.setDropTarget(new java.awt.dnd.DropTarget(desktopPane, this));
+                  });
 
-      this.addWindowListener(new WindowAdapter()
-      {
-        @Override
-        public void windowClosing(WindowEvent evt)
-        {
-          quit();
         }
-      });
 
-      MouseAdapter ma;
-      this.addMouseListener(ma = new MouseAdapter()
-      {
-        @Override
-        public void mousePressed(MouseEvent evt)
+        this.setDropTarget(new java.awt.dnd.DropTarget(desktopPane, this));
+
+        this.addWindowListener(new WindowAdapter()
         {
-          if (evt.isPopupTrigger()) // Mac
+          @Override
+          public void windowClosing(WindowEvent evt)
           {
-            showPasteMenu(evt.getX(), evt.getY());
+            quit();
           }
-        }
+        });
 
-        @Override
-        public void mouseReleased(MouseEvent evt)
+        MouseAdapter ma;
+        this.addMouseListener(ma = new MouseAdapter()
         {
-          if (evt.isPopupTrigger()) // Windows
+          @Override
+          public void mousePressed(MouseEvent evt)
           {
-            showPasteMenu(evt.getX(), evt.getY());
+            if (evt.isPopupTrigger()) // Mac
+            {
+              showPasteMenu(evt.getX(), evt.getY());
+            }
           }
-        }
-      });
-      desktopPane.addMouseListener(ma);
+
+          @Override
+          public void mouseReleased(MouseEvent evt)
+          {
+            if (evt.isPopupTrigger()) // Windows
+            {
+              showPasteMenu(evt.getX(), evt.getY());
+            }
+          }
+        });
+        desktopPane.addMouseListener(ma);
+      }
     } catch (Throwable t)
     {
       t.printStackTrace();
     }
+
   }
 
   /**
@@ -924,9 +904,9 @@ public class Desktop extends GDesktop
     }
     // THIS IS A PUBLIC STATIC METHOD, SO IT MAY BE CALLED EVEN IN
     // A HEADLESS STATE WHEN NO DESKTOP EXISTS. MUST RETURN
-    // IF JALVIEW IS RUNNING HEADLESS OR IN INSTANCE-ONLY (testNG) MODE
+    // IF JALVIEW IS RUNNING HEADLESS
     // ///////////////////////////////////////////////
-    if (Jalview.isHeadlessMode() || Desktop.instanceOnly)
+    if (Jalview.isHeadlessMode())
     {
       return;
     }
@@ -3309,7 +3289,7 @@ public class Desktop extends GDesktop
           {
           }
         }
-        if (instanceOnly || Jalview.isHeadlessMode())
+        if (Jalview.isHeadlessMode())
         {
           return;
         }