public ExternalSystemRunConfigurationAction(
        Project project, RunnerAndConfigurationSettings configurationSettings) {
      myConfigurationSettings = configurationSettings;
      ExternalSystemRunConfiguration runConfiguration =
          (ExternalSystemRunConfiguration) configurationSettings.getConfiguration();
      systemId = runConfiguration.getSettings().getExternalSystemId();

      ExternalSystemUiAware uiAware = ExternalSystemUiUtil.getUiAware(systemId);
      myGroup =
          uiAware.getProjectRepresentationName(
              runConfiguration.getSettings().getExternalProjectPath(), null);
      String actionIdPrefix =
          getActionPrefix(project, runConfiguration.getSettings().getExternalProjectPath());
      myId = actionIdPrefix + configurationSettings.getName();

      Presentation template = getTemplatePresentation();
      template.setText(myConfigurationSettings.getName(), false);
      template.setIcon(runConfiguration.getIcon());
    }
  @Override
  public boolean isConfigurationFromContext(
      ExternalSystemRunConfiguration configuration, ConfigurationContext context) {
    if (GradleSystemRunningSettings.getInstance().getPreferredTestRunner() == PLATFORM_TEST_RUNNER)
      return false;
    if (configuration == null) return false;
    if (!GradleConstants.SYSTEM_ID.equals(configuration.getSettings().getExternalSystemId()))
      return false;

    return doIsConfigurationFromContext(configuration, context);
  }
  @Override
  protected boolean setupConfigurationFromContext(
      ExternalSystemRunConfiguration configuration,
      ConfigurationContext context,
      Ref<PsiElement> sourceElement) {
    if (!GradleConstants.SYSTEM_ID.equals(configuration.getSettings().getExternalSystemId()))
      return false;
    if (GradleSystemRunningSettings.getInstance().getPreferredTestRunner() == PLATFORM_TEST_RUNNER)
      return false;

    return doSetupConfigurationFromContext(configuration, context, sourceElement);
  }
Exemplo n.º 4
0
  @Nullable
  public static Pair<ProgramRunner, ExecutionEnvironment> createRunner(
      @NotNull ExternalSystemTaskExecutionSettings taskSettings,
      @NotNull String executorId,
      @NotNull Project project,
      @NotNull 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));
  }