import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
+import java.beans.PropertyVetoException;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
public StructureViewerBase()
{
super();
- setFrameIcon(WindowIcons.structureIcon);
+ setFrameIcon(null);
}
/**
return session;
}
+ private static boolean quitClose = false;
+
+ public static void setQuitClose(boolean b)
+ {
+ quitClose = b;
+ }
+
+ @Override
+ public boolean stillRunning()
+ {
+ AAStructureBindingModel binding = getBinding();
+ return binding != null && binding.isViewerRunning();
+ }
+
/**
* Close down this instance of Jalview's Chimera viewer, giving the user the
* option to close the associated Chimera window (process). They may wish to
public void closeViewer(boolean forceClose)
{
AAStructureBindingModel binding = getBinding();
- if (binding != null && binding.isViewerRunning())
+ if (stillRunning())
{
if (!forceClose)
{
String viewerName = getViewerName();
- String prompt = MessageManager
- .formatMessage("label.confirm_close_viewer", new Object[]
- { binding.getViewerTitle(viewerName, false), viewerName });
- prompt = JvSwingUtils.wrapTooltip(true, prompt);
- int confirm = JvOptionPane.showConfirmDialog(this, prompt,
- MessageManager.getString("label.close_viewer"),
- JvOptionPane.YES_NO_CANCEL_OPTION);
+
+ int confirm = JvOptionPane.CANCEL_OPTION;
+ if (QuitHandler.quitting())
+ {
+ // already asked about closing external windows
+ confirm = quitClose ? JvOptionPane.YES_OPTION
+ : JvOptionPane.NO_OPTION;
+ }
+ else
+ {
+ String prompt = MessageManager
+ .formatMessage("label.confirm_close_viewer", new Object[]
+ { binding.getViewerTitle(viewerName, false),
+ viewerName });
+ prompt = JvSwingUtils.wrapTooltip(true, prompt);
+ String title = MessageManager.getString("label.close_viewer");
+ confirm = showCloseDialog(title, prompt);
+ }
+
/*
* abort closure if user hits escape or Cancel
*/
{
// abort possible quit handling if CANCEL chosen
if (confirm == JvOptionPane.CANCEL_OPTION)
+ {
+ try
+ {
+ // this is a bit futile
+ this.setClosed(false);
+ } catch (PropertyVetoException e)
+ {
+ }
QuitHandler.abortQuit();
+ }
return;
}
forceClose = confirm == JvOptionPane.YES_OPTION;
dispose();
}
+ private int showCloseDialog(final String title, final String prompt)
+ {
+ int confirmResponse = JvOptionPane.CANCEL_OPTION;
+ confirmResponse = JvOptionPane.showConfirmDialog(this, prompt,
+ MessageManager.getString("label.close_viewer"),
+ JvOptionPane.YES_NO_CANCEL_OPTION,
+ JvOptionPane.WARNING_MESSAGE);
+ return confirmResponse;
+ }
+
@Override
public void showHelp_actionPerformed()
{
&& viewerActionMenu.getItemCount() > 0
&& viewerActionMenu.isVisible();
}
+
}