use of com.intellij.execution.configurations.RunConfiguration in project intellij-plugins by JetBrains.
the class FlashRunConfigurationProducer method findSuitableRunConfig.
@Nullable
private static RunConfiguration findSuitableRunConfig(final Module module, final String fqn, final List<RunConfiguration> existing) {
final FlexBuildConfigurationManager manager = FlexBuildConfigurationManager.getInstance(module);
RunConfiguration basedOnBC = null;
RunConfiguration basedOnMainClass = null;
RunConfiguration basedOnMainClassAndActiveBC = null;
for (final RunConfiguration runConfig : existing) {
final FlashRunnerParameters params = ((FlashRunConfiguration) runConfig).getRunnerParameters();
if (module.getName().equals(params.getModuleName())) {
final FlexBuildConfiguration bc = manager.findConfigurationByName(params.getBCName());
if (bc == null)
continue;
if (params.isOverrideMainClass()) {
if (fqn.equals(params.getOverriddenMainClass())) {
if (manager.getActiveConfiguration() == bc) {
basedOnMainClassAndActiveBC = runConfig;
}
basedOnMainClass = runConfig;
}
} else {
if (bc.getOutputType() == OutputType.Application && fqn.equals(bc.getMainClass())) {
if (manager.getActiveConfiguration() == bc) {
// the best choice
return runConfig;
}
basedOnBC = runConfig;
}
}
}
}
// forth - based on overridden main class and any bc
return basedOnBC != null ? basedOnBC : basedOnMainClassAndActiveBC != null ? basedOnMainClassAndActiveBC : basedOnMainClass;
}
use of com.intellij.execution.configurations.RunConfiguration in project intellij-plugins by JetBrains.
the class FlashRunConfigurationProducer method isConfigurationFromContext.
public boolean isConfigurationFromContext(final FlashRunConfiguration configuration, final ConfigurationContext context) {
final Module module = context.getModule();
if (module == null || ModuleType.get(module) != FlexModuleType.getInstance())
return false;
if (!module.getName().equals(configuration.getRunnerParameters().getModuleName()))
return false;
final JSClass jsClass = getJSClass(context.getPsiLocation());
if (jsClass == null || !isAcceptedMainClass(jsClass, module))
return false;
final List<RunConfiguration> existing = RunManager.getInstance(module.getProject()).getConfigurationsList(getConfigurationType());
final RunConfiguration suitable = findSuitableRunConfig(module, jsClass.getQualifiedName(), existing);
return suitable == configuration;
}
use of com.intellij.execution.configurations.RunConfiguration 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.configurations.RunConfiguration in project android by JetBrains.
the class PostSyncProjectSetupTest method testJUnitRunConfigurationSetup.
public void testJUnitRunConfigurationSetup() {
when(myIdeInfo.isAndroidStudio()).thenReturn(true);
PostSyncProjectSetup.Request request = new PostSyncProjectSetup.Request();
mySetup.setUpProject(request, myProgressIndicator);
ConfigurationFactory configurationFactory = AndroidJUnitConfigurationType.getInstance().getConfigurationFactories()[0];
AndroidJUnitConfiguration jUnitConfiguration = new AndroidJUnitConfiguration("", getProject(), configurationFactory);
myRunManager.addConfiguration(myRunManager.createConfiguration(jUnitConfiguration, configurationFactory), true);
List<RunConfiguration> junitRunConfigurations = myRunManager.getConfigurationsList(AndroidJUnitConfigurationType.getInstance());
for (RunConfiguration runConfiguration : junitRunConfigurations) {
assertSize(1, myRunManager.getBeforeRunTasks(runConfiguration));
assertEquals(MakeBeforeRunTaskProvider.ID, myRunManager.getBeforeRunTasks(runConfiguration).get(0).getProviderId());
}
RunConfiguration runConfiguration = junitRunConfigurations.get(0);
List<BeforeRunTask> tasks = new LinkedList<>(myRunManager.getBeforeRunTasks(runConfiguration));
BeforeRunTask newTask = new MakeBeforeRunTaskProvider(getProject()).createTask(runConfiguration);
newTask.setEnabled(true);
tasks.add(newTask);
myRunManager.setBeforeRunTasks(runConfiguration, tasks, false);
mySetup.setUpProject(request, myProgressIndicator);
assertSize(2, myRunManager.getBeforeRunTasks(runConfiguration));
}
use of com.intellij.execution.configurations.RunConfiguration in project intellij-plugins by JetBrains.
the class JstdRunConfigurationProducer method setupConfigurationFromContext.
@Override
protected boolean setupConfigurationFromContext(JstdRunConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
Project project = configuration.getProject();
if (!JstdSettingsUtil.areJstdConfigFilesInProjectCached(project)) {
return false;
}
RunConfiguration original = context.getOriginalConfiguration(null);
if (original != null && !ConfigurationTypeUtil.equals(original.getType(), JstdConfigurationType.getInstance())) {
return false;
}
long startTimeNano = System.nanoTime();
@SuppressWarnings({ "unchecked" }) JstdRunSettings settings = buildRunSettingsContext(context.getLocation());
if (settings == null) {
logDoneCreateConfigurationByElement(startTimeNano, "1");
return false;
}
if (settings.getConfigFile().isEmpty()) {
JstdRunSettings clonedSettings = configuration.getRunSettings();
JstdRunSettings.Builder builder = new JstdRunSettings.Builder(settings);
builder.setConfigFile(clonedSettings.getConfigFile());
settings = builder.build();
}
configuration.setRunSettings(settings);
String configurationName = configuration.resetGeneratedName();
configuration.setName(configurationName);
logDoneCreateConfigurationByElement(startTimeNano, "3");
return true;
}
Aggregations