import javax.swing.event.MenuListener;
import jalview.api.AlignmentViewPanel;
+import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
import jalview.bin.Console;
import jalview.datamodel.AlignmentI;
}
/**
+ * Singleton list of all (open) instances of structureViewerBase
+ * TODO: JAL-3362 - review and adopt the swingJS-safe singleton pattern so each structure viewer base instance is kept to its own JalviewJS parent
+ */
+ private static List<JalviewStructureDisplayI> svbs = new ArrayList<>();
+
+ /**
+ *
+ * @return list with all existing StructureViewers instance
+ */
+ public static List<JalviewStructureDisplayI> getAllStructureViewerBases()
+ {
+ List<JalviewStructureDisplayI> goodSvbs = new ArrayList<>();
+ for (JalviewStructureDisplayI s : svbs)
+ {
+ if (s != null && !goodSvbs.contains(s))
+ {
+ goodSvbs.add(s);
+ }
+ }
+ return goodSvbs;
+ }
+
+ /**
* list of sequenceSet ids associated with the view
*/
protected List<String> _aps = new ArrayList<>();
{
super();
setFrameIcon(null);
+ svbs.add(this);
}
/**
return _aps.contains(ap2.av.getSequenceSetId());
}
+ @Override
public boolean isUsedforaligment(AlignmentViewPanel ap2)
{
}
} catch (Exception e)
{
- System.err.println(
+ jalview.bin.Console.errPrintln(
"Error retrieving PDB id " + pdbid + ": " + e.getMessage());
} finally
{
// TODO: check for memory leaks where instance isn't finalised because jmb
// holds a reference to the window
// jmb = null;
+
+ try {
+ svbs.remove(this);
+ } catch (Throwable t)
+ {
+ Console.info("Unexpected exception when deregistering structure viewer",t);
+ }
dispose();
}