com.intellij.execution.executors.DefaultRunExecutor Java Examples

The following examples show how to use com.intellij.execution.executors.DefaultRunExecutor. 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: ExecutorRegistryImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private Icon getInformativeIcon(Project project, final RunnerAndConfigurationSettings selectedConfiguration) {
  final ExecutionManagerImpl executionManager = ExecutionManagerImpl.getInstance(project);

  List<RunContentDescriptor> runningDescriptors = executionManager.getRunningDescriptors(s -> s == selectedConfiguration);
  runningDescriptors = ContainerUtil.filter(runningDescriptors, descriptor -> {
    RunContentDescriptor contentDescriptor = executionManager.getContentManager().findContentDescriptor(myExecutor, descriptor.getProcessHandler());
    return contentDescriptor != null && executionManager.getExecutors(contentDescriptor).contains(myExecutor);
  });

  if (!runningDescriptors.isEmpty() && DefaultRunExecutor.EXECUTOR_ID.equals(myExecutor.getId()) && selectedConfiguration.isSingleton()) {
    return AllIcons.Actions.Restart;
  }
  if (runningDescriptors.isEmpty()) {
    return TargetAWT.to(myExecutor.getIcon());
  }

  if (runningDescriptors.size() == 1) {
    return TargetAWT.to(ExecutionUtil.getIconWithLiveIndicator(myExecutor.getIcon()));
  }
  else {
    // FIXME [VISTALL] not supported by UI framework
    return IconUtil.addText(TargetAWT.to(myExecutor.getIcon()), String.valueOf(runningDescriptors.size()));
  }
}
 
Example #2
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 #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: AnalyzeStacktraceUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static RunContentDescriptor addConsole(Project project, @Nullable ConsoleFactory consoleFactory, final String tabTitle, String text, @Nullable consulo.ui.image.Image icon) {
  final TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
  builder.filters(EP_NAME.getExtensions(project));
  final ConsoleView consoleView = builder.getConsole();

  final DefaultActionGroup toolbarActions = new DefaultActionGroup();
  JComponent consoleComponent = consoleFactory != null ? consoleFactory.createConsoleComponent(consoleView, toolbarActions) : new MyConsolePanel(consoleView, toolbarActions);
  final RunContentDescriptor descriptor = new RunContentDescriptor(consoleView, null, consoleComponent, tabTitle, icon) {
    @Override
    public boolean isContentReuseProhibited() {
      return true;
    }
  };

  final Executor executor = DefaultRunExecutor.getRunExecutorInstance();
  for (AnAction action : consoleView.createConsoleActions()) {
    toolbarActions.add(action);
  }
  final ConsoleViewImpl console = (ConsoleViewImpl)consoleView;
  ConsoleViewUtil.enableReplaceActionForConsoleViewEditor(console.getEditor());
  console.getEditor().getSettings().setCaretRowShown(true);
  toolbarActions.add(new AnnotateStackTraceAction(console.getEditor(), console.getHyperlinks()));
  ExecutionManager.getInstance(project).getContentManager().showRunContent(executor, descriptor);
  consoleView.allowHeavyFilters();
  if (consoleFactory == null) {
    printStacktrace(consoleView, text);
  }
  return descriptor;
}
 
Example #5
Source File: RunIdeConsoleAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private static RunContentDescriptor createConsoleView(@Nonnull Project project, @Nonnull PsiFile psiFile) {
  ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole();

  DefaultActionGroup toolbarActions = new DefaultActionGroup();
  JComponent panel = new JPanel(new BorderLayout());
  panel.add(consoleView.getComponent(), BorderLayout.CENTER);
  ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, toolbarActions, false);
  toolbar.setTargetComponent(consoleView.getComponent());
  panel.add(toolbar.getComponent(), BorderLayout.WEST);

  final RunContentDescriptor descriptor = new RunContentDescriptor(consoleView, null, panel, psiFile.getName()) {
    @Override
    public boolean isContentReuseProhibited() {
      return true;
    }
  };
  Executor executor = DefaultRunExecutor.getRunExecutorInstance();
  toolbarActions.addAll(consoleView.createConsoleActions());
  toolbarActions.add(new CloseAction(executor, descriptor, project));
  ExecutionManager.getInstance(project).getContentManager().showRunContent(executor, descriptor);

  return descriptor;
}
 
