mirror of
https://github.com/processing/processing4.git
synced 2026-02-12 01:50:44 +01:00
more library and menu work
This commit is contained in:
@@ -370,7 +370,7 @@ public class PdeCompiler implements PdeMessageConsumer {
|
||||
e.printStackTrace(); // this would be odd
|
||||
}
|
||||
//System.out.println("included path is " + abuffer.toString());
|
||||
packageListFromClassPath(abuffer.toString());
|
||||
packageListFromClassPath(abuffer.toString()); // WHY?
|
||||
return abuffer.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -511,6 +511,7 @@ implements MRJAboutHandler, MRJQuitHandler, MRJPrefsHandler
|
||||
menu.add(item);
|
||||
|
||||
menu.add(sketchbook.rebuildMenu());
|
||||
menu.add(sketchbook.getExamplesMenu());
|
||||
|
||||
saveMenuItem = newJMenuItem("Save", 'S');
|
||||
saveMenuItem.addActionListener(new ActionListener() {
|
||||
@@ -670,6 +671,8 @@ implements MRJAboutHandler, MRJQuitHandler, MRJPrefsHandler
|
||||
JMenuItem item;
|
||||
|
||||
item = new JMenuItem("Help");
|
||||
item.setEnabled(false);
|
||||
/*
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
PdeBase.openURL(System.getProperty("user.dir") + File.separator +
|
||||
@@ -677,6 +680,7 @@ implements MRJAboutHandler, MRJQuitHandler, MRJPrefsHandler
|
||||
File.separator + "index.html");
|
||||
}
|
||||
});
|
||||
*/
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem("Reference");
|
||||
|
||||
@@ -90,9 +90,12 @@ public class PdeRuntime implements PdeMessageConsumer {
|
||||
|
||||
String command[] = new String[] {
|
||||
"java",
|
||||
"-Djava.library.path=" + sketch.libraryPath, // might be ""
|
||||
"-Djava.library.path=" +
|
||||
// sketch.libraryPath might be ""
|
||||
// librariesClassPath will always have sep char prepended
|
||||
sketch.libraryPath + PdeSketchbook.librariesClassPath,
|
||||
"-cp",
|
||||
sketch.classPath,
|
||||
sketch.classPath + PdeSketchbook.librariesClassPath,
|
||||
"processing.core.PApplet",
|
||||
location,
|
||||
PApplet.EXT_SKETCH_FOLDER + sketch.folder.getAbsolutePath(),
|
||||
|
||||
@@ -980,7 +980,7 @@ public class PdeSketch {
|
||||
protected String build(String buildPath, String suggestedClassName)
|
||||
throws PdeException {
|
||||
|
||||
String importPackageList[] = null;
|
||||
//String importPackageList[] = null;
|
||||
|
||||
String javaClassPath = System.getProperty("java.class.path");
|
||||
// remove quotes if any.. this is an annoying thing on windows
|
||||
@@ -988,7 +988,9 @@ public class PdeSketch {
|
||||
javaClassPath = javaClassPath.substring(1, javaClassPath.length() - 1);
|
||||
}
|
||||
|
||||
classPath = buildPath + File.pathSeparator + javaClassPath;
|
||||
classPath = buildPath +
|
||||
File.pathSeparator + PdeSketchbook.librariesClassPath +
|
||||
File.pathSeparator + javaClassPath;
|
||||
//System.out.println("cp = " + classPath);
|
||||
|
||||
// figure out the contents of the code folder to see if there
|
||||
@@ -998,12 +1000,11 @@ public class PdeSketch {
|
||||
externalRuntime = true;
|
||||
classPath += File.pathSeparator +
|
||||
PdeCompiler.contentsToClassPath(codeFolder);
|
||||
importPackageList = PdeCompiler.packageListFromClassPath(classPath);
|
||||
//libraryPath = codeFolder.getCanonicalPath();
|
||||
//importPackageList = PdeCompiler.packageListFromClassPath(classPath);
|
||||
libraryPath = codeFolder.getAbsolutePath();
|
||||
} else {
|
||||
externalRuntime = (codeCount > 1); // may still be set true later
|
||||
importPackageList = null;
|
||||
//importPackageList = null;
|
||||
libraryPath = "";
|
||||
}
|
||||
|
||||
|
||||
@@ -41,8 +41,9 @@ import com.apple.mrj.*;
|
||||
public class PdeSketchbook {
|
||||
PdeEditor editor;
|
||||
|
||||
JMenu menu;
|
||||
JMenu popup;
|
||||
JMenu menu;
|
||||
JMenu examples;
|
||||
JMenu addlib;
|
||||
|
||||
// set to true after the first time it's built.
|
||||
@@ -64,6 +65,11 @@ public class PdeSketchbook {
|
||||
static File librariesFolder;
|
||||
static String librariesPath;
|
||||
|
||||
// classpath for all known libraries for p5
|
||||
// (both those in the p5/libs folder and those with lib subfolders
|
||||
// found in the sketchbook)
|
||||
static String librariesClassPath;
|
||||
|
||||
|
||||
public PdeSketchbook(PdeEditor editor) {
|
||||
this.editor = editor;
|
||||
@@ -325,9 +331,14 @@ public class PdeSketchbook {
|
||||
boolean sketches =
|
||||
addSketches(popup, new File(PdePreferences.get("sketchbook.path")));
|
||||
if (sketches) popup.addSeparator();
|
||||
JMenu examples = new JMenu("Examples");
|
||||
addSketches(examples, examplesFolder);
|
||||
popup.add(examples);
|
||||
JMenu ex = new JMenu("Examples");
|
||||
addSketches(ex, examplesFolder);
|
||||
popup.add(ex);
|
||||
if (PdePreferences.getBoolean("export.library")) {
|
||||
JMenu m = new JMenu("Libraries");
|
||||
addSketches(m, librariesFolder);
|
||||
popup.add(m);
|
||||
}
|
||||
|
||||
// disable error messages while loading
|
||||
builtOnce = true;
|
||||
@@ -336,6 +347,7 @@ public class PdeSketchbook {
|
||||
// rebuild the open menu
|
||||
menu.removeAll();
|
||||
|
||||
/*
|
||||
if (sketches) {
|
||||
addSketches(menu, new File(PdePreferences.get("sketchbook.path")));
|
||||
menu.addSeparator();
|
||||
@@ -343,14 +355,22 @@ public class PdeSketchbook {
|
||||
examples = new JMenu("Examples");
|
||||
addSketches(examples, examplesFolder);
|
||||
menu.add(examples);
|
||||
*/
|
||||
if (sketches) {
|
||||
addSketches(menu, new File(PdePreferences.get("sketchbook.path")));
|
||||
}
|
||||
examples = new JMenu("Examples");
|
||||
addSketches(examples, examplesFolder);
|
||||
//menu.add(examples);
|
||||
|
||||
|
||||
// rebuild the "add library" menu
|
||||
// rebuild the "import library" menu
|
||||
addlib.removeAll();
|
||||
librariesClassPath = "";
|
||||
boolean libs =
|
||||
addLibraries(addlib, new File(PdePreferences.get("sketchbook.path")));
|
||||
if (libs) menu.addSeparator();
|
||||
if (libs) addlib.addSeparator();
|
||||
addLibraries(addlib, librariesFolder);
|
||||
//System.out.println("libraries cp is now " + librariesClassPath);
|
||||
|
||||
} catch (IOException e) {
|
||||
PdeBase.showWarning("Problem while building sketchbook menu",
|
||||
@@ -362,6 +382,11 @@ public class PdeSketchbook {
|
||||
}
|
||||
|
||||
|
||||
protected JMenu getExamplesMenu() {
|
||||
return examples;
|
||||
}
|
||||
|
||||
|
||||
protected boolean addSketches(JMenu menu, File folder) throws IOException {
|
||||
// skip .DS_Store files, etc
|
||||
if (!folder.isDirectory()) return false;
|
||||
@@ -494,6 +519,11 @@ public class PdeSketchbook {
|
||||
continue;
|
||||
}
|
||||
|
||||
// grab all jars and classes from this folder,
|
||||
// and append them to the library classpath
|
||||
librariesClassPath += File.pathSeparatorChar +
|
||||
PdeCompiler.contentsToClassPath(exported);
|
||||
|
||||
JMenuItem item = new JMenuItem(list[i]);
|
||||
item.addActionListener(listener);
|
||||
item.setActionCommand(entry.getAbsolutePath());
|
||||
|
||||
@@ -54,7 +54,8 @@ X several menu changes as discussed with casey
|
||||
X (capitalization, export/export app, tools)
|
||||
X add preference for showing library stuff
|
||||
_ figure out why user libraries not being added
|
||||
_ show internal libraries as part of the 'open' menu (in lib mode)
|
||||
_ in lib mode, show internal libraries as part of the 'open' menu
|
||||
_ make a note that p5 has to be restarted for libs
|
||||
_ after export of library, rebuild "import library" menu
|
||||
_ import all libraries into classpath
|
||||
_ all libs found during sketchbook build + all libs in libraries
|
||||
|
||||
Reference in New Issue
Block a user