ramblings/oxygen/js-require
Eric van der Vlist b62623370a Cosmetics... 2021-05-02 00:06:36 +02:00
..
css Copying 2021-05-01 18:48:45 +02:00
icons Copying 2021-05-01 18:48:45 +02:00
resources Copying 2021-05-01 18:48:45 +02:00
schema Copying 2021-05-01 18:48:45 +02:00
src-java/simple/documentation/framework Copying 2021-05-01 18:48:45 +02:00
subdir Testing... 2021-05-02 00:02:46 +02:00
templates Copying 2021-05-01 18:48:45 +02:00
xsl Copying 2021-05-01 18:48:45 +02:00
README.md Copying 2021-05-01 18:48:45 +02:00
catalog.xml Copying 2021-05-01 18:48:45 +02:00
commons.js Cosmetics... 2021-05-02 00:06:36 +02:00
debugger.js Copying 2021-05-01 18:48:45 +02:00
hello.js Testing... 2021-05-02 00:02:46 +02:00
js-require.xpr Copying 2021-05-01 18:48:45 +02:00
sdf.framework Testing... 2021-05-02 00:02:46 +02:00
sdf.jar Copying 2021-05-01 18:48:45 +02:00
sdf_sample.xml Copying 2021-05-01 18:48:45 +02:00
test.js Adapting... 2021-05-01 20:47:34 +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.