com.intellij.execution.runners.ProgramRunner Java Examples

The following examples show how to use com.intellij.execution.runners.ProgramRunner. 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: RunConfigurationsSEContributor.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
private static Executor findExecutor(@Nonnull RunnerAndConfigurationSettings settings, @MagicConstant(intValues = {RUN_MODE, DEBUG_MODE}) int mode) {
  Executor runExecutor = DefaultRunExecutor.getRunExecutorInstance();
  Executor debugExecutor = ExecutorRegistry.getInstance().getExecutorById(ToolWindowId.DEBUG);

  Executor executor = mode == RUN_MODE ? runExecutor : debugExecutor;
  if (executor == null) {
    return null;
  }

  RunConfiguration runConf = settings.getConfiguration();
  if (ProgramRunner.getRunner(executor.getId(), runConf) == null) {
    executor = runExecutor == executor ? debugExecutor : runExecutor;
  }

  return executor;
}
 
Example #2
Source File: GaugeCommandLineState.java    From Intellij-Plugin with Apache License 2.0 6 votes vote down vote up
@NotNull
@Override
public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
    addProjectClasspath();
    if (GaugeVersion.isGreaterOrEqual(GaugeRunConfiguration.TEST_RUNNER_SUPPORT_VERSION, false)
            && GaugeSettingsService.getSettings().useIntelliJTestRunner()) {
        ProcessHandler handler = startProcess();
        GaugeConsoleProperties properties = new GaugeConsoleProperties(config, "Gauge", executor, handler);
        ConsoleView console = SMTestRunnerConnectionUtil.createAndAttachConsole("Gauge", handler, properties);
        DefaultExecutionResult result = new DefaultExecutionResult(console, handler, createActions(console, handler));
        if (ActionManager.getInstance().getAction("RerunFailedTests") != null) {
            AbstractRerunFailedTestsAction action = properties.createRerunFailedTestsAction(console);
            if (action != null) {
                action.setModelProvider(((SMTRunnerConsoleView) console)::getResultsViewer);
                result.setRestartActions(action);
            }
        }
        return result;
    }
    return super.execute(executor, runner);
}
 
Example #3
Source File: ProjectExecutor.java    From tmc-intellij with MIT License 6 votes vote down vote up
public void executeConfiguration(Project project, ModuleBasedConfiguration appCon) {
    if (noProjectsAreOpen()) {
        logger.warn("No open projects found, can't execute the project.");
        return;
    }
    logger.info("Starting to build execution environment.");
    RunManager runManager = RunManager.getInstance(project);
    Executor executor = DefaultRunExecutor.getRunExecutorInstance();
    RunnerAndConfigurationSettingsImpl selectedConfiguration =
            getApplicationRunnerAndConfigurationSettings(runManager, appCon);
    ProgramRunner runner = getRunner(executor, selectedConfiguration);
    logger.info("Creating ExecutionEnvironment.");
    ExecutionEnvironment environment =
            new ExecutionEnvironment(
                    new DefaultRunExecutor(), runner, selectedConfiguration, project);
    try {
        logger.info("Executing project.");
        runner.execute(environment);
    } catch (ExecutionException e1) {
        JavaExecutionUtil.showExecutionErrorMessage(e1, "Error", project);
    }
}
 
Example #4
Source File: RunnerAndConfigurationSettingsImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void writeConfigurationPerRunnerSettings(final Comparator<Element> runnerComparator, final Element element)
        throws WriteExternalException {
  final ArrayList<Element> configurationPerRunnerSettings = new ArrayList<Element>();
  for (ProgramRunner runner : myConfigurationPerRunnerSettings.keySet()) {
    ConfigurationPerRunnerSettings settings = myConfigurationPerRunnerSettings.get(runner);
    Element runnerElement = new Element(CONFIGURATION_ELEMENT);
    if (settings != null) {
      settings.writeExternal(runnerElement);
    }
    runnerElement.setAttribute(RUNNER_ID, runner.getRunnerId());
    configurationPerRunnerSettings.add(runnerElement);
  }
  if (myUnloadedConfigurationPerRunnerSettings != null) {
    for (Element unloadedCRunnerSetting : myUnloadedConfigurationPerRunnerSettings) {
      configurationPerRunnerSettings.add(unloadedCRunnerSetting.clone());
    }
  }
  Collections.sort(configurationPerRunnerSettings, runnerComparator);
  for (Element runnerConfigurationSetting : configurationPerRunnerSettings) {
    element.addContent(runnerConfigurationSetting);
  }
}
 
