void doReset(RunnerAndConfigurationSettings settings) {
    myRunConfiguration = settings.getConfiguration();

    originalTasks.clear();
    RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(myRunConfiguration.getProject());
    originalTasks.addAll(runManager.getBeforeRunTasks(myRunConfiguration));
    myModel.replaceAll(originalTasks);
    myShowSettingsBeforeRunCheckBox.setSelected(settings.isEditBeforeRun());
    myShowSettingsBeforeRunCheckBox.setEnabled(!(isUnknown()));
    myPanel.setVisible(checkBeforeRunTasksAbility(false));
    updateText();
  }
Exemple #2
0
 @Override
 @Nullable
 public RunConfigurableBeforeRunTask createTask(RunConfiguration runConfiguration) {
   if (runConfiguration.getProject().isInitialized()) {
     Collection<RunnerAndConfigurationSettings> configurations =
         RunManagerImpl.getInstanceImpl(runConfiguration.getProject()).getSortedConfigurations();
     if (configurations.isEmpty()
         || (configurations.size() == 1
             && configurations.iterator().next().getConfiguration() == runConfiguration)) {
       return null;
     }
   }
   return new RunConfigurableBeforeRunTask();
 }
  private static boolean userApprovesStopForSameTypeConfigurations(
      Project project, String configName, int instancesCount) {
    RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project);
    final RunManagerConfig config = runManager.getConfig();
    if (!config.isRestartRequiresConfirmation()) return true;

    DialogWrapper.DoNotAskOption option =
        new DialogWrapper.DoNotAskOption() {
          @Override
          public boolean isToBeShown() {
            return config.isRestartRequiresConfirmation();
          }

          @Override
          public void setToBeShown(boolean value, int exitCode) {
            config.setRestartRequiresConfirmation(value);
          }

          @Override
          public boolean canBeHidden() {
            return true;
          }

          @Override
          public boolean shouldSaveOptionsOnCancel() {
            return false;
          }

          @NotNull
          @Override
          public String getDoNotShowMessage() {
            return CommonBundle.message("dialog.options.do.not.show");
          }
        };
    return Messages.showOkCancelDialog(
            project,
            ExecutionBundle.message(
                "rerun.singleton.confirmation.message", configName, instancesCount),
            ExecutionBundle.message("process.is.running.dialog.title", configName),
            ExecutionBundle.message("rerun.confirmation.button.text"),
            CommonBundle.message("button.cancel"),
            Messages.getQuestionIcon(),
            option)
        == Messages.OK;
  }
Exemple #4
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;
       }
     }
   }
 }
Exemple #5
0
  @NotNull
  private static 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;
  }
  private void getAllRunBeforeRuns(BeforeRunTask task, Set<RunConfiguration> configurationSet) {
    if (task instanceof RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask) {
      RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask runTask =
          (RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask) task;
      RunConfiguration configuration = runTask.getSettings().getConfiguration();

      List<BeforeRunTask> tasks =
          RunManagerImpl.getInstanceImpl(configuration.getProject())
              .getBeforeRunTasks(configuration);
      for (BeforeRunTask beforeRunTask : tasks) {
        if (beforeRunTask
            instanceof RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask) {
          if (configurationSet.add(
              ((RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask) beforeRunTask)
                  .getSettings()
                  .getConfiguration())) getAllRunBeforeRuns(beforeRunTask, configurationSet);
        }
      }
    }
  }
  private static boolean userApprovesStopForIncompatibleConfigurations(
      Project project,
      String configName,
      List<RunContentDescriptor> runningIncompatibleDescriptors) {
    RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project);
    final RunManagerConfig config = runManager.getConfig();
    if (!config.isStopIncompatibleRequiresConfirmation()) return true;

    DialogWrapper.DoNotAskOption option =
        new DialogWrapper.DoNotAskOption() {
          @Override
          public boolean isToBeShown() {
            return config.isStopIncompatibleRequiresConfirmation();
          }

          @Override
          public void setToBeShown(boolean value, int exitCode) {
            config.setStopIncompatibleRequiresConfirmation(value);
          }

          @Override
          public boolean canBeHidden() {
            return true;
          }

          @Override
          public boolean shouldSaveOptionsOnCancel() {
            return false;
          }

          @NotNull
          @Override
          public String getDoNotShowMessage() {
            return CommonBundle.message("dialog.options.do.not.show");
          }
        };

    final StringBuilder names = new StringBuilder();
    for (final RunContentDescriptor descriptor : runningIncompatibleDescriptors) {
      String name = descriptor.getDisplayName();
      if (names.length() > 0) {
        names.append(", ");
      }
      names.append(
          StringUtil.isEmpty(name)
              ? ExecutionBundle.message("run.configuration.no.name")
              : String.format("'%s'", name));
    }

    //noinspection DialogTitleCapitalization
    return Messages.showOkCancelDialog(
            project,
            ExecutionBundle.message(
                "stop.incompatible.confirmation.message",
                configName,
                names.toString(),
                runningIncompatibleDescriptors.size()),
            ExecutionBundle.message(
                "incompatible.configuration.is.running.dialog.title",
                runningIncompatibleDescriptors.size()),
            ExecutionBundle.message("stop.incompatible.confirmation.button.text"),
            CommonBundle.message("button.cancel"),
            Messages.getQuestionIcon(),
            option)
        == Messages.OK;
  }