diff --git a/processing/app/PdeCompiler.java b/processing/app/PdeCompiler.java index 6d8c1eaf3..084e0634b 100644 --- a/processing/app/PdeCompiler.java +++ b/processing/app/PdeCompiler.java @@ -49,7 +49,7 @@ public class PdeCompiler implements PdeMessageConsumer { } - public boolean compileJava(PrintStream leechErr) { + public boolean compile(PrintStream leechErr) { String userdir = System.getProperty("user.dir") + File.separator; //System.out.println(userdir + "jikes"); @@ -147,8 +147,12 @@ public class PdeCompiler implements PdeMessageConsumer { boolean firstErrorFound; boolean secondErrorFound; - // part of the PdeMessageConsumer interface - // + /** + * Part of the PdeMessageConsumer interface, this is called + * whenever a piece (usually a line) of error message is spewed + * out from the compiler. The errors are parsed for their contents + * and line number, which is then reported back to PdeEditor. + */ public void message(String s) { //System.err.println("MSG: " + s); System.err.print(s); @@ -156,8 +160,8 @@ public class PdeCompiler implements PdeMessageConsumer { // ignore cautions if (s.indexOf("Caution") != -1) return; - // jikes always uses a forward slash character as its separator, so - // we need to replace any platform-specific separator characters before + // jikes always uses a forward slash character as its separator, + // so replace any platform-specific separator characters before // attemping to compare // String partialTempPath = buildPath.replace(File.separatorChar, '/') @@ -218,48 +222,43 @@ public class PdeCompiler implements PdeMessageConsumer { } - static String additional; + static String bootClassPath; static public String calcBootClassPath() { - if (additional == null) { -#ifdef MACOS - additional = - includeFolder(new File("/System/Library/Java/Extensions/")); - /* - // for macosx only, doesn't work on macos9 - StringBuffer abuffer = new StringBuffer(); - - // add the build folder.. why isn't it already there? - //abuffer.append(":" + userdir + "lib/build"); - - String list[] = new File("/System/Library/Java/Extensions").list(); - for (int i = 0; i < list.length; i++) { - if (list[i].endsWith(".class") || list[i].endsWith(".jar") || - list[i].endsWith(".zip")) { - //abuffer.append(System.getProperty("path.separator")); - abuffer.append(":/System/Library/Java/Extensions/" + list[i]); - } + if (bootClassPath == null) { + if (PdeBase.platform == PdeBase.MACOSX) { + additional = + contentsToClassPath(new File("/System/Library/Java/Extensions/")); + } else { + additional = ""; } - additional = abuffer.toString(); - */ -#else - additional = ""; -#endif + bootClassPath = System.getProperty("sun.boot.class.path") + additional; } - return System.getProperty("sun.boot.class.path") + additional; + return bootClassPath; } + /** + * Return the java.class.path, along with additional items + * that were magically gleaned from the 'include' folder, + * which may contain additional library classes. + */ static public String calcClassPath(File include) { - return System.getProperty("java.class.path") + includeFolder(include); + return System.getProperty("java.class.path") + contentsToClassPath(include); } + /// + + /** * Return the path for a folder, with appended paths to * any .jar or .zip files inside that folder. + * This will prepend a colon so that it can be directly + * appended to another path string. */ - static public String includeFolder(File folder) { + //static public String includeFolder(File folder) { + static public String contentsToClassPath(File folder) { if (folder == null) return ""; StringBuffer abuffer = new StringBuffer(); @@ -341,7 +340,6 @@ public class PdeCompiler implements PdeMessageConsumer { } } } - //return null; String output[] = new String[importCount]; System.arraycopy(imports, 0, output, 0, importCount); return output; @@ -370,12 +368,13 @@ public class PdeCompiler implements PdeMessageConsumer { } - /// + /// - // goes through a colon (or semicolon on windows) separated list - // of all the paths inside the 'code' folder - + /** + * Slurps up .class files from a colon (or semicolon on windows) + * separated list of paths and adds them to a ZipOutputStream. + */ static public void magicExports(String path, ZipOutputStream zos) throws IOException { String pieces[] = @@ -394,23 +393,17 @@ public class PdeCompiler implements PdeMessageConsumer { while (entries.hasMoreElements()) { ZipEntry entry = (ZipEntry) entries.nextElement(); if (entry.isDirectory()) { - //String name = entry.getName(); - //if (name.indexOf("META-INF/") == 0) continue; // actually 'continue's for all dir entries } else { String name = entry.getName(); + // ignore contents of the META-INF folders if (name.indexOf("META-INF") == 0) continue; ZipEntry entree = new ZipEntry(name); zos.putNextEntry(entree); byte buffer[] = new byte[(int) entry.getSize()]; InputStream is = file.getInputStream(entry); - //DataInputStream is = - //new DataInputStream(file.getInputStream(entry)); - //is.readFully(buffer); - //System.out.println(buffer.length); - //System.out.println(count + " " + buffer.length); int offset = 0; int remaining = buffer.length; @@ -441,6 +434,11 @@ public class PdeCompiler implements PdeMessageConsumer { } + /** + * Continue the process of magical exporting. This function + * can be called recursively to walk through folders looking + * for more goodies that will be added to the ZipOutputStream. + */ static public void magicExportsRecursive(File dir, String sofar, ZipOutputStream zos) throws IOException { diff --git a/processing/app/PdeCompilerKjc.java b/processing/app/PdeCompilerKjc.java deleted file mode 100644 index 6e13978e8..000000000 --- a/processing/app/PdeCompilerKjc.java +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - PdeCompilerKjc - compiler interface to kjc.. someday this will go away - Part of the Processing project - http://Proce55ing.net - - Except where noted, code is written by Ben Fry and - Copyright (c) 2001-03 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -import java.io.*; - - -public class PdeCompilerKjc extends PdeCompiler { - - public PdeCompilerKjc(String buildPath, String className, - File includeFolder, PdeEditor editor) { - super(buildPath, className, includeFolder, editor); - } - - public boolean compileJava(PrintStream leechErr) { - System.setErr(leechErr); // redirect stderr to our leech filter - - String args[] = new String[2]; - args[0] = "-d" + buildPath; - args[1] = buildPath + File.separator + className + ".java"; - //System.out.println("args = " + args[0] + " " + args[1]); - - boolean success = at.dms.kjc.Main.compile(args); - - System.setErr(PdeEditorConsole.consoleErr); - - //System.err.println("success = " + success); - return success; - } - - // part of the PdeMessageConsumer interface - // - public void message(String s) { - // as in: lib\build\Temporary_5476_6442.java:88: caution:Assignment of an expression to itself [KOPI] - if (s.indexOf("caution") != -1) return; - - // - //System.out.println("leech2: " + new String(b, offset, length)); - //String s = new String(b, offset, length); - //if (s.indexOf(tempFilename) == 0) { - String fullTempFilename = buildPath + File.separator + className + ".java"; - if (s.indexOf(fullTempFilename) == 0) { - String s1 = s.substring(fullTempFilename.length() + 1); - int colon = s1.indexOf(':'); - int lineNumber = Integer.parseInt(s1.substring(0, colon)); - //System.out.println("pde / line number: " + lineNumber); - - //String s2 = s1.substring(colon + 2); - int err = s1.indexOf("error:"); - if (err != -1) { - //err += "error:".length(); - String description = s1.substring(err + "error:".length()); - description = description.trim(); - - // as in: ...error:Constructor setup must be named Temporary_5362_2548 [JL1 8.6] - if(description.indexOf("Constructor setup must be named") != -1) { - description = "Missing function return type, or constructor does not match class name"; - } - //exception = new PdeException(description, lineNumber-2); - exception = new PdeException(description, lineNumber-1); - editor.error(exception); - - } else { - System.err.println("i suck: " + s); - } - - } else { - //System.err.println("don't understand: " + s); - exception = new PdeException(SUPER_BADNESS); - editor.error(exception); - } - } -} diff --git a/processing/app/PdeEditor.java b/processing/app/PdeEditor.java index 450fb0c1d..5139c0f1c 100644 --- a/processing/app/PdeEditor.java +++ b/processing/app/PdeEditor.java @@ -78,10 +78,6 @@ public class PdeEditor extends JFrame JEditTextArea textarea; // currently opened program - //String sketchName; // name of the file (w/o pde if a sketch) - //File sketchFile; // the .pde file itself - //File sketchDir; // if a sketchbook project, the parent dir - //boolean sketchModified; PdeSketch sketch; Point appletLocation; //= new Point(0, 0); @@ -108,9 +104,6 @@ public class PdeEditor extends JFrame boolean presenting; boolean renaming; - //PdeBase base; - - //PrintStream leechErr; PdeMessageStream messageStream; // location for lib/build, contents for which will be emptied @@ -158,15 +151,11 @@ public class PdeEditor extends JFrame // add listener to handle window close box hit event - addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { handleQuit(); } }); - //frame.addWindowListener(windowListener); - //this.addWindowListener(windowListener); - PdeKeywords keywords = new PdeKeywords(); history = new PdeHistory(this); @@ -186,21 +175,6 @@ public class PdeEditor extends JFrame Container pain = getContentPane(); pain.setLayout(new BorderLayout()); - /* - Panel leftPanel = new Panel(); - leftPanel.setLayout(new BorderLayout()); - - // set bgcolor of buttons here, b/c also used for empty component - buttons = new PdeEditorButtons(this); - Color buttonBgColor = PdePreferences.getColor("editor.buttons.bgcolor"); - buttons.setBackground(buttonBgColor); - leftPanel.add("North", buttons); - Label dummy = new Label(); - dummy.setBackground(buttonBgColor); - leftPanel.add("Center", dummy); - - pain.add("West", leftPanel); - */ buttons = new PdeEditorButtons(this); pain.add("West", buttons); @@ -210,7 +184,6 @@ public class PdeEditor extends JFrame header = new PdeEditorHeader(this); rightPanel.add(header, BorderLayout.NORTH); - //textarea = new JEditTextArea(); textarea = new JEditTextArea(new PdeTextAreaDefaults()); textarea.setRightClickPopup(new TextAreaPopup()); textarea.setTokenMarker(new PdeKeywords()); @@ -285,16 +258,8 @@ public class PdeEditor extends JFrame Label label = new Label("stop"); label.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { - //System.out.println("got stop"); - //doStop(); setVisible(true); doClose(); - - //#ifdef JDK13 - // move editor to front in case it was hidden - //PdeBase.frame.setState(Frame.NORMAL); - //base.setState(Frame.NORMAL); - //#endif }}); Dimension labelSize = new Dimension(60, 20); @@ -343,8 +308,6 @@ public class PdeEditor extends JFrame } } }); - // can this happen here? - //restorePreferences(); } @@ -496,7 +459,7 @@ public class PdeEditor extends JFrame // last sketch that was in use //PdePreferences.set("last.sketch.name", sketchName); //PdePreferences.set("last.sketch.name", sketch.name); - PdePreferences.set("last.sketch.path", sketch.getPath()); + PdePreferences.set("last.sketch.path", sketch.getMainFilePath()); // location for the console/editor area divider int location = splitPane.getDividerLocation(); @@ -671,9 +634,6 @@ public class PdeEditor extends JFrame } history.attachMenu(menu); - - //menu.addActionListener(this); - //menubar.add(menu); // add the sketch menu return menu; } @@ -741,8 +701,6 @@ public class PdeEditor extends JFrame }); } - //menu.addActionListener(this); - //menubar.setHelpMenu(menu); return menu; } @@ -761,7 +719,7 @@ public class PdeEditor extends JFrame menu.addSeparator(); - // "cut" and "copy" should really only be enabled + // TODO "cut" and "copy" should really only be enabled // if some text is currently selected item = newMenuItem("Cut", 'X'); item.addActionListener(new ActionListener() { @@ -808,7 +766,6 @@ public class PdeEditor extends JFrame item = newMenuItem("Find...", 'F'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - //find(); if (find == null) { find = new PdeEditorFind(PdeEditor.this); } else { @@ -821,45 +778,22 @@ public class PdeEditor extends JFrame item = newMenuItem("Find Next", 'G'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - //findNext(); if (find != null) find.find(); } }); menu.add(item); - /* - item = newMenuItem("Find in Reference", 'F', true); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (textarea.isSelectionActive()) { - String text = textarea.getSelectedText(); - if (text.length() == 0) { - message("First select a word to find in the reference."); - - } else { - String referenceFile = PdeKeywords.getReference(text); - if (referenceFile == null) { - message("No reference available for \"" + text + "\""); - } else { - PdeBase.showReference(referenceFile); - } - } - } - } - }); - menu.add(item); - */ - return menu; } - // antidote for overthought swing api mess for setting accelerators - static public JMenuItem newMenuItem(String title, char what) { return newMenuItem(title, what, false); } + /** + * Antidote for overthought swing api mess for setting accelerators. + */ static public JMenuItem newMenuItem(String title, char what, boolean shift) { JMenuItem menuItem = new JMenuItem(title); menuItem.setAccelerator(KeyStroke.getKeyStroke(what, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | (shift ? ActionEvent.SHIFT_MASK : 0))); @@ -1002,7 +936,6 @@ public class PdeEditor extends JFrame */ public void handleQuit() { // check to see if the person actually wants to quit - //editor.doQuit(); doQuit(); } @@ -1010,7 +943,11 @@ public class PdeEditor extends JFrame // ................................................................... - protected void changeText(String what, boolean emptyUndo) { + /** + * Called by PdeEditorHeader when the tab is changed + * (or a new set of files are opened) + */ + public void changeText(String what, boolean emptyUndo) { textarea.setText(what); // TODO need to wipe out the undo state here @@ -1051,21 +988,8 @@ public class PdeEditor extends JFrame // String imports[] = null; if (externalCode != null) { - //String includePaths = PdeCompiler.includeFolder(externalCode); - //imports = PdeCompiler.magicImports(includePaths); imports = PdeCompiler.magicImports(externalPaths); - /* - StringBuffer buffer = new StringBuffer(); - for (int i = 0; i < imports.length; i++) { - buffer.append("import "); - buffer.append(imports[i]); - buffer.append(".*; "); - } - */ - //buffer.append(program); - //program = buffer.toString(); } - //System.out.println("imports is " + imports); PdePreprocessor preprocessor = null; preprocessor = new PdePreprocessor(program, buildPath); @@ -1119,22 +1043,13 @@ public class PdeEditor extends JFrame // PdeCompiler compiler = new PdeCompiler(buildPath, className, externalCode, this); - // macos9 now officially broken.. see PdeCompilerJavac - //PdeCompiler compiler = - // ((PdeBase.platform == PdeBase.MACOS9) ? - // new PdeCompilerJavac(buildPath, className, this) : - // new PdeCompiler(buildPath, className, this)); // run the compiler, and funnel errors to the leechErr // which is a wrapped around // (this will catch and parse errors during compilation // the messageStream will call message() for 'compiler') messageStream = new PdeMessageStream(compiler); - //PrintStream leechErr = new PrintStream(messageStream); - //boolean result = compiler.compileJava(leechErr); - //return compiler.compileJava(leechErr); - boolean success = - compiler.compileJava(new PrintStream(messageStream)); + boolean success = compiler.compile(new PrintStream(messageStream)); return success ? className : null; } @@ -1155,7 +1070,6 @@ public class PdeEditor extends JFrame * * 2. compile the code from that location * catching errors along the way - * currently done with kjc, but would be nice to use jikes * placing it in a ready classpath, or .. ? * * 3. run the code @@ -1177,6 +1091,8 @@ public class PdeEditor extends JFrame for (int i = 0; i < 10; i++) System.out.println(); + // if an external editor is being used, need to grab the + // latest version of the code from the file. if (PdePreferences.getBoolean("editor.external")) { // history gets screwed by the open.. String historySaved = history.lastRecorded; @@ -1192,18 +1108,11 @@ public class PdeEditor extends JFrame if (presenting) { presentationWindow.show(); presentationWindow.toFront(); - //doRun(true); } String program = textarea.getText(); - //makeHistory(program, RUN); history.record(program, PdeHistory.RUN); - //if (PdeBase.platform == PdeBase.MACOSX) { - //String pkg = "Proce55ing.app/Contents/Resources/Java/"; - //buildPath = pkg + "build"; - //} - //buildPath = "lib" + File.separator + "build"; tempBuildPath = "lib" + File.separator + "build"; File buildDir = new File(tempBuildPath); @@ -1211,14 +1120,12 @@ public class PdeEditor extends JFrame buildDir.mkdirs(); } - String dataPath = sketchFile.getParent() + File.separator + "data"; - - //if (dataPath != null) { - File dataDir = new File(dataPath); - if (dataDir.exists()) { - PdeBase.copyDir(dataDir, buildDir); - } + sketch.updateDataDirectory(buildDir); + //File dataDir = new File(dataPath); + //if (dataDir.exists()) { + //PdeBase.copyDir(dataDir, buildDir); //} + int numero1 = (int) (Math.random() * 10000); int numero2 = (int) (Math.random() * 10000); String className = TEMP_CLASS + "_" + numero1 + "_" + numero2; @@ -1684,16 +1591,6 @@ public class PdeEditor extends JFrame } - /** - * Returns true if this is a read-only sketch. Used for the - * examples directory, or when sketches are loaded from read-only - * volumes or folders without appropraite permissions. - */ - public boolean readOnlySketch() { - return false; - } - - public void doSave() { // true if lastfile not set, otherwise false, meaning no prompt //handleSave(lastFile == null); @@ -1992,32 +1889,9 @@ public class PdeEditor extends JFrame ps.flush(); ps.close(); -#ifdef MACOS - // this chunk left disabled, because safari doesn't actually - // set the type/creator of html files it makes - - // however, for macos9, this should be re-enabled - // (but it's not here since macos9 isn't supported for beta) - - /* - // thank you apple, for changing this *@#$*& - //com.apple.eio.setFileTypeAndCreator(String filename, int, int); - - // jdk13 on osx, or jdk11 - // though apparently still available for 1.4 - if ((PdeBase.platform == PdeBase.MACOS9) || - (PdeBase.platform == PdeBase.MACOSX)) { - MRJFileUtils.setFileTypeAndCreator(sketchFile, - MRJOSType.kTypeTEXT, - new MRJOSType("MSIE")); - } - */ -#endif - // create new .jar file FileOutputStream zipOutputFile = new FileOutputStream(new File(appletDir, exportSketchName + ".jar")); - //new FileOutputStream(new File(projectDir, projectName + ".jar")); ZipOutputStream zos = new ZipOutputStream(zipOutputFile); ZipEntry entry; @@ -2430,15 +2304,11 @@ public class PdeEditor extends JFrame String currentDir = System.getProperty("user.dir"); String referenceFile = null; - //static JEditTextArea parent; - JMenuItem cutItem, copyItem; JMenuItem referenceItem; - public TextAreaPopup(/*JEditTextArea parent*/) { - //this.parent = parent; - + public TextAreaPopup() { JMenuItem item; cutItem = new JMenuItem("Cut"); @@ -2484,29 +2354,6 @@ public class PdeEditor extends JFrame this.add(referenceItem); } - /* - // enables/disables "Reference Lookup" option - public void setReferenceLookup(String file) - { - if (file != null) { - this.getComponent(5).setEnabled(true); - referenceFile = file; - } - else { - this.getComponent(5).setEnabled(false); - } - } - */ - - /* - public void showReferenceFile() - { - PdeBase.openURL(currentDir + File.separator + - "reference" + File.separator + - referenceFile + ".html"); - } - */ - // if no text is selected, disable copy and cut menu items public void show(Component component, int x, int y) { if (textarea.isSelectionActive()) { diff --git a/processing/app/PdeEditorHeader.java b/processing/app/PdeEditorHeader.java index 11da6000e..9636d2c7f 100644 --- a/processing/app/PdeEditorHeader.java +++ b/processing/app/PdeEditorHeader.java @@ -29,7 +29,7 @@ import java.io.*; import javax.swing.*; -public class PdeEditorHeader extends JComponent { +public class PdeEditorHeader extends JComponent implements MouseInputListener { //static final String SKETCH_TITLER = "sketch"; //static Color primaryColor; @@ -42,9 +42,6 @@ public class PdeEditorHeader extends JComponent { int tabLeft[]; int tabRight[]; - int menuLeft; - int menuRight; - //int sketchLeft; //int sketchRight; //int sketchTitleLeft; @@ -56,9 +53,14 @@ public class PdeEditorHeader extends JComponent { // - boolean menuVisible; JMenu menu; + //boolean menuVisible; + JPopupMenu popup; + + int menuLeft; + int menuRight; + // static final String STATUS[] = { "unsel", "sel" }; @@ -114,6 +116,9 @@ public class PdeEditorHeader extends JComponent { } } }); + + addMouseListener(this); + //addMouseMotionListener(this); } @@ -201,7 +206,7 @@ public class PdeEditorHeader extends JComponent { menuLeft = sizeW - (16 + pieces[0][MENU].getWidth()); menuRight = sizeW - 16; // draw the dropdown menu target - g.drawImage(pieces[menuVisible ? SELECTED : UNSELECTED][MENU], + g.drawImage(pieces[popup.isVisible() ? SELECTED : UNSELECTED][MENU], menuLeft, 0); /* @@ -241,6 +246,19 @@ public class PdeEditorHeader extends JComponent { menu.removeAll(); } else { menu = new JMenu(); + popup = menu.getPopUp(); + add(popup); + popup.addPopupMenuListener(new PopupMenuListener() { + public void popupMenuCanceled(PopupMenuEvent e) { + // on redraw, the isVisible() will get checked. + // actually, a repaint may be fired anyway, so this + // may be redundant. + repaint(); + } + + //public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } + //public void popupMenuWillBecomeVisible(PopupMenuEvent e) { } + }); } JMenuItem item; @@ -318,6 +336,39 @@ public class PdeEditorHeader extends JComponent { } + public void deselectMenu() { + menuVisible = false; + repaint(); + } + + + public void mousePressed(MouseEvent e) { + int x = e.getX(); + int y = e.getY(); + + if ((x > menuLeft) && (x < menuRight)) { + popup.show(this, x, y); + + } else { + for (int i = 0; i < fileCount; i++) { + if ((x > tabLeft[i]) && (x < tabRight[i])) { + showTab(i); + } + } + } + } + + + public void showTab(int which) { + current = which; + + + + // set to the text for this file, and wipe out the undo buffer + editor.changeText(contents, true); + } + + public Dimension getPreferredSize() { return getMinimumSize(); } diff --git a/processing/app/PdePreprocessor.java b/processing/app/PdePreprocessor.java index 8b38a8fc5..d0a059630 100644 --- a/processing/app/PdePreprocessor.java +++ b/processing/app/PdePreprocessor.java @@ -190,40 +190,38 @@ public class PdePreprocessor { * Write any required header material (eg imports, class decl stuff) * * @param out PrintStream to write it to. - * @param extendsNormal Extending the normal renderer? * @param exporting Is this being exported from PDE? * @param name Name of the class being created. */ void writeHeader(PrintStream out, String imports[], - /*boolean extendsNormal,*/ boolean exporting, String name) { + // emit emports that are needed for classes from the code folder + // if (imports != null) { - //System.out.println("imports not null"); for (int i = 0; i < imports.length; i++) { out.print("import " + imports[i] + ".*; "); } } - if (programType < ADVANCED) { - - // spew out a bunch of java imports - // - if (!exporting) { // if running in environment, or exporting an app - for (int i = 0; i < application_imports.length; i++) { - out.print("import " + application_imports[i] + ".*; "); - } - } else { // exporting an applet - for (int i = 0; i < applet_imports.length; i++) { - out.print("import " + applet_imports[i] + ".*; "); - } + // Spew out a semi-standard set of java imports. + // + // Prior to 68, these were only done when not int ADVANCED mode, + // but these won't hurt, and may be helpful in cases where the user + // can't be bothered to add imports to the top of their classes. + // + if (!exporting) { // if running in environment, or exporting an app + for (int i = 0; i < application_imports.length; i++) { + out.print("import " + application_imports[i] + ".*; "); } + } else { // exporting an applet + for (int i = 0; i < applet_imports.length; i++) { + out.print("import " + applet_imports[i] + ".*; "); + } + } - //String extendsWhat = extendsNormal ? "BApplet" : "BAppletGL"; - String extendsWhat = "BApplet"; - - out.print("public class " + name + " extends " + - extendsWhat + " {"); + if (programType < ADVANCED) { + out.print("public class " + name + " extends BApplet {"); if (programType == BEGINNER) { // XXXdmose need to actually deal with size / background info here diff --git a/processing/app/PdeSketch.java b/processing/app/PdeSketch.java index b41af9181..9b6d23ac9 100644 --- a/processing/app/PdeSketch.java +++ b/processing/app/PdeSketch.java @@ -26,17 +26,27 @@ public class PdeSketch { String name; File directory; + static final int PDE = 0; + static final int JAVA = 1; + int current; int fileCount; String names[]; File files[]; + int flavor[]; + String program[]; boolean modified[]; int hiddenCount; String hiddenNames[]; File hiddenFiles[]; + //String sketchName; // name of the file (w/o pde if a sketch) + //File sketchFile; // the .pde file itself + //File sketchDir; // if a sketchbook project, the parent dir + //boolean sketchModified; + /** * path is location of the main .pde file, because this is also @@ -66,6 +76,8 @@ public class PdeSketch { names = new String[fileCount]; files = new File[fileCount]; modified = new boolean[fileCount]; + flavor = new int[fileCount]; + program = new String[fileCount]; hiddenNames = new String[hiddenCount]; hiddenFiles = new File[hiddenCount]; @@ -78,11 +90,13 @@ public class PdeSketch { if (list[i].endsWith(".pde")) { names[fileCounter] = list[i].substring(0, list[i].length() - 4); files[fileCounter] = new File(directory, list[i]); + flavor[fileCounter] = PDE; fileCounter++; } else if (list[i].endsWith(".java")) { names[fileCounter] = list[i].substring(0, list[i].length() - 5); files[fileCounter] = new File(directory, list[i]); + flavor[fileCounter] = JAVA; fileCounter++; } else if (list[i].endsWith(".pde.x")) { @@ -99,15 +113,51 @@ public class PdeSketch { } - public boolean getModified() { + /** + * Have the contents of the currently visible tab been modified. + */ + /* + public boolean isCurrentModified() { return modified[current]; } + */ + + + /** + * Returns true if this is a read-only sketch. Used for the + * examples directory, or when sketches are loaded from read-only + * volumes or folders without appropraite permissions. + */ + public boolean isReadOnly() { + return false; + } + + + /** + * Path to the data folder of this sketch. + */ + /* + public File getDataDirectory() { + File dataDir = new File(directory, "data"); + return dataDir.exists() ? dataDir : null; + } + */ + + // copy contents of data dir + // eventually, if the files already exist in the target, don't' bother. + public void updateDataDirectory(File buildDir) { + File dataDir = new File(directory, "data"); + if (dataDir.exists()) { + PdeBase.copyDir(dataDir, buildDir); + } + } + /** * Returns path to the main .pde file for this sketch. */ - public String getPath() { + public String getMainFilePath() { return files[0].getAbsolutePath(); } } diff --git a/processing/build/shared/bugs.txt b/processing/build/shared/bugs.txt index e38029bcd..53c11f24d 100644 --- a/processing/build/shared/bugs.txt +++ b/processing/build/shared/bugs.txt @@ -41,6 +41,13 @@ changed in the future, but for now, they're not actually 'broken'. Support.qtx" out of /Library/QuickTime (at least until you need to do video cd work). +- on windows, sometimes your programs will run in a window that has a + java coffee cup icon, instead of the usual processing icon. this + simply means that the application is being run outside of processing + (by java itself) rather than from within processing. this happens + when extra libraries, multiple source code files (more than one tab), + or extra code files in the 'code' folder are employed. + .................................................................. diff --git a/processing/todo.txt b/processing/todo.txt index 6b3a940e8..24f66827f 100644 --- a/processing/todo.txt +++ b/processing/todo.txt @@ -34,6 +34,7 @@ X get bracket highlighting to work X why won't loop() go bold? -> java 1.4 problem on the mac X test what it does on the pc X seems to be a mac-specific problem (probably because of monaco) +X removed kjc classes goodbye macos9 X posted to message board about it going away @@ -65,6 +66,18 @@ o http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;acti o try ariel's Thread.yield() suggestion o set default framerate of 24? 30? 2x that? +_ history: "archive this version" +_ makes a numbered archive of the current sketch as a zip file +_ checks to see if there are other versions in the current folder +_ or maybe just increments the numbers at the end of the sketch name + +when creating a new file, suggest untitled.pde +they can put a .java or .pde extension on the file +if no extension is found, add the .pde extension +if the file has a .pde extension, then it will be run through the preproc. + + +_ international: convert unicode chars to \uXXXX in the preproc _ fix command keys for menus (broken since switching to swing) @@ -568,12 +581,13 @@ BAGEL / Fonts PDE - Processing Development Environment - -PDE / Runtime (includes classloading) - - PDE / Details + 1 _ implement page setup and print + 1 _ pretty printing of code in project + 1 _ option to just print all code in project + 1 _ option to export all the code as colored html + 1 _ p5 becomes a memory hog (benelek and glen murphy) 1 _ even without sketches open, perhaps not gc'ing properly 1 _ objects probably not getting finalized