Search in sources :

Example 61 with RunnerAndConfigurationSettings

use of com.intellij.execution.RunnerAndConfigurationSettings in project android by JetBrains.

the class HotswapAction method doUpdate.

@Override
protected void doUpdate(@NotNull AnActionEvent e, @NotNull Project project) {
    Presentation presentation = e.getPresentation();
    presentation.setEnabled(false);
    if (!InstantRunSettings.isInstantRunEnabled()) {
        presentation.setText("Apply Changes: Instant Run has been disabled");
        return;
    }
    RunnerAndConfigurationSettings settings = RunManager.getInstance(project).getSelectedConfiguration();
    if (settings == null) {
        presentation.setText("Apply Changes: No run configuration selected");
        return;
    }
    AndroidSessionInfo session = getAndroidSessionInfo(project, settings);
    if (session == null) {
        presentation.setText(String.format("Apply Changes: No active '%1$s' launch", settings.getName()));
        return;
    }
    ProcessHandler processHandler = getActiveProcessHandler(project, settings);
    if (processHandler == null) {
        presentation.setText(String.format("Apply Changes: No active '%1$s' launch", settings.getName()));
        return;
    }
    RunConfiguration configuration = settings.getConfiguration();
    if (!(configuration instanceof ModuleBasedConfiguration)) {
        presentation.setText(String.format("Apply Changes: '%1$s' is not a module based configuration", settings.getName()));
        return;
    }
    Module module = ((ModuleBasedConfiguration) configuration).getConfigurationModule().getModule();
    if (module == null) {
        presentation.setText(String.format("Apply Changes: No module specified in '%1$s'", settings.getName()));
        return;
    }
    if (!(configuration instanceof AndroidRunConfigurationBase)) {
        presentation.setText(String.format("Apply Changes: '%1$s' is not an Android launch configuration", settings.getName()));
        return;
    }
    if (!((AndroidRunConfigurationBase) configuration).supportsInstantRun()) {
        presentation.setText(String.format("Apply Changes: Configuration '%1$s' does not support instant run", settings.getName()));
        return;
    }
    AndroidVersion androidVersion = InstantRunManager.getMinDeviceApiLevel(processHandler);
    if (androidVersion == null) {
        presentation.setText(String.format("Apply Changes: Cannot locate device from '%1$s'", settings.getName()));
        return;
    }
    if (!InstantRunManager.isInstantRunCapableDeviceVersion(androidVersion)) {
        presentation.setText(String.format("Apply Changes: Target device API level (%1$s) too low for Instant Run", androidVersion));
        return;
    }
    InstantRunGradleSupport status = InstantRunGradleUtils.getIrSupportStatus(InstantRunGradleUtils.getAppModel(module), androidVersion);
    if (status != SUPPORTED) {
        String notification = status.getUserNotification();
        if (notification == null) {
            notification = status.toString();
        }
        presentation.setText("Apply Changes: " + notification);
        return;
    }
    presentation.setText("Apply Changes" + getShortcutText());
    presentation.setEnabled(true);
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) AndroidRunConfigurationBase(com.android.tools.idea.run.AndroidRunConfigurationBase) AndroidSessionInfo(com.android.tools.idea.run.AndroidSessionInfo) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ProcessHandler(com.intellij.execution.process.ProcessHandler) InstantRunGradleSupport(com.android.tools.idea.fd.gradle.InstantRunGradleSupport) Presentation(com.intellij.openapi.actionSystem.Presentation) ModuleBasedConfiguration(com.intellij.execution.configurations.ModuleBasedConfiguration) Module(com.intellij.openapi.module.Module) AndroidVersion(com.android.sdklib.AndroidVersion)

Example 62 with RunnerAndConfigurationSettings

use of com.intellij.execution.RunnerAndConfigurationSettings in project android by JetBrains.

the class TestConfigurationTesting method createConfigurationFromPsiElement.

