// Since the interface is done in scripts too and we receive being /
// endExecution events for all UI notifications as well, we need to
// cheat a bit here.
// When file is set, we ignore the current state of "executing",
// as we're about to to execute a new script...
Script script = scope != null ? (Script) scope.get("script") : null;
// Only call Document.beginExecution for the first script in the call
// stack.
if (scriptStack.empty()) {
// Set script coordinate system and angle units on each execution,
// at the beginning of the script stack.
anglesInDegrees = AngleUnits.DEGREES == (script != null
? script.getAngleUnits()
: AngleUnits.DEFAULT);
topDownCoordinates = CoordinateSystem.TOP_DOWN == (script != null
? script.getCoordinateSystem()
: CoordinateSystem.DEFAULT);
// Pass topDownCoordinates value to the client side as well
Document.beginExecution(topDownCoordinates,
// Do not update coordinate systems for tool scripts,
// as this has already happened in Tool.onHandleEvent()
script == null || !script.isToolScript());
// Disable output to the console while the script is executed as it
// won't get updated anyway
// ConsoleOutputStream.enableOutput(false);
}
if (file != null) {
Dialog.destroyAll(false, false);
Timer.abortAll(false, false);
// Put a script object in the scope to offer the user
// access to information about it.
if (script == null) {
script = new Script(file, file.getPath().startsWith(
coreDir.getPath()));
scope.put("script", script, true);
}
}
if (scriptStack.empty() || file != null) {
if (script != null && !script.getShowProgress()) {
closeProgress();
} else if (file == null || !file.getName().startsWith("__")) {
showProgress(file != null ? "Executing " + file.getName()
+ "..." : "Executing...");
}