예제 #1
0
 @Override
 public void writeExternal(Element element) {
   super.writeExternal(element);
   if (myConfigurationName != null && myConfigurationType != null) {
     element.setAttribute("run_configuration_name", myConfigurationName);
     element.setAttribute("run_configuration_type", myConfigurationType);
   } else if (mySettings != null) {
     element.setAttribute("run_configuration_name", mySettings.getName());
     element.setAttribute("run_configuration_type", mySettings.getType().getId());
   }
 }
 public SelectConfigAction(
     final RunnerAndConfigurationSettings configuration, final Project project) {
   myConfiguration = configuration;
   myProject = project;
   String name = configuration.getName();
   if (name == null || name.length() == 0) {
     name = " ";
   }
   final Presentation presentation = getTemplatePresentation();
   presentation.setText(name, false);
   final ConfigurationType type = configuration.getType();
   if (type != null) {
     presentation.setDescription(
         "Select " + type.getConfigurationTypeDescription() + " '" + name + "'");
   }
   updateIcon(presentation);
 }
예제 #3
0
 void init() {
   if (myInitialized) {
     return;
   }
   if (myConfigurationName != null && myConfigurationType != null) {
     Collection<RunnerAndConfigurationSettings> configurations =
         RunManagerImpl.getInstanceImpl(myProject).getSortedConfigurations();
     for (RunnerAndConfigurationSettings runConfiguration : configurations) {
       ConfigurationType type = runConfiguration.getType();
       if (myConfigurationName.equals(runConfiguration.getName())
           && type != null
           && myConfigurationType.equals(type.getId())) {
         setSettings(runConfiguration);
         return;
       }
     }
   }
 }
  public static void executeConfiguration(
      @NotNull ExecutionEnvironment environment, boolean showSettings, boolean assignNewId) {
    if (ExecutorRegistry.getInstance().isStarting(environment)) {
      return;
    }

    RunnerAndConfigurationSettings runnerAndConfigurationSettings =
        environment.getRunnerAndConfigurationSettings();
    if (runnerAndConfigurationSettings != null) {
      if (!ExecutionTargetManager.canRun(environment)) {
        ExecutionUtil.handleExecutionError(
            environment,
            new ExecutionException(
                StringUtil.escapeXml(
                    "Cannot run '"
                        + environment.getRunProfile().getName()
                        + "' on '"
                        + environment.getExecutionTarget().getDisplayName()
                        + "'")));
        return;
      }

      if (!RunManagerImpl.canRunConfiguration(environment)
          || (showSettings && runnerAndConfigurationSettings.isEditBeforeRun())) {
        if (!RunDialog.editConfiguration(environment, "Edit configuration")) {
          return;
        }

        while (!RunManagerImpl.canRunConfiguration(environment)) {
          if (Messages.YES
              == Messages.showYesNoDialog(
                  environment.getProject(),
                  "Configuration is still incorrect. Do you want to edit it again?",
                  "Change Configuration Settings",
                  "Edit",
                  "Continue Anyway",
                  Messages.getErrorIcon())) {
            if (!RunDialog.editConfiguration(environment, "Edit configuration")) {
              return;
            }
          } else {
            break;
          }
        }
      }

      ConfigurationType configurationType = runnerAndConfigurationSettings.getType();
      if (configurationType != null) {
        UsageTrigger.trigger(
            "execute."
                + ConvertUsagesUtil.ensureProperKey(configurationType.getId())
                + "."
                + environment.getExecutor().getId());
      }
    }

    try {
      if (assignNewId) {
        environment.assignNewExecutionId();
      }
      environment.getRunner().execute(environment);
    } catch (ExecutionException e) {
      String name =
          runnerAndConfigurationSettings != null ? runnerAndConfigurationSettings.getName() : null;
      if (name == null) {
        name = environment.getRunProfile().getName();
      }
      if (name == null && environment.getContentToReuse() != null) {
        name = environment.getContentToReuse().getDisplayName();
      }
      if (name == null) {
        name = "<Unknown>";
      }
      ExecutionUtil.handleExecutionError(
          environment.getProject(), environment.getExecutor().getToolWindowId(), name, e);
    }
  }