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();