working on examples export, other tweaks

This commit is contained in:
benfry
2011-04-16 15:13:32 +00:00
parent d8a5150e2d
commit d6a8aa9736
9 changed files with 125 additions and 7 deletions
+6
View File
@@ -304,6 +304,11 @@ public abstract class Editor extends JFrame implements RunnerListener {
}
public Base getBase() {
return base;
}
public Mode getMode() {
return mode;
}
@@ -948,6 +953,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
menu.add(createToolMenuItem("processing.app.tools.ColorSelector"));
menu.add(createToolMenuItem("processing.app.tools.Archiver"));
menu.add(createToolMenuItem("processing.app.tools.FixEncoding"));
menu.add(createToolMenuItem("processing.app.tools.ExportExamples"));
// // These are temporary entries while Android mode is being worked out.
// // The mode will not be in the tools menu, and won't involve a cmd-key
+1 -1
View File
@@ -352,7 +352,7 @@ public abstract class Mode {
* Override this to control the order of the first set of example folders
* and how they appear in the examples window.
*/
protected File[] getExampleCategoryFolders() {
public File[] getExampleCategoryFolders() {
return examplesFolder.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return dir.isDirectory() && name.charAt(0) != '.';
+2 -2
View File
@@ -386,9 +386,9 @@ public class Sketch {
if (renamingCode) { // If creating a new tab, don't show this error
if (current == code[0]) { // If this is the main tab, disallow
Base.showWarning("Problem with rename",
"The main .pde file cannot be .java file.\n" +
"The first tab cannot be ." + newExtension + " file.\n" +
"(It may be time for your to graduate to a\n" +
"\"real\" programming environment)", null);
"\"real\" programming environment, hotshot.)", null);
return;
}
}
@@ -0,0 +1,100 @@
package processing.app.tools;
import java.io.*;
//import java.util.HashMap;
import processing.app.*;
import processing.mode.java.JavaBuild;
public class ExportExamples implements Tool {
static final String DELETE_TARGET = "export.delete_target_folder";
static final String SEPARATE_JAR = "export.applet.separate_jar_files";
// HashMap<String,Throwable> errors;
// Editor orig;
Base base;
File[] folders;
public void init(Editor editor) {
// orig = editor;
base = editor.getBase();
Mode mode = editor.getMode();
folders = mode.getExampleCategoryFolders();
}
public void run() {
new Thread(new Runnable() { public void run() {
// errors = new HashMap<String, Throwable>();
boolean delete = Preferences.getBoolean(DELETE_TARGET);
Preferences.setBoolean(DELETE_TARGET, false);
boolean separate = Preferences.getBoolean(SEPARATE_JAR);
Preferences.setBoolean(SEPARATE_JAR, true);
for (File folder : folders) {
if (!folder.getName().equals("Books")) {
handleFolder(folder);
}
}
Preferences.setBoolean(DELETE_TARGET, delete);
Preferences.setBoolean(SEPARATE_JAR, separate);
} }).start();
// if (errors.size() > 0) {
// orig.statusError((errors.size() == 1 ? "One sketch" : (errors.size() + " sketches")) + " had errors.");
// } else {
// orig.statusNotice("Finished exporting examples.");
// }
// for (String path : errors.keySet()) {
// System.err.println("Error: "
// }
}
public void handleFolder(File folder) {
File pdeFile = new File(folder, folder.getName() + ".pde");
if (pdeFile.exists()) {
String pdePath = pdeFile.getAbsolutePath();
Editor editor = base.handleOpen(pdePath);
if (editor != null) {
try {
// System.out.println(pdePath);
if (handle(editor)) {
base.handleClose(editor, false);
try {
Thread.sleep(20);
} catch (InterruptedException e) { }
}
} catch (Exception e) {
// errors.put(pdePath, e);
// System.err.println("Error handling " + pdePath);
// e.printStackTrace();
}
}
} else { // recurse into the folder
//System.out.println(" into " + folder.getAbsolutePath());
File[] sub = folder.listFiles();
for (File f : sub) {
if (f.isDirectory()) {
handleFolder(f);
}
}
}
}
public boolean handle(Editor editor) throws SketchException, IOException {
Sketch sketch = editor.getSketch();
JavaBuild build = new JavaBuild(sketch);
File appletFolder = new File(sketch.getFolder(), "applet");
return build.exportApplet(appletFolder);
}
public String getMenuTitle() {
return "Export Examples";
}
}
@@ -62,7 +62,7 @@ public class AndroidMode extends JavaMode {
}
protected File[] getExampleCategoryFolders() {
public File[] getExampleCategoryFolders() {
return new File[] {
new File(examplesFolder, "Basics"),
new File(examplesFolder, "Topics"),
+1 -1
View File
@@ -49,7 +49,7 @@ public class JavaBuild {
protected Sketch sketch;
protected Mode mode;
// what happens in the build, stays in the build.
// (which is to say that everything below this line, stays within this class)
+1 -1
View File
@@ -139,7 +139,7 @@ public class JavaMode extends Mode {
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
protected File[] getExampleCategoryFolders() {
public File[] getExampleCategoryFolders() {
// Basics, Topics, 3D, Books
return new File[] {
new File(examplesFolder, "Basics"),
@@ -85,7 +85,7 @@ public class JavaScriptMode extends Mode {
//TODO Add examples
protected File[] getExampleCategoryFolders() {
public File[] getExampleCategoryFolders() {
return new File[] {};
/*
return new File[] {
+12
View File
@@ -1,5 +1,14 @@
0196
_ checkbox in mode menu smashing into things
_ remove opengl2 for 1.5 and examples
_ colors for 2.0
_ nurbs or other arch stuff for 2.0?
_ changing number of screens between run causes things to show up off-screen
_ so when running, check to make sure that things are out of the area
_ help casey re-export all applets for the site
_ remove .java files, use one central loading.gif and core.jar?
@@ -7,6 +16,9 @@ _ use a custom applet.html template for the export
_ the tool could copy this into the folder just before exporting
_ build a new version of the reference
_ PDE change indicator partially broken
_ http://code.google.com/p/processing/issues/detail?id=620
from peter n lewis
_ Use Selection For Find
_ http://code.google.com/p/processing/issues/detail?id=571