Search in sources :

Example 11 with RunManager

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

the class AndroidUtils method getDefaultTargetSelectionMode.

@Nullable
public static TargetSelectionMode getDefaultTargetSelectionMode(@NotNull Module module, @NotNull ConfigurationType type, @NonNls ConfigurationType alternativeType) {
    final RunManager runManager = RunManager.getInstance(module.getProject());
    List<RunConfiguration> configurations = runManager.getConfigurationsList(type);
    TargetSelectionMode alternative = null;
    if (configurations.size() > 0) {
        for (RunConfiguration configuration : configurations) {
            if (configuration instanceof AndroidRunConfigurationBase) {
                final AndroidRunConfigurationBase runConfig = (AndroidRunConfigurationBase) configuration;
                final TargetSelectionMode targetMode = runConfig.getDeployTargetContext().getTargetSelectionMode();
                //noinspection IfStatementWithIdenticalBranches - branches are only identical for final iteration of outer loop
                if (runConfig.getConfigurationModule() == module) {
                    return targetMode;
                } else {
                    alternative = targetMode;
                }
            }
        }
    }
    if (alternative != null) {
        return alternative;
    }
    configurations = runManager.getConfigurationsList(alternativeType);
    if (configurations.size() > 0) {
        for (RunConfiguration configuration : configurations) {
            if (configuration instanceof AndroidRunConfigurationBase) {
                return ((AndroidRunConfigurationBase) configuration).getDeployTargetContext().getTargetSelectionMode();
            }
        }
    }
    return null;
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) AndroidRunConfigurationBase(com.android.tools.idea.run.AndroidRunConfigurationBase) TargetSelectionMode(com.android.tools.idea.run.TargetSelectionMode) RunManager(com.intellij.execution.RunManager) Nullable(org.jetbrains.annotations.Nullable)

Example 12 with RunManager

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

the class AndroidRunConfigurations method addRunConfiguration.

public void addRunConfiguration(@NotNull AndroidFacet facet, @Nullable String activityClass, @Nullable TargetSelectionMode targetSelectionMode, @Nullable String preferredAvdName) {
    Module module = facet.getModule();
    RunManager runManager = RunManager.getInstance(module.getProject());
    AndroidRunConfigurationType runConfigurationType = AndroidRunConfigurationType.getInstance();
    RunnerAndConfigurationSettings settings = runManager.createRunConfiguration(module.getName(), runConfigurationType.getFactory());
    AndroidRunConfiguration configuration = (AndroidRunConfiguration) settings.getConfiguration();
    configuration.setModule(module);
    if (activityClass != null) {
        configuration.setLaunchActivity(activityClass);
    } else if (facet.getProjectType() == PROJECT_TYPE_INSTANTAPP) {
        configuration.setLaunchUrl(getDefaultRunConfigurationUrl(facet));
    } else if (isWatchFaceApp(facet)) {
        // In case of a watch face app, there is only a service and no default activity that can be launched
        // Eventually, we'd need to support launching a service, but currently you cannot launch a watch face service as well.
        // See https://code.google.com/p/android/issues/detail?id=151353
        configuration.MODE = DO_NOTHING;
    } else {
        configuration.MODE = LAUNCH_DEFAULT_ACTIVITY;
    }
    if (targetSelectionMode != null) {
        configuration.getDeployTargetContext().setTargetSelectionMode(targetSelectionMode);
    }
    if (preferredAvdName != null) {
        configuration.PREFERRED_AVD = preferredAvdName;
    }
    runManager.addConfiguration(settings, false);
    runManager.setSelectedConfiguration(settings);
}
Also used : AndroidRunConfigurationType(com.android.tools.idea.run.AndroidRunConfigurationType) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) AndroidRunConfiguration(com.android.tools.idea.run.AndroidRunConfiguration) Module(com.intellij.openapi.module.Module) RunManager(com.intellij.execution.RunManager)

Example 13 with RunManager

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

the class FlexModuleBuilder method createRunConfiguration.

public static void createRunConfiguration(final Module module, final FlexBuildConfiguration bc) {
    final RunManager runManager = RunManagerEx.getInstance(module.getProject());
    final List<RunConfiguration> existingConfigurations = runManager.getConfigurationsList(FlashRunConfigurationType.getInstance());
    for (RunConfiguration configuration : existingConfigurations) {
        final FlashRunnerParameters parameters = ((FlashRunConfiguration) configuration).getRunnerParameters();
        if (module.getName().equals(parameters.getModuleName()) && bc.getName().equals(parameters.getBCName())) {
            //already exists
            return;
        }
    }
    final RunnerAndConfigurationSettings settings = runManager.createConfiguration("", FlashRunConfigurationType.getFactory());
    final FlashRunConfiguration runConfiguration = (FlashRunConfiguration) settings.getConfiguration();
    final FlashRunnerParameters params = runConfiguration.getRunnerParameters();
    params.setModuleName(module.getName());
    params.setBCName(bc.getName());
    if (bc.getNature().isMobilePlatform()) {
        if (bc.getAndroidPackagingOptions().isEnabled()) {
            params.setAppDescriptorForEmulator(FlashRunnerParameters.AppDescriptorForEmulator.Android);
        } else if (bc.getIosPackagingOptions().isEnabled()) {
            params.setAppDescriptorForEmulator(FlashRunnerParameters.AppDescriptorForEmulator.IOS);
        }
    }
    settings.setName(params.suggestUniqueName(existingConfigurations));
    settings.setTemporary(false);
    runManager.addConfiguration(settings, false);
    runManager.setSelectedConfiguration(settings);
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) RunManager(com.intellij.execution.RunManager) FlashRunnerParameters(com.intellij.lang.javascript.flex.run.FlashRunnerParameters)

