mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-29 01:37:51 +08:00
91 lines
3.7 KiB
Markdown
91 lines
3.7 KiB
Markdown
[//]: # (title: Run Configurations Tutorial)
|
|
|
|
<!-- Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
|
|
|
<microformat>
|
|
|
|
**Product Help:** [Run/Debug Configuration](https://www.jetbrains.com/idea/help/run-debug-configuration.html)
|
|
|
|
</microformat>
|
|
|
|
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](%gh-sdk-samples%/run_configuration).
|
|
See [Code Samples](code_samples.md) on how to set up and run the plugin.
|
|
|
|
## Pre-Requirements
|
|
|
|
Create an empty plugin project.
|
|
See the [](creating_plugin_project.md) section for details.
|
|
|
|
## Register a New ConfigurationType
|
|
|
|
Add new `com.intellij.configurationType` extension to the [plugin.xml](%gh-sdk-samples%/run_configuration/src/main/resources/META-INF/plugin.xml)
|
|
|
|
```xml
|
|
<extensions defaultExtensionNs="com.intellij">
|
|
<configurationType
|
|
implementation="org.jetbrains.sdk.runConfiguration.DemoRunConfigurationType"/>
|
|
</extensions>
|
|
```
|
|
|
|
## Implement ConfigurationType
|
|
|
|
Implement [`ConfigurationType`](%gh-ic%/platform/execution/src/com/intellij/execution/configurations/ConfigurationType.java) interface registered in the Step 1.
|
|
|
|
```java
|
|
```
|
|
{src="run_configuration/src/main/java/org/jetbrains/sdk/runConfiguration/DemoRunConfigurationType.java"}
|
|
|
|
## Implement a ConfigurationFactory
|
|
|
|
Implement a new [`ConfigurationFactory`](%gh-ic%/platform/execution/src/com/intellij/execution/configurations/ConfigurationFactory.java) through which custom run configurations will be created.
|
|
|
|
```java
|
|
```
|
|
{src="run_configuration/src/main/java/org/jetbrains/sdk/runConfiguration/DemoConfigurationFactory.java"}
|
|
|
|
Implement corresponding configuration options class extending [`RunConfigurationOptions`](%gh-ic%/platform/execution/src/com/intellij/execution/configurations/RunConfigurationOptions.kt) to store settings.
|
|
|
|
```java
|
|
```
|
|
{src="run_configuration/src/main/java/org/jetbrains/sdk/runConfiguration/DemoRunConfigurationOptions.java"}
|
|
|
|
## 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`](%gh-ic%/platform/execution/src/com/intellij/execution/configurations/RunConfigurationBase.java).
|
|
If you need to implement specific settings externalization rules and I/O behaviour, use [`RunConfiguration`](%gh-ic%/platform/execution/src/com/intellij/execution/configurations/RunConfiguration.java) interface.
|
|
|
|
```java
|
|
```
|
|
{src="run_configuration/src/main/java/org/jetbrains/sdk/runConfiguration/DemoRunConfiguration.java"}
|
|
|
|
## Create and Implement Run Configuration UI Form
|
|
|
|
Make sure _UI Designer_ plugin is [enabled](https://www.jetbrains.com/help/idea/managing-plugins.html).
|
|
|
|
Create a new [UI form](https://www.jetbrains.com/help/idea/designing-gui-major-steps.html) that defines, how an inner part of the new Run Configuration should look like.
|
|
|
|
Default Run Configuration will be looking like this:
|
|
|
|

|
|
|
|
## Bind the UI Form
|
|
|
|
The UI Form should be bound with a Java class responsible for handling UI components logic.
|
|
|
|
```java
|
|
```
|
|
{src="run_configuration/src/main/java/org/jetbrains/sdk/runConfiguration/DemoSettingsEditor.java"}
|
|
|
|
## Compile and Run the Plugin
|
|
|
|
Refer to [Running and Debugging a Plugin](creating_plugin_project.md#executing-the-plugin).
|
|
|
|
After going through the steps described above you can create a custom Run Configuration from your plugin.
|
|
|
|

|