void (@NlsSafe String fqn, @NotNull Editor editor) { ProgressManager.getInstance().run(new Task.Modal(editor.getProject(), JavaBundle.message("progress.title.looking.for.libraries"), true) { final Map<String, String> libs = new HashMap<>(); @Override public void run(@NotNull ProgressIndicator indicator) { try { String html = HttpRequests.request(CLASS_ROOT_URL + fqn.replace('.', '/') + CLASS_PAGE_EXT).readString(indicator); indicator.checkCanceled(); Matcher matcher = URLUtil.HREF_PATTERN.matcher(html); if (!matcher.find()) { return; } do { indicator.checkCanceled(); String pathToJar = matcher.group(1); if (pathToJar != null && (pathToJar.startsWith("/jar/") || pathToJar.startsWith("/class/../"))) { libs.put(matcher.group(2), SERVICE_URL + pathToJar); } } while (matcher.find()); } catch (IOException e) { LOG.warn(e); } } @Override public void onSuccess() { if (libs.isEmpty()) { HintManager.getInstance().showInformationHint(editor, JavaBundle.message("find.jar.hint.text.no.libraries.found.for.fqn", fqn)); } else { JBList<@NlsSafe String> libNames = new JBList<>(ContainerUtil.sorted(libs.keySet())); libNames.installCellRenderer(o -> new JLabel(o, PlatformIcons.JAR_ICON, SwingConstants.LEFT)); if (libs.size() == 1) { String jarName = libs.keySet().iterator().next(); String url = libs.get(jarName); initiateDownload(url, jarName, editor.getProject()); } else { JBPopupFactory.getInstance() .createListPopupBuilder(libNames) .setTitle(JavaBundle.message("popup.title.select.a.jar.file")) .setItemChosenCallback(() -> { String jarName = libNames.getSelectedValue(); String url = libs.get(jarName); if (url != null) { initiateDownload(url, jarName, editor.getProject()); } }) .createPopup().showInBestPositionFor(editor); } } } }); }