Java Code Examples for com.intellij.execution.executors.DefaultRunExecutor#getRunExecutorInstance()

The following examples show how to use com.intellij.execution.executors.DefaultRunExecutor#getRunExecutorInstance() . 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: 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 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: 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 4
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 5
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 6
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 7
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 8
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 9
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 10
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 11
Source File: ChooseRunConfigurationPopupAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected Executor getDefaultExecutor() {
  return DefaultRunExecutor.getRunExecutorInstance();
}
 
Example 12
Source File: AbstractConsoleRunnerWithHistory.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected Executor getExecutor() {
  return DefaultRunExecutor.getRunExecutorInstance();
}
 
Example 13
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 14
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 15
Source File: RunnerUtil.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected Executor getExecutor() {
    return DefaultRunExecutor.getRunExecutorInstance();
}
 
Example 16
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 17
Source File: MainMavenActionGroup.java    From MavenHelper with Apache License 2.0 4 votes vote down vote up
protected AnAction getRunConfigurationAction(Project project, RunnerAndConfigurationSettings cfg) {
	return new RunConfigurationAction(DefaultRunExecutor.getRunExecutorInstance(), true, project, cfg);
}
 
Example 18
Source File: BaseAction.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected Executor getExecutor() {
    return DefaultRunExecutor.getRunExecutorInstance();
}