use of processing.mode.java.runner.Runner in project processing by processing.
the class Debugger method startDebug.
/**
* Start a debugging session. Builds the sketch and launches a VM to run it.
* VM starts suspended. Should produce a VMStartEvent.
*/
public synchronized void startDebug() {
//stopDebug(); // stop any running sessions
if (isStarted()) {
// do nothing
return;
}
// we are busy now
editor.statusBusy();
// clear console
editor.clearConsole();
// clear variable inspector (also resets expanded states)
editor.variableInspector().reset();
// load edits into sketch obj, etc...
editor.prepareRun();
// after prepareRun, since this removes highlights
editor.activateDebug();
try {
Sketch sketch = editor.getSketch();
JavaBuild build = new JavaBuild(sketch);
log("building sketch: " + sketch.getName());
//LineMapping.addLineNumbers(sketch); // annotate
// mainClassName = build.build(false);
mainClassName = build.build(true);
//LineMapping.removeLineNumbers(sketch); // annotate
log("class: " + mainClassName);
// folder with assembled/preprocessed src
srcPath = build.getSrcFolder().getPath();
log("build src: " + srcPath);
// folder with compiled code (.class files)
log("build bin: " + build.getBinFolder().getPath());
if (mainClassName != null) {
// generate the source line mapping
//lineMap = LineMapping.generateMapping(srcPath + File.separator + mainClassName + ".java");
log("launching debuggee runtime");
runtime = new Runner(build, editor);
// non-blocking
VirtualMachine vm = runtime.debug(null);
if (vm == null) {
loge("error 37: launch failed", null);
}
// start receiving vm events
VMEventReader eventThread = new VMEventReader(vm.eventQueue(), vmEventListener);
eventThread.start();
startTrackingLineChanges();
editor.statusBusy();
}
} catch (Exception e) {
editor.statusError(e);
}
}
use of processing.mode.java.runner.Runner in project processing by processing.
the class JavaMode method handleTweak.
/** Start a sketch in tweak mode */
public Runner handleTweak(Sketch sketch, RunnerListener listener) throws SketchException {
// final boolean present) throws SketchException {
final JavaEditor editor = (JavaEditor) listener;
// first try to build the unmodified code
JavaBuild build = new JavaBuild(sketch);
// String appletClassName = build.build(false);
String appletClassName = build.build(true);
if (appletClassName == null) {
// unmodified build failed, so fail
return null;
}
// if compilation passed, modify the code and build again
// save the original sketch code of the user
editor.initBaseCode();
// check for "// tweak" comment in the sketch
boolean requiresTweak = SketchParser.containsTweakComment(editor.baseCode);
// parse the saved sketch to get all (or only with "//tweak" comment) numbers
final SketchParser parser = new SketchParser(editor.baseCode, requiresTweak);
// add our code to the sketch
final boolean launchInteractive = editor.automateSketch(sketch, parser);
build = new JavaBuild(sketch);
appletClassName = build.build(false);
if (appletClassName != null) {
final Runner runtime = new Runner(build, listener);
new Thread(new Runnable() {
public void run() {
// these block until finished
// if (present) {
// runtime.present(null);
// } else {
runtime.launch(null);
// next lines are executed when the sketch quits
if (launchInteractive) {
// fix swing deadlock issue: https://github.com/processing/processing/issues/3928
SwingUtilities.invokeLater(new Runnable() {
public void run() {
editor.initEditorCode(parser.allHandles, false);
editor.stopTweakMode(parser.allHandles);
}
});
}
}
}).start();
if (launchInteractive) {
// fix swing deadlock issue: https://github.com/processing/processing/issues/3928
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// replace editor code with baseCode
editor.initEditorCode(parser.allHandles, false);
editor.updateInterface(parser.allHandles, parser.colorBoxes);
editor.startTweakMode();
}
});
}
return runtime;
}
return null;
}
use of processing.mode.java.runner.Runner in project processing by processing.
the class JavaMode method handleLaunch.
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/** Handles the standard Java "Run" or "Present" */
public Runner handleLaunch(Sketch sketch, RunnerListener listener, final boolean present) throws SketchException {
JavaBuild build = new JavaBuild(sketch);
// String appletClassName = build.build(false);
String appletClassName = build.build(true);
if (appletClassName != null) {
final Runner runtime = new Runner(build, listener);
new Thread(new Runnable() {
public void run() {
// these block until finished
if (present) {
runtime.present(null);
} else {
runtime.launch(null);
}
}
}).start();
return runtime;
}
return null;
}
Aggregations