fixes to make "read only" sketches handle properly, also from examples

folder
This commit is contained in:
benfry
2004-06-21 17:13:28 +00:00
parent e2e26caf45
commit 124ad261b8
3 changed files with 45 additions and 31 deletions
+9 -8
View File
@@ -72,17 +72,18 @@ public class PdeCode {
// TODO re-enable history
//history.record(s, PdeHistory.SAVE);
try {
//try {
//System.out.println("saving to " + file);
//System.out.println("stuff to save: " + program);
//System.out.println("-------");
PdeBase.saveFile(program, file);
} catch (Exception e) {
PdeBase.showWarning("Error saving file",
"Could not save " + file + "\n" +
"because of an error.", e);
}
PdeBase.saveFile(program, file);
modified = false;
//} catch (Exception e) {
//PdeBase.showWarning("Error saving file",
// "Could not save '" + file.getName() + "'\n" +
// "to '" + file.getParent() + "'\n" +
// "because of an error.", e);
//}
}
}
+17 -7
View File
@@ -275,10 +275,10 @@ public class PdeSketch {
// if so, need to first do a "save as".
if (isReadOnly()) {
PdeBase.showMessage("Sketch is read-only",
"You can't save changes to this sketch\n" +
"in the place it's currently located.\n" +
"You'll have to save it to another location.");
saveAs();
"Some files are marked \"read-only\", so you'll\n" +
"need to re-save this sketch to another location.");
// if the user cancels, give up on the save()
if (!saveAs()) return;
}
for (int i = 0; i < codeCount; i++) {
@@ -1221,12 +1221,22 @@ public class PdeSketch {
* volumes or folders without appropraite permissions.
*/
public boolean isReadOnly() {
//System.out.println("checking read only: " + folder.canWrite());
if (folder.getAbsolutePath().startsWith(PdeSketchbook.examplesPath)) {
return true;
} else if (!folder.canWrite()) { // is this ok for directories?
System.err.println("read only directory...");
return true;
// this doesn't work on directories
//} else if (!folder.canWrite()) { // is this ok for directories?
//System.err.println("read only directory...");
} else {
// check to see if each modified code file can be written to
for (int i = 0; i < codeCount; i++) {
if (code[i].modified && !code[i].file.canWrite()) {
//System.err.println("found a read-only file " + code[i].file);
return true;
}
}
//return true;
}
return false;
}
+19 -16
View File
@@ -30,30 +30,43 @@ X adding files to data folder that are already in the data folder
X makes the file zero, because of internal error
X added something to check to make sure they weren't the same
X http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1076358515
X implement read-only sketch folder
X examples are sort of there but need to be debugged
X read-only files should be checked
X check if file is read-only, and if so, ask where to put sketch
X http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1075149564;start=0
X how to handle examples: read only, somewhere inside lib
X move examples to folder that goes w/ p5 app
X set examples somehow read-only
X 'save as' from examples puts into examples dir.. :(
X make it default to the user's sketch dir
_ after using sketchbook menu as popup, disappears from file menu
_ dashes shouldn't be allowed in filenames for sketches
_ actually, lost the naming stuff because now using FileDialog
_ can this requirement just be on the pde file, not the directory?
_ bug: after using sketchbook menu as popup, disappears from file menu
_ re-implement history
_ write sketchbook.clean()
_ write 'new text file'
_ implement hide/unhide
_ implement read-only sketch folder
_ examples are sort of there but need to be debugged
_ read-only files should be checked
_ export is badly broken
_ get the console working again
_ appendText is disabled due to NullPointerEx on startup
_ ctrl-5 (confirmed on xp) is marking the current sketch as modified
_ running present mode with a bug in the program hoses things
_ make sure the program compiles before starting present mode
_ if 'applet.html' is in sketch folder, use that as the template
_ comments -> embedding in applet text? (ala javadoc)
_ would this help casey with the examples?
now implemented for [url=http://processing.org/discourse/yabb/YaBB.cgi?board=Collaboration;action=display;num=1084285917]megabucket[/url].
discuss with casey
_ 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
_ comments -> embedding in applet text? (ala javadoc)
_ would this help casey with the examples?
_ NullPointerException when alt is pressed
@@ -121,16 +134,6 @@ _ warn about writing non-1.1 code.
_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1079867179;start=0
EXAMPLES
_ check if file is read-only, and if so, ask where to put sketch
_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1075149564;start=0
_ how to handle examples: read only, somewhere inside lib
_ move examples to folder that goes w/ p5 app
_ set examples somehow read-only
_ 'save as' from examples puts into examples dir.. :(
_ make it default to the user's sketch dir
LIBRARIES
_ "add library" menu item and submenu
_ iterate through the 'library' folders