Example #5
Source File: FastBuildRunProfileState.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Override
public ExecutionResult execute(Executor executor, ProgramRunner runner)
    throws ExecutionException {
  DefaultExecutionResult result = (DefaultExecutionResult) super.execute(executor, runner);
  AbstractRerunFailedTestsAction rerunFailedAction =
      SmRunnerUtils.createRerunFailedTestsAction(result);
  RerunFastBuildConfigurationWithBlazeAction rerunWithBlazeAction =
      new RerunFastBuildConfigurationWithBlazeAction(
          getConfiguration().getProject(), getFastBuildInfo().label(), getEnvironment());
  if (rerunFailedAction != null) {
    result.setRestartActions(rerunFailedAction, rerunWithBlazeAction);
  } else {
    result.setRestartActions(rerunWithBlazeAction);
  }
  return result;
}
 
Example #6
Source File: RunnerAndConfigurationSettingsImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void checkSettings(@Nullable Executor executor) throws RuntimeConfigurationException {
  myConfiguration.checkConfiguration();
  if (myConfiguration instanceof RunConfigurationBase) {
    final RunConfigurationBase runConfigurationBase = (RunConfigurationBase) myConfiguration;
    Set<ProgramRunner> runners = new THashSet<ProgramRunner>();
    runners.addAll(myRunnerSettings.keySet());
    runners.addAll(myConfigurationPerRunnerSettings.keySet());
    for (ProgramRunner runner : runners) {
      if (executor == null || runner.canRun(executor.getId(), myConfiguration)) {
        runConfigurationBase.checkRunnerSettings(runner, myRunnerSettings.get(runner), myConfigurationPerRunnerSettings.get(runner));
      }
    }
    if (executor != null) {
      runConfigurationBase.checkSettingsBeforeRun();
    }
  }
}
 
Example #7
Source File: CommandLineState.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public ExecutionResult execute(@Nonnull final Executor executor, @Nonnull final ProgramRunner runner) throws ExecutionException {
  final ProcessHandler processHandler = startProcess();
  final ConsoleView console = createConsole(executor);
  if (console != null) {
    console.attachToProcess(processHandler);
  }
  return new DefaultExecutionResult(console, processHandler, createActions(console, processHandler, executor));
}
 
Example #8
Source File: MavenDebugConfigurationType.java    From MavenHelper with Apache License 2.0 5 votes vote down vote up
public static void debugConfiguration(Project project, @NotNull MavenRunnerParameters params,
		@Nullable MavenGeneralSettings settings, @Nullable MavenRunnerSettings runnerSettings,
		@Nullable ProgramRunner.Callback callback) {

	RunnerAndConfigurationSettings configSettings = MavenRunConfigurationType.createRunnerAndConfigurationSettings(
			settings, runnerSettings, params, project);
	final Executor executor = DefaultDebugExecutor.getDebugExecutorInstance();

	debugConfiguration(project, callback, configSettings, executor);
}
 
Example #9
Source File: ExternalSystemUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public static Pair<ProgramRunner, ExecutionEnvironment> createRunner(@Nonnull ExternalSystemTaskExecutionSettings taskSettings,
                                                                     @Nonnull String executorId,
                                                                     @Nonnull Project project,
                                                                     @Nonnull ProjectSystemId externalSystemId) {
  Executor executor = ExecutorRegistry.getInstance().getExecutorById(executorId);
  if (executor == null) return null;

  String runnerId = getRunnerId(executorId);
  if (runnerId == null) return null;

  ProgramRunner runner = RunnerRegistry.getInstance().findRunnerById(runnerId);
  if (runner == null) return null;

  AbstractExternalSystemTaskConfigurationType configurationType = findConfigurationType(externalSystemId);
  if (configurationType == null) return null;

  String name = AbstractExternalSystemTaskConfigurationType.generateName(project, taskSettings);
  RunnerAndConfigurationSettings settings = RunManager.getInstance(project).createRunConfiguration(name, configurationType.getFactory());
  ExternalSystemRunConfiguration runConfiguration = (ExternalSystemRunConfiguration)settings.getConfiguration();
  runConfiguration.getSettings().setExternalProjectPath(taskSettings.getExternalProjectPath());
  runConfiguration.getSettings().setTaskNames(ContainerUtil.newArrayList(taskSettings.getTaskNames()));
  runConfiguration.getSettings().setTaskDescriptions(ContainerUtil.newArrayList(taskSettings.getTaskDescriptions()));
  runConfiguration.getSettings().setVmOptions(taskSettings.getVmOptions());
  runConfiguration.getSettings().setScriptParameters(taskSettings.getScriptParameters());
  runConfiguration.getSettings().setExecutionName(taskSettings.getExecutionName());

  return Pair.create(runner, new ExecutionEnvironment(executor, runner, settings, project));
}
 
