ramblings/oxygen/js-options
Eric van der Vlist 25ac1d1a96 Copying 2021-04-28 15:12:30 +02:00
..
css Copying 2021-04-28 15:12:30 +02:00
icons Copying 2021-04-28 15:12:30 +02:00
resources Copying 2021-04-28 15:12:30 +02:00
schema Copying 2021-04-28 15:12:30 +02:00
src-java/simple/documentation/framework Copying 2021-04-28 15:12:30 +02:00
templates Copying 2021-04-28 15:12:30 +02:00
xsl Copying 2021-04-28 15:12:30 +02:00
README.md Copying 2021-04-28 15:12:30 +02:00
catalog.xml Copying 2021-04-28 15:12:30 +02:00
commons.js Copying 2021-04-28 15:12:30 +02:00
debugger.js Copying 2021-04-28 15:12:30 +02:00
hello.js Copying 2021-04-28 15:12:30 +02:00
js-debugger-include.xpr Copying 2021-04-28 15:12:30 +02:00
sdf.framework Copying 2021-04-28 15:12:30 +02:00
sdf.jar Copying 2021-04-28 15:12:30 +02:00
sdf_sample.xml Copying 2021-04-28 15:12:30 +02:00

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.