How to open the Terminal in New UI

Answered

Hi I use the code below to open the Terminal in IDE then paste some text to the command line, in the old UI it works well, but it won't work in New UI. 
ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow("Terminal");
if (toolWindow != null) {
    if (!toolWindow.isVisible()) {
        toolWindow.show(null);
        TerminalView terminalView = ServiceManager.getService(project, TerminalView.class);
        JBTerminalWidget terminalWidget = terminalView.getWidgets().iterator().next();
        Terminal terminal = terminalWidget.getTerminal();
        terminal.writeCharacters(command);
    }
}
How to do that in New UI? Thank you very much for help!!

0
2 comments

Sorry, my mistake. I found out the problem.

0

Hi,

Could you please share the solution so others can benefit from it in the future?

0

Please sign in to leave a comment.