- labels: 518468 -->
When closing the program before saving alignment
changes, a dialog box comes up with the message:
"Please Save Current File"
Ater hitting ok, a file save box comes up when then has
to be canceled if the user doesn't want to save.
In my version, I have replaced the code (see below)
with a 2 part dialog box that says
"Save <file name>" with yes-no options. That way I can
avoid going to the file save box if I don't want to save
my changes.
I would prefer to have a yes-no-cancel options (hooks
are shown below) but the cancel code didn't work so I
just give the user the yes-no options
Enjoy!
Old:
if (alignment.hasChanged()) {
JOptionPane.showMessageDialog
(AlignmentFrame.this,
"Please save current file.");
alignmentSaveAsQuery();
}
========================
New:
if (alignment.hasChanged())
{
try
{
switch
(JOptionPane.showConfirmDialog(AlignmentFrame.this,
"Save "
+ AlignmentFrame.this.alignment.getName(),
"Save",
JOptionPane.YES_NO_OPTION))
{
case
JOptionPane.YES_OPTION: // statements to execute
if variable equals value1
alignmentSaveAsQuery();
break;
case JOptionPane.NO_OPTION:
break;
case JOptionPane.CANCEL_OPTION:
return;
default:
return;
}
}
catch (Exception ex)
{
ErrorDialog.showErrorDialog
(AlignmentFrame.this,
"Unable to
save "
+ "alignment: ",
ex);
}
}