Recently I've been developing an intellij plugin. I designed a button, and I hope that when this button is double clicked, a process can be executed and be shown in the Run ToolWindow.
For example, in Maven's IDEA plugin, when we double-click the button 'clean', it will execute mvn clean and display the execution process in the run window. I hope to achieve the same effect.
So how can I reach this effect? I've tried as the question Intellij plugin development print in console window shows:
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);
But there are 2 questions:
- If the Run ToolWindow weren't activated, the function getToolWindow would return null, so how can I take my initiative to activate the Run ToolWindow?
- The console is open but nothing to show. Does the function attachToProcess really take effect or I need to do some other thing?
Thank you for some advice.
question from:
https://stackoverflow.com/questions/65859657/intellj-idea-development-use-the-run-toolwindow-to-show-my-process-below 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…