void (final int delayMillis) { if (ApplicationManager.getApplication().isUnitTestMode() || myPopup.isDisposed()) { return; } Alarm alarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, myPopup); alarm.addRequest(new Runnable() { String filter = ""; @Override public void run() { alarm.cancelAllRequests(); String prefix = mySpeedSearch.getEnteredPrefix(); myTree.getEmptyText().setText(StringUtil.isEmpty(prefix) ? LangBundle.message("status.text.structure.empty") : "'" + prefix + "' " + LangBundle.message("status.text.structure.empty.not.found")); if (prefix == null) prefix = ""; if (!filter.equals(prefix)) { boolean isBackspace = prefix.length() < filter.length(); filter = prefix; rebuild(true).onProcessed(ignore -> UIUtil.invokeLaterIfNeeded(() -> { if (isDisposed()) return; TreeUtil.promiseExpandAll(myTree); if (isBackspace && handleBackspace(filter)) { return; } if (myFilteringStructure.getRootElement().getChildren().length == 0) { for (JBCheckBox box : myCheckBoxes.values()) { if (!box.isSelected()) { myAutoClicked.add(box); myTriggeredCheckboxes.add(0, Pair.create(filter, box)); box.doClick(); filter = ""; break; } } } })); } if (!alarm.isDisposed()) { alarm.addRequest(this, delayMillis); } } }, delayMillis); }