Search in sources :

Example 31 with BeforeRunTask

use of com.intellij.execution.BeforeRunTask in project azure-tools-for-java by Microsoft.

the class RunFunctionAction method runConfiguration.

private void runConfiguration(Module module) {
    // todo: investigate when will module be null
    if (module == null) {
        return;
    }
    final Project project = module.getProject();
    final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
    final ConfigurationFactory factory = new FunctionRunConfigurationFactory(configType);
    final RunnerAndConfigurationSettings settings = RunConfigurationUtils.getOrCreateRunConfigurationSettings(module, manager, factory);
    if (RunDialog.editConfiguration(project, settings, message("function.run.configuration.title"), DefaultRunExecutor.getRunExecutorInstance())) {
        final List<BeforeRunTask> tasks = new ArrayList<>(manager.getBeforeRunTasks(settings.getConfiguration()));
        manager.addConfiguration(settings, false, tasks, false);
        manager.setSelectedConfiguration(settings);
        ProgramRunnerUtil.executeConfiguration(project, settings, DefaultRunExecutor.getRunExecutorInstance());
    }
}
Also used : BeforeRunTask(com.intellij.execution.BeforeRunTask) Project(com.intellij.openapi.project.Project) RunManagerEx(com.intellij.execution.RunManagerEx) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) FunctionRunConfigurationFactory(com.microsoft.azure.toolkit.intellij.function.runner.localrun.FunctionRunConfigurationFactory) ArrayList(java.util.ArrayList) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) FunctionRunConfigurationFactory(com.microsoft.azure.toolkit.intellij.function.runner.localrun.FunctionRunConfigurationFactory)

Example 32 with BeforeRunTask

use of com.intellij.execution.BeforeRunTask in project azure-tools-for-java by Microsoft.

the class BeforeRunTaskUtils method addTask.

private static synchronized <T extends BeforeRunTask<?>> void addTask(@Nonnull ConfigurationSettingsEditorWrapper editor, List<? extends T> tasks, T task, RunConfiguration config) {
    if (tasks.isEmpty()) {
        task.setEnabled(true);
        final RunManagerEx manager = RunManagerEx.getInstanceEx(config.getProject());
        final List<BeforeRunTask> tasksFromConfig = new ArrayList<>(manager.getBeforeRunTasks(config));
        // need to add the before run task back to runConfiguration since for the create scenario:
        // the before run task editor will reset tasks in runConfiguration, that's the reason why
        // here we need to add the task here
        tasksFromConfig.add(task);
        manager.setBeforeRunTasks(config, tasksFromConfig);
        editor.addBeforeLaunchStep(task);
    } else {
        for (final T t : tasks) {
            t.setEnabled(true);
        }
    }
}
Also used : BuildArtifactsBeforeRunTask(com.intellij.packaging.impl.run.BuildArtifactsBeforeRunTask) BeforeRunTask(com.intellij.execution.BeforeRunTask) MavenBeforeRunTask(org.jetbrains.idea.maven.tasks.MavenBeforeRunTask) ExternalSystemBeforeRunTask(com.intellij.openapi.externalSystem.service.execution.ExternalSystemBeforeRunTask) RunManagerEx(com.intellij.execution.RunManagerEx) ArrayList(java.util.ArrayList)

Example 33 with BeforeRunTask

use of com.intellij.execution.BeforeRunTask in project azure-tools-for-java by Microsoft.

the class MavenRunTaskUtil method addMavenPackageBeforeRunTask.

/**
 * Add Maven package goal into the run configuration's before run task.
 */
public static void addMavenPackageBeforeRunTask(RunConfiguration runConfiguration) {
    final RunManagerEx manager = RunManagerEx.getInstanceEx(runConfiguration.getProject());
    if (isMavenProject(runConfiguration.getProject())) {
        List<BeforeRunTask> tasks = new ArrayList<>(manager.getBeforeRunTasks(runConfiguration));
        if (MavenRunTaskUtil.shouldAddMavenPackageTask(tasks, runConfiguration.getProject())) {
            MavenBeforeRunTask task = new MavenBeforeRunTask();
            task.setEnabled(true);
            task.setProjectPath(runConfiguration.getProject().getBasePath() + File.separator + MavenConstants.POM_XML);
            task.setGoal(MAVEN_TASK_PACKAGE);
            tasks.add(task);
            manager.setBeforeRunTasks(runConfiguration, tasks);
        }
    }
}
Also used : MavenBeforeRunTask(org.jetbrains.idea.maven.tasks.MavenBeforeRunTask) BeforeRunTask(com.intellij.execution.BeforeRunTask) RunManagerEx(com.intellij.execution.RunManagerEx) ArrayList(java.util.ArrayList) MavenBeforeRunTask(org.jetbrains.idea.maven.tasks.MavenBeforeRunTask)

