Scripting AnyJ
The current API is intended to extend AnyJ (e.g. to create small helpers in the editor) or to integrate
third party products (e.g. versioncontrol).
What you can do using scripts
- Define new Menu Items
- Access the current selection of the IDE
- Access some basic settings of the current workspace
- Manipulate the document of an Editor
- (limited) remote control of AnyJ
What is used as Scripting Language ?
The scripting language is Java. In 4.0 we dropped the use of the 'Dynamic Java' java interpreter [memory leaks, performance].
Anyway existing AnyJ 3.x scripts are easy to port.
Scripts can be developed interactively (without restarting AnyJ after each change).
Writing a Service (Menu Item)
A service is similar to an 'Action' in swing. A service shows up in the gui as a toolbar button or
menu item. See the API javadoc for further explanation.
- Choose 'Tools|Scripting Support|Mount Scripting Directory' from the menu. The directory containing scripts should get mounted to
your workspace.
- Choose 'Tools|Scripting Support|new Scripting package'
- Follow the instructions in the template code:
- Define when your menu item should be enabled.
- Implement the action to be done when the menu item gets selected.
Use the helper scripts Tools|Scripting Support|Dump selected objects and Tools|Scripting Support|Dump Environment to
discover which objects are selected (depends on the last selection made in the IDE).
- Choose 'Tools|Scripting Support|Compile Scripts' to compile your scripts. Ensure there are no error messages.
- Enable your scripts choosing 'Tools|Scripting Support|Enable/Disable Scripts'
- Choose 'Tools|Scripting Support|Reload Scripts' to enforce AnyJ to update the newly compiled classes
- Test your new menu item
- make changes if necessary and again use 'Tools|Scripting Support|Compile Scripts' and 'Tools|Scripting Support|Reload Scripts' to make the changes active
- submit your script to support@netcomputing.de ;) .
- assign a shortcut the usual way (Preferences|Menus and Shortcuts).
Accessing external .jars from your Script
All .jar file copied into the scripts directory are automatically added to a scripts classpath.
Predelivered Scripts
AnyJ comes with some sample scripts, among them a set of scripts making up a rather complete interface to
the CCC Harvest version control system. Use these as examples to roll your own ..