* only view *should* be coped with sensibly.
*/
// This must have been loaded, is it still visible?
- JInternalFrame[] frames = null;
+ List<StructureViewerBase> viewFrames = new ArrayList<>();
if (Desktop.desktop != null)
{
- frames = Desktop.desktop.getAllFrames();
+ JInternalFrame[] jifs = Desktop.desktop.getAllFrames();
+ if (jifs != null)
+ {
+ for (JInternalFrame jif : jifs)
+ {
+ if (jif instanceof StructureViewerBase)
+ {
+ viewFrames.add((StructureViewerBase) jif);
+ }
+ }
+ }
}
else if (Jalview.isHeadlessMode()
&& Jalview.getInstance().getCommands() != null)
{
- // TODO
- }
- else
- {
- frames = null;
+ viewFrames.addAll(
+ StructureViewerBase.getAllStructureViewerBases());
}
+
String matchedFile = null;
- if (frames != null)
+ for (StructureViewerBase viewFrame : viewFrames)
{
- for (int f = frames.length - 1; f > -1; f--)
+ matchedFile = saveStructureViewer(ap, jds, pdb, entry, viewIds,
+ matchedFile, viewFrame);
+ /*
+ * Only store each structure viewer's state once in the project
+ * jar. First time through only (storeDS==false)
+ */
+ String viewId = viewFrame.getViewId();
+ String viewerType = viewFrame.getViewerType().toString();
+ if (!storeDS && !viewIds.contains(viewId))
{
- if (frames[f] instanceof StructureViewerBase)
+ viewIds.add(viewId);
+ File viewerState = viewFrame.saveSession();
+ if (viewerState != null)
{
- StructureViewerBase viewFrame = (StructureViewerBase) frames[f];
- matchedFile = saveStructureViewer(ap, jds, pdb, entry,
- viewIds, matchedFile, viewFrame);
- /*
- * Only store each structure viewer's state once in the project
- * jar. First time through only (storeDS==false)
- */
- String viewId = viewFrame.getViewId();
- String viewerType = viewFrame.getViewerType().toString();
- if (!storeDS && !viewIds.contains(viewId))
- {
- viewIds.add(viewId);
- File viewerState = viewFrame.saveSession();
- if (viewerState != null)
- {
- copyFileToJar(jout, viewerState.getPath(),
- getViewerJarEntryName(viewId), viewerType);
- }
- else
- {
- Console.error("Failed to save viewer state for "
- + viewerType);
- }
- }
+ copyFileToJar(jout, viewerState.getPath(),
+ getViewerJarEntryName(viewId), viewerType);
+ }
+ else
+ {
+ Console.error(
+ "Failed to save viewer state for " + viewerType);
}
}
}