|
|
Scripting Tool |
|---|---|
|
|
Jambalaya and Shrimp support the Bean Scripting Framework (BSF). Currently scripts can only be written in Javascript. In the future we might include support for the other languages supported by BSF (such as Jython and Ruby).
To show the scripting window select Tools > Scripting from the main menu.
Scripts can be run using the Script > Run menu inside the scripting window, or by pressing the F5 key.
The Scripting Tool has many new features:
- Content Assist on the constants and mainView variables. To use press CTRL+Space after typing in either "constants." or "mainView." and a drop down list will appear showing the defined constants and methods.
- Syntax highlighting
- Undo/redo support
For a complete listing of all the available functions the see the Scripting API
Examples
1) A simple script to perform different layouts on the children of selected nodes is given below:
Runs a vertical tree layout on the selected node's children:
constants = bsf.lookupBean("scriptingConstants");
mainView = bsf.lookupBean("mainViewScriptingBean");
mainView.layoutChildren(constants.TREE_VERTICAL);
Put a try catch block around your code to alert you when an error happens:
try {
constants = bsf.lookupBean("scriptingConstants");
mainView = bsf.lookupBean("mainViewScriptingBean");
mainView.badMethod(); // throws an exception
} catch (e) {
mainView.alert("Caught exception: "+e);
}
All scripts can be saved using the File > Save menu. Then later you can load a script using the File > Open menu.

