better idea:
Desktop.getInstanceOnly()
- creates an instance with no dialog prompting and no frame display,
similar to headless mode, but not fully bypassing the code that
Jalview.headless bypasses.
* store the new singleton; note that a
* null value is saved if construction failed
*/
* store the new singleton; note that a
* null value is saved if construction failed
*/
+ getContextMap().put(c, o);
- public static void setInstance(Class<? extends ApplicationSingletonI> c,
- ApplicationSingletonI o)
- {
- getContextMap().put(c, o);
- }
/**
* Removes the current singleton instance of the given class from the current
* application context. This has the effect of ensuring that a new instance is
/**
* Removes the current singleton instance of the given class from the current
* application context. This has the effect of ensuring that a new instance is
* object but no actual frames. Though not headless, this option disallows
* dialogs to run in test environments.
*
* 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 set by invoking Desktop.getInstanceOnly().
*
*/
boolean instanceOnly;
*
*/
boolean instanceOnly;
/**
* For TestNG, this constructor can be utilized to allow the creation of a
/**
* For TestNG, this constructor can be utilized to allow the creation of a
- * singleton Desktop instance without the formation of frames and, especially,
- * not involving dialogs. Cache.log is also initialized for some tests that
- * require it despite there being no Desktop.
+ * 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 Desktop(boolean forInstance)
+ public static Desktop getInstanceOnly()
- ApplicationSingletonProvider.setInstance(Desktop.class, this);
- Cache.initLogger();
- instanceOnly = true;
+ Desktop d = (Desktop) ApplicationSingletonProvider
+ .getInstance(Desktop.class);
+ d.instanceOnly = true;
+ return d;
}
// THIS IS A PUBLIC STATIC METHOD, SO IT MAY BE CALLED EVEN IN
// A HEADLESS STATE WHEN NO DESKTOP EXISTS. MUST RETURN
}
// 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.getInstance().instanceOnly)
{
- System.out.println("Desktop headless or instanceonly" + instanceOnly
- + " " + Jalview.isHeadlessMode());
if (instanceOnly || Jalview.isHeadlessMode())
{
return;
if (instanceOnly || Jalview.isHeadlessMode())
{
return;