Java Code Examples for com.intellij.execution.ui.ConsoleView#attachToProcess()

The following examples show how to use com.intellij.execution.ui.ConsoleView#attachToProcess() . 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: FreelineUtil.java    From freeline with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
private static void processConsole(Project project, ProcessHandler processHandler) {
    ConsoleView consoleView = FreeUIManager.getInstance(project).getConsoleView(project);
    consoleView.clear();
    consoleView.attachToProcess(processHandler);

    ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    ToolWindow toolWindow;
    toolWindow = toolWindowManager.getToolWindow(TOOL_ID);

    // if already exist tool window then show it
    if (toolWindow != null) {
        toolWindow.show(null);
        return;
    }

    toolWindow = toolWindowManager.registerToolWindow(TOOL_ID, true, ToolWindowAnchor.BOTTOM);
    toolWindow.setTitle("free....");
    toolWindow.setStripeTitle("Free Console");
    toolWindow.setShowStripeButton(true);
    toolWindow.setIcon(PluginIcons.ICON_TOOL_WINDOW);
    toolWindow.getContentManager().addContent(new ContentImpl(consoleView.getComponent(), "Build", true));
    toolWindow.show(null);
}
 
Example 2
Source File: FreeRunConfiguration.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private ExecutionResult buildExecutionResult() throws ExecutionException {
    GeneralCommandLine commandLine = createDefaultCommandLine();
    ProcessHandler processHandler = createProcessHandler(commandLine);
    ProcessTerminatedListener.attach(processHandler);
    ConsoleView console = new TerminalExecutionConsole(getProject(), processHandler);

    console.print(
        "Welcome to React Native Console, now please click one button on top toolbar to start.\n",
        ConsoleViewContentType.SYSTEM_OUTPUT);
    console.attachToProcess(processHandler);

    console.print(
        "Give a Star or Suggestion:\n",
        ConsoleViewContentType.NORMAL_OUTPUT);


    processHandler.destroyProcess();
    return new DefaultExecutionResult(console, processHandler);
}
 
Example 3
Source File: DuneCompiler.java    From reasonml-idea-plugin with MIT License 6 votes vote down vote up
@Override
public void run(@NotNull VirtualFile file, @NotNull CliType cliType, @Nullable Compiler.ProcessTerminated onProcessTerminated) {
    if (!(cliType instanceof CliType.Dune)) {
        LOG.error("Invalid cliType for dune compiler. cliType = " + cliType);
        return;
    }
    CompilerProcess process = DuneProcess.getInstance(project);
    if (process.start()) {
        ProcessHandler duneHandler = process.recreate(cliType, onProcessTerminated);
        if (duneHandler != null) {
            ConsoleView console = getConsoleView();
            if (console != null) {
                console.attachToProcess(duneHandler);
                duneHandler.addProcessListener(new ProcessFinishedListener());
            }
            process.startNotify();
            ServiceManager.getService(project, InsightManager.class).downloadRincewindIfNeeded(file);
        } else {
            process.terminate();
        }
    }
}
 
Example 4
Source File: LaunchState.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@NotNull
protected ExecutionResult setUpConsoleAndActions(@NotNull FlutterApp app) throws ExecutionException {
  final ConsoleView console = createConsole(getEnvironment().getExecutor());
  if (console != null) {
    app.setConsole(console);
    console.attachToProcess(app.getProcessHandler());
  }

  // Add observatory actions.
  // These actions are effectively added only to the Run tool window.
  // For Debug see FlutterDebugProcess.registerAdditionalActions()
  final Computable<Boolean> observatoryAvailable = () -> !app.getProcessHandler().isProcessTerminated() &&
                                                         app.getConnector().getBrowserUrl() != null;
  final List<AnAction> actions = new ArrayList<>(Arrays.asList(
    super.createActions(console, app.getProcessHandler(), getEnvironment().getExecutor())));
  actions.add(new Separator());
  actions.add(new OpenDevToolsAction(app.getConnector(), observatoryAvailable));

  return new DefaultExecutionResult(console, app.getProcessHandler(), actions.toArray(new AnAction[0]));
}
 
Example 5
Source File: LaunchState.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@NotNull
protected ExecutionResult setUpConsoleAndActions(@NotNull FlutterApp app) throws ExecutionException {
  final ConsoleView console = createConsole(getEnvironment().getExecutor());
  if (console != null) {
    app.setConsole(console);
    console.attachToProcess(app.getProcessHandler());
  }

  // Add observatory actions.
  // These actions are effectively added only to the Run tool window.
  // For Debug see FlutterDebugProcess.registerAdditionalActions()
  final Computable<Boolean> observatoryAvailable = () -> !app.getProcessHandler().isProcessTerminated() &&
                                                         app.getConnector().getBrowserUrl() != null;
  final List<AnAction> actions = new ArrayList<>(Arrays.asList(
    super.createActions(console, app.getProcessHandler(), getEnvironment().getExecutor())));
  actions.add(new Separator());
  actions.add(new OpenDevToolsAction(app.getConnector(), observatoryAvailable));

  return new DefaultExecutionResult(console, app.getProcessHandler(), actions.toArray(new AnAction[0]));
}
 
