Java 类org.mozilla.javascript.tools.debugger.Main 实例源码

项目:taskexecutor    文件:DebuggerTest.java   
private void displayDebugger(final ContextFactory fac, final Scriptable scope) {

//        // Set the look and feel.
//        try {
//            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
//            // UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
//        } catch (Exception e) {
//        }

        // This code is mostly copied from
        // org.mozilla.javascript.tools.debugger.Main#mainEmbeddedImpl. The
        // difference is that we do not call main.doBreak(), which would cause
        // the debugger to stop on the first line of code that it executes.
        Main main = new Main("JS Debugger");

        main.setExitAction(new Runnable() {
            @Override
            public void run() {
                System.out.println("nos vamos");
                System.exit(0);
            }
        });

        main.attachTo(fac);
        main.setScope(scope);

//        main.setScopeProvider(new ScopeProvider() {
//            @Override
//            public Scriptable getScope() {
//                throw new UnsupportedOperationException();
//            }
//        });

        main.doBreak();


        main.pack();
        main.setSize(600, 460);
        main.setVisible(true);
    }
项目:phon    文件:QueryEditorWindow.java   
private void onDebugQuery() {
    final QueryScript script = (QueryScript)scriptEditor.getScript();
    final QueryName queryName = script.getExtension(QueryName.class);
    final String name = (queryName != null ? queryName.getName() : "untitled");

    final Main debugger = Main.mainEmbedded("Debugger : " + name);
    debugger.setBreakOnEnter(false);
    debugger.setBreakOnExceptions(true);

    PhonScriptContext scriptContext = script.getContext();
    try {
        final ScriptParameters scriptParams = scriptContext.getScriptParameters(scriptContext.getEvaluatedScope());

        // we need to reset the context to activate debugging
        script.resetContext();
        scriptContext = script.getContext();

        final Context ctx = scriptContext.enter();
        final ScriptableObject debugScope = ctx.initStandardObjects();
        ctx.setOptimizationLevel(-1);
        debugger.attachTo(ctx.getFactory());
        debugger.setScope(debugScope);
        scriptContext.exit();

        final ScriptParameters newParams = scriptContext.getScriptParameters(scriptContext.getEvaluatedScope(debugScope));
        ScriptParameters.copyParams(scriptParams, newParams);
    } catch (PhonScriptException e) {
        LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
    }

    debugger.setExitAction(new Runnable() {

        @Override
        public void run() {
            debugger.detach();
            debugger.setVisible(false);
        }

    });
    // break on entering main query script
    debugger.doBreak();
    debugger.pack();
    debugger.setVisible(true);
    debugger.go();

    onRunQuery();
}
项目:GuideMe    文件:MainShell.java   
public Main getDbg() {
    return dbg;
}
项目:imcjava    文件:ImcScript.java   
public void openIDE() {
    Main m = Main.mainEmbedded(context.getFactory(), global, "JS Debugger");
    System.setErr(m.getErr());
    System.setOut(m.getOut());
    System.setIn(m.getIn());
}
项目:taskexecutor    文件:DebuggerTest.java   
private void displayDebugger2(final ContextFactory fac, final Scriptable scope) {


        Main.mainEmbedded(fac, scope, "my JS debugger");
    }