X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDesktop.java;h=8b12ca891a88403694d41306421cecb8530dd16b;hb=refs%2Fheads%2FJAL-3437_load_project;hp=85ec3aecf2c5b616c88a8e7e80522f6a69f42be2;hpb=cb51e62fe2166b236ef488e0a8f35081fcd71388;p=jalview.git diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 85ec3aecf..8b12ca8 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -231,18 +231,13 @@ public class Desktop extends GDesktop * 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. The issue has to do with the mess-up of the - * Windows JInternalFrame implementation, which surreptitiously and - * unforgivingly accesses a native peer class, preventing headless operation. + * object but no actual frames. Though not headless, this option disallows + * dialogs to run in test environments. * - * It is set by invoking the Desktop(true) constructor. - * - * It is possible that we can remove this option now, since headless mode is - * finally working on Windows through careful attention to not creating any - * JInternalFrame objects when in that mode. + * It is set by invoking Desktop.getInstanceOnly(). * */ - private boolean instanceOnly; + static boolean instanceOnly; class MyDesktopManager implements DesktopManager { @@ -384,26 +379,23 @@ public class Desktop extends GDesktop } /** - * For testing purposes, this constructor can be utilized to allow the creation - * of a singleton Desktop instance without the formation of frames. The Cache is - * initialized, but that is all. - * - * It is not currently used. + * 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. * - * @param forInstance */ - public Desktop(boolean forInstance) + public static Desktop getInstanceOnly() { - - Cache.initLogger(); instanceOnly = true; + return getInstance(); } /** * Private constructor enforces singleton pattern. It is called by reflection * from ApplicationSingletonProvider.getInstance(). */ - @SuppressWarnings("unused") private Desktop() { Cache.initLogger(); @@ -932,9 +924,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 + // IF JALVIEW IS RUNNING HEADLESS OR IN INSTANCE-ONLY (testNG) MODE // /////////////////////////////////////////////// - if (Jalview.isHeadlessMode() || Desktop.getInstance().instanceOnly) + if (Jalview.isHeadlessMode() || Desktop.instanceOnly) { return; } @@ -1881,7 +1873,7 @@ public class Desktop extends GDesktop { try { - new Jalview2XML().loadJalviewAlign(choice); + new Jalview2XML().loadJalviewAlign(selectedFile); } catch (OutOfMemoryError oom) { new OOMWarning("Whilst loading project from " + choice, oom); @@ -3317,7 +3309,7 @@ public class Desktop extends GDesktop { } } - if (instanceOnly) + if (instanceOnly || Jalview.isHeadlessMode()) { return; }