Search in sources :

Example 81 with RunnerAndConfigurationSettings

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

the class ConfigurationSettingsEditorWrapper method doApply.

private void doApply(final RunnerAndConfigurationSettings settings) {
    final RunConfiguration runConfiguration = settings.getConfiguration();
    final RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(runConfiguration.getProject());
    runManager.setBeforeRunTasks(runConfiguration, myBeforeRunStepsPanel.getTasks(true), false);
    RunnerAndConfigurationSettings runManagerSettings = runManager.getSettings(runConfiguration);
    if (runManagerSettings != null) {
        runManagerSettings.setEditBeforeRun(myBeforeRunStepsPanel.needEditBeforeRun());
        runManagerSettings.setActivateToolWindowBeforeRun(myBeforeRunStepsPanel.needActivateToolWindowBeforeRun());
    } else {
        settings.setEditBeforeRun(myBeforeRunStepsPanel.needEditBeforeRun());
        settings.setActivateToolWindowBeforeRun(myBeforeRunStepsPanel.needActivateToolWindowBeforeRun());
    }
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings)

Example 82 with RunnerAndConfigurationSettings

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

the class CompoundRunConfigurationSettingsEditor method canBeAdded.

private boolean canBeAdded(@NotNull RunConfiguration candidate, @NotNull final CompoundRunConfiguration root) {
    if (candidate.getType() == root.getType() && candidate.getName().equals(root.getName()))
        return false;
    List<BeforeRunTask> tasks = myRunManager.getBeforeRunTasks(candidate);
    for (BeforeRunTask task : tasks) {
        if (task instanceof RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask) {
            RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask runTask = (RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask) task;
            RunnerAndConfigurationSettings settings = runTask.getSettings();
            if (settings != null) {
                if (!canBeAdded(settings.getConfiguration(), root))
                    return false;
            }
        }
    }
    if (candidate instanceof CompoundRunConfiguration) {
        Set<RunConfiguration> set = ((CompoundRunConfiguration) candidate).getSetToRun();
        for (RunConfiguration configuration : set) {
            if (!canBeAdded(configuration, root))
                return false;
        }
    }
    return true;
}
Also used : BeforeRunTask(com.intellij.execution.BeforeRunTask) RunConfigurationBeforeRunProvider(com.intellij.execution.impl.RunConfigurationBeforeRunProvider) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings)

Example 83 with RunnerAndConfigurationSettings

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

the class BaseRunConfigurationAction method canBePerformed.

@Override
public boolean canBePerformed(DataContext dataContext) {
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    if (project != null && DumbService.isDumb(project)) {
        return false;
    }
    final ConfigurationContext context = ConfigurationContext.getFromContext(dataContext);
    final RunnerAndConfigurationSettings existing = context.findExisting();
    if (existing == null) {
        final List<ConfigurationFromContext> fromContext = getConfigurationsFromContext(context);
        return fromContext.size() <= 1;
    }
    return true;
}
Also used : Project(com.intellij.openapi.project.Project) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings)

Example 84 with RunnerAndConfigurationSettings

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

the class BaseRunConfigurationAction method perform.

private void perform(final ConfigurationFromContext configurationFromContext, final ConfigurationContext context) {
    RunnerAndConfigurationSettings configurationSettings = configurationFromContext.getConfigurationSettings();
    context.setConfiguration(configurationSettings);
    configurationFromContext.onFirstRun(context, () -> perform(context));
}
Also used : RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings)

Example 85 with RunnerAndConfigurationSettings

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

the class BaseRunConfigurationAction method update.

@Override
public void update(final AnActionEvent event) {
    final ConfigurationContext context = ConfigurationContext.getFromContext(event.getDataContext());
    final Presentation presentation = event.getPresentation();
    final RunnerAndConfigurationSettings existing = context.findExisting();
    RunnerAndConfigurationSettings configuration = existing;
    if (configuration == null) {
        configuration = context.getConfiguration();
    }
    if (configuration == null) {
        presentation.setEnabled(false);
        presentation.setVisible(false);
    } else {
        presentation.setEnabled(true);
        presentation.setVisible(true);
        final List<ConfigurationFromContext> fromContext = getConfigurationsFromContext(context);
        if (existing == null && !fromContext.isEmpty()) {
            //todo[nik,anna] it's dirty fix. Otherwise wrong configuration will be returned from context.getConfiguration()
            context.setConfiguration(fromContext.get(0).getConfigurationSettings());
        }
        final String name = suggestRunActionName((LocatableConfiguration) configuration.getConfiguration());
        updatePresentation(presentation, existing != null || fromContext.size() <= 1 ? name : "", context);
    }
}
Also used : 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