save simulation before exit
This commit is contained in:
parent
b9f1b9b205
commit
2e8ede93cf
@ -2622,8 +2622,7 @@ public class GUI extends Observable {
|
|||||||
/**
|
/**
|
||||||
* Quit program
|
* Quit program
|
||||||
*
|
*
|
||||||
* @param askForConfirmation
|
* @param askForConfirmation Should we ask for confirmation before quitting?
|
||||||
* Should we ask for confirmation before quitting?
|
|
||||||
*/
|
*/
|
||||||
public void doQuit(boolean askForConfirmation) {
|
public void doQuit(boolean askForConfirmation) {
|
||||||
if (isVisualizedInApplet()) {
|
if (isVisualizedInApplet()) {
|
||||||
@ -2631,16 +2630,26 @@ public class GUI extends Observable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (askForConfirmation) {
|
if (askForConfirmation) {
|
||||||
String s1 = "Quit";
|
if (getSimulation() != null) {
|
||||||
String s2 = "Cancel";
|
/* Save? */
|
||||||
Object[] options = { s1, s2 };
|
String s1 = "Yes";
|
||||||
|
String s2 = "No";
|
||||||
|
String s3 = "Cancel";
|
||||||
|
Object[] options = { s1, s2, s3 };
|
||||||
int n = JOptionPane.showOptionDialog(GUI.getTopParentContainer(),
|
int n = JOptionPane.showOptionDialog(GUI.getTopParentContainer(),
|
||||||
"Sure you want to quit?",
|
"Do you want to save the current simulation?",
|
||||||
"Quit", JOptionPane.YES_NO_OPTION,
|
WINDOW_TITLE, JOptionPane.YES_NO_CANCEL_OPTION,
|
||||||
JOptionPane.QUESTION_MESSAGE, null, options, s1);
|
JOptionPane.WARNING_MESSAGE, null, options, s1);
|
||||||
if (n != JOptionPane.YES_OPTION) {
|
if (n == JOptionPane.YES_OPTION) {
|
||||||
|
if (myGUI.doSaveConfig(true) == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else if (n == JOptionPane.CANCEL_OPTION) {
|
||||||
|
return;
|
||||||
|
} else if (n != JOptionPane.NO_OPTION) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getSimulation() != null) {
|
if (getSimulation() != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user