Example #6
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 #7
Source File: RunContentExecutor.java    From consulo with Apache License 2.0 5 votes vote down vote up
private ConsoleView createConsole(@Nonnull Project project) {
  TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
  consoleBuilder.filters(myFilterList);
  final ConsoleView console = consoleBuilder.getConsole();

  if (myHelpId != null) {
    console.setHelpId(myHelpId);
  }
  Executor executor = DefaultRunExecutor.getRunExecutorInstance();
  DefaultActionGroup actions = new DefaultActionGroup();

  final JComponent consolePanel = createConsolePanel(console, actions);
  RunContentDescriptor descriptor = new RunContentDescriptor(console, myProcess, consolePanel, myTitle);

  Disposer.register(descriptor, this);
  Disposer.register(descriptor, console);

  actions.add(new RerunAction(consolePanel));
  actions.add(new StopAction());
  actions.add(new CloseAction(executor, descriptor, myProject));

  ExecutionManager.getInstance(myProject).getContentManager().showRunContent(executor, descriptor);

  if (myActivateToolWindow) {
    activateToolWindow();
  }

  return console;
}
 
Example #8
Source File: ExternalSystemTasksTreeModel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private ExternalTaskExecutionInfo buildTaskInfo(@Nonnull ExternalTaskPojo task) {
  ExternalSystemTaskExecutionSettings settings = new ExternalSystemTaskExecutionSettings();
  settings.setExternalProjectPath(task.getLinkedExternalProjectPath());
  settings.setTaskNames(Collections.singletonList(task.getName()));
  settings.setTaskDescriptions(Collections.singletonList(task.getDescription()));
  settings.setExternalSystemIdString(myExternalSystemId.toString());
  return new ExternalTaskExecutionInfo(settings, DefaultRunExecutor.EXECUTOR_ID);
}
 
Example #9
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 #10
Source File: DeployToServerRunner.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canRun(@Nonnull String executorId, @Nonnull RunProfile profile) {
  if (!(profile instanceof DeployToServerRunConfiguration)) {
    return false;
  }
  if (executorId.equals(DefaultRunExecutor.EXECUTOR_ID)) {
    return true;
  }
  if (executorId.equals(DefaultDebugExecutor.EXECUTOR_ID)) {
    return ((DeployToServerRunConfiguration<?, ?>)profile).getServerType().createDebugConnector() != null;
  }
  return false;
}
 
Example #11
Source File: GeneralToSMTRunnerEventsConvertorTest.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void testPreserveFullOutputAfterImport() throws Exception {

    mySuite.addChild(mySimpleTest);
    for (int i = 0; i < 550; i++) {
      String message = "line" + i + "\n";
      mySimpleTest.addLast(printer -> printer.print(message, ConsoleViewContentType.NORMAL_OUTPUT));
    }
    mySimpleTest.setFinished();
    mySuite.setFinished();

    SAXTransformerFactory transformerFactory = (SAXTransformerFactory)TransformerFactory.newInstance();
    TransformerHandler handler = transformerFactory.newTransformerHandler();
    handler.getTransformer().setOutputProperty(OutputKeys.INDENT, "yes");
    handler.getTransformer().setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
    File output = FileUtil.createTempFile("output", "");
    try {
      FileUtilRt.createParentDirs(output);
      handler.setResult(new StreamResult(new FileWriter(output)));
      MockRuntimeConfiguration configuration = new MockRuntimeConfiguration(getProject());
      TestResultsXmlFormatter.execute(mySuite, configuration, new SMTRunnerConsoleProperties(configuration, "framework", new DefaultRunExecutor()), handler);

      String savedText = FileUtil.loadFile(output);
      assertTrue(savedText.split("\n").length > 550);

      myEventsProcessor.onStartTesting();
      ImportedToGeneralTestEventsConverter.parseTestResults(() -> new StringReader(savedText), myEventsProcessor);
      myEventsProcessor.onFinishTesting();

      List<? extends SMTestProxy> children = myResultsViewer.getTestsRootNode().getChildren();
      assertSize(1, children);
      SMTestProxy testProxy = children.get(0);
      MockPrinter mockPrinter = new MockPrinter();
      testProxy.printOn(mockPrinter);
      assertSize(550, mockPrinter.getAllOut().split("\n"));
    }
    finally {
      FileUtil.delete(output);
    }
  }
 
