Java Code Examples for com.intellij.execution.impl.RunManagerImpl#addConfiguration()

The following examples show how to use com.intellij.execution.impl.RunManagerImpl#addConfiguration() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PantsIntegrationTestCase.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
protected void assertAndRunPantsMake(JUnitConfiguration runConfiguration) {

    RunManager runManager = RunManager.getInstance(myProject);
    assertTrue(runManager instanceof RunManagerImpl);
    RunManagerImpl runManagerImpl = (RunManagerImpl) runManager;

    RunnerAndConfigurationSettings runnerAndConfigurationSettings =
      runManagerImpl.createConfiguration(runConfiguration, JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
    runManagerImpl.addConfiguration(runnerAndConfigurationSettings, false);

    // Make sure PantsMake is the one and only task before JUnit run.
    List<BeforeRunTask<?>> beforeRunTaskList = runManagerImpl.getBeforeRunTasks(runConfiguration);
    assertEquals(1, beforeRunTaskList.size());
    BeforeRunTask task = beforeRunTaskList.iterator().next();
    assertEquals(PantsMakeBeforeRun.ID, task.getProviderId());

    /*
     * Manually invoke BeforeRunTask as {@link ExecutionManager#compileAndRun} launches another task asynchronously,
     * and there is no way to catch that.
     */
    BeforeRunTaskProvider provider = BeforeRunTaskProvider.getProvider(myProject, task.getProviderId());
    assertNotNull(String.format("Cannot find BeforeRunTaskProvider for id='%s'", task.getProviderId()), provider);
    assertTrue(provider.executeTask(null, runConfiguration, null, task));
  }
 
Example 2
Source File: OSSPantsIntegrationTest.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
private List<BeforeRunTask<?>> getBeforeRunTask(RunConfiguration configuration) {
  RunManagerImpl runManager = (RunManagerImpl) RunManager.getInstance(myProject);
  RunnerAndConfigurationSettingsImpl configurationSettings = new RunnerAndConfigurationSettingsImpl(runManager, configuration, true);
  runManager.addConfiguration(configurationSettings, true);
  List<BeforeRunTask<?>> tasks = runManager.getBeforeRunTasks(configuration);
  runManager.removeConfiguration(configurationSettings);
  return tasks;
}
 
Example 3
Source File: CreateAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void perform(final ConfigurationContext context) {
  final RunManagerImpl runManager = (RunManagerImpl)context.getRunManager();
  final RunnerAndConfigurationSettings configuration = context.getConfiguration();
  final RunnerAndConfigurationSettings template = runManager.getConfigurationTemplate(configuration.getFactory());
  final RunConfiguration templateConfiguration = template.getConfiguration();
  runManager.addConfiguration(configuration,
                              runManager.isConfigurationShared(template),
                              runManager.getBeforeRunTasks(templateConfiguration),
                              false);
  runManager.setSelectedConfiguration(configuration);
}
 
Example 4
Source File: CreateAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void perform(final ConfigurationContext context) {
  final RunnerAndConfigurationSettings configuration = context.getConfiguration();
  if (RunDialog.editConfiguration(context.getProject(), configuration, ExecutionBundle.message("create.run.configuration.for.item.dialog.title", configuration.getName()))) {
    final RunManagerImpl runManager = (RunManagerImpl)context.getRunManager();
    runManager.addConfiguration(configuration,
                                runManager.isConfigurationShared(configuration),
                                runManager.getBeforeRunTasks(configuration.getConfiguration()), false);
    runManager.setSelectedConfiguration(configuration);
  }
}