use of com.android.tools.idea.run.TargetSelectionMode 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.android.tools.idea.run.TargetSelectionMode in project android by JetBrains.
the class AndroidTestConfigurationProducer method setupConfiguration.
private boolean setupConfiguration(AndroidTestRunConfiguration configuration, PsiElement element, ConfigurationContext context, Ref<PsiElement> sourceElement) {
final Module module = AndroidUtils.getAndroidModule(context);
if (module == null) {
return false;
}
sourceElement.set(element);
setupConfigurationModule(context, configuration);
final TargetSelectionMode targetSelectionMode = AndroidUtils.getDefaultTargetSelectionMode(module, AndroidTestRunConfigurationType.getInstance(), AndroidRunConfigurationType.getInstance());
if (targetSelectionMode != null) {
configuration.getDeployTargetContext().setTargetSelectionMode(targetSelectionMode);
}
return true;
}
Aggregations