import java.io.File;
import java.util.Date;
+import java.util.List;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import com.formdev.flatlaf.extras.FlatDesktop;
+import jalview.api.AlignmentViewPanel;
import jalview.bin.Console;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.SequenceI;
+import jalview.gui.AlignFrame;
+import jalview.gui.Desktop;
import jalview.io.BackupFiles;
+import jalview.project.Jalview2XML;
import jalview.util.MessageManager;
import jalview.util.Platform;
Console.debug("Non interactive quit -- not confirming");
confirmQuit = false;
}
- /*
- else if (undostack is empty) {
+ else if (Jalview2XML.allSavedUpToDate())
+ {
Console.debug("Nothing changed -- not confirming quit");
- confirmQuit = false
+ confirmQuit = false;
}
- */
else
{
confirmQuit = jalview.bin.Cache
// the save time to finish!
if (confirmQuit)
{
- answer = frameOnTop(MessageManager.getString("label.quit_jalview"),
+ answer = frameOnTop(
+ new StringBuilder(
+ MessageManager.getString("label.quit_jalview"))
+ .append(" ")
+ .append(MessageManager
+ .getString("label.unsaved_changes"))
+ .toString(),
MessageManager.getString("action.quit"),
JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
}
}
// check for saves in progress
- int waitForSave = 5000; // MAKE THIS BETTER
- int waitIncrement = 2000;
+ int waitForSave = 1000; // MAKE THIS BETTER
+ AlignFrame[] afArray = Desktop.getAlignFrames();
+ if (afArray == null || afArray.length == 0)
+ {
+ // no change
+ }
+ else
+ {
+ int size = 0;
+ for (int i = 0; i < afArray.length; i++)
+ {
+ AlignFrame af = afArray[i];
+ List<AlignmentViewPanel> avpList = (List<AlignmentViewPanel>) af
+ .getAlignPanels();
+ for (AlignmentViewPanel avp : avpList)
+ {
+ AlignmentI a = avp.getAlignment();
+ List<SequenceI> sList = a.getSequences();
+ for (SequenceI s : sList)
+ {
+ size += s.getLength();
+ }
+ }
+ }
+ waitForSave = size;
+ Console.debug("Set waitForSave to " + waitForSave);
+ }
+ int waitIncrement = 3000;
long startTime = new Date().getTime();
boolean saving = BackupFiles.hasSavesInProgress();
if (saving)
{
StringBuilder messageSB = new StringBuilder(
MessageManager.getString("label.save_in_progress"));
+ messageSB.append(":");
+ boolean any = false;
for (File file : BackupFiles.savesInProgressFiles())
{
- messageSB.append("\n");
+ messageSB.append("\n- ");
messageSB.append(file.getName());
+ any = true;
+ }
+ if (!any)
+ {
+ messageSB.append("\n");
+ messageSB.append(MessageManager.getString("label.unknown"));
}
int waitLonger = interactive ? JOptionPane.YES_OPTION
: JOptionPane.NO_OPTION;
MessageManager.getString("action.wait"));
if (waitLonger == JOptionPane.YES_OPTION) // wait
{
- Console.debug("*** YES answer=" + waitLonger);
// do wait stuff
saving = !waitForSave(waitIncrement);
}
else if (waitLonger == JOptionPane.NO_OPTION) // force quit
{
- Console.debug("*** NO answer=" + waitLonger);
// do a force quit
return returnResponse(QResponse.FORCE_QUIT); // shouldn't reach this
}
else if (waitLonger == JOptionPane.CANCEL_OPTION) // cancel quit
{
- Console.debug("*** CANCEL answer=" + waitLonger);
return returnResponse(QResponse.CANCEL_QUIT);
}
else