From 31e725d341cf448eb4a61c0cbc7cf56592e792bd Mon Sep 17 00:00:00 2001 From: benfry Date: Sat, 27 Sep 2003 15:36:55 +0000 Subject: [PATCH] window placement, and exact placement now working for external --- app/PdeBase.java | 6 +++--- app/PdeEditor.java | 30 +++++++++++++++++++++++++----- app/PdeMessageSiphon.java | 1 + app/PdeRuntime.java | 25 +++++++++++++++++-------- todo.txt | 12 ++++++------ 5 files changed, 52 insertions(+), 22 deletions(-) diff --git a/app/PdeBase.java b/app/PdeBase.java index 79d3b7e66..170628cdb 100644 --- a/app/PdeBase.java +++ b/app/PdeBase.java @@ -472,7 +472,7 @@ public class PdeBase extends Frame menu.add(new MenuItem("Stop", new MenuShortcut('T'))); menu.addSeparator(); - menu.add(new MenuItem("Add data file...")); + menu.add(new MenuItem("Add file...")); menu.add(new MenuItem("Create font...")); if ((platform == WINDOWS) || (platform == MACOSX)) { @@ -1101,8 +1101,8 @@ public class PdeBase extends Frame } else if (command.equals("Beautify")) { editor.doBeautify(); - } else if (command.equals("Add data file...")) { - editor.addDataFile(); + } else if (command.equals("Add file...")) { + editor.addFile(); } else if (command.equals("Create font...")) { new PdeFontBuilder(new File(editor.sketchDir, "data")); diff --git a/app/PdeEditor.java b/app/PdeEditor.java index cafc27b9d..2e738dd73 100644 --- a/app/PdeEditor.java +++ b/app/PdeEditor.java @@ -848,7 +848,13 @@ public class PdeEditor extends JPanel { } else { try { - appletLocation = runtime.window.getLocation(); + // the window will also be null the process was running + // externally. so don't even try setting if window is null + // since PdeRuntime will set the appletLocation when an + // external process is in use. + if (runtime.window != null) { + appletLocation = runtime.window.getLocation(); + } } catch (NullPointerException e) { } } //System.out.println("doclose2"); @@ -1813,7 +1819,7 @@ public class PdeEditor extends JPanel { } - public void addDataFile() { + public void addFile() { // get a dialog, select a file to add to the sketch String prompt = "Select an image or other data file to copy to your sketch"; FileDialog fd = new FileDialog(new Frame(), prompt, FileDialog.LOAD); @@ -1830,10 +1836,24 @@ public class PdeEditor extends JPanel { // if people don't want it to copy, they can do it by hand File sourceFile = new File(directory, filename); - File dataFolder = new File(sketchDir, "data"); - if (!dataFolder.exists()) dataFolder.mkdirs(); + File destFile = null; - File destFile = new File(dataFolder, filename); + // if the file appears to be code related, drop it + // into the code folder, instead of the data folder + if (filename.toLowerCase().endsWith(".class") || + filename.toLowerCase().endsWith(".jar") || + filename.toLowerCase().endsWith(".dll") || + filename.toLowerCase().endsWith(".jnilib") || + filename.toLowerCase().endsWith(".so")) { + File codeFolder = new File(sketchDir, "code"); + if (!codeFolder.exists()) codeFolder.mkdirs(); + destFile = new File(codeFolder, filename); + + } else { + File dataFolder = new File(sketchDir, "data"); + if (!dataFolder.exists()) dataFolder.mkdirs(); + destFile = new File(dataFolder, filename); + } //System.out.println("copying from " + sourceFile); //System.out.println("copying to " + destFile); copyFile(sourceFile, destFile); diff --git a/app/PdeMessageSiphon.java b/app/PdeMessageSiphon.java index 178e4d045..2927b6fb0 100644 --- a/app/PdeMessageSiphon.java +++ b/app/PdeMessageSiphon.java @@ -57,6 +57,7 @@ class PdeMessageSiphon implements Runnable { } } catch (Exception e) { System.err.println("PdeMessageSiphon err " + e); + e.printStackTrace(); //thread.stop(); // implicit (and no longer supported) } //System.err.println("siphon thread exiting"); diff --git a/app/PdeRuntime.java b/app/PdeRuntime.java index 1c021162a..3132023e1 100644 --- a/app/PdeRuntime.java +++ b/app/PdeRuntime.java @@ -68,25 +68,24 @@ public class PdeRuntime implements PdeMessageConsumer { this.leechErr = leechErr; - //Frame frame = PdeBase.frame; - Point parentLoc = editor.base.getLocation(); //frame.getLocation(); - Insets parentInsets = editor.base.getInsets(); //frame.getInsets(); + Point parentLoc = editor.base.getLocation(); + Insets parentInsets = editor.base.getInsets(); int x1 = parentLoc.x - 20; int y1 = parentLoc.y; try { - //if (PdeBase.getBoolean("play.external", false)) { - //System.out.println(externalPaths); - if (externalRuntime) { - //System.out.println("going external"); String command[] = new String[] { "java", "-cp", externalPaths, "BApplet", - "--external=" + x1 + "," + y1, + BApplet.EXTERNAL_FLAG + ((windowLocation != null) ? + ("e" + + windowLocation.x + "," + + windowLocation.y) : + (x1 + "," + y1)), className }; @@ -382,6 +381,16 @@ public class PdeRuntime implements PdeMessageConsumer { return; } + if (s.indexOf(BApplet.EXTERNAL_MOVE) == 0) { + String nums = s.substring(s.indexOf(' ') + 1); + int space = nums.indexOf(' '); + int left = Integer.parseInt(nums.substring(0, space)); + int top = Integer.parseInt(nums.substring(space + 1)); + editor.appletLocation = new Point(left, top); + //System.out.println("wanna move to " + left + " " + top); + return; + } + //System.err.println("message " + s.length() + ":" + s); if (s.length() > 2) System.err.println(s); diff --git a/todo.txt b/todo.txt index d69d21f4f..e8fa7a505 100644 --- a/todo.txt +++ b/todo.txt @@ -6,21 +6,21 @@ X beginShape/endShape.. 3D scenes with boxes.. X newPixels is in BGraphics.endFrame, X screen.drawImage is in BApplet.paint X need to move both to BApplet.paint() - -_ external applet stuff +X external applet stuff X set initial position of external applets via BApplet X closing window doesn't disable the stop button X hitting 'stop' should freeze applet, not close window o what was the random NullPointerException - -_ 'add files' for .class, .jar should drop the stuff in -_ send messages for window location -_ external classes using loadStream, etc have trouble +X send messages for window location +X remove 'wanna move' msg, and actually record the position +X 'add files' for .class, .jar should drop the stuff into 'code' +o external classes using loadStream, etc have trouble _ history could be gzipped and appended to history.dat _ along with another file that is actually a table of offsets _ no need to make the thing a gzip stream _ checkbox on menu for 'record history' ? +_ history converter option? _ jikes errors are missing newline/linefeed ?