Example #12
Source File: OutputToGeneralTestsEventsConverterTest.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();

  final String testFrameworkName = "SMRunnerTests";
  final SMTRunnerConsoleProperties properties = new SMTRunnerConsoleProperties(createRunConfiguration(),
                                                                               testFrameworkName,
                                                                               DefaultRunExecutor.getRunExecutorInstance());
  myOutputConsumer = new OutputToGeneralTestEventsConverter(testFrameworkName, properties);
  myEnventsProcessor = new MockGeneralTestEventsProcessorAdapter(getProject(), testFrameworkName, new SMTestProxy.SMRootTestProxy());
  myOutputConsumer.setProcessor(myEnventsProcessor);
}
 
Example #13
Source File: AbstractImportTestsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ImportRunProfile(VirtualFile file, Project project) {
  myFile = file;
  myProject = project;
  try {
    final Document document = JDOMUtil.loadDocument(VfsUtilCore.virtualToIoFile(myFile));
    final Element config = document.getRootElement().getChild("config");
    if (config != null) {
      String configTypeId = config.getAttributeValue("configId");
      if (configTypeId != null) {
        final ConfigurationType configurationType = ConfigurationTypeUtil.findConfigurationType(configTypeId);
        if (configurationType != null) {
          myConfiguration = configurationType.getConfigurationFactories()[0].createTemplateConfiguration(project);
          myConfiguration.setName(config.getAttributeValue("name"));
          myConfiguration.readExternal(config);

          final Executor executor = ExecutorRegistry.getInstance().getExecutorById(DefaultRunExecutor.EXECUTOR_ID);
          if (executor != null) {
            if (myConfiguration instanceof SMRunnerConsolePropertiesProvider) {
              myProperties = ((SMRunnerConsolePropertiesProvider)myConfiguration).createTestConsoleProperties(executor);
            }
          }
        }
      }
      myTargetId = config.getAttributeValue("target");
    }
  }
  catch (Exception ignore) {
  }
}
 
Example #14
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 #15
Source File: QuickRunMavenGoalAction.java    From MavenHelper with Apache License 2.0 5 votes vote down vote up
protected AnAction getRunConfigurationAction(Project project, RunnerAndConfigurationSettings cfg) {
	RunConfigurationAction action = new RunConfigurationAction(DefaultRunExecutor.getRunExecutorInstance(), true, project, cfg);

	return new ActionGroup(action.getTemplatePresentation().getText(), action.getTemplatePresentation().getDescription(), action.getTemplatePresentation().getIcon()) {
		@NotNull
		@Override
		public AnAction[] getChildren(@Nullable AnActionEvent anActionEvent) {
			DebugConfigurationAction debugConfigurationAction = new DebugConfigurationAction(DefaultDebugExecutor.getDebugExecutorInstance(), true, project, cfg);
			debugConfigurationAction.getTemplatePresentation().setText("Debug");
			return new AnAction[]{debugConfigurationAction};
		}

		@Override
		public void actionPerformed(@NotNull AnActionEvent e) {
			action.actionPerformed(e);
		}

		@Override
		public boolean canBePerformed(@NotNull DataContext context) {
			return true;
		}

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

	};
}
 
Example #16
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 #17
Source File: PantsIntegrationTestCase.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@NotNull
protected RunResult runWithConfiguration(RunConfiguration configuration) {
  PantsMakeBeforeRun.replaceDefaultMakeWithPantsMake(configuration);
  PantsMakeBeforeRun.setRunConfigurationWorkingDirectory(configuration);
  PantsJUnitRunnerAndConfigurationSettings runnerAndConfigurationSettings =
    new PantsJUnitRunnerAndConfigurationSettings(configuration);
  ExecutionEnvironmentBuilder environmentBuilder =
    ExecutionUtil.createEnvironment(DefaultRunExecutor.getRunExecutorInstance(), runnerAndConfigurationSettings);
  ExecutionEnvironment environment = environmentBuilder.build();

  List<String> output = new ArrayList<>();
  List<String> errors = new ArrayList<>();
  ProcessAdapter processAdapter = new ProcessAdapter() {
    @Override
    public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) {
      if (outputType == ProcessOutputTypes.STDOUT) {
        output.add(event.getText());
      }
      else if (outputType == ProcessOutputTypes.STDERR) {
        errors.add(event.getText());
      }
    }
  };

  ProgramRunnerUtil.executeConfiguration(environment, false, false);
  OSProcessHandler handler = (OSProcessHandler) environment.getContentToReuse().getProcessHandler();
  handler.addProcessListener(processAdapter);
  assertTrue(handler.waitFor());

  return new RunResult(handler.getExitCode(), output, errors);
}
 