Example 34 with BeforeRunTask

use of com.intellij.execution.BeforeRunTask in project azure-tools-for-java by Microsoft.

the class WebAppOnLinuxAction method runConfiguration.

@SuppressWarnings({ "deprecation", "Duplicates" })
private void runConfiguration(Module module) {
    Project project = module.getProject();
    final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
    final ConfigurationFactory factory = configType.getWebAppOnLinuxDeployConfigurationFactory();
    RunnerAndConfigurationSettings settings = manager.findConfigurationByName(String.format("%s: %s:%s", factory.getName(), project.getName(), module.getName()));
    if (settings == null) {
        settings = manager.createConfiguration(String.format("%s: %s:%s", factory.getName(), project.getName(), module.getName()), factory);
    }
    if (RunDialog.editConfiguration(project, settings, DIALOG_TITLE, DefaultRunExecutor.getRunExecutorInstance())) {
        List<BeforeRunTask> tasks = new ArrayList<>(manager.getBeforeRunTasks(settings.getConfiguration()));
        manager.addConfiguration(settings, false, tasks, false);
        manager.setSelectedConfiguration(settings);
        ProgramRunnerUtil.executeConfiguration(project, settings, DefaultRunExecutor.getRunExecutorInstance());
    }
}
Also used : BeforeRunTask(com.intellij.execution.BeforeRunTask) Project(com.intellij.openapi.project.Project) RunManagerEx(com.intellij.execution.RunManagerEx) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) ArrayList(java.util.ArrayList) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings)

Example 35 with BeforeRunTask

use of com.intellij.execution.BeforeRunTask in project azure-tools-for-java by Microsoft.

the class RunOnDockerHostAction method runConfiguration.

@SuppressWarnings({ "deprecation", "Duplicates" })
private void runConfiguration(Module module) {
    Project project = module.getProject();
    final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
    final ConfigurationFactory factory = configType.getDockerHostRunConfigurationFactory();
    RunnerAndConfigurationSettings settings = manager.findConfigurationByName(String.format("%s: %s:%s", factory.getName(), project.getName(), module.getName()));
    if (settings == null) {
        settings = manager.createConfiguration(String.format("%s: %s:%s", factory.getName(), project.getName(), module.getName()), factory);
    }
    if (RunDialog.editConfiguration(project, settings, DIALOG_TITLE, DefaultRunExecutor.getRunExecutorInstance())) {
        List<BeforeRunTask> tasks = new ArrayList<>(manager.getBeforeRunTasks(settings.getConfiguration()));
        manager.addConfiguration(settings, false, tasks, false);
        manager.setSelectedConfiguration(settings);
        ProgramRunnerUtil.executeConfiguration(project, settings, DefaultRunExecutor.getRunExecutorInstance());
    }
}
Also used : BeforeRunTask(com.intellij.execution.BeforeRunTask) Project(com.intellij.openapi.project.Project) RunManagerEx(com.intellij.execution.RunManagerEx) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) ArrayList(java.util.ArrayList) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings)

Aggregations

BeforeRunTask (com.intellij.execution.BeforeRunTask)44 RunManagerEx (com.intellij.execution.RunManagerEx)25 ArrayList (java.util.ArrayList)23 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)18 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)13 Project (com.intellij.openapi.project.Project)12 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)7 MavenBeforeRunTask (org.jetbrains.idea.maven.tasks.MavenBeforeRunTask)6 BeforeRunTaskProvider (com.intellij.execution.BeforeRunTaskProvider)4 UnknownRunConfiguration (com.intellij.execution.configurations.UnknownRunConfiguration)4 ConfigurationSettingsEditorWrapper (com.intellij.execution.impl.ConfigurationSettingsEditorWrapper)3 DataContext (com.intellij.openapi.actionSystem.DataContext)3 RunConfigurationBeforeRunProvider (com.intellij.execution.impl.RunConfigurationBeforeRunProvider)2 ExternalSystemBeforeRunTask (com.intellij.openapi.externalSystem.service.execution.ExternalSystemBeforeRunTask)2 Module (com.intellij.openapi.module.Module)2 JBPopupFactory (com.intellij.openapi.ui.popup.JBPopupFactory)2 ListPopup (com.intellij.openapi.ui.popup.ListPopup)2 Key (com.intellij.openapi.util.Key)2 AbstractArtifactsBeforeRunTask (com.intellij.packaging.impl.run.AbstractArtifactsBeforeRunTask)2 BuildArtifactsBeforeRunTask (com.intellij.packaging.impl.run.BuildArtifactsBeforeRunTask)2