[code] simple custom run configuration

This commit is contained in:
Anna Bulenkova 2015-02-04 12:43:55 +01:00
parent 3f4f6fe4b3
commit e6cde7920e
7 changed files with 217 additions and 0 deletions

View File

@ -0,0 +1,30 @@
<idea-plugin version="2" url="www.jetbrains.com">
<id>org.jetbrains.tutorials.run.configuration</id>
<name>Run Configuration</name>
<version>1.0</version>
<vendor email="support@jetbrains.com" url="http://www.jetbrains.com">JetBrains</vendor>
<description>Illustration of working with run configurations</description>
<change-notes>Initial commit</change-notes>
<!-- please see http://confluence.jetbrains.com/display/IDEADEV/Build+Number+Ranges for description -->
<idea-version since-build="131"/>
<depends>com.intellij.modules.lang</depends>
<extensions defaultExtensionNs="com.intellij">
<configurationType implementation="org.jetbrains.tutorials.run.configuration.DemoRunConfigurationType"/>
</extensions>
<application-components>
<!-- Add your application components here -->
</application-components>
<project-components>
<!-- Add your project components here -->
</project-components>
<actions>
</actions>
</idea-plugin>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PLUGIN_MODULE" version="4">
<component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/META-INF/plugin.xml" />
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,27 @@
package org.jetbrains.tutorials.run.configuration;
import com.intellij.execution.configurations.ConfigurationFactory;
import com.intellij.execution.configurations.ConfigurationType;
import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.openapi.project.Project;
/**
* @author Anna Bulenkova
*/
public class DemoConfigurationFactory extends ConfigurationFactory {
private static final String FACTORY_NAME = "Demo configuration factory";
protected DemoConfigurationFactory(ConfigurationType type) {
super(type);
}
@Override
public RunConfiguration createTemplateConfiguration(Project project) {
return new DemoRunConfiguration(project, this, "Demo");
}
@Override
public String getName() {
return FACTORY_NAME;
}
}

View File

@ -0,0 +1,36 @@
package org.jetbrains.tutorials.run.configuration;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.Executor;
import com.intellij.execution.configurations.*;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author Anna Bulenkova
*/
public class DemoRunConfiguration extends RunConfigurationBase {
protected DemoRunConfiguration(Project project, ConfigurationFactory factory, String name) {
super(project, factory, name);
}
@NotNull
@Override
public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() {
return new DemoSettingsEditor();
}
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
}
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment executionEnvironment) throws ExecutionException {
return null;
}
}

View File

@ -0,0 +1,39 @@
package org.jetbrains.tutorials.run.configuration;
import com.intellij.execution.configurations.ConfigurationFactory;
import com.intellij.execution.configurations.ConfigurationType;
import com.intellij.icons.AllIcons;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
/**
* @author Anna Bulenkova
*/
public class DemoRunConfigurationType implements ConfigurationType {
@Override
public String getDisplayName() {
return "Demo";
}
@Override
public String getConfigurationTypeDescription() {
return "Demo Run Configuration Type";
}
@Override
public Icon getIcon() {
return AllIcons.General.Information;
}
@NotNull
@Override
public String getId() {
return "DEMO_RUN_CONFIGURATION";
}
@Override
public ConfigurationFactory[] getConfigurationFactories() {
return new ConfigurationFactory[]{new DemoConfigurationFactory(this)};
}
}

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.tutorials.run.configuration.DemoSettingsEditor">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="57eab" class="com.intellij.openapi.ui.LabeledComponent" binding="myMainClass" custom-create="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="-1" height="20"/>
</grid>
</constraints>
<properties>
<labelLocation value="West"/>
<text value="Script file"/>
</properties>
</component>
<vspacer id="93bd6">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
</children>
</grid>
</form>

View File

@ -0,0 +1,44 @@
package org.jetbrains.tutorials.run.configuration;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.ui.ComponentWithBrowseButton;
import com.intellij.openapi.ui.LabeledComponent;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
/**
* @author Anna Bulenkova
*/
/**
* @author Anna Bulenkova
*/
public class DemoSettingsEditor extends SettingsEditor<DemoRunConfiguration> {
private JPanel myPanel;
private LabeledComponent<ComponentWithBrowseButton> myMainClass;
@Override
protected void resetEditorFrom(DemoRunConfiguration demoRunConfiguration) {
}
@Override
protected void applyEditorTo(DemoRunConfiguration demoRunConfiguration) throws ConfigurationException {
}
@NotNull
@Override
protected JComponent createEditor() {
return myPanel;
}
private void createUIComponents() {
myMainClass = new LabeledComponent<ComponentWithBrowseButton>();
myMainClass.setComponent(new TextFieldWithBrowseButton());
}
}