While the Eclipse APIs are powerful, they can also be a bit overwhelming for typical scripts, thus Eclipse Monkey is designed for users to provide their own DOMs (or to use other's DOMs) in addition to the straight Eclipse APIs.
To provide a new DOM, create a new plug-in that extends the org.eclipse.eclipsemonkey.dom
extension point. This extension requires two things:
IMonkeyDOMFactory
Each script is run in a separate instance of the script engine and the DOM factories are called to create their root objects for each of those instances. The DOM factory returns the root DOM object which can be either a Java object or a org.mozilla.javascript.Scriptable object
.
The key to writing a good DOM is to design just the right simple abstractions. It is always tempting to provide everything possible under the sun in one's DOM, but such DOMs turn out to be counter-productive - they are too complex to be easily usable in scripts. We solve the tension between simplicity and features by providing access through our DOMs to the underlying Eclipse API objects; thus when an author finds that our DOM is insufficient, she can reach through to the "real" objects and manipulate the APIs directly.
The "Eclipse Monkey Standard DOMs" plug-in contains a couple illustrative DOM and DOM factory examples.