Eric van der Vlist f1060d6007 | ||
---|---|---|
.. | ||
css | ||
icons | ||
resources | ||
schema | ||
src-java/simple/documentation/framework | ||
subdir | ||
templates | ||
xsl | ||
README.md | ||
catalog.xml | ||
commons.js | ||
debugger.js | ||
hello.js | ||
js-require.xpr | ||
sdf.framework | ||
sdf.jar | ||
sdf_sample.xml | ||
test.js |
README.md
Alltogether: opening a JavaScript debugger within Oxygen JS Operations through inclusion
This rambling shows how a debugger can be launched using an inclusion.
Installation
To do so:
1) add the include() function to your commons.js file:
include = function (filepath, isAbsolute) {
if (isAbsolute === undefined || isAbsolute == false) {
filepath = Packages.ro.sync.ecss.extensions.commons.operations.CommonsOperationsUtil.expandAndResolvePath(authorAccess, filepath);
}
var text = new java.lang.String(java.nio.file.Files.readAllBytes(java.nio.file.Paths. get (java.net.URI(filepath))));
text = String(text);
eval(text);
}
2) create a debugger.js file:
startDebugger = function () {
var runnable = {
run: function () {
main.dispose();
}
}
var context = Packages.org.mozilla.javascript.Context.getCurrentContext();
// Within the current context...
var contextFactory = context.getFactory();
var scope = Packages.org.mozilla.javascript.tools.shell.Environment(runnable.__parent__);
// and the scope of the runnable variable's parent ...
var main = Packages.org.mozilla.javascript.tools. debugger.Main.mainEmbedded(contextFactory, scope, 'Debugger');
// start a debugging session ...
main.setExitAction(java.lang.Runnable(runnable));
// , clean the resources at exit time...
main.setVisible(true);
// and make it visible/
}
3) Use these functions in your doOperation() method:
doOperation = function () {
include('debugger.js');
startDebugger();
}
See also
More details on these hacks:
Framework
This directory includes the Oxygen sample framework on which ou can test these techniques but they should work on any framework.