- super();
- /**
- * A note to implementors. It is ESSENTIAL that any activities that might
- * block are spawned off as threads rather than waited for during this
- * constructor.
- */
- instance = this;
- if (!Platform.isJS())
- {
- doVamsasClientCheck();
- }
-
- doConfigureStructurePrefs();
- setTitle("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- boolean selmemusage = jalview.bin.Cache.getDefault("SHOW_MEMUSAGE",
- false);
- boolean showjconsole = jalview.bin.Cache.getDefault("SHOW_JAVA_CONSOLE",
- false);
- desktop = new MyDesktopPane(selmemusage);
-
- showMemusage.setSelected(selmemusage);
- desktop.setBackground(Color.white);
- getContentPane().setLayout(new BorderLayout());
- // alternate config - have scrollbars - see notes in JAL-153
- // JScrollPane sp = new JScrollPane();
- // sp.getViewport().setView(desktop);
- // getContentPane().add(sp, BorderLayout.CENTER);
-
- // BH 2018 - just an experiment to try unclipped JInternalFrames.
- if (Platform.isJS())
+ return Jalview.isHeadlessMode() ? null
+ : (Desktop) ApplicationSingletonProvider
+ .getInstance(Desktop.class);
+ }
+
+ /**
+ * 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.
+ *
+ * @param forInstance
+ */
+ public Desktop(boolean forInstance)
+ {
+
+ Cache.initLogger();
+ instanceOnly = true;
+ }
+
+ /**
+ * Private constructor enforces singleton pattern. It is called by reflection
+ * from ApplicationSingletonProvider.getInstance().
+ */
+ @SuppressWarnings("unused")
+ private Desktop()
+ {
+ Cache.initLogger();
+ try