Example #10
Source File: DeployToServerState.java    From consulo with Apache License 2.0 5 votes vote down vote up
@javax.annotation.Nullable
@Override
public ExecutionResult execute(Executor executor, @Nonnull ProgramRunner runner) throws ExecutionException {
  final ServerConnection connection = ServerConnectionManager.getInstance().getOrCreateConnection(myServer);
  final Project project = myEnvironment.getProject();
  RemoteServersView.getInstance(project).showServerConnection(connection);

  final DebugConnector<?,?> debugConnector;
  if (DefaultDebugExecutor.getDebugExecutorInstance().equals(executor)) {
    debugConnector = myServer.getType().createDebugConnector();
  }
  else {
    debugConnector = null;
  }
  connection.computeDeployments(new Runnable() {
    @Override
    public void run() {
      connection.deploy(new DeploymentTaskImpl(mySource, myConfiguration, project, debugConnector, myEnvironment),
                        new ParameterizedRunnable<String>() {
                          @Override
                          public void run(String s) {
                            RemoteServersView.getInstance(project).showDeployment(connection, s);
                          }
                        });
    }
  });
  return null;
}
 
Example #11
Source File: ImportedTestRunnableState.java    From consulo with Apache License 2.0 5 votes vote down vote up
@javax.annotation.Nullable
@Override
public ExecutionResult execute(Executor executor, @Nonnull ProgramRunner runner) throws ExecutionException {
  final MyEmptyProcessHandler handler = new MyEmptyProcessHandler();
  final SMTRunnerConsoleProperties properties = myRunProfile.getProperties();
  RunProfile configuration;
  final String frameworkName;
  if (properties != null) {
    configuration = properties.getConfiguration();
    frameworkName = properties.getTestFrameworkName();
  }
  else {
    configuration = myRunProfile;
    frameworkName = "Import Test Results";
  }
  final ImportedTestConsoleProperties consoleProperties = new ImportedTestConsoleProperties(properties, myFile, handler, myRunProfile.getProject(),
                                                                                            configuration, frameworkName, executor);
  final BaseTestsOutputConsoleView console = SMTestRunnerConnectionUtil.createConsole(consoleProperties.getTestFrameworkName(),
                                                                                      consoleProperties);
  final JComponent component = console.getComponent();
  AbstractRerunFailedTestsAction rerunFailedTestsAction = null;
  if (component instanceof TestFrameworkRunningModel) {
    rerunFailedTestsAction = consoleProperties.createRerunFailedTestsAction(console);
    if (rerunFailedTestsAction != null) {
      rerunFailedTestsAction.setModelProvider(new Getter<TestFrameworkRunningModel>() {
        @Override
        public TestFrameworkRunningModel get() {
          return (TestFrameworkRunningModel)component;
        }
      });
    }
  }

  console.attachToProcess(handler);
  final DefaultExecutionResult result = new DefaultExecutionResult(console, handler);
  if (rerunFailedTestsAction != null) {
    result.setRestartActions(rerunFailedTestsAction);
  }
  return result;
}
 
