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;
}
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);
}
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);
}
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");
}
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");
}
Aggregations