Fix: when there an empty queue, display a better exit dialog

This commit is contained in:
Laurent Clouet
2023-09-09 13:29:23 +02:00
parent ef81e2384b
commit 39182e0f92

View File

@@ -559,17 +559,30 @@ public class Working implements Activity {
} }
int jobsQueueSize = getJobsQueueSize(client); int jobsQueueSize = getJobsQueueSize(client);
int userDecision = showCloseDialog(jobsQueueSize); if (jobsQueueSize == 0) {
int userDecision = showCloseDialogNoFrame();
if (userDecision == 0) { if (userDecision == 0) {
finishJobBeforeExit(client, jobsQueueSize); exitImmediately(client);
}
} }
else if (userDecision == 1) { else {
exitImmediately(client); int userDecision = showCloseDialog(jobsQueueSize);
if (userDecision == 0) {
finishJobBeforeExit(client, jobsQueueSize);
}
else if (userDecision == 1) {
exitImmediately(client);
}
} }
} }
} }
public int showCloseDialogNoFrame() {
String[] exitJobOptions = {"Exit Immediately", "Do Nothing" };
return JOptionPane.showOptionDialog(null, "Exit Now or Later", "Exit Now or Later",
JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, exitJobOptions, exitJobOptions[1]); // Make the "Do nothing" button the default one to avoid mistakes
}
public int showCloseDialog(int jobsQueueSize) { public int showCloseDialog(int jobsQueueSize) {
String[] exitJobOptions = { "Exit after current Jobs", "Exit Immediately", "Do Nothing" }; String[] exitJobOptions = { "Exit after current Jobs", "Exit Immediately", "Do Nothing" };
return JOptionPane.showOptionDialog(null, String.format( return JOptionPane.showOptionDialog(null, String.format(