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
ToolWindowManager manager = ToolWindowManager.getInstance(e.getProject());
ToolWindow window = manager.getToolWindow("Run");
if (window == null) {
return;
}
Content[] contents = window.getContentManager().getContents();
for (Content content : contents) {
final RunManagerImpl runManager = (RunManagerImpl) RunManager.getInstance(e.getProject());
final Collection<RunnerAndConfigurationSettings> allConfigurations = runManager.getSortedConfigurations();
for (RunnerAndConfigurationSettings runConfiguration : allConfigurations) {
if (content.getTabName().contains(runConfiguration.getName())) {
String name = runConfiguration.getName();
System.out.println(name);
content.setDisplayName("!" + name);
ExecutionManager.getInstance(e.getProject()).restartRunProfile(e.getProject(),
DefaultRunExecutor.getRunExecutorInstance(),
DefaultExecutionTarget.INSTANCE,
runManager.findConfigurationByName(name),
e.getData(RunContentManager.RUN_CONTENT_DESCRIPTOR));
}
}
}
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:
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();
}