Attach process to Debug Console
Hello everyone,
I am trying to send some commands through debug console but I can't get reference to it.
Currently I am using this code, but its not work because component is wrong.
ToolWindowManager manager = ToolWindowManager.getInstance(project);
window = manager.getToolWindow("Debug");
window.show(null);
window.activate(new Runnable() {
@Override
public void run() {
ContentManager contentManager = window.getContentManager();
Content[] contents = contentManager.getContents();
for(Content content:contents) {
Component component = content.getComponent();
if(component instanceof ConsoleView) {
((ConsoleView) component).attachToProcess(handler);
}
}
}
});
Possibly there are another way to get it?
Please sign in to leave a comment.
Normally a debug console already has a process attached. What exactly are you trying to accomplish?
I need to send some commands through this console.
There can be multiple processes running in the debugger at the same time. XDebuggerManager.getInstance(project).getSessions() returns you the list of active debug sessions. For a session, you can call getRunContentDescriptor().getExecutionConsole() to get the console. Normally the returned object will be an instance of ConsoleView.
Thank you for your help.
But is launched JavaCommandLine and debug has different handlers? Because my command line that should read commands didn't see commands that I sent programmatically.
How exactly are you sending your commands?
Thanks for the help i fix my problem