Example #12
Source File: AbstractImportTestsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  final Project project = e.getProject();
  LOG.assertTrue(project != null);
  final VirtualFile file = getFile(project);
  if (file != null) {
    try {
      final ImportRunProfile profile = new ImportRunProfile(file, project);
      SMTRunnerConsoleProperties properties = profile.getProperties();
      if (properties == null) {
        properties = myProperties;
        LOG.info("Failed to detect test framework in " + file.getPath() +
                 "; use " + (properties != null ? properties.getTestFrameworkName() + " from toolbar" : "no properties"));
      }
      final Executor executor = properties != null ? properties.getExecutor()
                                                   : ExecutorRegistry.getInstance().getExecutorById(DefaultRunExecutor.EXECUTOR_ID);
      ExecutionEnvironmentBuilder builder = ExecutionEnvironmentBuilder.create(project, executor, profile);
      ExecutionTarget target = profile.getTarget();
      if (target != null) {
        builder = builder.target(target);
      }
      final RunConfiguration initialConfiguration = profile.getInitialConfiguration();
      final ProgramRunner runner =
              initialConfiguration != null ? RunnerRegistry.getInstance().getRunner(executor.getId(), initialConfiguration) : null;
      if (runner != null) {
        builder = builder.runner(runner);
      }
      builder.buildAndExecute();
    }
    catch (ExecutionException e1) {
      Messages.showErrorDialog(project, e1.getMessage(), "Import Failed");
    }
  }
}
 
Example #13
Source File: MavenDebugConfigurationType.java    From MavenHelper with Apache License 2.0 5 votes vote down vote up
public static void debugConfiguration(Project project, ProgramRunner.Callback callback,
		RunnerAndConfigurationSettings configSettings, Executor executor) {
	ProgramRunner runner = ProgramRunner.findRunnerById(DefaultDebugExecutor.EXECUTOR_ID);
	ExecutionEnvironment env = new ExecutionEnvironment(executor, runner, configSettings, project);

	try {
		runner.execute(env, callback);
	} catch (ExecutionException e) {
		MavenUtil.showError(project, "Failed to execute Maven goal", e);
	}
}
 
Example #14
Source File: BashTerminalCommandLineState.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
    String workingDir = BashRunConfigUtil.findWorkingDir(runConfig);
    GeneralCommandLine cmd = BashRunConfigUtil.createCommandLine(workingDir, runConfig);

    BashLocalTerminalRunner myRunner = new BashLocalTerminalRunner(runConfig.getProject(), runConfig.getScriptName(), cmd);
    myRunner.run();
    return new BashTerminalExecutionResult(myRunner.getProcessHandler());
}
 
Example #15
Source File: BlazeJavaRunProfileState.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public ExecutionResult execute(Executor executor, ProgramRunner runner)
    throws ExecutionException {
  if (BlazeCommandRunConfigurationRunner.isDebugging(getEnvironment())) {
    new MultiRunDebuggerSessionListener(getEnvironment(), this).startListening();
  }
  DefaultExecutionResult result = (DefaultExecutionResult) super.execute(executor, runner);
  return SmRunnerUtils.attachRerunFailedTestsAction(result);
}
 
Example #16
Source File: BlazeAndroidRunState.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public ExecutionResult execute(Executor executor, ProgramRunner runner)
    throws ExecutionException {
  DefaultExecutionResult result = executeInner(executor, runner);
  if (result == null) {
    return null;
  }
  return SmRunnerUtils.attachRerunFailedTestsAction(result);
}
 
Example #17
Source File: TestExecutionState.java    From buck with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner)
    throws ExecutionException {
  final ProcessHandler processHandler = runBuildCommand(executor);
  final TestConsoleProperties properties =
      new BuckTestConsoleProperties(
          processHandler, mProject, mConfiguration, "Buck test", executor);
  final ConsoleView console =
      SMTestRunnerConnectionUtil.createAndAttachConsole("buck test", processHandler, properties);
  return new DefaultExecutionResult(console, processHandler, AnAction.EMPTY_ARRAY);
}
 
Example #18
Source File: ReplGenericState.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
@Nullable
@Override
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
    ProcessHandler processHandler = startProcess();
    if (processHandler == null) {
        return null;
    }

    PromptConsoleView consoleView = new PromptConsoleView(m_environment.getProject(), true, true);
    consoleView.attachToProcess(processHandler);

    return new DefaultExecutionResult(consoleView, processHandler);
}
 
