mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
get export working again, fix applet html, allow custom applet.html in
sketch
This commit is contained in:
+5
-2
@@ -1233,8 +1233,11 @@ public class PdeEditor extends JFrame
|
||||
public void handleSave() {
|
||||
message("Saving...");
|
||||
try {
|
||||
sketch.save();
|
||||
message("Done Saving.");
|
||||
if (sketch.save()) {
|
||||
message("Done Saving.");
|
||||
} else {
|
||||
message(EMPTY);
|
||||
}
|
||||
// rebuild sketch menu in case a save-as was forced
|
||||
sketchbook.rebuildMenu();
|
||||
|
||||
|
||||
@@ -188,8 +188,8 @@ public class PdePreprocessor {
|
||||
// output the code
|
||||
//
|
||||
PdeEmitter emitter = new PdeEmitter();
|
||||
PrintStream stream = new PrintStream(
|
||||
new FileOutputStream(buildPath + File.separator + name + ".java"));
|
||||
File streamFile = new File(buildPath, name + ".java");
|
||||
PrintStream stream = new PrintStream(new FileOutputStream(streamFile));
|
||||
|
||||
writeHeader(stream, extraImports, name);
|
||||
|
||||
|
||||
+17
-7
@@ -105,7 +105,7 @@ public class PdeSketch {
|
||||
}
|
||||
|
||||
folder = new File(new File(path).getParent());
|
||||
System.out.println("sketch dir is " + folder);
|
||||
//System.out.println("sketch dir is " + folder);
|
||||
|
||||
codeFolder = new File(folder, "code");
|
||||
dataFolder = new File(folder, "data");
|
||||
@@ -262,14 +262,14 @@ public class PdeSketch {
|
||||
/**
|
||||
* Save all code in the current sketch.
|
||||
*/
|
||||
public void save() throws IOException {
|
||||
public boolean save() throws IOException {
|
||||
// first get the contents of the editor text area
|
||||
if (current.modified) {
|
||||
current.program = editor.getText();
|
||||
}
|
||||
|
||||
// see if actually modified
|
||||
if (!modified) return;
|
||||
if (!modified) return false;
|
||||
|
||||
// check if the files are read-only.
|
||||
// if so, need to first do a "save as".
|
||||
@@ -278,13 +278,14 @@ public class PdeSketch {
|
||||
"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;
|
||||
if (!saveAs()) return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < codeCount; i++) {
|
||||
if (code[i].modified) code[i].save();
|
||||
}
|
||||
calcModified();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -703,6 +704,7 @@ public class PdeSketch {
|
||||
try {
|
||||
// if (i != 0) preproc will fail if a pde file is not
|
||||
// java mode, since that's required
|
||||
//System.out.println("build path is " + buildPath);
|
||||
String className =
|
||||
preprocessor.write(code[i].program, buildPath,
|
||||
(i == 0) ? suggestedClassName : null,
|
||||
@@ -895,7 +897,7 @@ public class PdeSketch {
|
||||
}
|
||||
|
||||
// build the sketch
|
||||
String foundName = build(name, appletDir.getPath());
|
||||
String foundName = build(appletDir.getPath(), name);
|
||||
|
||||
// (already reported) error during export, exit this function
|
||||
if (foundName == null) return false;
|
||||
@@ -959,7 +961,7 @@ public class PdeSketch {
|
||||
|
||||
StringBuffer sources = new StringBuffer();
|
||||
for (int i = 0; i < codeCount; i++) {
|
||||
sources.append("<a href=\'" + code[i].file.getName() + "\">" +
|
||||
sources.append("<a href=\"" + code[i].file.getName() + "\">" +
|
||||
code[i].name + "</a> ");
|
||||
}
|
||||
|
||||
@@ -969,7 +971,15 @@ public class PdeSketch {
|
||||
|
||||
// @@sketch@@, @@width@@, @@height@@, @@archive@@, @@source@@
|
||||
|
||||
InputStream is = PdeBase.getStream("applet.html");
|
||||
InputStream is = null;
|
||||
// if there is an applet.html file in the sketch folder, use that
|
||||
File customHtml = new File(folder, "applet.html");
|
||||
if (customHtml.exists()) {
|
||||
is = new FileInputStream(customHtml);
|
||||
}
|
||||
if (is == null) {
|
||||
is = PdeBase.getStream("applet.html");
|
||||
}
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||
|
||||
String line = null;
|
||||
|
||||
@@ -93,11 +93,16 @@ X http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs
|
||||
X after using sketchbook menu as popup, disappears from file menu
|
||||
X probably just need to build two
|
||||
X the popup from the toolbar needs an "Open..." on it as well
|
||||
X make save() return true/false so it doesn't say "saved" when it hasn't
|
||||
X export is badly broken, fix it.. file names were backwards
|
||||
X if 'applet.html' is in sketch folder, use that as the template
|
||||
|
||||
_ dashes shouldn't be allowed in filenames for sketches
|
||||
_ actually, lost the naming stuff because now using FileDialog
|
||||
_ this also needs to be checked when building the sketch menu
|
||||
|
||||
_ make export save to multiple files
|
||||
|
||||
_ 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:
|
||||
@@ -108,13 +113,11 @@ _ but need to deal with simply, not providing a new exception case
|
||||
_ write sketchbook.clean()
|
||||
_ write 'new text file'
|
||||
_ implement hide/unhide
|
||||
_ export is badly broken
|
||||
_ get the console working again
|
||||
_ appendText is disabled due to NullPointerEx on startup
|
||||
_ ctrl-5 (at least 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
|
||||
_ re-implement history
|
||||
|
||||
_ maybe bring back the prompt option for "new sketch"
|
||||
|
||||
Reference in New Issue
Block a user