mirror of
https://github.com/processing/processing4.git
synced 2026-05-03 09:26:25 +02:00
properly handle loose pde files, lots of error messages, etc
This commit is contained in:
@@ -1219,6 +1219,80 @@ public class PdeEditor extends JFrame
|
||||
*/
|
||||
protected void handleOpen2(String path) {
|
||||
try {
|
||||
// check to make sure that this .pde file is
|
||||
// in a folder of the same name
|
||||
File file = new File(path);
|
||||
File parentFile = new File(file.getParent());
|
||||
String parentName = parentFile.getName();
|
||||
String pdeName = parentName + ".pde";
|
||||
File altFile = new File(file.getParent(), pdeName);
|
||||
|
||||
//System.out.println("path = " + file.getParent());
|
||||
//System.out.println("name = " + file.getName());
|
||||
//System.out.println("pname = " + parentName);
|
||||
|
||||
if (pdeName.equals(file.getName())) {
|
||||
// no beef with this guy
|
||||
|
||||
} else if (altFile.exists()) {
|
||||
// user selected a .java from the same sketch,
|
||||
// but open the .pde instead
|
||||
path = altFile.getAbsolutePath();
|
||||
//System.out.println("found alt file in same folder");
|
||||
|
||||
} else if (!path.endsWith(".pde")) {
|
||||
PdeBase.showWarning("Bad file selected",
|
||||
"Processing can only open its own sketches\n" +
|
||||
"and other files ending in .pde", null);
|
||||
return;
|
||||
|
||||
} else {
|
||||
String properParent =
|
||||
file.getName().substring(0, file.getName().length() - 4);
|
||||
|
||||
Object[] options = { "OK", "Cancel" };
|
||||
String prompt =
|
||||
"The file \"" + file.getName() + "\" needs to be inside\n" +
|
||||
"a sketch folder named \"" + properParent + "\".\n" +
|
||||
"Create this folder, move the file, and continue?";
|
||||
|
||||
int result = JOptionPane.showOptionDialog(this,
|
||||
prompt,
|
||||
"Moving",
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE,
|
||||
null,
|
||||
options,
|
||||
options[0]);
|
||||
|
||||
if (result == JOptionPane.YES_OPTION) {
|
||||
// create properly named folder
|
||||
File properFolder = new File(file.getParent(), properParent);
|
||||
if (properFolder.exists()) {
|
||||
PdeBase.showWarning("Error",
|
||||
"A folder named \"" + properParent + "\" " +
|
||||
"already exists. Can't open sketch.", null);
|
||||
return;
|
||||
}
|
||||
if (!properFolder.mkdirs()) {
|
||||
throw new IOException("Couldn't create sketch folder");
|
||||
}
|
||||
// copy the sketch inside
|
||||
File properPdeFile = new File(properFolder, file.getName());
|
||||
File origPdeFile = new File(path);
|
||||
PdeBase.copyFile(origPdeFile, properPdeFile);
|
||||
|
||||
// remove the original file, so user doesn't get confused
|
||||
origPdeFile.delete();
|
||||
|
||||
// update with the new path
|
||||
path = properPdeFile.getAbsolutePath();
|
||||
|
||||
} else if (result == JOptionPane.NO_OPTION) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
sketch = new PdeSketch(this, path);
|
||||
header.rebuild();
|
||||
if (PdePreferences.getBoolean("console.auto_clear")) {
|
||||
|
||||
@@ -239,7 +239,7 @@ public class PdeSketchbook {
|
||||
public String handleOpen() {
|
||||
// swing's file choosers are ass ugly, so we use the
|
||||
// native (awt peered) dialogs instead
|
||||
FileDialog fd = new FileDialog(new Frame(),
|
||||
FileDialog fd = new FileDialog(editor, //new Frame(),
|
||||
"Open a Processing sketch...",
|
||||
FileDialog.LOAD);
|
||||
//if (handleOpenDirectory == null) {
|
||||
@@ -249,8 +249,10 @@ public class PdeSketchbook {
|
||||
fd.setDirectory(PdePreferences.get("sketchbook.path"));
|
||||
|
||||
// only show .pde files as eligible bachelors
|
||||
// TODO this doesn't seem to ever be used. AWESOME.
|
||||
fd.setFilenameFilter(new FilenameFilter() {
|
||||
public boolean accept(File dir, String name) {
|
||||
System.out.println("check filter on " + dir + " " + name);
|
||||
return name.endsWith(".pde");
|
||||
}
|
||||
});
|
||||
|
||||
35
todo.txt
35
todo.txt
@@ -79,7 +79,7 @@ X was adding all folders in the classpath
|
||||
X workaround for the // causing an OutOfMemoryError
|
||||
X http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1067717095
|
||||
|
||||
040622 monday evening
|
||||
040622 monday evening/night
|
||||
X jikes errors have no newlines because it's a buffered reader
|
||||
X and the newlines are removed when read
|
||||
X make the filedialog come up with the p5 window on handlenew
|
||||
@@ -113,22 +113,30 @@ X rewrite sketchbook.clean()
|
||||
X prompt user if they don't have it set to auto
|
||||
X add a pref to the preferences window
|
||||
|
||||
_ don't force everything into a single .jar on export
|
||||
040622 monday late night
|
||||
X set handleOpen to use editor as its parent frame
|
||||
X what happens when the .pde file isn't named
|
||||
X the same as the enclosing folder?
|
||||
X maybe put up a window saying no way, and ask:
|
||||
X ( ) rename enclosing or ( ) add a subfolder
|
||||
X or maybe even ( ) rename the sketch file
|
||||
X also double-check to see if there *is* a proper pde in the folder
|
||||
X in which case, default to that (maybe show a message?)
|
||||
X it's useful to have loose .pde files be runnable..
|
||||
X i.e. when double-clicking on them.. downloaded off web..
|
||||
X but need to deal with simply, not providing a new exception case
|
||||
|
||||
_ what happens when the .pde file isn't named
|
||||
_ the same as the enclosing folder?
|
||||
_ maybe put up a window saying no way, and ask:
|
||||
_ ( ) rename enclosing or ( ) add a subfolder
|
||||
_ it's useful to have loose .pde files be runnable..
|
||||
_ i.e. when double-clicking on them.. downloaded off web..
|
||||
_ but need to deal with simply, not providing a new exception case
|
||||
_ write 'new text file'
|
||||
_ write 'new text file' (ctrl-t)
|
||||
_ implement hide/unhide
|
||||
|
||||
_ ctrl-5 (at least on xp) is marking the current sketch as modified
|
||||
_ write export-to-application
|
||||
_ write export-to-library
|
||||
_ need to be able to produce the serial, video, etc libs
|
||||
_ put bagel into its own package
|
||||
_ don't force everything into a single .jar on export
|
||||
|
||||
_ running present mode with a bug in the program hoses things
|
||||
_ make sure the program compiles before starting present mode
|
||||
_ re-implement history
|
||||
|
||||
|
||||
now implemented for [url=http://processing.org/discourse/yabb/YaBB.cgi?board=Collaboration;action=display;num=1084285917]megabucket[/url].
|
||||
@@ -136,6 +144,7 @@ now implemented for [url=http://processing.org/discourse/yabb/YaBB.cgi?board=Col
|
||||
|
||||
discuss with casey
|
||||
_ how should history be handled
|
||||
_ then re-implement history
|
||||
_ is the sketch folder something that is never seen by the user?
|
||||
_ i.e. flash programs 'import' all data, etc
|
||||
_ same with how imovie works
|
||||
@@ -148,6 +157,7 @@ _ .pde files opened on their own
|
||||
_ what should the prefs file be named?
|
||||
_ horizontal buttons? need final decision
|
||||
_ remove underscores from the tab title?
|
||||
_ need nice yes/no dialog boxes, also showError/Message/Warning
|
||||
|
||||
_ NullPointerException when alt is pressed
|
||||
_ might be something to do with the applet frame being an awt not swing
|
||||
@@ -219,6 +229,7 @@ _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs
|
||||
_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1067643186
|
||||
_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1078714442;start=0
|
||||
_ something in that one about mouse position halting or not
|
||||
_ ctrl-5 (at least on xp) is marking the current sketch as modified
|
||||
|
||||
|
||||
BUGS / Linux
|
||||
|
||||
Reference in New Issue
Block a user