You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by "K. W. Landry" <kw...@gmail.com> on 2007/02/05 17:27:01 UTC

Associating the Rhino debugger with the Batik JScript Interpreter Context.

Ok, I've got the Rhino jscript debugger running but it does not show any
debugging info of the Batik canvas' svg jscript.

I'm guessing it's because the Rhino interpreter "Context" of Batik is not in
any way associated with the Rhino Debugger  that I've instantiated.

I've gone back to using exactly the code that JSVGViewer is using to start
the jscript debugger. At first, that actually failed with a class cast
problem in addcontextlistener, I replaced debuggerFrame with Main and that
fixed that.

I've also since moved the Context Listener up into the first "try" block,
but other than that it's still the same stuff.

Anyone have any tips, thoughts, guidelines on getting the Rhino Interpreter
Context associated with the Debugger? Or, what generally has to be done to
get the Debugger to see the Context of the interpreter as its invoked by
Batik so that it can debug jscript in the svg of the canvas?

Thanks for any help, tips, thoughts,

Here's the code in use:

    public static void showJSDebugger() {
        if (debuggerClass == null) return;
        if (debuggerFrame == null) {
            try {
//              Constructor rc = debuggerClass.getConstructor(new Class [] {
String.class });
                Object o = rc.newInstance(new Object[] { "Rhino JavaScript
Debugger" });
                Main m = (Main)o;
                Context.addContextListener ((ContextListener)m);
//                ContextFactory cf = new ContextFactory();
//                cf.addListener((ContextFactory.Listener)m);
//                cf.enter();
//                Context.enter();

                debuggerFrame = m.getDebugFrame();
                o.hashCode();
                // debuggerFrame = (JFrame)o;
                // Customize the menubar a bit, disable menu
                // items that can't be used and change 'Exit' to 'Close'.
                JMenuBar menuBar = debuggerFrame.getJMenuBar();
                JMenu    menu    = menuBar.getMenu(0);
                menu.getItem(0).setEnabled(false); // Open...
                menu.getItem (1).setEnabled(false); // Run...
                menu.getItem(3).setText
                    (Resources.getString("Close.text")); // Exit -> "Close"
                menu.getItem(3).setAccelerator( KeyStroke.getKeyStroke(
KeyEvent.VK_W, java.awt.Event.CTRL_MASK));

                debuggerFrame.setSize(600, 460);
                debuggerFrame.pack();
                WindowAdapter wa = new WindowAdapter() {
                        public void windowClosing(WindowEvent e) {
                            hideDebugger();
                        }};

                m.setExitAction(new Runnable() {
                                             public void run() {
                                                 hideDebugger();
                                             }});

//                setExitAction.invoke(debuggerFrame,
//                                     new Object [] { new Runnable() {
//                                             public void run() {
//                                                 hideDebugger();
//                                             }}});
                debuggerFrame.addWindowListener(wa);
            } catch (Exception ex) {
                ex.printStackTrace();
                return;
            }
        }
        if (debuggerFrame != null) {
            debuggerFrame.setVisible(true);

//            Context.addContextListener((ContextListener)debuggerFrame);
        }
    }
//    /**
//     * Attaches the debugger to the given ContextFactory.
//     */
//    public void attachTo(ContextFactory factory) {
//        detach();
//        this.contextFactory = factory;
//        this.listener = new DimIProxy(this, IPROXY_LISTEN);
//        factory.addListener(this.listener);
//    }

Re: Associating the Rhino debugger with the Batik JScript Interpreter Context.

Posted by Cameron McCormack <ca...@mcc.id.au>.
Hi.

K. W. Landry:
> Ok, I've got the Rhino jscript debugger running but it does not show any
> debugging info of the Batik canvas' svg jscript.
> 
> I'm guessing it's because the Rhino interpreter "Context" of Batik is not in
> any way associated with the Rhino Debugger  that I've instantiated.
> 
> I've gone back to using exactly the code that JSVGViewer is using to start
> the jscript debugger. At first, that actually failed with a class cast
> problem in addcontextlistener, I replaced debuggerFrame with Main and that
> fixed that.
> 
> I've also since moved the Context Listener up into the first "try" block,
> but other than that it's still the same stuff.
> 
> Anyone have any tips, thoughts, guidelines on getting the Rhino Interpreter
> Context associated with the Debugger? Or, what generally has to be done to
> get the Debugger to see the Context of the interpreter as its invoked by
> Batik so that it can debug jscript in the svg of the canvas?

Yes you need to do:

  RhinoInterpreter interp = …;
  Main debugger = …;

  ContextFactory cf = interp.getContextFactory();
  debugger.attachTo(cf);

See how JSVGViewerFrame.Debugger.attach uses the subclassed JSVGCanvas
object (JSVGViewerFrame.Canvas) to get access to the RhinoIntepreter
object.

-- 
Cameron McCormack, http://mcc.id.au/
	xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org