Example 6
Source File: RunContentExecutor.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void run() {
  FileDocumentManager.getInstance().saveAllDocuments();

  // Use user-provided console if exist. Create new otherwise
  ConsoleView view = (myUserProvidedConsole != null ? myUserProvidedConsole :  createConsole(myProject));
  view.attachToProcess(myProcess);
  if (myAfterCompletion != null) {
    myProcess.addProcessListener(new ProcessAdapter() {
      @Override
      public void processTerminated(ProcessEvent event) {
        SwingUtilities.invokeLater(myAfterCompletion);
      }
    });
  }
  myProcess.startNotify();
}
 
Example 7
Source File: EsyCompiler.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
@Override
public void run(@NotNull VirtualFile file, @NotNull CliType cliType, @Nullable ProcessTerminated onProcessTerminated) {
    if (!(cliType instanceof CliType.Esy)) {
        LOG.error("Invalid cliType for esy compiler. cliType = " + cliType);
        return;
    }
    EsyProcess process = EsyProcess.getInstance(m_project);
    ProcessHandler processHandler = process.recreate(cliType, onProcessTerminated);
    if (processHandler != null) {
        processHandler.addProcessListener(new ProcessFinishedListener());
        ConsoleView console = getConsoleView();
        console.attachToProcess(processHandler);
        process.startNotify();
    }
}
 
Example 8
Source File: BlazeAndroidBinaryConsoleProvider.java    From intellij with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
public ConsoleView createAndAttach(
    @NotNull Disposable parent, @NotNull ProcessHandler handler, @NotNull Executor executor)
    throws ExecutionException {
  final TextConsoleBuilder builder =
      TextConsoleBuilderFactory.getInstance().createBuilder(project);
  ConsoleView console = builder.getConsole();
  console.attachToProcess(handler);
  return console;
}
 
Example 9
Source File: AndroidTestConsoleProvider.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public ConsoleView createAndAttach(Disposable parent, ProcessHandler handler, Executor executor)
    throws ExecutionException {
  switch (configState.getLaunchMethod()) {
    case BLAZE_TEST:
      ConsoleView console = createBlazeTestConsole(executor);
      console.attachToProcess(handler);
      return console;
    case NON_BLAZE:
    case MOBILE_INSTALL:
      return getStockConsoleProvider().createAndAttach(parent, handler, executor);
  }
  throw new AssertionError();
}
 
Example 10
Source File: UnityDebugProcess.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public ExecutionConsole createConsole()
{
	if(myConsoleView != null)
	{
		return myConsoleView;
	}
	ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(getSession().getProject()).getConsole();
	consoleView.attachToProcess(getProcessHandler());
	return consoleView;
}
 
Example 11
Source File: CommandLineState.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public ExecutionResult execute(@Nonnull final Executor executor, @Nonnull final ProgramRunner runner) throws ExecutionException {
  final ProcessHandler processHandler = startProcess();
  final ConsoleView console = createConsole(executor);
  if (console != null) {
    console.attachToProcess(processHandler);
  }
  return new DefaultExecutionResult(console, processHandler, createActions(console, processHandler, executor));
}
 
Example 12
Source File: RNUtil.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static void processConsole(Project project, ProcessHandler processHandler) {
        ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole();
        consoleView.clear();
        consoleView.attachToProcess(processHandler);
        processHandler.startNotify();

        ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
        ToolWindow toolWindow;
        toolWindow = toolWindowManager.getToolWindow(TOOL_ID);

        // if already exist tool window then show it
        if (toolWindow != null) {
            toolWindow.show(null);// TODO add more tabs here?
            return;
        }

        toolWindow = toolWindowManager.registerToolWindow(TOOL_ID, true, ToolWindowAnchor.BOTTOM);
        toolWindow.setTitle("Android....");
        toolWindow.setStripeTitle("Android Console");
        toolWindow.setShowStripeButton(true);
        toolWindow.setIcon(PluginIcons.ICON_TOOL_WINDOW);

        JPanel panel = new JPanel((LayoutManager) new BorderLayout());
        panel.add((Component) consoleView.getComponent(), "Center");

        // Create toolbars
        DefaultActionGroup toolbarActions = new DefaultActionGroup();
        AnAction[]
                consoleActions = consoleView.createConsoleActions();// 必须在 consoleView.getComponent() 调用后组件真正初始化之后调用
        toolbarActions.addAll((AnAction[]) Arrays.copyOf(consoleActions, consoleActions.length));
        toolbarActions.add((AnAction) new StopProcessAction("Stop process", "Stop process", processHandler));
//        toolbarActions.add((AnAction) new CloseAction(defaultExecutor, runDescriptor, project));


        ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("unknown", (ActionGroup) toolbarActions, false);
        toolbar.setTargetComponent(consoleView.getComponent());
        panel.add((Component) toolbar.getComponent(), "West");

        ContentImpl consoleContent = new ContentImpl(panel, "Build", false);
        consoleContent.setManager(toolWindow.getContentManager());

        toolbarActions.add(new CloseTabAction(consoleContent));

//        addAdditionalConsoleEditorActions(consoleView, consoleContent);
//        consoleComponent.setActions();
        toolWindow.getContentManager().addContent(consoleContent);
        toolWindow.getContentManager().addContent(new ContentImpl(new JButton("Test"), "Build2", false));
        toolWindow.show(null);
    }