Search in sources :

Example 1 with RunnerAndConfigurationSettings

use of com.intellij.execution.RunnerAndConfigurationSettings in project buck by facebook.

the class AndroidDebugger method attachDebugger.

public static void attachDebugger(final String packageName, final Project project) throws InterruptedException {
    IDevice[] devices = AndroidDebugBridge.getBridge().getDevices();
    if (devices.length == 0) {
        return;
    }
    IDevice device = devices[0];
    Client client;
    int currentRetryNumber = 0;
    int currentRetryTime = RETRY_TIME;
    // It takes some time to get the updated client process list, so wait for it
    do {
        client = device.getClient(packageName);
        currentRetryTime *= 2;
        Thread.sleep(currentRetryTime);
        currentRetryNumber++;
    } while (client == null && currentRetryNumber < MAX_RETRIES);
    if (client == null) {
        throw new RuntimeException("Connecting to the adb debug server timed out." + "Can't find package with name " + packageName + ".");
    }
    String debugPort = String.valueOf(client.getDebuggerListenPort());
    final RunnerAndConfigurationSettings settings = createRunConfiguration(project, debugPort);
    ApplicationManager.getApplication().invokeLater(new Runnable() {

        @Override
        public void run() {
            // Needs read access which is available on the read thread.
            ProgramRunnerUtil.executeConfiguration(project, settings, DefaultDebugExecutor.getDebugExecutorInstance());
        }
    });
}
Also used : IDevice(com.android.ddmlib.IDevice) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) Client(com.android.ddmlib.Client)

Example 2 with RunnerAndConfigurationSettings

use of com.intellij.execution.RunnerAndConfigurationSettings in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoBuildingRunner method getOutputFile.

@NotNull
private static File getOutputFile(@NotNull ExecutionEnvironment environment, @NotNull GoApplicationRunningState state) throws ExecutionException {
    File outputFile;
    String outputDirectoryPath = state.getConfiguration().getOutputFilePath();
    RunnerAndConfigurationSettings settings = environment.getRunnerAndConfigurationSettings();
    String configurationName = settings != null ? settings.getName() : "application";
    if (StringUtil.isEmpty(outputDirectoryPath)) {
        try {
            outputFile = FileUtil.createTempFile(configurationName, "go", true);
        } catch (IOException e) {
            throw new ExecutionException("Cannot create temporary output file", e);
        }
    } else {
        File outputDirectory = new File(outputDirectoryPath);
        if (outputDirectory.isDirectory() || !outputDirectory.exists() && outputDirectory.mkdirs()) {
            outputFile = new File(outputDirectoryPath, GoEnvironmentUtil.getBinaryFileNameForPath(configurationName));
            try {
                if (!outputFile.exists() && !outputFile.createNewFile()) {
                    throw new ExecutionException("Cannot create output file " + outputFile.getAbsolutePath());
                }
            } catch (IOException e) {
                throw new ExecutionException("Cannot create output file " + outputFile.getAbsolutePath());
            }
        } else {
            throw new ExecutionException("Cannot create output file in " + outputDirectory.getAbsolutePath());
        }
    }
    if (!prepareFile(outputFile)) {
        throw new ExecutionException("Cannot make temporary file executable " + outputFile.getAbsolutePath());
    }
    return outputFile;
}
Also used : RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) IOException(java.io.IOException) ExecutionException(com.intellij.execution.ExecutionException) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with RunnerAndConfigurationSettings

use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-community by JetBrains.

the class RemoveMavenRunConfigurationAction method update.

@Override
public void update(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    RunnerAndConfigurationSettings settings = MavenDataKeys.RUN_CONFIGURATION.getData(e.getDataContext());
    boolean enabled = settings != null && project != null;
    e.getPresentation().setEnabledAndVisible(enabled);
}
Also used : Project(com.intellij.openapi.project.Project) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings)

Example 4 with RunnerAndConfigurationSettings

use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-community by JetBrains.

the class RemoveMavenRunConfigurationAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    RunnerAndConfigurationSettings settings = MavenDataKeys.RUN_CONFIGURATION.getData(e.getDataContext());
    assert settings != null && project != null;
    int res = Messages.showYesNoDialog(project, "Delete \"" + settings.getName() + "\"?", "Confirmation", Messages.getQuestionIcon());
    if (res == Messages.YES) {
        ((RunManagerEx) RunManager.getInstance(project)).removeConfiguration(settings);
    }
}
Also used : Project(com.intellij.openapi.project.Project) RunManagerEx(com.intellij.execution.RunManagerEx) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings)

Example 5 with RunnerAndConfigurationSettings

use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-community by JetBrains.

the class ConfigurationsTest method createConfiguration.

private static TestNGConfiguration createConfiguration(final Project project) {
    final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
    final RunnerAndConfigurationSettings settings = manager.createRunConfiguration("testt", TestNGConfigurationType.getInstance().getConfigurationFactories()[0]);
    manager.addConfiguration(settings, false);
    return (TestNGConfiguration) settings.getConfiguration();
}
Also used : RunManagerEx(com.intellij.execution.RunManagerEx) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings)

Aggregations

RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)104 Project (com.intellij.openapi.project.Project)24 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)16 RunManagerEx (com.intellij.execution.RunManagerEx)14 Nullable (org.jetbrains.annotations.Nullable)14 RunManager (com.intellij.execution.RunManager)12 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 Module (com.intellij.openapi.module.Module)10 NotNull (org.jetbrains.annotations.NotNull)9 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)7 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)7 ExternalSystemRunConfiguration (com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration)7 ExternalSystemTaskExecutionSettings (com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings)6 Executor (com.intellij.execution.Executor)4 RunManagerImpl (com.intellij.execution.impl.RunManagerImpl)4 AbstractExternalSystemTaskConfigurationType (com.intellij.openapi.externalSystem.service.execution.AbstractExternalSystemTaskConfigurationType)4 ExternalSystemNode (com.intellij.openapi.externalSystem.view.ExternalSystemNode)4 RunConfigurationNode (com.intellij.openapi.externalSystem.view.RunConfigurationNode)4 PsiElement (com.intellij.psi.PsiElement)4 ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)3