void (final Tree tree, @NlsContexts.PopupTitle String title) { if (myPopup != null) { myPopup.cancel(); } tree.getModel().addTreeModelListener(createTreeListener(tree)); myPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(createMainPanel(tree), tree) .setRequestFocus(true) .setTitle(title) .setResizable(true) .setMovable(true) .setDimensionServiceKey(myProject, DIMENSION_SERVICE_KEY, false) .setMayBeParent(true) .setCancelOnOtherWindowOpen(true) .setKeyEventHandler(event -> { if (AbstractPopup.isCloseRequest(event)) { // Do not process a close request if the tree shows a speed search popup SpeedSearchSupply supply = SpeedSearchSupply.getSupply(tree); return supply != null && StringUtil.isEmpty(supply.getEnteredPrefix()); } return false; }) .addListener(new JBPopupListener() { @Override public void onClosed(@NotNull LightweightWindowEvent event) { if (myHideRunnable != null) { myHideRunnable.run(); } } }) .setCancelCallback(() -> { Window parent = SwingUtilities.getWindowAncestor(tree); if (parent != null) { for (Window child : parent.getOwnedWindows()) { if (child.isShowing()) { return false; } } } return true; }) .createPopup(); registerTreeDisposable(myPopup, tree); //Editor may be disposed before later invokator process this action if (myEditor.getComponent().getRootPane() == null) { myPopup.cancel(); return; } myPopup.show(new RelativePoint(myEditor.getContentComponent(), myPoint)); setAutoResize(tree, myToolbar, myPopup); }