IntelliJ IDEA Setup: Live Templates for Scout Development
This page provides IntelliJ IDEA live templates that accelerate Scout field development by auto-generating boilerplate code for adding configuration properties.
Live Templates for Scout Properties
The following templates help you quickly add new configuration properties to Scout form fields. They generate the complete property implementation including getters, setters, and configured methods.
Installation
To install these templates in IntelliJ IDEA:
-
Open Settings (Preferences on macOS) → Editor → Live Templates
-
Click the + button → Template Group → Create a new group named "Scout"
-
Select the "Scout" group → Click + → Live Template
-
Copy and paste the template XML below into the template editor
-
Define the context (Java or TypeScript) as shown in each template
Java Property Template (scoutprop
)
<template name="scoutprop" value=" @Override @ConfigProperty(ConfigProperty.$TYPE$) public void set$Prop$($Type$ $prop$) { propertySupport.setProperty$Type$(PROP_$PROP$, $prop$); } @Override @ConfigProperty(ConfigProperty.$TYPE$) public $Type$ get$Prop$() { return propertySupport.getProperty$Type$(PROP_$PROP$); } @ConfigProperty(ConfigProperty.$TYPE$) protected $Type$ getConfigured$Prop$() { return $default$; }" toReformat="false" toShortenFQNames="true">
<variable name="TYPE" expression="" defaultValue="STRING" alwaysStopAt="true" />
<variable name="Prop" expression="" defaultValue="Name" alwaysStopAt="true" />
<variable name="Type" expression="" defaultValue="String" alwaysStopAt="true" />
<variable name="prop" expression="" defaultValue="name" alwaysStopAt="true" />
<variable name="PROP" expression="" defaultValue="NAME" alwaysStopAt="true" />
<variable name="default" expression="" defaultValue=""default"" alwaysStopAt="true" />
<context>
<option name="JAVA_CODE" value="true" />
</context>
</template>
Usage in Java:
-
Position cursor in a Scout field class (e.g.,
AbstractAceField
) -
Type
scoutprop
and press Tab -
Fill in the template variables:
-
TYPE
: Property type constant (e.g.,STRING
,BOOLEAN
,INTEGER
) -
Prop
: Property name in PascalCase (e.g.,ShowGutter
) -
Type
: Java type (e.g.,boolean
,String
,int
) -
prop
: Property name in camelCase (e.g.,showGutter
) -
PROP
: Property constant name (e.g.,SHOW_GUTTER
) -
default
: Default value (e.g.,true
,"default"
,0
)
-
Example output:
@Override
@ConfigProperty(ConfigProperty.BOOLEAN)
public void setShowGutter(boolean showGutter) {
propertySupport.setPropertyBool(PROP_SHOW_GUTTER, showGutter);
}
@Override
@ConfigProperty(ConfigProperty.BOOLEAN)
public boolean isShowGutter() {
return propertySupport.getPropertyBool(PROP_SHOW_GUTTER);
}
@ConfigProperty(ConfigProperty.BOOLEAN)
protected boolean getConfiguredShowGutter() {
return true;
}
TypeScript Property Template (scoutprop
)
<template name="scoutprop" value="set$Varname$($varname$: $type$) { this.setProperty('$varname$', $varname$); } _set$Varname$($varname$: $type$){ this.$varname$ = $varname$; } get$Varname$(): $type${ return this.$varname$; } _render$Varname$(){ this.editor.session.set$Varname$(this.$varname$); }" toReformat="false" toShortenFQNames="true">
<variable name="Varname" expression="capitalize($varname$)" defaultValue="" alwaysStopAt="true" />
<variable name="varname" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="type" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_SCRIPT" value="true" />
<option name="TS_CLASS" value="false" />
<option name="TS_EXPRESSION" value="false" />
<option name="TS_STATEMENT" value="false" />
<option name="TypeScript" value="true" />
</context>
</template>
Usage in TypeScript:
-
Position cursor in a Scout field TypeScript class (e.g.,
AceField
) -
Type
scoutprop
and press Tab -
Fill in the template variables:
-
varname
: Property name in camelCase (e.g.,showGutter
) -
Varname
: Property name in PascalCase (auto-generated fromvarname
) -
type
: TypeScript type (e.g.,boolean
,string
,number
)
-
Example output:
setShowGutter(showGutter: boolean) {
this.setProperty('showGutter', showGutter);
}
_setShowGutter(showGutter: boolean){
this.showGutter = showGutter;
}
getShowGutter(): boolean{
return this.showGutter;
}
_renderShowGutter(){
this.editor.session.setShowGutter(this.showGutter);
}
Additional Resources
For a detailed explanation of how properties flow through Scout’s field architecture, see Scout Value Field Data Flow.