import javax.swing.JCheckBoxMenuItem;
import javax.swing.JColorChooser;
-import javax.swing.JInternalFrame;
import javax.swing.JMenu;
-import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.SwingUtilities;
openNewJmol(ap, pe, seqs);
}
- /**
- * Returns a list of any Jmol viewers. The list is restricted to those linked
- * to the given alignment panel if it is not null.
- */
- @Override
- protected List<StructureViewerBase> getViewersFor(AlignmentPanel apanel)
- {
- List<StructureViewerBase> result = new ArrayList<StructureViewerBase>();
- JInternalFrame[] frames = Desktop.instance.getAllFrames();
-
- for (JInternalFrame frame : frames)
- {
- if (frame instanceof AppJmol)
- {
- if (apanel == null
- || ((StructureViewerBase) frame).isLinkedWith(apanel))
- {
- result.add((StructureViewerBase) frame);
- }
- }
- }
- return result;
- }
-
void initJmol(String command)
{
jmb.setFinishedInit(false);
import javax.swing.JColorChooser;
import javax.swing.JInternalFrame;
import javax.swing.JMenu;
-import javax.swing.JOptionPane;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.MenuEvent;
setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE);
}
- /**
- * Returns a list of any Chimera viewers in the desktop. The list is
- * restricted to those linked to the given alignment panel if it is not null.
- */
- @Override
- protected List<StructureViewerBase> getViewersFor(AlignmentPanel ap)
- {
- List<StructureViewerBase> result = new ArrayList<StructureViewerBase>();
- JInternalFrame[] frames = Desktop.instance.getAllFrames();
-
- for (JInternalFrame frame : frames)
- {
- if (frame instanceof ChimeraViewFrame)
- {
- if (ap == null || ((StructureViewerBase) frame).isLinkedWith(ap))
- {
- result.add((StructureViewerBase) frame);
- }
- }
- }
- return result;
- }
/**
* Launch Chimera. If we have a chimera session file name, send Chimera the
* option to close the associated Chimera window (process). They may wish to
* keep it open until they have had an opportunity to save any work.
*
- * @param closeChimera
+ * @param forceCloseChimera
* if true, close any linked Chimera process; if false, prompt first
*/
@Override
- public void closeViewer(boolean closeChimera)
+ public void closeViewer(boolean forceCloseChimera)
{
- if (jmb != null && jmb.isChimeraRunning())
+ if (jmb != null)
{
- if (!closeChimera)
+ if (jmb.isChimeraRunning())
{
- String prompt = MessageManager.formatMessage(
- "label.confirm_close_chimera",
- new Object[] { jmb.getViewerTitle("Chimera", false) });
- prompt = JvSwingUtils.wrapTooltip(true, prompt);
- int confirm = JvOptionPane.showConfirmDialog(this, prompt,
- MessageManager.getString("label.close_viewer"),
- JvOptionPane.YES_NO_CANCEL_OPTION);
/*
- * abort closure if user hits escape or Cancel
+ * force close, or prompt to close, Chimera
*/
- if (confirm == JvOptionPane.CANCEL_OPTION
- || confirm == JvOptionPane.CLOSED_OPTION)
+ if (!forceCloseChimera)
{
- return;
+ String prompt = MessageManager.formatMessage(
+ "label.confirm_close_chimera",
+ new Object[] { jmb.getViewerTitle("Chimera", false) });
+ prompt = JvSwingUtils.wrapTooltip(true, prompt);
+ int confirm = JvOptionPane.showConfirmDialog(this, prompt,
+ MessageManager.getString("label.close_viewer"),
+ JvOptionPane.YES_NO_CANCEL_OPTION);
+ /*
+ * abort closure if user hits escape or Cancel
+ */
+ if (confirm == JvOptionPane.CANCEL_OPTION
+ || confirm == JvOptionPane.CLOSED_OPTION)
+ {
+ return;
+ }
+ forceCloseChimera = confirm == JvOptionPane.YES_OPTION;
}
- closeChimera = confirm == JvOptionPane.YES_OPTION;
}
- jmb.closeViewer(closeChimera);
+
+ /*
+ * close the viewer plus any side-effects e.g. remove mappings
+ * note we do this also if closing Chimera triggered this method
+ */
+ jmb.closeViewer(forceCloseChimera);
}
+
setAlignmentPanel(null);
_aps.clear();
_alignwith.clear();
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;
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
protected abstract boolean hasPdbId(String pdbId);
- protected abstract List<StructureViewerBase> 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<StructureViewerBase> getViewersFor(AlignmentPanel alp){
+
+ List<StructureViewerBase> result = new ArrayList<StructureViewerBase>();
+ 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
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)
{