X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FStructureViewerBase.java;h=19291ac4b8f190c93bab08be1ce858da69981779;hb=refs%2Fheads%2Fbug%2FJAL-2358phantomChimera;hp=91d71309c7c57ff198eb650efd0310aed15ab70a;hpb=2da3a29ae39b692964b85456353985d388aa3858;p=jalview.git diff --git a/src/jalview/gui/StructureViewerBase.java b/src/jalview/gui/StructureViewerBase.java index 91d7130..19291ac 100644 --- a/src/jalview/gui/StructureViewerBase.java +++ b/src/jalview/gui/StructureViewerBase.java @@ -26,6 +26,7 @@ import jalview.gui.StructureViewer.ViewerType; import jalview.gui.ViewSelectionMenu.ViewSetProvider; import jalview.io.DataSourceType; import jalview.jbgui.GStructureViewer; +import jalview.structure.StructureSelectionManager; import jalview.structures.models.AAStructureBindingModel; import jalview.util.MessageManager; @@ -39,8 +40,8 @@ import java.util.List; import java.util.Vector; import javax.swing.JCheckBoxMenuItem; +import javax.swing.JInternalFrame; import javax.swing.JMenuItem; -import javax.swing.JOptionPane; /** * Base class with common functionality for JMol, Chimera or other structure @@ -352,8 +353,29 @@ public abstract class StructureViewerBase extends GStructureViewer protected abstract boolean hasPdbId(String pdbId); - protected abstract List getViewersFor( - AlignmentPanel alp); + /** + * Returns a list of any structure viewers of the same type. The list is + * restricted to those linked to the given alignment panel if it is not null. + */ + protected List getViewersFor(AlignmentPanel alp){ + + List result = new ArrayList(); + JInternalFrame[] frames = Desktop.instance.getAllFrames(); + + for (JInternalFrame frame : frames) + { + if (this.getClass().isAssignableFrom(frame.getClass())) + { + if (alp == null + || ((StructureViewerBase) frame).isLinkedWith(alp)) + { + result.add((StructureViewerBase) frame); + } + } + } + return result; + + } /** * Check for any existing views involving this alignment and give user the @@ -473,8 +495,8 @@ public abstract class StructureViewerBase extends GStructureViewer final AlignmentPanel apanel, String pdbId) { boolean finished = false; - String alreadyMapped = apanel.getStructureSelectionManager() - .alreadyMappedToFile(pdbId); + StructureSelectionManager ssm = apanel.getStructureSelectionManager(); + String alreadyMapped = ssm.alreadyMappedToFile(pdbId); if (alreadyMapped != null) {