How to rerun programmatically the program Follow
Hi, I want to programmatically rerun(There is a command for this also you can use ctrl-f5) Below is a picture of rhis button in idea
So how I can run this action by myself?
Please sign in to leave a comment.
Hi Evgeniy,
You should use ExecutionManager.restartRunProfile() for that.
Default IJ implementation achieves that via RestartAction (the one from your screenshot).
Denis
Thank you, this helped me a lot :)
You are welcome
I did it and restarted the process sucessfully. But if I have two or more processes running, I cannot rerun all of them, it just reruns one of them
Here is my code
Try
and then use them for restarting with ExecutionManager.getInstance(project).restartRunProfile()
Also you can invoke RunContentDescriptor.getRestarter().run()
I don't have method getAllDescriptors() in 12 version of IDEA ?:|
UPDATE: sorry, it was on RunContentManager, not in ContentManager, my fault
OK, code snipped has been updated, my fault too.
I used the way you suggested, but there is only one tab reruns from all tabs in Run wndow
Here is my new code
Now there is a bug and you cannot restart more than one running instance at the same time. It's going to be fixed in next 13 EAP. You can use this code snippet:
ExecutionManager executionManager = ExecutionManager.getInstance(project);
List<RunContentDescriptor> descriptors = executionManager.getContentManager().getAllDescriptors();
for (RunContentDescriptor descriptor : descriptors) {
descriptor.getRestarter().run();
}