Example #19
Source File: RemoteProcessSupport.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void startProcess(Target target, Parameters configuration, Pair<Target, Parameters> key) {
  ProgramRunner runner = new DefaultProgramRunner() {
    @Override
    @Nonnull
    public String getRunnerId() {
      return "MyRunner";
    }

    @Override
    public boolean canRun(@Nonnull String executorId, @Nonnull RunProfile profile) {
      return true;
    }
  };
  Executor executor = DefaultRunExecutor.getRunExecutorInstance();
  ProcessHandler processHandler = null;
  try {
    RunProfileState state = getRunProfileState(target, configuration, executor);
    ExecutionResult result = state.execute(executor, runner);
    //noinspection ConstantConditions
    processHandler = result.getProcessHandler();
  }
  catch (Exception e) {
    dropProcessInfo(key, e instanceof ExecutionException? e.getMessage() : ExceptionUtil.getUserStackTrace(e, LOG), processHandler);
    return;
  }
  processHandler.addProcessListener(getProcessListener(key));
  processHandler.startNotify();
}
 
Example #20
Source File: RunContextAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private Pair<Boolean, Boolean> isEnabledAndVisible(ConfigurationContext context) {
  RunnerAndConfigurationSettings configuration = context.findExisting();
  if (configuration == null) {
    configuration = context.getConfiguration();
  }

  ProgramRunner runner = configuration == null ? null : getRunner(configuration.getConfiguration());
  if (runner == null) {
    return Pair.create(false, false);
  }
  return Pair.create(!ExecutorRegistry.getInstance().isStarting(context.getProject(), myExecutor.getId(), runner.getRunnerId()), true);
}
 
Example #21
Source File: SingleConfigurationConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private ValidationResult getValidationResult() {
  if (!myValidationResultValid) {
    myLastValidationResult = null;
    try {
      RunnerAndConfigurationSettings snapshot = getSnapshot();
      if (snapshot != null) {
        snapshot.setName(getNameText());
        snapshot.checkSettings(myExecutor);
        for (ProgramRunner runner : RunnerRegistry.getInstance().getRegisteredRunners()) {
          for (Executor executor : ExecutorRegistry.getInstance().getRegisteredExecutors()) {
            if (runner.canRun(executor.getId(), snapshot.getConfiguration())) {
              checkConfiguration(runner, snapshot);
              break;
            }
          }
        }
      }
    }
    catch (RuntimeConfigurationException exception) {
      myLastValidationResult =
        exception != null ? new ValidationResult(exception.getLocalizedMessage(), exception.getTitle(), exception.getQuickFix()) : null;
    }
    catch (ConfigurationException e) {
      myLastValidationResult = new ValidationResult(e.getLocalizedMessage(), ExecutionBundle.message("invalid.data.dialog.title"), null);
    }

    myValidationResultValid = true;
  }
  return myLastValidationResult;
}
 
Example #22
Source File: SingleConfigurationConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void checkConfiguration(final ProgramRunner runner, final RunnerAndConfigurationSettings snapshot)
  throws RuntimeConfigurationException {
  final RunnerSettings runnerSettings = snapshot.getRunnerSettings(runner);
  final ConfigurationPerRunnerSettings configurationSettings = snapshot.getConfigurationSettings(runner);
  try {
    runner.checkConfiguration(runnerSettings, configurationSettings);
  }
  catch (AbstractMethodError e) {
    //backward compatibility
  }
}
 
Example #23
Source File: RunnerAndConfigurationSettingsImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void writeRunnerSettings(@Nonnull Comparator<Element> runnerComparator, @Nonnull Element element) throws WriteExternalException {
  List<Element> runnerSettings = new SmartList<Element>();
  for (ProgramRunner runner : myRunnerSettings.keySet()) {
    RunnerSettings settings = myRunnerSettings.get(runner);
    boolean wasLoaded = myLoadedRunnerSettings.contains(runner.getRunnerId());
    if (settings == null && !wasLoaded) {
      continue;
    }

    Element runnerElement = new Element(RUNNER_ELEMENT);
    if (settings != null) {
      settings.writeExternal(runnerElement);
    }
    if (wasLoaded || !JDOMUtil.isEmpty(runnerElement)) {
      runnerElement.setAttribute(RUNNER_ID, runner.getRunnerId());
      runnerSettings.add(runnerElement);
    }
  }
  if (myUnloadedRunnerSettings != null) {
    for (Element unloadedRunnerSetting : myUnloadedRunnerSettings) {
      runnerSettings.add(unloadedRunnerSetting.clone());
    }
  }
  Collections.sort(runnerSettings, runnerComparator);
  for (Element runnerSetting : runnerSettings) {
    element.addContent(runnerSetting);
  }
}
 
