public static MyDesktopPane getDesktopPane()
{
- return Desktop.getInstance().desktopPane;
+ Desktop desktop = Desktop.getInstance();
+ return desktop == null ? null : desktop.desktopPane;
}
- public StructureSelectionManager getStructureSelectionManager()
+ public static StructureSelectionManager getStructureSelectionManager()
{
return StructureSelectionManager
- .getStructureSelectionManager(this);
+ .getStructureSelectionManager(getInstance());
}
static int openFrameCount = 0;
private static int fileLoadingCount = 0;
- public JInternalFrame conservationSlider, PIDSlider;
+ public JInternalFrame conservationSlider;
+
+ public JInternalFrame PIDSlider;
/**
* just an instance (for testng, probably); no actual frames
*/
public static Desktop getInstance()
{
- return (Desktop) ApplicationSingletonProvider
- .getInstance(Desktop.class);
+ return Jalview.isHeadlessMode() ? null
+ : (Desktop) ApplicationSingletonProvider
+ .getInstance(Desktop.class);
}
/**
@SuppressWarnings("unused")
private Desktop()
{
+ try
+ {
/**
* A note to implementors. It is ESSENTIAL that any activities that might
* block are spawned off as threads rather than waited for during this
}
});
desktopPane.addMouseListener(ma);
+ } catch (Throwable t)
+ {
+ t.printStackTrace();
+ }
}
/**
public void doConfigureStructurePrefs()
{
// configure services
- StructureSelectionManager ssm = getStructureSelectionManager();
+ StructureSelectionManager ssm = StructureSelectionManager
+ .getStructureSelectionManager(this);
if (jalview.bin.Cache.getDefault(Preferences.ADD_SS_ANN, true))
{
ssm.setAddTempFacAnnot(jalview.bin.Cache
FileFormatI format = new IdentifyFile().identify(file,
DataSourceType.PASTE);
- new FileLoader().LoadFile(file, DataSourceType.PASTE, format);
+ new FileLoader().loadFile(file, DataSourceType.PASTE, format);
}
} catch (Exception ex)
final JInternalFrame frame, String title, int w, int h,
boolean resizable)
{
- addInternalFrame(frame, title, true, w, h, resizable, false);
+ addInternalFrame(frame, title, true, w, h, resizable, false, null);
+ }
+
+ /**
+ * Add an internal frame to the Jalview desktop
+ *
+ * @param frame
+ * Frame to show
+ * @param title
+ * Visible Title
+ * @param makeVisible
+ * When true, display frame immediately, otherwise, caller must call
+ * setVisible themselves.
+ * @param w
+ * width
+ * @param h
+ * height
+ * @param resizable
+ * Allow resize
+ * @param ignoreMinSize
+ * Do not set the default minimum size for frame
+ */
+ public static synchronized void addInternalFrame(
+ JInternalFrame frame, String title, boolean makeVisible, int w,
+ int h, boolean resizable, boolean ignoreMinSize)
+ {
+ addInternalFrame(frame, title, makeVisible, w, h, resizable,
+ ignoreMinSize, null);
}
/**
* Allow resize
* @param ignoreMinSize
* Do not set the default minimum size for frame
+ * @param name
+ * for HTML div embedding
*/
public static synchronized void addInternalFrame(
final JInternalFrame frame, String title, boolean makeVisible,
- int w, int h, boolean resizable, boolean ignoreMinSize)
+ int w, int h, boolean resizable, boolean ignoreMinSize,
+ String name)
{
+
// TODO: allow callers to determine X and Y position of frame (eg. via
// bounds object).
// TODO: consider fixing method to update entries in the window submenu with
// the current window title
+ if (name != null)
+ {
+ frame.setName(Jalview.getAppID(name));
+ }
+
frame.setTitle(title);
if (frame.getWidth() < 1 || frame.getHeight() < 1)
{
{
Platform.cacheFileData((File) file);
}
- new FileLoader().LoadFile(null, file, protocol, format);
+ new FileLoader().loadFile(null, file, protocol, format);
}
} catch (Exception ex)
}
}
- new FileLoader().LoadFile(viewport, selectedFile,
+ new FileLoader().loadFile(viewport, selectedFile,
DataSourceType.FILE, format);
}
});
{
if (viewport != null)
{
- new FileLoader().LoadFile(viewport, url, DataSourceType.URL,
+ new FileLoader().loadFile(viewport, url, DataSourceType.URL,
FileFormat.Jalview);
}
else
{
- new FileLoader().LoadFile(url, DataSourceType.URL,
+ new FileLoader().loadFile(url, DataSourceType.URL,
FileFormat.Jalview);
}
}
if (viewport != null)
{
- new FileLoader().LoadFile(viewport, url, DataSourceType.URL,
+ new FileLoader().loadFile(viewport, url, DataSourceType.URL,
format);
}
else
{
- new FileLoader().LoadFile(url, DataSourceType.URL, format);
+ new FileLoader().loadFile(url, DataSourceType.URL, format);
}
}
}
public static groovy.ui.Console getGroovyConsole()
{
- return Desktop.getInstance().groovyConsole;
+ Desktop desktop = Desktop.getInstance();
+ return desktop == null ? null : desktop.groovyConsole;
}
/**