Search in sources :

Example 11 with BeforeRunTask

use of com.intellij.execution.BeforeRunTask in project google-cloud-intellij by GoogleCloudPlatform.

the class BuildDeploymentSourceType method setBuildBeforeRunTask.

/**
 * Creates a pre-deploy task ({@link BeforeRunTask}) for the given build-system and attaches it to
 * this module deployment source type. Invoked when a new deployment configuration is created.
 *
 * <p>Provides the common functionality for creating the build-system packaging task, delegating
 * build-system specific functions to the concrete sub-types.
 *
 * <p>Only creates a new task if one is not already configured.
 */
@Override
public void setBuildBeforeRunTask(@NotNull RunConfiguration configuration, @NotNull ModuleDeploymentSource source) {
    Module module = source.getModule();
    if (module == null) {
        return;
    }
    setConfiguration(configuration);
    RunManagerEx runManager = RunManagerEx.getInstanceEx(configuration.getProject());
    final Collection<? extends BeforeRunTask> buildTasks = getBuildTasks(runManager, configuration);
    if (!hasBuildTaskForModule(buildTasks, module)) {
        BeforeRunTask buildTask = createBuildTask(module);
        if (buildTask != null) {
            List<BeforeRunTask> tasks = runManager.getBeforeRunTasks(configuration);
            ImmutableList<BeforeRunTask> newTaskList = ImmutableList.<BeforeRunTask>builder().addAll(tasks).add(buildTask).build();
            runManager.setBeforeRunTasks(configuration, newTaskList, true);
        }
    }
}
Also used : BeforeRunTask(com.intellij.execution.BeforeRunTask) RunManagerEx(com.intellij.execution.RunManagerEx) Module(com.intellij.openapi.module.Module)

Example 12 with BeforeRunTask

use of com.intellij.execution.BeforeRunTask in project google-cloud-intellij by GoogleCloudPlatform.

the class BuildDeploymentSourceType method updateBuildBeforeRunOption.

/**
 * Updates the pre-deploy build tasks ({@link BeforeRunTask}) when the deployment source is
 * updated.
 *
 * <p>Similar to {@link BuildDeploymentSourceType#setBuildBeforeRunTask(RunConfiguration,
 * ModuleDeploymentSource)}, but it is invoked when switching between deployment sources in the
 * UI.
 *
 * <p>Only creates a new task if one is not already configured. In following the IntelliJ pattern
 * used for bundled deployment sources, this does NOT remove any existing tasks.
 */
@Override
public void updateBuildBeforeRunOption(@NotNull JComponent runConfigurationEditorComponent, @NotNull Project project, @NotNull ModuleDeploymentSource source, boolean select) {
    final DataContext dataContext = DataManager.getInstance().getDataContext(runConfigurationEditorComponent);
    final ConfigurationSettingsEditorWrapper editor = ConfigurationSettingsEditorWrapper.CONFIGURATION_EDITOR_KEY.getData(dataContext);
    Module module = source.getModule();
    if (module == null || editor == null) {
        return;
    }
    List<BeforeRunTask> buildTasks = editor.getStepsBeforeLaunch();
    if (select && !hasBuildTaskForModule(buildTasks, module)) {
        BeforeRunTask buildTask = createBuildTask(module);
        if (buildTask != null) {
            editor.addBeforeLaunchStep(buildTask);
        }
    }
}
Also used : BeforeRunTask(com.intellij.execution.BeforeRunTask) DataContext(com.intellij.openapi.actionSystem.DataContext) ConfigurationSettingsEditorWrapper(com.intellij.execution.impl.ConfigurationSettingsEditorWrapper) Module(com.intellij.openapi.module.Module)

Example 13 with BeforeRunTask

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

the class DeployFunctionAppAction method actionPerformed.

@Override
protected void actionPerformed(final NodeActionEvent nodeActionEvent) throws AzureCmdException {
    final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
    final RunnerAndConfigurationSettings settings = getRunConfigurationSettings(manager);
    if (RunDialog.editConfiguration(project, settings, message("function.deploy.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) RunManagerEx(com.intellij.execution.RunManagerEx) ArrayList(java.util.ArrayList) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings)

Example 14 with BeforeRunTask

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

the class DeployFunctionAction 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 FunctionDeploymentConfigurationFactory(configType);
    final RunnerAndConfigurationSettings settings = RunConfigurationUtils.getOrCreateRunConfigurationSettings(module, manager, factory);
    if (RunDialog.editConfiguration(project, settings, message("function.deploy.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) FunctionDeploymentConfigurationFactory(com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeploymentConfigurationFactory) ArrayList(java.util.ArrayList) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) FunctionDeploymentConfigurationFactory(com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeploymentConfigurationFactory)

Example 15 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)

Aggregations

BeforeRunTask (com.intellij.execution.BeforeRunTask)37 RunManagerEx (com.intellij.execution.RunManagerEx)24 ArrayList (java.util.ArrayList)22 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)17 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)13 Project (com.intellij.openapi.project.Project)12 MavenBeforeRunTask (org.jetbrains.idea.maven.tasks.MavenBeforeRunTask)6 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)4 BeforeRunTaskProvider (com.intellij.execution.BeforeRunTaskProvider)2 UnknownRunConfiguration (com.intellij.execution.configurations.UnknownRunConfiguration)2 ConfigurationSettingsEditorWrapper (com.intellij.execution.impl.ConfigurationSettingsEditorWrapper)2 DataContext (com.intellij.openapi.actionSystem.DataContext)2 ExternalSystemBeforeRunTask (com.intellij.openapi.externalSystem.service.execution.ExternalSystemBeforeRunTask)2 Module (com.intellij.openapi.module.Module)2 Key (com.intellij.openapi.util.Key)2 BuildArtifactsBeforeRunTask (com.intellij.packaging.impl.run.BuildArtifactsBeforeRunTask)2 FunctionDeploymentConfigurationFactory (com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeploymentConfigurationFactory)2 FunctionRunConfigurationFactory (com.microsoft.azure.toolkit.intellij.function.runner.localrun.FunctionRunConfigurationFactory)2 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)2 LinkedList (java.util.LinkedList)2