in app/src/main/java/com/oracle/javafx/scenebuilder/app/SceneBuilderApp.java [710:790]
private void performExit() {
// Check if an editing session is on going
for (DocumentWindowController dwc : windowList) {
if (dwc.getEditorController().isTextEditingSessionOnGoing()) {
// Check if we can commit the editing session
if (dwc.getEditorController().canGetFxmlText() == false) {
// Commit failed
return;
}
}
}
// Collects the documents with pending changes
final List<DocumentWindowController> pendingDocs = new ArrayList<>();
for (DocumentWindowController dwc : windowList) {
if (dwc.isDocumentDirty()) {
pendingDocs.add(dwc);
}
}
// Notifies the user if some documents are dirty
final boolean exitConfirmed;
switch (pendingDocs.size()) {
case 0: {
exitConfirmed = true;
break;
}
case 1: {
final DocumentWindowController dwc0 = pendingDocs.get(0);
exitConfirmed = dwc0.performCloseAction() == ActionStatus.DONE;
break;
}
default: {
assert pendingDocs.size() >= 2;
final AlertDialog d = new AlertDialog(null);
d.setMessage(I18N.getString("alert.review.question.message", pendingDocs.size()));
d.setDetails(I18N.getString("alert.review.question.details"));
d.setOKButtonTitle(I18N.getString("label.review.changes"));
d.setActionButtonTitle(I18N.getString("label.discard.changes"));
d.setActionButtonVisible(true);
switch (d.showAndWait()) {
default:
case OK: { // Review
int i = 0;
ActionStatus status;
do {
status = pendingDocs.get(i++).performCloseAction();
} while ((status == ActionStatus.DONE) && (i < pendingDocs.size()));
exitConfirmed = (status == ActionStatus.DONE);
break;
}
case CANCEL: {
exitConfirmed = false;
break;
}
case ACTION: { // Do not review
exitConfirmed = true;
break;
}
}
break;
}
}
// Exit if confirmed
if (exitConfirmed) {
for (DocumentWindowController dwc : new ArrayList<>(windowList)) {
// Write to java preferences before closing
dwc.updatePreferences();
documentWindowRequestClose(dwc);
}
logTimestamp(ACTION.STOP);
// TODO (elp): something else here ?
Platform.exit();
}
}