From 00854a8b46d2f16a506ce8556ce5818bca06c0c0 Mon Sep 17 00:00:00 2001 From: benfry Date: Sat, 18 Oct 2003 16:56:27 +0000 Subject: [PATCH] fix play button, was sticking.. fix renameTo when file is re-capitalized --- processing/app/PdeEditor.java | 94 +++++++++++++++++++++------------- processing/app/PdeRuntime.java | 2 +- processing/todo.txt | 10 ++-- 3 files changed, 63 insertions(+), 43 deletions(-) diff --git a/processing/app/PdeEditor.java b/processing/app/PdeEditor.java index 32e425f3f..f45e89f33 100644 --- a/processing/app/PdeEditor.java +++ b/processing/app/PdeEditor.java @@ -839,26 +839,33 @@ public class PdeEditor extends JPanel { public void run() { while (Thread.currentThread() == thread) { - if (runtime != null) { + if (runtime == null) { + stop(); + + } else { if (runtime.applet != null) { - //System.out.println(runtime.applet.finished); - buttons.running(!runtime.applet.finished); - //} else { - //System.out.println("still pooping"); + if (runtime.applet.finished) { + stop(); + } + //buttons.running(!runtime.applet.finished); + } else if (runtime.process != null) { - buttons.running(true); // ?? + //buttons.running(true); // ?? + + } else { + stop(); } - } + } try { Thread.sleep(250); } catch (InterruptedException e) { } + //System.out.println("still inside runner thread"); } } public void stop() { buttons.running(false); thread = null; - //thread.stop(); } } @@ -1257,51 +1264,64 @@ public class PdeEditor extends JPanel { // nothing changes return; } - //doSave(); // save changes before renaming.. risky but oh well - String textareaContents = textarea.getText(); - int textareaPosition = textarea.getCaretPosition(); File newSketchDir = new File(sketchDir.getParent() + File.separator + newSketchName); File newSketchFile = new File(newSketchDir, newSketchName + ".pde"); - // make new dir - newSketchDir.mkdirs(); - // copy the sketch file itself with new name - copyFile(sketchFile, newSketchFile); + //doSave(); // save changes before renaming.. risky but oh well + String textareaContents = textarea.getText(); + int textareaPosition = textarea.getCaretPosition(); - // copy everything from the old dir to the new one - copyDir(sketchDir, newSketchDir); + // if same name, but different case, just use renameTo + if (newSketchName.toLowerCase(). + equals(sketchName.toLowerCase())) { + //System.out.println("using renameTo"); - // remove the old sketch file from the new dir - new File(newSketchDir, sketchName + ".pde").delete(); + boolean problem = (sketchDir.renameTo(newSketchDir) || + sketchFile.renameTo(newSketchFile)); + if (problem) { + status.error("Error while trying to re-save the sketch."); + } - // remove the old dir (!) - if (renaming) { - // in case java is holding on to any files we want to delete - System.gc(); - removeDir(sketchDir); + } else { + // make new dir + newSketchDir.mkdirs(); + // copy the sketch file itself with new name + copyFile(sketchFile, newSketchFile); + + // copy everything from the old dir to the new one + copyDir(sketchDir, newSketchDir); + + // remove the old sketch file from the new dir + new File(newSketchDir, sketchName + ".pde").delete(); + + // remove the old dir (!) + if (renaming) { + // in case java is holding on to any files we want to delete + System.gc(); + removeDir(sketchDir); + } + + // (important!) has to be done before opening, + // otherwise the new dir is set to sketchDir.. + // remove .jar, .class, and .java files from the applet dir + File appletDir = new File(newSketchDir, "applet"); + File oldjar = new File(appletDir, sketchName + ".jar"); + if (oldjar.exists()) oldjar.delete(); + File oldjava = new File(appletDir, sketchName + ".java"); + if (oldjava.exists()) oldjava.delete(); + File oldclass = new File(appletDir, sketchName + ".class"); + if (oldclass.exists()) oldclass.delete(); } - // (important!) has to be done before opening, - // otherwise the new dir is set to sketchDir.. - - // remove .jar, .class, and .java files from the applet dir - File appletDir = new File(newSketchDir, "applet"); - File oldjar = new File(appletDir, sketchName + ".jar"); - if (oldjar.exists()) oldjar.delete(); - File oldjava = new File(appletDir, sketchName + ".java"); - if (oldjava.exists()) oldjava.delete(); - File oldclass = new File(appletDir, sketchName + ".class"); - if (oldclass.exists()) oldclass.delete(); + // get the changes into the sketchbook menu base.rebuildSketchbookMenu(); // open the new guy handleOpen(newSketchName, newSketchFile, newSketchDir); // update with the new junk and save that as the new code - //textarea.editorSetText(textareaContents); - //textarea.setText(textareaContents); changeText(textareaContents, true); textarea.setCaretPosition(textareaPosition); doSave(); diff --git a/processing/app/PdeRuntime.java b/processing/app/PdeRuntime.java index de7e41d49..9fd1be75b 100644 --- a/processing/app/PdeRuntime.java +++ b/processing/app/PdeRuntime.java @@ -298,7 +298,7 @@ public class PdeRuntime implements PdeMessageConsumer { // this handles errors that happen inside setup() // mod by fry for removal of KjcEngine - //newMessage = true; + applet.finished = true; leechErr.println(BApplet.LEECH_WAKEUP); e.printStackTrace(this.leechErr); } diff --git a/processing/todo.txt b/processing/todo.txt index 1b4dc0ebb..1f366592c 100644 --- a/processing/todo.txt +++ b/processing/todo.txt @@ -13,10 +13,11 @@ X is this a p5 bug? or his bug? X http://www.cs.uml.edu/~jzhou/previous/91.541/hw1_applet/my_cellular_automata_2.pde X new code from toxi for changes to how image api functions are laid out X runtime exceptions are killing the environment - -_ play button stays stuck on runtime exceptions - -_ rename bug is destroying files +X play button stays stuck on runtime exceptions +X rewrote pieces of the code +X also the thread wasn't exiting properly, could cause slowdowns +X rename bug is destroying files +X if saveas/rename names match, use renameTo _ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1065306548 _ macosx open sketch folder problems.. spaces in filename problem? @@ -29,7 +30,6 @@ _ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs _ curvePoint not initializing _ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1065383874 - _ new html code for eolas patent case _ move html to external file in the lib folder