Ok, I've got the Rhino jscript debugger running but it does not show any
debugging info of the 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 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?

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);
//    }




On 1/30/07, K. W. Landry <[EMAIL PROTECTED]> wrote:

Cameron,
Thanks, that makes obvious sense to me. I over-think myself into these
corners and just a nudge in the right direction does the trick,
Thanks,
KWL

On 1/30/07, Cameron McCormack <[EMAIL PROTECTED]> wrote:
>
> Hi.
>
> K. W. Landry:
> > I've worked on this for a long time and I'm getting no where.  Other
> than
> > the source for Squiggle, there are no examples for getting this done
> that I
> > can find. It's possible I'm going about it all wrong but, I can't find
> any
> > other references, so......
> >
> > JS.jar is in the build path, I've visually checked it and I get the
> class
> > references in the early lines of the code, as I step through in the
> eclipse
> > debug view,
> >
> > My code to invoke the mozilla jscript debugger from my batik svg
> viewer
> > fails like so:
> >
> > java.lang.InstantiationException:
> org.mozilla.javascript.tools.debugger.Main
> >    at java.lang.Class.newInstance0 (Unknown Source)
> >    at java.lang.Class.newInstance(Unknown Source)
> >    at com.bluepearlsystems.Client.BluePearlViewer.showDebugger(
> > BluePearlViewer.java:255)
> >    at com.bluepearlsystems.Client.BluePearlViewer.setSVGCanvas (
> > BluePearlViewer.java:352)
> >    at com.bluepearlsystems.Client.BluePearlViewer.main(
> BluePearlViewer.java
> > :179)
> >
> > 255 is marked below, it is o = debuggerClass.newInstance();
> >
> > on this code:
> >
> >   public static void showDebugger() {
> >        jDebugger();
> >        if (debuggerClass == null) return;
> >        if (debuggerFrame == null) {
> >            Constructor dbgcon = null;
> >            Constructor[] ca = null;
> >            try {
> >                ca = debuggerClass.getConstructors();
> >                int l = ca.length;
> >                dbgcon = debuggerClass.getConstructor (new Class [] {
> > String.class });
> >            } catch (SecurityException e1) {
> >                log.debug("GetConstructor Security Exception:\n "+e1);
> >                e1.printStackTrace ();
> >            }
> >             catch (NoSuchMethodException e1) {
> >                log.debug("GetConstructor No Such Method Exception:\n
> "+e1);
> >                e1.printStackTrace();
> >            }
> >
> >            Object o = null;
> >            try {
> > #255                o = debuggerClass.newInstance();
> >            } catch (InstantiationException e2) {
> >                 e2.printStackTrace();
> >            } catch (IllegalAccessException e2) {
> >                e2.printStackTrace();
> >            }
> >
> >            debuggerFrame = (JFrame)o;
>
> The org.mozilla.javascript.tools.debugger.Main class only has a
> constructor that takes a String argument, so calling
> debuggerClass.newInstance() will fail because there's no constructor
> with no arguments.  You should use the constructor stored in dbgcon to
> instantiate Main.
>
> Note that the only reason Squiggle's JSVGViewerFrame uses reflection to
> invoke the debugger is that Rhino is optional, so the code needs to be
> able to compile even without Rhino present.  If in your application you
> will always have Rhino present, you should just instantiate the debugger
> normally, like:
>
>   import org.mozilla.javascript.tools.debugger.Main;
>
>       …
>       Main debuggerMain = new Main("My debugger");
>
> > JS.jar is copied  to the same directory as Squiggle.
> > Squiggle fails after it has started and I click on "Tools", then
> Script
> > Debugger" with the following (copied from the dos box):
>
> This is a separate issue, a bug in Rhino that is causing the debugger
> not to be able to run with the policy files that Batik has in place
> (see https://bugzilla.mozilla.org/show_bug.cgi?id=367627 ).  Hopefully
> the patch will go into Rhino soon.
>
> --
> Cameron McCormack, http://mcc.id.au/
>         xmpp:[EMAIL PROTECTED]  ▪  ICQ 26955922  ▪  MSN [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to