Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
979 views
in Technique[技术] by (71.8m points)

plugins - Intellj Idea development use the Run ToolWindow to show my process below

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:

  1. 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?
  2. 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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...