Example #18
Source File: BlazeAndroidTestProgramRunner.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canRun(String executorId, RunProfile profile) {
  BlazeAndroidRunConfigurationHandler handler =
      BlazeAndroidRunConfigurationHandler.getHandlerFrom(profile);
  if (!(handler instanceof BlazeAndroidTestRunConfigurationHandler)) {
    return false;
  }
  if (!(profile instanceof BlazeCommandRunConfiguration)) {
    return false;
  }
  return DefaultRunExecutor.EXECUTOR_ID.equals(executorId)
      || DefaultDebugExecutor.EXECUTOR_ID.equals(executorId);
}
 
Example #19
Source File: BlazeAndroidBinaryProgramRunner.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canRun(String executorId, RunProfile profile) {
  BlazeAndroidRunConfigurationHandler handler =
      BlazeAndroidRunConfigurationHandler.getHandlerFrom(profile);
  if (!(handler instanceof BlazeAndroidBinaryRunConfigurationHandler)) {
    return false;
  }
  return (DefaultDebugExecutor.EXECUTOR_ID.equals(executorId)
      || DefaultRunExecutor.EXECUTOR_ID.equals(executorId)
      || ProfileRunExecutor.EXECUTOR_ID.equals(executorId));
}
 
Example #20
Source File: GotoTestOrCodeHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
protected String getAdText(PsiElement source, int length) {
  if (length > 0 && !TestFinderHelper.isTest(source)) {
    final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
    final Shortcut[] shortcuts = keymap.getShortcuts(DefaultRunExecutor.getRunExecutorInstance().getContextActionId());
    if (shortcuts.length > 0) {
      return ("Press " + KeymapUtil.getShortcutText(shortcuts[0]) + " to run selected tests");
    }
  }
  return null;
}
 
Example #21
Source File: RunConfigurationsSEContributor.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void fillExecutorInfo(ChooseRunConfigurationPopup.ItemWrapper wrapper, JList<?> list, boolean selected) {

      SimpleTextAttributes commandAttributes = selected ? new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, list.getSelectionForeground()) : SimpleTextAttributes.GRAYED_ATTRIBUTES;
      SimpleTextAttributes shortcutAttributes = selected ? new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, list.getSelectionForeground()) : SimpleTextAttributes.GRAY_ATTRIBUTES;

      String input = myCommandSupplier.get();
      if (isCommand(input, RUN_COMMAND)) {
        fillWithMode(wrapper, RUN_MODE, commandAttributes);
        return;
      }
      if (isCommand(input, DEBUG_COMMAND)) {
        fillWithMode(wrapper, DEBUG_MODE, commandAttributes);
        return;
      }

      Executor debugExecutor = ExecutorRegistry.getInstance().getExecutorById(ToolWindowId.DEBUG);
      Executor runExecutor = DefaultRunExecutor.getRunExecutorInstance();

      KeyStroke enterStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
      KeyStroke shiftEnterStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK);
      if (debugExecutor != null) {
        executorInfo.append(debugExecutor.getId(), commandAttributes);
        executorInfo.append("(" + KeymapUtil.getKeystrokeText(enterStroke) + ")", shortcutAttributes);
        if (runExecutor != null) {
          executorInfo.append(" / " + runExecutor.getId(), commandAttributes);
          executorInfo.append("(" + KeymapUtil.getKeystrokeText(shiftEnterStroke) + ")", shortcutAttributes);
        }
      }
      else {
        if (runExecutor != null) {
          executorInfo.append(runExecutor.getId(), commandAttributes);
          executorInfo.append("(" + KeymapUtil.getKeystrokeText(enterStroke) + ")", shortcutAttributes);
        }
      }
    }
 