Example 14 with RunManager

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

the class FlexRenameTest method testConfigUpdatedOnPackageRename.

@JSTestOptions({ JSTestOption.WithFlexFacet })
public void testConfigUpdatedOnPackageRename() throws Exception {
    FlexTestUtils.modifyBuildConfiguration(myModule, bc -> bc.setMainClass("foo.bar.SomeClass"));
    final RunManager runManager = RunManager.getInstance(myProject);
    FlexTestUtils.createFlexUnitRunConfig(runManager, "SomeClass.testSomething()", myModule, FlexUnitRunnerParameters.Scope.Method, "", "foo.bar.SomeClass", "testSomething", true);
    FlexTestUtils.createFlexUnitRunConfig(runManager, "SomeClass", myModule, FlexUnitRunnerParameters.Scope.Class, "", "foo.bar.SomeClass", "", true);
    FlexTestUtils.createFlexUnitRunConfig(runManager, "foo.bar", myModule, FlexUnitRunnerParameters.Scope.Package, "foo.bar", "", "", true);
    FlexTestUtils.createFlashRunConfig(runManager, myModule, "SomeClass", "foo.bar.SomeClass", true);
    doTest("renamed", "as");
    assertEquals("foo.renamed.SomeClass", FlexBuildConfigurationManager.getInstance(myModule).getActiveConfiguration().getMainClass());
    FlexTestUtils.checkFlexUnitRunConfig(runManager, myModule, "SomeClass.testSomething()", "", "foo.renamed.SomeClass", "testSomething");
    FlexTestUtils.checkFlexUnitRunConfig(runManager, myModule, "SomeClass", "", "foo.renamed.SomeClass", "");
    FlexTestUtils.checkFlexUnitRunConfig(runManager, myModule, "foo.renamed", "foo.renamed", "", "");
    FlexTestUtils.checkFlashRunConfig(runManager, myModule, "SomeClass", "foo.renamed.SomeClass");
}
Also used : RunManager(com.intellij.execution.RunManager)

Example 15 with RunManager

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

the class FlexRenameTest method testRunConfigUpdatedOnMethodRename.

@JSTestOptions({ JSTestOption.WithFlexFacet })
public void testRunConfigUpdatedOnMethodRename() throws Exception {
    final RunManager runManager = RunManager.getInstance(myProject);
    FlexTestUtils.createFlexUnitRunConfig(runManager, "SomeTest.testSomething()", myModule, FlexUnitRunnerParameters.Scope.Method, "", "SomeTest", "testSomething", true);
    doTest("testAnotherThing", "as");
    FlexTestUtils.checkFlexUnitRunConfig(runManager, myModule, "SomeTest.testAnotherThing()", "", "SomeTest", "testAnotherThing");
}
Also used : RunManager(com.intellij.execution.RunManager)

Aggregations

RunManager (com.intellij.execution.RunManager)18 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)11 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)3 Nullable (org.jetbrains.annotations.Nullable)3 JSTestOptions (com.intellij.lang.javascript.JSTestOptions)2 Project (com.intellij.openapi.project.Project)2 NotNull (org.jetbrains.annotations.NotNull)2 AndroidRunConfiguration (com.android.tools.idea.run.AndroidRunConfiguration)1 AndroidRunConfigurationBase (com.android.tools.idea.run.AndroidRunConfigurationBase)1 AndroidRunConfigurationType (com.android.tools.idea.run.AndroidRunConfigurationType)1 TargetSelectionMode (com.android.tools.idea.run.TargetSelectionMode)1 PhoneGapConfigurationType (com.github.masahirosuzuka.PhoneGapIntelliJPlugin.runner.PhoneGapConfigurationType)1 PhoneGapRunConfiguration (com.github.masahirosuzuka.PhoneGapIntelliJPlugin.runner.PhoneGapRunConfiguration)1 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)1 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)1 WebBrowser (com.intellij.ide.browsers.WebBrowser)1 UsageDescriptor (com.intellij.internal.statistic.beans.UsageDescriptor)1 JavaScriptDebugConfiguration (com.intellij.javascript.debugger.execution.JavaScriptDebugConfiguration)1 PreferableRunConfiguration (com.intellij.javascript.testFramework.PreferableRunConfiguration)1 FlashRunConfiguration (com.intellij.lang.javascript.flex.run.FlashRunConfiguration)1