protected void initialize() throws ExecutionException { JavaParametersUtil.configureConfiguration(myJavaParameters, myConfiguration); myJavaParameters.setMainClass(JUnitConfiguration.JUNIT_START_CLASS); final Module module = myConfiguration.getConfigurationModule().getModule(); if (myJavaParameters.getJdk() == null) { myJavaParameters.setJdk( module != null ? ModuleRootManager.getInstance(module).getSdk() : ProjectRootManager.getInstance(myProject).getProjectSdk()); } myJavaParameters.getClassPath().add(JavaSdkUtil.getIdeaRtJarPath()); myJavaParameters.getClassPath().add(PathUtil.getJarPathForClass(JUnitStarter.class)); myJavaParameters .getProgramParametersList() .add(JUnitStarter.IDE_VERSION + JUnitStarter.VERSION); for (RunConfigurationExtension ext : Extensions.getExtensions(RunConfigurationExtension.EP_NAME)) { ext.updateJavaParameters(myConfiguration, myJavaParameters, getRunnerSettings()); } final Object[] listeners = Extensions.getExtensions(IDEAJUnitListener.EP_NAME); final StringBuilder buf = new StringBuilder(); for (final Object listener : listeners) { boolean enabled = true; for (RunConfigurationExtension ext : Extensions.getExtensions(RunConfigurationExtension.EP_NAME)) { if (ext.isListenerDisabled(myConfiguration, listener, getRunnerSettings())) { enabled = false; break; } } if (enabled) { final Class classListener = listener.getClass(); buf.append(classListener.getName()).append("\n"); myJavaParameters.getClassPath().add(PathUtil.getJarPathForClass(classListener)); } } if (buf.length() > 0) { try { myListenersFile = FileUtil.createTempFile("junit_listeners_", ""); myListenersFile.deleteOnExit(); myJavaParameters.getProgramParametersList().add("@@" + myListenersFile.getPath()); FileUtil.writeToFile(myListenersFile, buf.toString().getBytes()); } catch (IOException e) { LOG.error(e); } } }
@SuppressWarnings("unchecked") @Nullable public static <T> T getToolWindowElement( @NotNull Class<T> clazz, @NotNull Project project, @NotNull DataKey<T> key, @NotNull ProjectSystemId externalSystemId) { if (project.isDisposed() || !project.isOpen()) { return null; } final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project); if (toolWindowManager == null) { return null; } final ToolWindow toolWindow = ensureToolWindowContentInitialized(project, externalSystemId); if (toolWindow == null) { return null; } final ContentManager contentManager = toolWindow.getContentManager(); if (contentManager == null) { return null; } for (Content content : contentManager.getContents()) { final JComponent component = content.getComponent(); if (component instanceof DataProvider) { final Object data = ((DataProvider) component).getData(key.getName()); if (data != null && clazz.isInstance(data)) { return (T) data; } } } return null; }