* 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.
- *
*/
- private boolean instanceOnly;
+ boolean instanceOnly;
class MyDesktopManager implements DesktopManager
{
}
/**
- * 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 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.
*
* @param forInstance
*/
public Desktop(boolean forInstance)
{
-
+ ApplicationSingletonProvider.setInstance(Desktop.class, this);
Cache.initLogger();
instanceOnly = true;
}
frame.setIconifiable(resizable);
frame.setOpaque(Platform.isJS());
- if (frame.getX() < 1 && frame.getY() < 1)
+ boolean isEmbedded = (Platform.getDimIfEmbedded(frame, -1, -1) != null);
+ if (!isEmbedded && frame.getX() < 1 && frame.getY() < 1)
{
frame.setLocation(xOffset * openFrameCount,
yOffset * ((openFrameCount - 1) % 10) + yOffset);
{
}
}
- if (instanceOnly)
+ System.out.println("Desktop headless or instanceonly" + instanceOnly
+ + " " + Jalview.isHeadlessMode());
+ if (instanceOnly || Jalview.isHeadlessMode())
{
return;
}