void (@NotNull ProgressIndicator indicator) { List<AttachItem> allItems = Collections.unmodifiableList(getTopLevelItems(indicator, project)); ApplicationManager.getApplication().invokeLater(() -> { AttachListStep step = new AttachListStep(allItems, XDebuggerBundle.message("xdebugger.attach.popup.title.default"), project); final ListPopup popup = JBPopupFactory.getInstance().createListPopup(step); final JList mainList = ((ListPopupImpl) ListPopupWrapper.getRootPopup(popup)).getList(); ListSelectionListener listener = event -> { if (event.getValueIsAdjusting()) return; Object item = ((JList<?>)event.getSource()).getSelectedValue(); // if a sub-list is closed, fallback to the selected value from the main list if (item == null) { item = mainList.getSelectedValue(); } if (item instanceof AttachToProcessItem) { popup.setCaption(((AttachToProcessItem)item).getSelectedDebugger().getDebuggerSelectedTitle()); } if (item instanceof AttachHostItem hostItem) { String attachHostName = hostItem.getText(project); attachHostName = StringUtil.shortenTextWithEllipsis(attachHostName, 50, 0); popup.setCaption(XDebuggerBundle.message("xdebugger.attach.host.popup.title", attachHostName)); } }; popup.addListSelectionListener(listener); // force first valueChanged event listener.valueChanged(new ListSelectionEvent(mainList, mainList.getMinSelectionIndex(), mainList.getMaxSelectionIndex(), false)); popup.showCenteredInCurrentWindow(project); }, project.getDisposed()); }