Example #24
Source File: RunnerAndConfigurationSettingsImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public RunnerSettings getRunnerSettings(@Nonnull ProgramRunner runner) {
  if (!myRunnerSettings.containsKey(runner)) {
    try {
      RunnerSettings runnerSettings = createRunnerSettings(runner);
      myRunnerSettings.put(runner, runnerSettings);
      return runnerSettings;
    }
    catch (AbstractMethodError ignored) {
      LOG.error("Update failed for: " + myConfiguration.getType().getDisplayName() + ", runner: " + runner.getRunnerId(), new ExtensionException(runner.getClass()));
    }
  }
  return myRunnerSettings.get(runner);
}
 
Example #25
Source File: RunnerAndConfigurationSettingsImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public ConfigurationPerRunnerSettings getConfigurationSettings(@Nonnull ProgramRunner runner) {
  if (!myConfigurationPerRunnerSettings.containsKey(runner)) {
    ConfigurationPerRunnerSettings settings = myConfiguration.createRunnerSettings(new InfoProvider(runner));
    myConfigurationPerRunnerSettings.put(runner, settings);
    return settings;
  }
  return myConfigurationPerRunnerSettings.get(runner);
}
 
Example #26
Source File: RunnerRegistryImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public ProgramRunner getRunner(final String executorId, final RunProfile settings) {
  final ProgramRunner[] runners = getRegisteredRunners();
  for (final ProgramRunner runner : runners) {
    if (runner.canRun(executorId, settings)) {
      return runner;
    }
  }

  return null;
}
 
Example #27
Source File: RunnerRegistryImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public ProgramRunner findRunnerById(String id) {
  ProgramRunner[] registeredRunners = getRegisteredRunners();
  for (ProgramRunner registeredRunner : registeredRunners) {
    if (Comparing.equal(id, registeredRunner.getRunnerId())) {
      return registeredRunner;
    }
  }
  return null;
}
 
Example #28
Source File: RunConfigurationBeforeRunProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private List<RunnerAndConfigurationSettings> getAvailableConfigurations(RunConfiguration runConfiguration) {
  Project project = runConfiguration.getProject();
  if (project == null || !project.isInitialized()) return Collections.emptyList();
  final RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project);

  final ArrayList<RunnerAndConfigurationSettings> configurations = new ArrayList<RunnerAndConfigurationSettings>(runManager.getSortedConfigurations());
  String executorId = DefaultRunExecutor.getRunExecutorInstance().getId();
  for (Iterator<RunnerAndConfigurationSettings> iterator = configurations.iterator(); iterator.hasNext(); ) {
    RunnerAndConfigurationSettings settings = iterator.next();
    final ProgramRunner runner = ProgramRunnerUtil.getRunner(executorId, settings);
    if (runner == null || settings.getConfiguration() == runConfiguration) iterator.remove();
  }
  return configurations;
}
 
Example #29
Source File: RunConfigurationBeforeRunProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canExecuteTask(RunConfiguration configuration, RunConfigurableBeforeRunTask task) {
  RunnerAndConfigurationSettings settings = task.getSettings();
  if (settings == null) {
    return false;
  }
  String executorId = DefaultRunExecutor.getRunExecutorInstance().getId();
  final ProgramRunner runner = ProgramRunnerUtil.getRunner(executorId, settings);
  if (runner == null) return false;
  return runner.canRun(executorId, settings.getConfiguration());
}
 
Example #30
Source File: ExecutionManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void restartRunProfile(@Nullable ProgramRunner runner, @Nonnull ExecutionEnvironment environment, @Nullable RunContentDescriptor currentDescriptor) {
  ExecutionEnvironmentBuilder builder = new ExecutionEnvironmentBuilder(environment).contentToReuse(currentDescriptor);
  if (runner != null) {
    builder.runner(runner);
  }
  restartRunProfile(builder.build());
}