MCPcopy Index your code
hub / github.com/processing/processing / handleClose

Method handleClose

app/src/processing/app/Base.java:1458–1541  ·  view source on GitHub ↗

Close a sketch as specified by its editor window. @param editor Editor object of the sketch to be closed. @param modeSwitch Whether this close is being done in the context of a mode switch. @return true if succeeded in closing, false if canceled.

(Editor editor, boolean modeSwitch)

Source from the content-addressed store, hash-verified

1456 * @return true if succeeded in closing, false if canceled.
1457 */
1458 public boolean handleClose(Editor editor, boolean modeSwitch) {
1459 // Check if modified
1460// boolean immediate = editors.size() == 1;
1461 if (!editor.checkModified()) {
1462 return false;
1463 }
1464
1465 // Close the running window, avoid window boogers with multiple sketches
1466 editor.internalCloseRunner();
1467
1468// System.out.println("editors size is " + editors.size());
1469 if (editors.size() == 1) {
1470 // For 0158, when closing the last window /and/ it was already an
1471 // untitled sketch, just give up and let the user quit.
1472// if (Preferences.getBoolean("sketchbook.closing_last_window_quits") ||
1473// (editor.untitled && !editor.getSketch().isModified())) {
1474 if (Platform.isMacOS()) {
1475 // If the central menubar isn't supported on this OS X JVM,
1476 // we have to do the old behavior. Yuck!
1477 if (defaultFileMenu == null) {
1478 Object[] options = { Language.text("prompt.ok"), Language.text("prompt.cancel") };
1479 String prompt =
1480 "<html> " +
1481 "<head> <style type=\"text/css\">"+
1482 "b { font: 13pt \"Lucida Grande\" }"+
1483 "p { font: 11pt \"Lucida Grande\"; margin-top: 8px; width: 300px }"+
1484 "</style> </head>" +
1485 "<b>Are you sure you want to Quit?</b>" +
1486 "<p>Closing the last open sketch will quit Processing.";
1487
1488 int result = JOptionPane.showOptionDialog(editor,
1489 prompt,
1490 "Quit",
1491 JOptionPane.YES_NO_OPTION,
1492 JOptionPane.QUESTION_MESSAGE,
1493 null,
1494 options,
1495 options[0]);
1496 if (result == JOptionPane.NO_OPTION ||
1497 result == JOptionPane.CLOSED_OPTION) {
1498 return false;
1499 }
1500 }
1501 }
1502
1503 Preferences.unset("server.port"); //$NON-NLS-1$
1504 Preferences.unset("server.key"); //$NON-NLS-1$
1505
1506// // This will store the sketch count as zero
1507// editors.remove(editor);
1508// System.out.println("editors size now " + editors.size());
1509// storeSketches();
1510
1511 // Save out the current prefs state
1512 Preferences.save();
1513
1514 if (defaultFileMenu == null) {
1515 if (modeSwitch) {

Callers 2

changeModeMethod · 0.95
handleDeleteCodeMethod · 0.45

Calls 13

isMacOSMethod · 0.95
textMethod · 0.95
unsetMethod · 0.95
saveMethod · 0.95
getMenuMethod · 0.95
checkModifiedMethod · 0.80
exitMethod · 0.80
setVisibleMethod · 0.65
internalCloseRunnerMethod · 0.45
sizeMethod · 0.45
disposeMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected