Thursday, March 30, 2006

Monkey Matters

The Eclipse Monkey scripting stuff looks cool. The ability to easily wire-up your own (& others) DOMs will make for handy little apps. Wayne Beaton has a great example here.

I thought I'd give it a go - but hit a small hurdle when trying to access my own DOM. The notes on the Eclipse site give the syntax:

DOM: http://update-site/plugin-id

My problem was - I didn't have an update site: I was doing this all on a local PC.

As ever, the answer was in front of my nose - or rather, in the code ... A quick check of the monkey code reveals that the metadata is simply extracted using a regular expression. In this case, it's this:

DOM:\s*(\p{Graph}+)\/((\p{Alnum}|\.)+)

meaning, anything before the slash is considered the URL, anything after is the plugin-id. And reading a little more reveals that Monkey will try and see if your plugin is loaded first - before using the update-site.

It was then a simply matter of:
  1. exporting the plugin containing my DOM.
  2. then installing my plugin in my workspace (copy to plugin directory)
  3. and then running the script!
I finally had access to my DOM !! plus, learnt a little of the Monkey internals on the way :-)

No comments: