Search in sources :

Example 41 with RunConfiguration

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

the class AntConfigurationImpl method convertToBeforeRunTask.

private static void convertToBeforeRunTask(Project project, String buildFileUrl, String targetName, String configType, String configName) {
    if (buildFileUrl == null || targetName == null || configType == null) {
        return;
    }
    final RunManagerImpl runManager = (RunManagerImpl) RunManagerEx.getInstanceEx(project);
    final ConfigurationType type = runManager.getConfigurationType(configType);
    if (type == null) {
        return;
    }
    if (configName != null) {
        for (RunConfiguration configuration : runManager.getConfigurationsList(type)) {
            if (configName.equals(configuration.getName())) {
                final List<AntBeforeRunTask> tasks = runManager.getBeforeRunTasks(configuration, AntBeforeRunTaskProvider.ID);
                if (!tasks.isEmpty()) {
                    //This is legacy code, we had only one task that time
                    AntBeforeRunTask task = tasks.get(0);
                    task.setEnabled(true);
                    task.setTargetName(targetName);
                    task.setAntFileUrl(buildFileUrl);
                }
            }
        }
    } else {
        for (ConfigurationFactory factory : type.getConfigurationFactories()) {
            final RunConfiguration template = runManager.getConfigurationTemplate(factory).getConfiguration();
            final List<AntBeforeRunTask> tasks = runManager.getBeforeRunTasks(template, AntBeforeRunTaskProvider.ID);
            if (!tasks.isEmpty()) {
                //This is legacy code, we had only one task that time
                AntBeforeRunTask task = tasks.get(0);
                task.setEnabled(true);
                task.setTargetName(targetName);
                task.setAntFileUrl(buildFileUrl);
            }
        }
    }
}
Also used : ConfigurationType(com.intellij.execution.configurations.ConfigurationType) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) RunManagerImpl(com.intellij.execution.impl.RunManagerImpl)

Example 42 with RunConfiguration

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

the class TestsUIUtil method getData.

@Nullable
public static Object getData(final AbstractTestProxy testProxy, final String dataId, final TestFrameworkRunningModel model) {
    final TestConsoleProperties properties = model.getProperties();
    final Project project = properties.getProject();
    if (testProxy == null)
        return null;
    if (AbstractTestProxy.DATA_KEY.is(dataId))
        return testProxy;
    if (CommonDataKeys.NAVIGATABLE.is(dataId))
        return getOpenFileDescriptor(testProxy, model);
    if (CommonDataKeys.PSI_ELEMENT.is(dataId)) {
        final Location location = testProxy.getLocation(project, properties.getScope());
        if (location != null) {
            final PsiElement element = location.getPsiElement();
            return element.isValid() ? element : null;
        } else {
            return null;
        }
    }
    if (Location.DATA_KEY.is(dataId))
        return testProxy.getLocation(project, properties.getScope());
    if (RunConfiguration.DATA_KEY.is(dataId)) {
        final RunProfile configuration = properties.getConfiguration();
        if (configuration instanceof RunConfiguration) {
            return configuration;
        }
    }
    return null;
}
Also used : Project(com.intellij.openapi.project.Project) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) RunProfile(com.intellij.execution.configurations.RunProfile) PsiElement(com.intellij.psi.PsiElement) Location(com.intellij.execution.Location) Nullable(org.jetbrains.annotations.Nullable)

Example 43 with RunConfiguration

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

the class TemplateModuleBuilder method fixModuleName.

private void fixModuleName(Module module) {
    List<RunConfiguration> configurations = RunManager.getInstance(module.getProject()).getAllConfigurationsList();
    for (RunConfiguration configuration : configurations) {
        if (configuration instanceof ModuleBasedConfiguration) {
            ((ModuleBasedConfiguration) configuration).getConfigurationModule().setModule(module);
        }
    }
    ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
    for (WizardInputField field : myAdditionalFields) {
        ProjectTemplateParameterFactory factory = WizardInputField.getFactoryById(field.getId());
        factory.applyResult(field.getValue(), model);
    }
    model.commit();
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ModuleBasedConfiguration(com.intellij.execution.configurations.ModuleBasedConfiguration)

Example 44 with RunConfiguration

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

the class RunConfigurationRefactoringElementListenerProvider method getListener.

@Override
public RefactoringElementListener getListener(final PsiElement element) {
    RefactoringElementListenerComposite composite = null;
    final List<RunConfiguration> configurations = RunManager.getInstance(element.getProject()).getAllConfigurationsList();
    for (RunConfiguration configuration : configurations) {
        if (configuration instanceof RefactoringListenerProvider) {
            // todo: perhaps better way to handle listeners?
            RefactoringElementListener listener;
            try {
                listener = ((RefactoringListenerProvider) configuration).getRefactoringElementListener(element);
            } catch (Exception e) {
                LOG.error(e);
                continue;
            }
            if (listener != null) {
                if (configuration instanceof LocatableConfiguration) {
                    listener = new NameGeneratingListenerDecorator((LocatableConfiguration) configuration, listener);
                }
                if (composite == null) {
                    composite = new RefactoringElementListenerComposite();
                }
                composite.addListener(listener);
            }
        }
    }
    return composite;
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) LocatableConfiguration(com.intellij.execution.configurations.LocatableConfiguration) RefactoringElementListener(com.intellij.refactoring.listeners.RefactoringElementListener) RefactoringElementListenerComposite(com.intellij.refactoring.listeners.RefactoringElementListenerComposite) RefactoringListenerProvider(com.intellij.execution.configurations.RefactoringListenerProvider)

Example 45 with RunConfiguration

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

the class RunDialog method editConfiguration.

public static boolean editConfiguration(final Project project, final RunnerAndConfigurationSettings configuration, final String title, @Nullable final Executor executor) {
    final SingleConfigurationConfigurable<RunConfiguration> configurable = SingleConfigurationConfigurable.editSettings(configuration, executor);
    final SingleConfigurableEditor dialog = new SingleConfigurableEditor(project, configurable, IdeModalityType.IDE) {

        {
            if (executor != null)
                setOKButtonText(executor.getActionName());
            if (executor != null)
                setOKButtonIcon(executor.getIcon());
        }
    };
    dialog.setTitle(title);
    return dialog.showAndGet();
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) SingleConfigurableEditor(com.intellij.openapi.options.ex.SingleConfigurableEditor)

Aggregations

RunConfiguration (com.intellij.execution.configurations.RunConfiguration)59 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)16 Module (com.intellij.openapi.module.Module)13 Nullable (org.jetbrains.annotations.Nullable)12 Project (com.intellij.openapi.project.Project)10 PsiElement (com.intellij.psi.PsiElement)7 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)6 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)6 Pair (com.intellij.openapi.util.Pair)6 NotNull (org.jetbrains.annotations.NotNull)6 AndroidTestRunConfiguration (com.android.tools.idea.testartifacts.instrumented.AndroidTestRunConfiguration)5 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)5 BeforeRunTask (com.intellij.execution.BeforeRunTask)4 FlashRunConfiguration (com.intellij.lang.javascript.flex.run.FlashRunConfiguration)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 ArrayList (java.util.ArrayList)4 AndroidJUnitConfiguration (com.android.tools.idea.testartifacts.junit.AndroidJUnitConfiguration)3 BeforeRunTaskProvider (com.intellij.execution.BeforeRunTaskProvider)3 Location (com.intellij.execution.Location)3 RunManager (com.intellij.execution.RunManager)3