The best way to learn how scripting works in IJC is to study some examples. Below is our ever-growing repository of scripts with brief explanations. There is further discussion about the utility and function on the individual script page. We welcome submissions from IJC users to include in this list.
Scripts are executed in the context of a data tree or schema. When the script is executed the data tree or schema is 'injected' into the script as a variable that can be used by the script. The variable name is 'schema' when scripting a schema and 'dataTree' when scripting a data tree. The built-in 'Getter and Setter' syntax simply translates
dataTree.getRootVertex().getEntity()
to
dataTree.rootVertex.entity
. The two key injected variables are
dataTree
and
schema
, which follow the API for DFDataTree and DFSchema .
The editor opens with a very simple example script that demonstrates a number of fundamental uses for this variable.
Since IJC 5.10 scripts can be cancelled at any point during their execution. The Cancel button is located in the bottom right corner of the status bar. When pressed for a running script, it is interrupted and forced to halt execution. We provided a simple mechanism for cancelling several scripts (e.g. Simple SDF Exporter) previously. You can see additional lines in the source code, that are well commented there. This "manual" approach is no longer needed since a ThreadInterrupt transformation is injected for key syntactical elements of any script, which force to check for an interrupt at those points. More information about the details, can be found at Groovy website .
Scripting within IJC is a continuously developing process. Current limitations that are in a process of development.
Item | Description |
---|---|
Editor support | Scripts are edited using a pretty basic editor. Improved editor support (with better syntax highlighting, formatting and code completion etc.) is in the pipeline. |
A script cannot easily access multiple schemas | While a script can access the data or structure from another schema, it is not a trivial task. Please contact us if you have need for the feature. |
Forms have limited scripting capability | Several things can be scripted on the forms currently. There is the 'Button' widget for running scripts. Also double-click event on following widgets can be customized: MolPane, MolMatrix, TextField, TextArea, Table and GridView. We plan to support more widgets and events in the near future. |
Improved syntax | Groovy allows easy generation of Domain Specific Languages (DSLs) which can provide a simpler approach that a traditional Java API. We plan to provide DSLs for accessing the IJC APIs to make working with scripts easier. |