Roll back introduction of enum for handleClose param.

This commit is contained in:
Jonathan Feinberg
2014-04-17 13:14:04 -04:00
parent 13ec3ce8ee
commit 406f2c3ffa
3 changed files with 9 additions and 13 deletions
+6 -8
View File
@@ -623,13 +623,13 @@ public class Base {
if (newModeCanHandleCurrentSource) {
final File props = new File(sketch.getCodeFolder(), "sketch.properties");
saveModeSettings(props, nextMode);
handleClose(activeEditor, LastEditorClosePolicy.DO_NOT_QUIT);
handleClose(activeEditor, true);
handleOpen(sketch.getMainFilePath());
} else {
// If you're changing modes, and there's nothing in the current sketch, you probably
// don't intend to keep the old, wrong-mode editor around.
if (sketch.isUntitled()) {
handleClose(activeEditor, LastEditorClosePolicy.DO_NOT_QUIT);
handleClose(activeEditor, true);
}
handleNew();
}
@@ -1074,16 +1074,14 @@ public class Base {
return null;
}
enum LastEditorClosePolicy {
QUIT, DO_NOT_QUIT
}
/**
* 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.
*/
public boolean handleClose(Editor editor, LastEditorClosePolicy closePolicy) {
public boolean handleClose(Editor editor, boolean modeSwitch) {
// Check if modified
// boolean immediate = editors.size() == 1;
if (!editor.checkModified()) {
@@ -1140,7 +1138,7 @@ public class Base {
Preferences.save();
if (defaultFileMenu == null) {
if (closePolicy == LastEditorClosePolicy.DO_NOT_QUIT) {
if (modeSwitch) {
// need to close this editor, ever so temporarily
editor.setVisible(false);
editor.dispose();
+2 -3
View File
@@ -22,7 +22,6 @@
package processing.app;
import processing.app.Base.LastEditorClosePolicy;
import processing.app.contrib.ToolContribution;
import processing.app.syntax.*;
import processing.app.tools.*;
@@ -127,7 +126,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
// add listener to handle window close box hit event
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
base.handleClose(Editor.this, LastEditorClosePolicy.QUIT);
base.handleClose(Editor.this, false);
}
});
// don't close the window when clicked, the app will take care
@@ -602,7 +601,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
item = Toolkit.newJMenuItem("Close", 'W');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
base.handleClose(Editor.this, LastEditorClosePolicy.QUIT);
base.handleClose(Editor.this, false);
}
});
fileMenu.add(item);
+1 -2
View File
@@ -23,7 +23,6 @@
package processing.app;
import processing.app.Base.LastEditorClosePolicy;
import processing.core.*;
import java.awt.*;
@@ -570,7 +569,7 @@ public class Sketch {
// make a new sketch, and i think this will rebuild the sketch menu
//editor.handleNewUnchecked();
//editor.handleClose2();
editor.base.handleClose(editor, LastEditorClosePolicy.QUIT);
editor.base.handleClose(editor, false);
} else {
// delete the file