mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
force a save before exporting.. fixes bug #157
This commit is contained in:
+31
-5
@@ -1614,12 +1614,9 @@ public class Editor extends JFrame
|
||||
* hitting export twice, quickly, and horking things up.
|
||||
*/
|
||||
synchronized public void handleExport() {
|
||||
//String what = sketch.isLibrary() ? "Applet" : "Library";
|
||||
//message("Exporting " + what + "...");
|
||||
//message("Exporting applet...");
|
||||
if (!handleExportCheckModified()) return;
|
||||
|
||||
try {
|
||||
//boolean success = sketch.isLibrary() ?
|
||||
//sketch.exportLibrary() : sketch.exportApplet();
|
||||
boolean success = sketch.exportApplet();
|
||||
if (success) {
|
||||
File appletFolder = new File(sketch.folder, "applet");
|
||||
@@ -1636,6 +1633,8 @@ public class Editor extends JFrame
|
||||
|
||||
|
||||
synchronized public void handleExportApp() {
|
||||
if (!handleExportCheckModified()) return;
|
||||
|
||||
message("Exporting application...");
|
||||
try {
|
||||
boolean success = sketch.exportApplication();
|
||||
@@ -1654,6 +1653,33 @@ public class Editor extends JFrame
|
||||
}
|
||||
|
||||
|
||||
public boolean handleExportCheckModified() {
|
||||
if (!sketch.modified) return true;
|
||||
|
||||
Object[] options = { "OK", "Cancel" };
|
||||
int result = JOptionPane.showOptionDialog(this,
|
||||
"Save changes before export?",
|
||||
"Save",
|
||||
JOptionPane.OK_CANCEL_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE,
|
||||
null,
|
||||
options,
|
||||
options[0]);
|
||||
if (result == JOptionPane.OK_OPTION) {
|
||||
handleSave();
|
||||
|
||||
} else {
|
||||
// why it's not CANCEL_OPTION is beyond me (at least on the mac)
|
||||
// but f-- it.. let's get this shite done..
|
||||
//} else if (result == JOptionPane.CANCEL_OPTION) {
|
||||
message("Export canceled, changes must first be saved.");
|
||||
buttons.clear();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Quit, but first ask user if it's ok. Also store preferences
|
||||
* to disk just in case they want to quit. Final exit() happens
|
||||
|
||||
@@ -18,10 +18,9 @@ o also make sure pack() is happening
|
||||
X PApplet.main(new String[] { "TheClass" });
|
||||
X this will need to detect whether the user has their own main()
|
||||
o or even PApplet.main(new String[] { getClass().getName() });
|
||||
|
||||
_ save code before export, otherwise .pde exported is empty
|
||||
_ ask user ok or cancel to save code before exporting
|
||||
_ http://dev.processing.org/bugs/show_bug.cgi?id=157
|
||||
X save code before export, otherwise .pde exported is empty
|
||||
X ask user ok or cancel to save code before exporting
|
||||
X http://dev.processing.org/bugs/show_bug.cgi?id=157
|
||||
|
||||
_ documentation
|
||||
_ people using "java" mode must create their own main
|
||||
|
||||
Reference in New Issue
Block a user