changing how 'sketch' variable is set on startup

This commit is contained in:
benfry
2009-11-29 16:32:06 +00:00
parent 110f8c3c1e
commit fb2562f05c
6 changed files with 25 additions and 55 deletions

View File

@@ -203,8 +203,8 @@ public class Commander implements RunnerListener {
String className = sketch.build(outputPath);
if (className != null) {
success = true;
Runner runner = new Runner(this);
runner.launch(sketch, className, mode == PRESENT);
Runner runner = new Runner(this, sketch);
runner.launch(className, mode == PRESENT);
} else {
success = false;

View File

@@ -1633,8 +1633,8 @@ public class Editor extends JFrame implements RunnerListener {
sketch.prepare();
String appletClassName = sketch.build();
if (appletClassName != null) {
runtime = new Runner(Editor.this);
runtime.launch(sketch, appletClassName, false);
runtime = new Runner(Editor.this, sketch);
runtime.launch(appletClassName, false);
}
} catch (Exception e) {
statusError(e);
@@ -1649,8 +1649,8 @@ public class Editor extends JFrame implements RunnerListener {
sketch.prepare();
String appletClassName = sketch.build();
if (appletClassName != null) {
runtime = new Runner(Editor.this);
runtime.launch(sketch, appletClassName, true);
runtime = new Runner(Editor.this, sketch);
runtime.launch(appletClassName, true);
}
} catch (Exception e) {
statusError(e);

View File

@@ -81,8 +81,9 @@ public class Runner implements MessageConsumer {
private String appletClassName;
public Runner(RunnerListener listener) {
public Runner(RunnerListener listener, Sketch sketch) {
this.listener = listener;
this.sketch = sketch;
if (listener instanceof Editor) {
this.editor = (Editor) listener;
@@ -92,9 +93,7 @@ public class Runner implements MessageConsumer {
}
public void launch(Sketch sketch, String appletClassName,
boolean presenting) {
this.sketch = sketch;
public void launch(String appletClassName, boolean presenting) {
this.appletClassName = appletClassName;
this.presenting = presenting;

View File

@@ -729,7 +729,7 @@ public class Android implements Tool {
System.out.println("creating runner");
//System.out.println("editor from Android is " + editor);
AndroidRunner ar = new AndroidRunner(editor);
AndroidRunner ar = new AndroidRunner(editor, editor.getSketch());
System.out.println("launching vm");
return ar.launch(ADB_SOCKET_PORT);
//System.out.println("vm launched");

View File

@@ -36,58 +36,21 @@ import com.sun.jdi.event.ExceptionEvent;
public class AndroidRunner extends Runner {
// private boolean presenting;
// Object that listens for error messages or exceptions.
// private RunnerListener listener;
// Running remote VM
// private VirtualMachine vm;
// Thread transferring remote error stream to our error stream
// private Thread errThread = null;
// Thread transferring remote output stream to our output stream
// private Thread outThread = null;
// Mode for tracing the Trace program (default= 0 off)
// private int debugTraceMode = 0;
// Do we want to watch assignments to fields
// private boolean watchFields = false;
// Class patterns for which we don't want events
// private String[] excludes = {
// "java.*", "javax.*", "sun.*", "com.sun.*",
// "apple.*",
// "processing.*"
// };
// private RunnerException exception;
// private Editor editor;
// private Sketch sketch;
// private String appletClassName;
public AndroidRunner(RunnerListener listener) {
super(listener);
if (editor != null) {
sketch = editor.getSketch();
}
public AndroidRunner(RunnerListener listener, Sketch sketch) {
super(listener, sketch);
}
public boolean launch(String port) {
vm = launchVirtualMachine(port);
System.out.println("vm launched");
// System.out.println("vm launched");
if (vm != null) {
System.out.println("starting trace");
// System.out.println("starting trace");
generateTrace(null);
System.out.println("done starting trace");
// System.out.println("done starting trace");
return true;
}
System.out.println("no trace for you");
// System.out.println("no trace for you");
return false;
}
@@ -271,7 +234,10 @@ public class AndroidRunner extends Runner {
// PApplet.println("attaching now...");
//return connector.attach(arguments);
System.out.println("Attaching to the debugger. If this command hangs, ");
System.out.println("you may need to use Tools \u2192 " + Reset.MENU_TITLE + ".");
VirtualMachine machine = connector.attach(arguments);
System.out.println("Debugger successfully attached, nevermind that last bit.");
// PApplet.println("attached");
return machine;

View File

@@ -28,16 +28,21 @@ import processing.app.tools.Tool;
public class Reset implements Tool {
static final String MENU_TITLE = "Reset Android";
Editor editor;
public String getMenuTitle() {
return "Reset Android Tools";
return MENU_TITLE;
}
public void init(Editor editor) {
this.editor = editor;
}
public void run() {
if (Android.sdkPath == null) {
JOptionPane.showMessageDialog(editor,