How to close Run console tab/window programmatically?
Hi,
my plugin is implementing AbstractConsoleRunnerWithHistory to provide a "Run"-Tab. I can open and use it programmatically with
RConsoleRunner runner = new RConsoleRunner(project, project.getBasePath());
runner.initAndRun();
and this works pretty well. But is it possible to close it as well? My guess would be to go via `runner.getConsoleView().??`. but there's no obvious `quit()` or `hide()` method (or something similar).
Best regards,
Holger
Please sign in to leave a comment.
Pleas try ExecutionManager.getInstance(Project).getContentManager().removeRunContent(Executor, RunContentDescriptor)
Thanks Vassiliy. I've tried as suggested and managed to find the descriptor via
but I don't know how to get a the executor instance given my RConsoleRunner which extends
I've tried
but this Set seems always empty. How can I obtain the executor?
Actually AbstractConsoleRunnerWithHistory has getExecutor() method that returns DefaultRunExecutor.getRunExecutorInstance() if it's not overriden.
That method is protected that's why I missed it in the first place, but since I did not override it I could follow your 2nd suggestion. It works now, and the window is nicely closing. Thanks for your kind help.
In case somebody else stumbles over this thread, and wants to see the full example see https://github.com/holgerbrandl/r4intellij/blob/master/src/com/r4intellij/inspections/InstallLibraryFix.java#L91
Best,
Holger
I'm trying to unit-test the solution from above using LightPlatformCodeInsightFixtureTestCase. However in contrast to interactive use, when running the test the `executionManager.getContentManager().getSelectedContent()` as discussed above always return null. Without the descriptor I can not close the tool-window and the test stumbles over some built-in assertion:
How can i avoid such a CompositeException?
Intention
https://github.com/holgerbrandl/r4intellij/blob/master/src/com/r4intellij/intentions/InstallLibraryFix.java#L91
Test
https://github.com/holgerbrandl/r4intellij/blob/master/test/com/r4intellij/intentions/InstallLibraryFixTest.java#L48
Many thanks in advance,
Holger