2023-02-27 13:11:32 +01:00

4.0 KiB

Run Configurations Tutorial

Adding custom run configuration tutorial.

Product Help: Run/Debug Configuration

These series of steps show how to register and implement a simple Run Configuration. Run Configurations are used to run internal and external processes from within IntelliJ Platform based products.

Consider the runConfiguration sample plugin available in the code samples. See Code Samples on how to set up and run the plugin.

Pre-Requirements

Create an empty plugin project. See the section for details.

Register a New ConfigurationType

Add new com.intellij.configurationType extension to the plugin.xml

<extensions defaultExtensionNs="com.intellij">
  <configurationType
      implementation="org.jetbrains.sdk.runConfiguration.DemoRunConfigurationType"/>
</extensions>

Implement ConfigurationType

Implement ConfigurationType interface registered in the Step 1.

{src="run_configuration/src/main/java/org/jetbrains/sdk/runConfiguration/DemoRunConfigurationType.java" include-symbol="DemoRunConfigurationType"}

Implement a ConfigurationFactory

Implement a new ConfigurationFactory through which custom run configurations will be created.

{src="run_configuration/src/main/java/org/jetbrains/sdk/runConfiguration/DemoConfigurationFactory.java" include-symbol="DemoConfigurationFactory"}

Implement corresponding configuration options class extending RunConfigurationOptions to store settings.

{src="run_configuration/src/main/java/org/jetbrains/sdk/runConfiguration/DemoRunConfigurationOptions.java" include-symbol="DemoRunConfigurationOptions"}

Implement a Run Configuration

To make your changes visible from the UI, implement a new Run Configuration.

Note: In most of the cases you can derive a custom Run Configuration class from the RunConfigurationBase. If you need to implement specific settings externalization rules and I/O behaviour, use RunConfiguration interface.

{src="run_configuration/src/main/java/org/jetbrains/sdk/runConfiguration/DemoRunConfiguration.java" include-symbol="DemoRunConfiguration"}

Create and Implement Run Configuration UI Form

Make sure UI Designer plugin is enabled.

Create a new UI form that defines, how an inner part of the new Run Configuration should look like.

Default Run Configuration will be looking like this:

Default Run Configuration Look

Bind the UI Form

The UI Form should be bound with a Java class responsible for handling UI components logic.

{src="run_configuration/src/main/java/org/jetbrains/sdk/runConfiguration/DemoSettingsEditor.java" include-symbol="DemoSettingsEditor"}

Compile and Run the Plugin

Refer to Running and Debugging a Plugin.

After going through the steps described above you can create a custom Run Configuration from your plugin.

New Run Configuration Type