MCPcopy Index your code
hub / github.com/benfry/processing4 / handleClose

Method handleClose

app/src/processing/app/Base.java:1693–1751  ·  view source on GitHub ↗

Close a sketch as specified by its editor window. @param editor Editor object of the sketch to be closed. @param preventQuit For platforms that must have a window open, prevent a quit because a new window will be opened (i.e. when upgrading or changing the Mode)

(Editor editor, boolean preventQuit)

Source from the content-addressed store, hash-verified

1691 * @return true if succeeded in closing, false if canceled.
1692 */
1693 public boolean handleClose(Editor editor, boolean preventQuit) {
1694 if (!editor.checkModified()) {
1695 return false;
1696 }
1697
1698 // Close the running window, avoid window boogers with multiple sketches
1699 editor.internalCloseRunner();
1700
1701 if (editors.size() == 1) {
1702 if (Platform.isMacOS()) {
1703 // If the central menu bar isn't supported on this macOS JVM,
1704 // we have to do the old behavior. Yuck!
1705 if (defaultFileMenu == null) {
1706 Object[] options = { Language.text("prompt.ok"), Language.text("prompt.cancel") };
1707
1708 int result = JOptionPane.showOptionDialog(editor,
1709 Toolkit.formatMessage("Are you sure you want to Quit?",
1710 "Closing the last open sketch will quit Processing."),
1711 "Quit",
1712 JOptionPane.YES_NO_OPTION,
1713 JOptionPane.QUESTION_MESSAGE,
1714 null,
1715 options,
1716 options[0]);
1717 if (result == JOptionPane.NO_OPTION ||
1718 result == JOptionPane.CLOSED_OPTION) {
1719 return false;
1720 }
1721 }
1722 }
1723
1724 if (defaultFileMenu == null) {
1725 if (preventQuit) {
1726 // need to close this editor, ever so temporarily
1727 editor.setVisible(false);
1728 editor.dispose();
1729 activeEditor = null;
1730 editors.remove(editor);
1731 } else {
1732 // Since this wasn't an actual Quit event, call System.exit()
1733 System.exit(0);
1734 }
1735 } else { // on OS X, update the default file menu
1736 editor.setVisible(false);
1737 editor.dispose();
1738 defaultFileMenu.insert(Recent.getMenu(), 2);
1739 activeEditor = null;
1740 editors.remove(editor);
1741 }
1742
1743 } else {
1744 // More than one editor window open,
1745 // proceed with closing the current window.
1746 editor.setVisible(false);
1747 editor.dispose();
1748 editors.remove(editor);
1749 }
1750 return true;

Callers 2

changeModeMethod · 0.95
handleDeleteCodeMethod · 0.45

Calls 12

isMacOSMethod · 0.95
textMethod · 0.95
formatMessageMethod · 0.95
getMenuMethod · 0.95
checkModifiedMethod · 0.80
setVisibleMethod · 0.65
internalCloseRunnerMethod · 0.45
sizeMethod · 0.45
disposeMethod · 0.45
removeMethod · 0.45
exitMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected