boolean (@NotNull T element, @Nullable Comparator comparator) { if (tryAppendUsage(element)) return true; if (myCanceled) return false; if (myPopup.isDisposed()) return false; ModalityState modalityState = ModalityState.stateForComponent(myPopup.getContent()); synchronized (lock) { if (myData.contains(element)) return true; myData.add(element); if (comparator != null && myData instanceof List) { ((List)myData).sort(comparator); } } myAlarm.addRequest(() -> { myAlarm.cancelAllRequests(); refreshModelImmediately(); }, 200, modalityState); return true; }