Example #22
Source File: RunAnythingPopupUI.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static Executor getExecutor() {
  final Executor runExecutor = DefaultRunExecutor.getRunExecutorInstance();
  final Executor debugExecutor = ExecutorRegistry.getInstance().getExecutorById(ToolWindowId.DEBUG);

  return !SHIFT_IS_PRESSED.get() ? runExecutor : debugExecutor;
}
 
Example #23
Source File: RunServerAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected Executor getExecutor() {
  return DefaultRunExecutor.getRunExecutorInstance();
}
 
Example #24
Source File: RunConfigurationBeforeRunProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public AsyncResult<Void> executeTaskAsync(UIAccess uiAccess, DataContext context, RunConfiguration configuration, ExecutionEnvironment env, RunConfigurableBeforeRunTask task) {
  RunnerAndConfigurationSettings settings = task.getSettings();
  if (settings == null) {
    return AsyncResult.rejected();
  }
  final Executor executor = DefaultRunExecutor.getRunExecutorInstance();
  String executorId = executor.getId();
  final ProgramRunner runner = ProgramRunnerUtil.getRunner(executorId, settings);
  if (runner == null) return AsyncResult.rejected();
  final ExecutionEnvironment environment = new ExecutionEnvironment(executor, runner, settings, myProject);
  environment.setExecutionId(env.getExecutionId());
  if (!ExecutionTargetManager.canRun(settings, env.getExecutionTarget())) {
    return AsyncResult.rejected();
  }

  if (!runner.canRun(executorId, environment.getRunProfile())) {
    return AsyncResult.rejected();
  }
  else {
    AsyncResult<Void> result = AsyncResult.undefined();

    uiAccess.give(() -> {
      try {
        runner.execute(environment, descriptor -> {
          ProcessHandler processHandler = descriptor != null ? descriptor.getProcessHandler() : null;
          if (processHandler != null) {
            processHandler.addProcessListener(new ProcessAdapter() {
              @Override
              public void processTerminated(ProcessEvent event) {
                if(event.getExitCode() == 0) {
                  result.setDone();
                }
                else {
                  result.setRejected();
                }
              }
            });
          }
        });
      }
      catch (ExecutionException e) {
        result.setRejected();
        LOG.error(e);
      }
    }).doWhenRejectedWithThrowable(result::rejectWithThrowable);

    return result;
  }
}
 
Example #25
Source File: AbstractConsoleRunnerWithHistory.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected Executor getExecutor() {
  return DefaultRunExecutor.getRunExecutorInstance();
}
 
Example #26
Source File: BasicProgramRunner.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean canRun(@Nonnull String executorId, @Nonnull RunProfile profile) {
  return DefaultRunExecutor.EXECUTOR_ID.equals(executorId) && !(profile instanceof RunConfigurationWithSuppressedDefaultRunAction);
}
 
Example #27
Source File: RunIdeConsoleAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static void selectContent(RunContentDescriptor descriptor) {
  Executor executor = DefaultRunExecutor.getRunExecutorInstance();
  ConsoleViewImpl consoleView = ObjectUtils.assertNotNull((ConsoleViewImpl)descriptor.getExecutionConsole());
  ExecutionManager.getInstance(consoleView.getProject()).getContentManager().toFrontRunContent(executor, descriptor);
}
 
Example #28
Source File: ChooseRunConfigurationPopupAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected Executor getDefaultExecutor() {
  return DefaultRunExecutor.getRunExecutorInstance();
}
 
Example #29
Source File: ToolProgramRunner.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean canRun(@Nonnull final String executorId, @Nonnull final RunProfile profile) {
  return DefaultRunExecutor.EXECUTOR_ID.equals(executorId) && profile instanceof ToolRunProfile;
}
 
Example #30
Source File: CppRunner.java    From CppTools with Apache License 2.0 4 votes vote down vote up
public boolean canRun(@NotNull final String executorId, @NotNull final RunProfile profile) {
  return DefaultRunExecutor.EXECUTOR_ID.equals(executorId) && profile instanceof CppRunConfiguration;
}