Jeff Mesnil
Weblog · About

workspace and window variables in Eclipse Monkey

March 19, 2006

I'm playing with Eclipse Monkey and its DOM examples.

At first I did not understood in the Find_System_Prints.em example where the window variable was coming from.
After diving into in the org.eclipse.eclipsemonkey plug-in source code, I found out that it is defined as a standard global variable in RunMonkeyScript.defineStandardGlobalVariables(Scriptable scope) method.
Incidentally, it is the only global variable added by Eclipse Monkey.

The following code is also commented in this method (in version 0.1.6 of the o.e.eclipsemonkey plug-in):

// Object wrappedWorkspace = Context.javaToJS(ResourcesPlugin
// .getWorkspace(), scope);
// ScriptableObject.putProperty(scope, "workspace", wrappedWorkspace);

The workspace variable is instead contributed by the org.eclipse.dash.doms plug-in.

To sum up, window is available for free in your Monkey scripts while you will have to reference this DOM URL to have access to the workspace variable.