Chapter 2: Writing Scripts

Scripts can be written using arbitrary development tools or just plain text editors, as long as they can be saved as a file and published (copied) into the project later. However, the tool comes with built-in support to develop scripting using Java Script. By default, all scripting development capabilities are disabled at the user interface. To enable them, the user has to edit the "Scripting" preferences and check the relevant options. Note that the execution of scripts is an independent feature and always enabled. The preferences page is just about script development. Having it enabled the developer has rich Java Script editing capabilities including a Java Script editor with auto completion, syntax highlighting and refactoring support.

The easiest way to get started as a script developer is to use the "Enable Script Development" action that is available at any project node in the model browser. Once executed, the project is prepared automatically. Refresh the project once and you will see an additional virtual folder "scripts" in your project that contains an initial sample script to get started. Note that the "scripts" folder is created inside the project file structure but not inside any project model. More precisely: the project is changed and prepared on file system level but not changed at model level, even though the folder is virtually visible in the model browser. Note again that the "Enable Script Development" action is nice to have for writing scripts but not necessarily required to execute them.

Any script file that is found in the "scripts" folder is visible in the model browser now. New files can be easily dropped from the outside into the folder or created using the "Navigator" view, or duplicated using Ctrl-C / Ctrl-V. Scripts can be opened and edited by double-click with the Java Script Development Toolkit (JSDT) or directly executed using the context menu.