Starting with version 2.0.0, the JMCF add-on is provided with a Groovy script editor and tester in the configuration screens of calculated custom field provided by JMCF. This document details the Groovy editor in JMCF, its features, its availability and keyboard shortcuts.
Groovy editor features
Groovy editor in JMCF is where you should be writing your Groovy scripts. This editor has the
- Basic features like automatically indenting the code, checking for syntax errors in the code, colorizing keywords, comments, variables and so on and
- Advanced features, such as Find and Replace, that are available through keyboard shortcuts.
Groovy Help in the Groovy editor
The editor also has a Groovy help section that assists you in writing your Groovy scripts with ease. It has the following tabs:
Expected Value: This tab lists the possible expected values for the calculated custom field being configured. Click on
Expected Value tab of the Groovy help editor to see the expected values for the calculated field.
Globals: This tab lists the Global variables and functions that are available for your Groovy expressions. Hover over any button to get the information, click on it to insert it into the editor. For more information, click here.
Issue Fields: This tab lists the fields of the current issue, linked issue or the parent issue depending on the context. Select a field. The help editor displays a few Groovy expressions accessing the field values, sub-fields etc by the field name. You can refer to the issue either by the
field name or the
field ID. Groovy expressions to access all the fields of an issue are listed here.
Issue Methods: This tab lists the methods applicable to the current issue, linked issue or the parent issue depending on the context. Hover over any button to get the information, click on it to insert it into the editor. For more information, click here.
Interfaces: This tab can describe any Jira, Groovy or Java interface or class. Select an interface and the editor displays the properties and methods of the selected interface. Hover over any button to get the information, click on it to insert it into the editor. For more information, click here.
More help: This menu gives you access to additional help pages.
Using Groovy Help in the Groovy editor
Suppose you want the calculate and display the Project name of the issue's project
- Create a Calculated Text custom field type:
Project Category, from the Custom fields administration page.
- Locate the custom field on the Custom Fields administration page.
- Click on the cog wheel and click on
- Click on
Edit Groovy Formula
- Click on
Issue Fieldstab of the help editor.
- Select Project under
Select a field.
- Under the
Accessing sub-fieldssection locate the Groovy expression to access the project name.
- Click on it to insert it into the editor.
Groovy editor availability
The Groovy script editor in JMCF is available on the Custom field configuration screens of calculated custom field types that expect the result of a
Groovy editor toolbar
The Groovy editor has a toolbar with the following features. Clicking on:
- Find: Opens the search box. Use /re/ syntax for regexp search
- Find Next: Finds the next occurrence of a search
- Replace: Opens the Replace window. Replace a certain text with a specified text
- Test Groovy Script: Opens the Test Groovy script window to input the Issue key. Use it to test your script.
- Test again: Retests your script
The shortcuts for
Find, Find Next and
Replace are shown in the table below.
Groovy editor keyboard shortcuts
You can use the following shortcut keys as an alternative to the mouse when working in this editor, while the cursor is active in a code editor:
Opens the search box. Use /re/ syntax for regexp search
|Post a search, finds the next occurrence of the search|
|Post a search, finds the previous occurrence of the search|
Opens the Replace window.
|Opens the Replace all window|
|Select the whole content of the editor|
|When multiple selections are present, this deselects all but the primary selection|
|Deletes the part of the line after the cursor. If that consists only of whitespace, the newline at the end of the line is also deleted.|
|Deletes the whole line under the cursor, including newline at the end.|
|Delete the part of the line from the left side of the visual line the cursor is on to the cursor.|
|Delete the part of the line from the cursor to the right side of the visual line the cursor is on.|
|Undo the last change|
|Redo the last undone change|
|Undo the last change to the selection, or if there are no selection only changes at the top of the history, undo the last change.|
|Redo the last change to the selection, or the last text change if no selection changes remain.|
|Move the cursor to the start of the document.|
|Move the cursor to the end of the document.|
|Move the cursor to the start of the line.|
|Move to the start of the text on the line, or if we are already there, to the actual start of the line (including whitespace).|
|Move the cursor to the end of the line.|
|Move the cursor to the right side of the visual line it is on.|
|Move the cursor to the left side of the visual line it is on. If this line is wrapped, that may not be the start of the line.|
|Move the cursor up one line.|
|Move down one line.|
|Move the cursor up one screen and scroll up by the same distance.|
|Move the cursor down one screen and scroll down by the same distance.|
|Move the cursor one character left, going to the previous line when hitting the start of the line.|
|Move the cursor one character right, going to the next line when hitting the end of the line.|
|Move the cursor to the start of the previous word.|
|Move the cursor to the end of the next word.|
|Move to the left of the group before the cursor.|
|Move to the right of the group after the cursor.|
|Delete the character before the cursor.|
|Delete the character after the cursor.|
|Delete up to the start of the word before the cursor.|
|Delete up to the end of the word after the cursor.|
|Delete to the left of the group before the cursor.|
|Delete to the start of the group after the cursor.|
|Auto-indent the current line or selection.|
|Indent the current line or selection by one indent unit.|
|Dedent the current line or selection by one indent unit.|
|If something is selected, indent it by one indent unit. If nothing is selected, insert a tab character.|
|Swap the characters before and after the cursor.|
|Insert a newline and auto-indent the new line.|
|Flip the overwrite flag.|
A group is a stretch of word characters, a stretch of punctuation characters, a newline, or a stretch of more than one whitespace character.