2 * Copyright 2000-2014 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.intellij.execution.runners;
19 import com.intellij.execution.*;
20 import com.intellij.execution.configurations.*;
21 import com.intellij.execution.ui.RunContentDescriptor;
22 import com.intellij.openapi.options.SettingsEditor;
23 import org.jetbrains.annotations.NotNull;
24 import org.jetbrains.annotations.Nullable;
26 abstract class BaseProgramRunner<Settings extends RunnerSettings> implements ProgramRunner<Settings> {
29 public Settings createConfigurationData(ConfigurationInfoProvider settingsProvider) {
34 public void checkConfiguration(RunnerSettings settings, ConfigurationPerRunnerSettings configurationPerRunnerSettings)
35 throws RuntimeConfigurationException {
39 public void onProcessStarted(RunnerSettings settings, ExecutionResult executionResult) {
44 public SettingsEditor<Settings> getSettingsEditor(Executor executor, RunConfiguration configuration) {
49 public void execute(@NotNull ExecutionEnvironment environment) throws ExecutionException {
50 execute(environment, null);
54 public void execute(@NotNull ExecutionEnvironment environment, @Nullable Callback callback) throws ExecutionException {
55 RunProfileState state = environment.getState();
60 RunManager.getInstance(environment.getProject()).refreshUsagesList(environment.getRunProfile());
61 execute(environment, callback, state);
64 protected abstract void execute(@NotNull ExecutionEnvironment environment,
65 @Nullable Callback callback,
66 @NotNull RunProfileState state) throws ExecutionException;
69 static RunContentDescriptor postProcess(@NotNull ExecutionEnvironment environment, @Nullable RunContentDescriptor descriptor, @Nullable Callback callback) {
70 if (descriptor != null) {
71 descriptor.setExecutionId(environment.getExecutionId());
72 RunnerAndConfigurationSettings settings = environment.getRunnerAndConfigurationSettings();
73 if (settings != null) {
74 descriptor.setActivateToolWindowWhenAdded(settings.isActivateToolWindowBeforeRun());
77 if (callback != null) {
78 callback.processStarted(descriptor);