Writing Scripts
There are three main ways that Groovy is integrated into uDig. A view with a input area where scripts can be written and executed. An operation that allows scripts to be written and ran on the selected item. Finally a styling page allows styles to be written with groovy and applied to a layer.
Groovy View
The groovy view has an input field and a output field. System.out and System.err messages generated from the scripts are printed to the output field. The input field is a primitive code editor. See Groovy Shell for more details. Scripts created in the Groovy View can be saved or loaded and ran from with in the view. Only the default methods are available for use.
Groovy Operation
The groovy operation can be ran on an number of selected items. Each selected item is one of the elements in the args variable. For example args[0] will retrieve the first selected element. The groovy operation has the Groovy Shell and allows scripts to be written, saved, loaded and ran.
Groovy Shell
The Groovy Shell provides support for writing scripts. It has primitive syntax highlighting as well as primitive code completion. This is not eclipse so don't expect that level of sophistication.
| Command |
Action |
| CTRL+Enter |
Run the current script |
| CTRL+SHIFT+Enter |
Execute the current line; interactive scripting |
| CTRL+SPACE |
Cycle throw code-completion options |
Code Completion
There are different types of code completion available and pressing CTRL+SPACE allows a user to cycle through the different options.
| Completion |
Description |
| Variable |
Lists the available variables |
| Method |
Lists the available methods |
| Class |
Lists the available classes |