最近我一直在开发一个intellij插件。我设计了一个按钮,希望当这个按钮被双击时,一个进程可以被执行并显示在Run ToolWindow中。
比如在Maven的IDEA插件中,当我们双击'clean'按钮时,就会执行mvn clean,并在运行窗口中显示执行过程。我希望能达到同样的效果。
那么我怎样才能达到这个效果呢?我试过问题 Intellij plugin development print in console window 显示:
ConsoleView cslView = TextConsoleBuilderFactory.getInstance().createBuilder(project).
getConsole();
GeneralCommandLine commandLine = new GeneralCommandLine("C:\\Works\\ojworks\\hello.exe");
OSProcessHandler processHandler = ProcessHandlerFactory.getInstance().createColoredProcessHandler(commandLine);
ProcessTerminatedListener.attach(processHandler);
cslView.attachToProcess(processHandler);
ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow("Run");
Content content = toolWindow.getContentManager().getFactory().createContent(cslView.getComponent(), "Console", true);
但是有两个问题:
谢谢你的建议。