private boolean checkRunConfiguration( Executor executor, Project project, RunnerAndConfigurationSettings configuration) { ExecutionTarget target = ExecutionTargetManager.getActiveTarget(project); if (!ExecutionTargetManager.canRun(configuration, target)) { ExecutionUtil.handleExecutionError( project, executor.getToolWindowId(), configuration.getConfiguration(), new ExecutionException( StringUtil.escapeXml( "Cannot run '" + configuration.getName() + "' on '" + target.getDisplayName() + "'"))); return false; } if (!RunManagerImpl.canRunConfiguration(configuration, executor) || configuration.isEditBeforeRun()) { if (!RunDialog.editConfiguration(project, configuration, "Edit configuration", executor)) { return false; } while (!RunManagerImpl.canRunConfiguration(configuration, executor)) { if (0 == Messages.showYesNoDialog( project, "Configuration is still incorrect. Do you want to edit it again?", "Change Configuration Settings", "Edit", "Continue Anyway", Messages.getErrorIcon())) { if (!RunDialog.editConfiguration( project, configuration, "Edit configuration", executor)) { break; } } else { break; } } } return true; }
public void perform(final ConfigurationContext context) { final RunnerAndConfigurationSettingsImpl 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())); runManager.setActiveConfiguration(configuration); } }
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); } }