@Nullable
private static RunConfiguration createConfigurationFromPsiElement(@NotNull Project project, @NotNull PsiElement psiElement) {
    ConfigurationContext context = createContext(project, psiElement);
    RunnerAndConfigurationSettings settings = context.getConfiguration();
    if (settings == null) {
        return null;
    }
    RunConfiguration configuration = settings.getConfiguration();
    if (configuration instanceof AndroidTestRunConfiguration || configuration instanceof AndroidJUnitConfiguration) {
        return configuration;
    }
    return null;
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) AndroidTestRunConfiguration(com.android.tools.idea.testartifacts.instrumented.AndroidTestRunConfiguration) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) AndroidTestRunConfiguration(com.android.tools.idea.testartifacts.instrumented.AndroidTestRunConfiguration) AndroidJUnitConfiguration(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfiguration) Nullable(org.jetbrains.annotations.Nullable)

Example 63 with RunnerAndConfigurationSettings

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

the class FlexTestUtils method checkFlashRunConfig.

public static void checkFlashRunConfig(final RunManager runManager, final Module module, final String configName, final String className) {
    final List<RunnerAndConfigurationSettings> settings = runManager.getConfigurationSettingsList(FlashRunConfigurationType.getInstance());
    RunnerAndConfigurationSettings settingsToCheck = null;
    for (RunnerAndConfigurationSettings setting : settings) {
        if (configName.equals(setting.getName())) {
            settingsToCheck = setting;
            break;
        }
    }
    Assert.assertNotNull("Run configuration not found: " + configName, settingsToCheck);
    final FlashRunnerParameters params = ((FlashRunConfiguration) settingsToCheck.getConfiguration()).getRunnerParameters();
    Assert.assertEquals(className, params.getOverriddenMainClass());
    Assert.assertEquals(FlexBuildConfigurationManager.getInstance(module).getActiveConfiguration().getName(), params.getBCName());
}
Also used : FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) FlashRunnerParameters(com.intellij.lang.javascript.flex.run.FlashRunnerParameters)

Example 64 with RunnerAndConfigurationSettings

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

the class FlexTestUtils method createFlexUnitRunConfig.

public static void createFlexUnitRunConfig(final RunManager runManager, final String configName, final Module module, final FlexUnitRunnerParameters.Scope scope, final String packageName, final String className, final String methodName, boolean generatedName) {
    final RunnerAndConfigurationSettings settings = runManager.createRunConfiguration(configName, FlexUnitRunConfigurationType.getFactory());
    runManager.addConfiguration(settings, false);
    final FlexUnitRunnerParameters params = ((FlexUnitRunConfiguration) settings.getConfiguration()).getRunnerParameters();
    params.setModuleName(module.getName());
    params.setBCName(FlexBuildConfigurationManager.getInstance(module).getActiveConfiguration().getName());
    params.setScope(scope);
    params.setPackageName(packageName);
    params.setClassName(className);
    params.setMethodName(methodName);
    if (generatedName) {
        ((FlexUnitRunConfiguration) settings.getConfiguration()).setGeneratedName();
    }
}
Also used : FlexUnitRunnerParameters(com.intellij.lang.javascript.flex.flexunit.FlexUnitRunnerParameters) FlexUnitRunConfiguration(com.intellij.lang.javascript.flex.flexunit.FlexUnitRunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings)

Example 65 with RunnerAndConfigurationSettings

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

the class CfmlRunConfigurationTest method generateNonDefaultRunConfiguration.

public void generateNonDefaultRunConfiguration() throws IOException, ConfigurationException {
    final CfmlRunConfiguration defaultCfmlRunConfiguration = getDefaultCfmlRunConfiguration();
    final CfmlRunConfiguration clonedConfiguration = (CfmlRunConfiguration) defaultCfmlRunConfiguration.clone();
    clonedConfiguration.getRunnerParameters().setUrl("http://4.4.4.4/src/index.cfm");
    final RunnerAndConfigurationSettings runnerAndConfigurationSettings = RunManager.getInstance(getProject()).createConfiguration(clonedConfiguration, CfmlRunConfigurationType.getInstance().getConfigurationFactories()[0]);
    RunManager.getInstance(getProject()).addConfiguration(runnerAndConfigurationSettings, false);
}
Also used : CfmlRunConfiguration(com.intellij.coldFusion.UI.runner.CfmlRunConfiguration) 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